comparison src/controller.c @ 31:b87b3ad5068c

Forgot to add the controller source files
author Michael Pavone <pavone@retrodev.com>
date Sun, 03 Apr 2016 18:37:31 -0700
parents
children
comparison
equal deleted inserted replaced
30:78068060313a 31:b87b3ad5068c
1 #include <stdint.h>
2 #include <string.h>
3 #include "controller.h"
4
5 static controllers *current_context;
6
7 //UDLR SMAB CXYZ
8
9 void controller_init(controllers *context)
10 {
11 memset(context, 0, sizeof(controllers));
12 current_context = context;
13 }
14
15 void controller_pressed(int which, uint16_t buttons)
16 {
17 if (which > 1) {
18 return;
19 }
20 current_context->state[which] |= buttons;
21 }
22
23 void controller_released(int which, uint16_t buttons)
24 {
25 if (which > 1) {
26 return;
27 }
28 current_context->state[which] &= (~buttons) & 0xFFF;
29 }
30
31 uint16_t controller_read(controllers *context, int which)
32 {
33 if (which > 1) {
34 return 0xFFFF;
35 }
36 return context->state[which];
37 }