Commit | Line | Data |
---|---|---|
75b18496 | 1 | #ifndef INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc |
2 | #define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1 | |
3 | ||
da767bd5 | 4 | #define IN_MAX_DEVS 10 |
df77913a | 5 | #define IN_ABS_RANGE 1024 /* abs must be centered at 0, move upto +- this */ |
da767bd5 | 6 | |
82abf46f | 7 | /* unified menu keys */ |
8 | #define PBTN_UP (1 << 0) | |
9 | #define PBTN_DOWN (1 << 1) | |
10 | #define PBTN_LEFT (1 << 2) | |
11 | #define PBTN_RIGHT (1 << 3) | |
12 | ||
13 | #define PBTN_MOK (1 << 4) | |
14 | #define PBTN_MBACK (1 << 5) | |
15 | #define PBTN_MA2 (1 << 6) /* menu action 2 */ | |
16 | #define PBTN_MA3 (1 << 7) | |
17 | ||
18 | #define PBTN_L (1 << 8) | |
19 | #define PBTN_R (1 << 9) | |
20 | ||
21 | #define PBTN_MENU (1 << 10) | |
22 | ||
9934732a | 23 | #define PBTN_CHAR (1 << 11) /* character (text input) */ |
bededcb4 | 24 | #define PBTN_RDRAW (1 << 12) /* redraw event */ |
9934732a | 25 | |
8754b84c | 26 | // TODO: move to pico |
27 | #if 0 | |
28 | ||
388947f3 | 29 | /* ui events */ |
30 | #define PEVB_VOL_DOWN 30 | |
31 | #define PEVB_VOL_UP 29 | |
32 | #define PEVB_STATE_LOAD 28 | |
33 | #define PEVB_STATE_SAVE 27 | |
34 | #define PEVB_SWITCH_RND 26 | |
35 | #define PEVB_SSLOT_PREV 25 | |
36 | #define PEVB_SSLOT_NEXT 24 | |
37 | #define PEVB_MENU 23 | |
38 | #define PEVB_FF 22 | |
93c18cb4 | 39 | #define PEVB_PICO_PNEXT 21 |
40 | #define PEVB_PICO_PPREV 20 | |
41 | #define PEVB_PICO_SWINP 19 | |
388947f3 | 42 | |
43 | #define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN) | |
44 | #define PEV_VOL_UP (1 << PEVB_VOL_UP) | |
45 | #define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD) | |
46 | #define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE) | |
47 | #define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND) | |
48 | #define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV) | |
49 | #define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT) | |
50 | #define PEV_MENU (1 << PEVB_MENU) | |
51 | #define PEV_FF (1 << PEVB_FF) | |
93c18cb4 | 52 | #define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT) |
53 | #define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV) | |
54 | #define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP) | |
388947f3 | 55 | |
93c18cb4 | 56 | #define PEV_MASK 0x7ff80000 |
388947f3 | 57 | |
8754b84c | 58 | #endif |
388947f3 | 59 | |
2c600560 | 60 | enum { |
e9b29264 | 61 | IN_CFG_BIND_COUNT = 0, |
62 | IN_CFG_DOES_COMBOS, | |
63 | IN_CFG_BLOCKING, | |
64 | IN_CFG_KEY_NAMES, | |
df77913a | 65 | IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */ |
66 | IN_CFG_ABS_AXIS_COUNT, /* number of abs axes (ro) */ | |
215aec76 | 67 | IN_CFG_DEFAULT_DEV, |
34581c95 | 68 | }; |
2258f158 | 69 | |
8e77275e | 70 | enum { |
71 | IN_BINDTYPE_NONE = -1, | |
72 | IN_BINDTYPE_EMU = 0, | |
73 | IN_BINDTYPE_PLAYER12, | |
25cfdf0a | 74 | IN_BINDTYPE_PLAYER34, |
8e77275e | 75 | IN_BINDTYPE_COUNT |
76 | }; | |
77 | ||
78 | #define IN_BIND_OFFS(key, btype) \ | |
79 | ((key) * IN_BINDTYPE_COUNT + (btype)) | |
80 | ||
c19e28f6 PC |
81 | typedef struct InputDriver in_drv_t; |
82 | ||
83 | struct InputDriver { | |
da767bd5 | 84 | const char *prefix; |
c19e28f6 | 85 | void (*probe)(const in_drv_t *drv); |
da767bd5 | 86 | void (*free)(void *drv_data); |
23fb16c8 | 87 | const char * const * |
d685ce46 | 88 | (*get_key_names)(const in_drv_t *drv, int *count); |
8e77275e | 89 | int (*clean_binds)(void *drv_data, int *binds, int *def_finds); |
e9b29264 | 90 | int (*get_config)(void *drv_data, int what, int *val); |
91 | int (*set_config)(void *drv_data, int what, int val); | |
c4334e00 | 92 | int (*update)(void *drv_data, const int *binds, int *result); |
df77913a | 93 | int (*update_analog)(void *drv_data, int axis_id, int *result); |
23fb16c8 | 94 | /* return -1 on no event, -2 on error */ |
7f022a8d | 95 | int (*update_keycode)(void *drv_data, int *is_down); |
9934732a | 96 | int (*menu_translate)(void *drv_data, int keycode, char *charcode); |
da767bd5 | 97 | int (*get_key_code)(const char *key_name); |
98 | const char * (*get_key_name)(int keycode); | |
215aec76 | 99 | |
100 | const struct in_default_bind *defbinds; | |
c19e28f6 PC |
101 | const void *pdata; |
102 | }; | |
da767bd5 | 103 | |
4c918681 | 104 | struct in_default_bind { |
105 | unsigned short code; | |
106 | unsigned char btype; /* IN_BINDTYPE_* */ | |
107 | unsigned char bit; | |
108 | }; | |
da767bd5 | 109 | |
c19e28f6 PC |
110 | struct menu_keymap { |
111 | short key; | |
112 | short pbtn; | |
113 | }; | |
114 | ||
115 | struct in_pdata { | |
116 | const struct in_default_bind *defbinds; | |
117 | const struct menu_keymap *key_map; | |
118 | size_t kmap_size; | |
119 | const struct menu_keymap *joy_map; | |
120 | size_t jmap_size; | |
d685ce46 | 121 | const char * const *key_names; |
c19e28f6 PC |
122 | }; |
123 | ||
2258f158 | 124 | /* to be called by drivers */ |
c19e28f6 PC |
125 | int in_register_driver(const in_drv_t *drv, |
126 | const struct in_default_bind *defbinds, const void *pdata); | |
c4334e00 | 127 | void in_register(const char *nname, int drv_fd_hnd, void *drv_data, |
e9b29264 | 128 | int key_count, const char * const *key_names, int combos); |
8e77275e | 129 | void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts); |
130 | int in_combos_do(int keys, const int *binds, int last_key, int combo_keys, int combo_acts); | |
2258f158 | 131 | |
132 | void in_init(void); | |
133 | void in_probe(void); | |
8e77275e | 134 | int in_update(int *result); |
df77913a | 135 | int in_update_analog(int dev_id, int axis_id, int *value); |
9934732a | 136 | int in_update_keycode(int *dev_id, int *is_down, char *charcode, int timeout_ms); |
137 | int in_menu_wait_any(char *charcode, int timeout_ms); | |
138 | int in_menu_wait(int interesting, char *charcode, int autorep_delay_ms); | |
da767bd5 | 139 | int in_config_parse_dev(const char *dev_name); |
8e77275e | 140 | int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type); |
e9b29264 | 141 | int in_get_config(int dev_id, int what, void *val); |
142 | int in_set_config(int dev_id, int what, const void *val, int size); | |
d166ceb6 | 143 | int in_get_key_code(int dev_id, const char *key_name); |
e9b29264 | 144 | int in_name_to_id(const char *dev_name); |
92068389 | 145 | int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind); |
146 | void in_unbind_all(int dev_id, int act_mask, int bind_type); | |
45a39652 | 147 | void in_clean_binds(void); |
da767bd5 | 148 | void in_debug_dump(void); |
149 | ||
150 | const int *in_get_dev_binds(int dev_id); | |
151 | const int *in_get_dev_def_binds(int dev_id); | |
049a6b3e | 152 | const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix); |
595491c4 | 153 | const char *in_get_key_name(int dev_id, int keycode); |
e9b29264 | 154 | |
155 | #define in_set_config_int(dev_id, what, v) { \ | |
156 | int val_ = v; \ | |
157 | in_set_config(dev_id, what, &val_, sizeof(val_)); \ | |
158 | } | |
75b18496 | 159 | |
160 | #endif /* INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc */ |