license some code GPL compatible to use in PCSX
[picodrive.git] / platform / common / input.h
CommitLineData
819ef025 1#define IN_MAX_DEVS 10
2
991473ad 3/* unified menu keys */
4#define PBTN_UP (1 << 0)
5#define PBTN_DOWN (1 << 1)
6#define PBTN_LEFT (1 << 2)
7#define PBTN_RIGHT (1 << 3)
8
9#define PBTN_MOK (1 << 4)
10#define PBTN_MBACK (1 << 5)
11#define PBTN_MA2 (1 << 6) /* menu action 2 */
12#define PBTN_MA3 (1 << 7)
13
14#define PBTN_L (1 << 8)
15#define PBTN_R (1 << 9)
16
17#define PBTN_MENU (1 << 10)
18
d34a42f9 19/* ui events */
20#define PEVB_VOL_DOWN 30
21#define PEVB_VOL_UP 29
22#define PEVB_STATE_LOAD 28
23#define PEVB_STATE_SAVE 27
24#define PEVB_SWITCH_RND 26
25#define PEVB_SSLOT_PREV 25
26#define PEVB_SSLOT_NEXT 24
27#define PEVB_MENU 23
28#define PEVB_FF 22
f2cf8472 29#define PEVB_PICO_PNEXT 21
30#define PEVB_PICO_PPREV 20
31#define PEVB_PICO_SWINP 19
d34a42f9 32
33#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
34#define PEV_VOL_UP (1 << PEVB_VOL_UP)
35#define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD)
36#define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE)
37#define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND)
38#define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV)
39#define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT)
40#define PEV_MENU (1 << PEVB_MENU)
41#define PEV_FF (1 << PEVB_FF)
f2cf8472 42#define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT)
43#define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV)
44#define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP)
d34a42f9 45
f2cf8472 46#define PEV_MASK 0x7ff80000
d34a42f9 47
48
3b13ec65 49enum {
819ef025 50 IN_DRVID_UNKNOWN = 0,
7201dc73 51 IN_DRVID_GP2X,
217d08bc 52 IN_DRVID_EVDEV,
823b9004 53 IN_DRVID_VK,
9025b931 54 IN_DRVID_COUNT,
55};
56
57enum {
603c28b3 58 IN_CFG_BIND_COUNT = 0,
59 IN_CFG_DOES_COMBOS,
60 IN_CFG_BLOCKING,
61 IN_CFG_KEY_NAMES,
62 IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */
3b13ec65 63};
e1f99f2b 64
093b8a42 65enum {
66 IN_BINDTYPE_NONE = -1,
67 IN_BINDTYPE_EMU = 0,
68 IN_BINDTYPE_PLAYER12,
69 IN_BINDTYPE_COUNT
70};
71
72#define IN_BIND_OFFS(key, btype) \
73 ((key) * IN_BINDTYPE_COUNT + (btype))
74
819ef025 75typedef struct {
76 const char *prefix;
77 void (*probe)(void);
78 void (*free)(void *drv_data);
79 int (*get_bind_count)(void);
80 void (*get_def_binds)(int *binds);
093b8a42 81 int (*clean_binds)(void *drv_data, int *binds, int *def_finds);
603c28b3 82 int (*get_config)(void *drv_data, int what, int *val);
83 int (*set_config)(void *drv_data, int what, int val);
7201dc73 84 int (*update_keycode)(void *drv_data, int *is_down);
603c28b3 85 int (*menu_translate)(void *drv_data, int keycode);
819ef025 86 int (*get_key_code)(const char *key_name);
87 const char * (*get_key_name)(int keycode);
88} in_drv_t;
89
72f3f175 90struct in_default_bind {
91 unsigned short code;
92 unsigned char btype; /* IN_BINDTYPE_* */
93 unsigned char bit;
94};
819ef025 95
e1f99f2b 96/* to be called by drivers */
093b8a42 97void in_register(const char *nname, int drv_id, int drv_fd_hnd, void *drv_data,
603c28b3 98 int key_count, const char * const *key_names, int combos);
093b8a42 99void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts);
100int in_combos_do(int keys, const int *binds, int last_key, int combo_keys, int combo_acts);
e1f99f2b 101
102void in_init(void);
103void in_probe(void);
093b8a42 104int in_update(int *result);
f484a9fe 105int in_update_keycode(int *dev_id, int *is_down, int timeout_ms);
b6820926 106int in_menu_wait_any(int timeout_ms);
713c9224 107int in_menu_wait(int interesting, int autorep_delay_ms);
819ef025 108void in_config_start(void);
109int in_config_parse_dev(const char *dev_name);
093b8a42 110int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type);
819ef025 111void in_config_end(void);
603c28b3 112int in_get_config(int dev_id, int what, void *val);
113int in_set_config(int dev_id, int what, const void *val, int size);
b9574f42 114int in_get_key_code(int dev_id, const char *key_name);
603c28b3 115int in_name_to_id(const char *dev_name);
37807164 116int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind);
117void in_unbind_all(int dev_id, int act_mask, int bind_type);
819ef025 118void in_debug_dump(void);
119
120const int *in_get_dev_binds(int dev_id);
121const int *in_get_dev_def_binds(int dev_id);
713c9224 122const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix);
3427e573 123const char *in_get_key_name(int dev_id, int keycode);
603c28b3 124
125#define in_set_config_int(dev_id, what, v) { \
126 int val_ = v; \
127 in_set_config(dev_id, what, &val_, sizeof(val_)); \
128}