2016-03-30 23:07:55 +03:00
|
|
|
#ifndef joypad_h
|
|
|
|
#define joypad_h
|
2021-11-07 13:39:18 +02:00
|
|
|
#include "defs.h"
|
2018-05-27 19:30:23 +03:00
|
|
|
#include <stdbool.h>
|
2016-03-30 23:07:55 +03:00
|
|
|
|
2017-04-17 20:16:17 +03:00
|
|
|
typedef enum {
|
|
|
|
GB_KEY_RIGHT,
|
|
|
|
GB_KEY_LEFT,
|
|
|
|
GB_KEY_UP,
|
|
|
|
GB_KEY_DOWN,
|
|
|
|
GB_KEY_A,
|
|
|
|
GB_KEY_B,
|
|
|
|
GB_KEY_SELECT,
|
|
|
|
GB_KEY_START,
|
|
|
|
GB_KEY_MAX
|
|
|
|
} GB_key_t;
|
|
|
|
|
2021-12-02 11:23:44 +02:00
|
|
|
typedef enum {
|
|
|
|
GB_KEY_RIGHT_MASK = 1 << GB_KEY_RIGHT,
|
|
|
|
GB_KEY_LEFT_MASK = 1 << GB_KEY_LEFT,
|
|
|
|
GB_KEY_UP_MASK = 1 << GB_KEY_UP,
|
|
|
|
GB_KEY_DOWN_MASK = 1 << GB_KEY_DOWN,
|
|
|
|
GB_KEY_A_MASK = 1 << GB_KEY_A,
|
|
|
|
GB_KEY_B_MASK = 1 << GB_KEY_B,
|
|
|
|
GB_KEY_SELECT_MASK = 1 << GB_KEY_SELECT,
|
|
|
|
GB_KEY_START_MASK = 1 << GB_KEY_START,
|
|
|
|
} GB_key_mask_t;
|
|
|
|
|
|
|
|
// For example, for player 2's (0-based; logical player 3) A button, use GB_MASK_FOR_PLAYER(GB_KEY_A_MASK, 2)
|
|
|
|
#define GB_MASK_FOR_PLAYER(mask, player) ((x) << (player * 8))
|
|
|
|
|
2017-04-17 20:16:17 +03:00
|
|
|
void GB_set_key_state(GB_gameboy_t *gb, GB_key_t index, bool pressed);
|
2018-11-12 00:37:06 +02:00
|
|
|
void GB_set_key_state_for_player(GB_gameboy_t *gb, GB_key_t index, unsigned player, bool pressed);
|
2021-12-02 11:23:44 +02:00
|
|
|
void GB_set_key_mask(GB_gameboy_t *gb, GB_key_mask_t mask);
|
|
|
|
void GB_set_key_mask_for_player(GB_gameboy_t *gb, GB_key_mask_t mask, unsigned player);
|
2019-07-16 21:42:57 +03:00
|
|
|
void GB_icd_set_joyp(GB_gameboy_t *gb, uint8_t value);
|
2021-12-18 01:25:06 +02:00
|
|
|
bool GB_get_joyp_accessed(GB_gameboy_t *gb);
|
|
|
|
void GB_clear_joyp_accessed(GB_gameboy_t *gb);
|
2021-12-19 00:28:24 +02:00
|
|
|
void GB_set_allow_illegal_inputs(GB_gameboy_t *gb, bool allow);
|
2021-12-18 01:25:06 +02:00
|
|
|
|
2016-03-30 23:07:55 +03:00
|
|
|
|
2017-04-17 20:16:17 +03:00
|
|
|
#ifdef GB_INTERNAL
|
2021-11-07 14:13:52 +02:00
|
|
|
internal void GB_update_joyp(GB_gameboy_t *gb);
|
2017-04-17 20:16:17 +03:00
|
|
|
#endif
|
2016-03-30 23:07:55 +03:00
|
|
|
#endif /* joypad_h */
|