diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-06-25 19:20:39 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-06-25 19:20:39 -0700 |
commit | 3caaed844a05a897e44df0685abfcbd1b162f862 (patch) | |
tree | 89596787e001cc65b41cb3b826e82350fd8d8ee2 /io.h | |
parent | f8296ee1fa057adc180ed4d6a2066a841dbe74c4 (diff) |
Move IO code to a separate file and do a tiny bit of refactoring
Diffstat (limited to 'io.h')
-rw-r--r-- | io.h | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#ifndef IO_H_ +#define IO_H_ +#include <stdint.h> + +typedef struct { + uint32_t th_counter; + uint32_t timeout_cycle; + uint8_t output; + uint8_t control; + uint8_t input[3]; +} io_port; + +#define GAMEPAD_TH0 0 +#define GAMEPAD_TH1 1 +#define GAMEPAD_EXTRA 2 +#define GAMEPAD_NONE 0xF + +void set_keybindings(); +void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction); +void io_data_write(io_port * pad, uint8_t value, uint32_t current_cycle); +uint8_t io_data_read(io_port * pad, uint32_t current_cycle); +void handle_keydown(int keycode); +void handle_keyup(int keycode); +void handle_joydown(int joystick, int button); +void handle_joyup(int joystick, int button); +void handle_joy_dpad(int joystick, int dpad, uint8_t state); + +#endif //IO_H_ + |