1a9c3e2b |
1 | #ifndef INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc |
2 | #define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1 |
3 | |
819ef025 |
4 | #define IN_MAX_DEVS 10 |
bdefb7c1 |
5 | #define IN_ABS_RANGE 1024 /* abs must be centered at 0, move upto +- this */ |
819ef025 |
6 | |
991473ad |
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 | |
23bfd0f2 |
23 | // TODO: move to pico |
24 | #if 0 |
25 | |
d34a42f9 |
26 | /* ui events */ |
27 | #define PEVB_VOL_DOWN 30 |
28 | #define PEVB_VOL_UP 29 |
29 | #define PEVB_STATE_LOAD 28 |
30 | #define PEVB_STATE_SAVE 27 |
31 | #define PEVB_SWITCH_RND 26 |
32 | #define PEVB_SSLOT_PREV 25 |
33 | #define PEVB_SSLOT_NEXT 24 |
34 | #define PEVB_MENU 23 |
35 | #define PEVB_FF 22 |
f2cf8472 |
36 | #define PEVB_PICO_PNEXT 21 |
37 | #define PEVB_PICO_PPREV 20 |
38 | #define PEVB_PICO_SWINP 19 |
d34a42f9 |
39 | |
40 | #define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN) |
41 | #define PEV_VOL_UP (1 << PEVB_VOL_UP) |
42 | #define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD) |
43 | #define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE) |
44 | #define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND) |
45 | #define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV) |
46 | #define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT) |
47 | #define PEV_MENU (1 << PEVB_MENU) |
48 | #define PEV_FF (1 << PEVB_FF) |
f2cf8472 |
49 | #define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT) |
50 | #define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV) |
51 | #define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP) |
d34a42f9 |
52 | |
f2cf8472 |
53 | #define PEV_MASK 0x7ff80000 |
d34a42f9 |
54 | |
23bfd0f2 |
55 | #endif |
d34a42f9 |
56 | |
9025b931 |
57 | enum { |
603c28b3 |
58 | IN_CFG_BIND_COUNT = 0, |
59 | IN_CFG_DOES_COMBOS, |
60 | IN_CFG_BLOCKING, |
61 | IN_CFG_KEY_NAMES, |
bdefb7c1 |
62 | IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */ |
63 | IN_CFG_ABS_AXIS_COUNT, /* number of abs axes (ro) */ |
3b13ec65 |
64 | }; |
e1f99f2b |
65 | |
093b8a42 |
66 | enum { |
67 | IN_BINDTYPE_NONE = -1, |
68 | IN_BINDTYPE_EMU = 0, |
69 | IN_BINDTYPE_PLAYER12, |
70 | IN_BINDTYPE_COUNT |
71 | }; |
72 | |
73 | #define IN_BIND_OFFS(key, btype) \ |
74 | ((key) * IN_BINDTYPE_COUNT + (btype)) |
75 | |
819ef025 |
76 | typedef struct { |
77 | const char *prefix; |
78 | void (*probe)(void); |
79 | void (*free)(void *drv_data); |
cb906f69 |
80 | const char * const * |
81 | (*get_key_names)(int *count); |
819ef025 |
82 | void (*get_def_binds)(int *binds); |
093b8a42 |
83 | int (*clean_binds)(void *drv_data, int *binds, int *def_finds); |
603c28b3 |
84 | int (*get_config)(void *drv_data, int what, int *val); |
85 | int (*set_config)(void *drv_data, int what, int val); |
dde168a1 |
86 | int (*update)(void *drv_data, const int *binds, int *result); |
bdefb7c1 |
87 | int (*update_analog)(void *drv_data, int axis_id, int *result); |
cb906f69 |
88 | /* return -1 on no event, -2 on error */ |
7201dc73 |
89 | int (*update_keycode)(void *drv_data, int *is_down); |
603c28b3 |
90 | int (*menu_translate)(void *drv_data, int keycode); |
819ef025 |
91 | int (*get_key_code)(const char *key_name); |
92 | const char * (*get_key_name)(int keycode); |
93 | } in_drv_t; |
94 | |
72f3f175 |
95 | struct in_default_bind { |
96 | unsigned short code; |
97 | unsigned char btype; /* IN_BINDTYPE_* */ |
98 | unsigned char bit; |
99 | }; |
819ef025 |
100 | |
e1f99f2b |
101 | /* to be called by drivers */ |
dde168a1 |
102 | int in_register_driver(const in_drv_t *drv); |
103 | void in_register(const char *nname, int drv_fd_hnd, void *drv_data, |
603c28b3 |
104 | int key_count, const char * const *key_names, int combos); |
093b8a42 |
105 | void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts); |
106 | int in_combos_do(int keys, const int *binds, int last_key, int combo_keys, int combo_acts); |
e1f99f2b |
107 | |
108 | void in_init(void); |
109 | void in_probe(void); |
093b8a42 |
110 | int in_update(int *result); |
bdefb7c1 |
111 | int in_update_analog(int dev_id, int axis_id, int *value); |
f484a9fe |
112 | int in_update_keycode(int *dev_id, int *is_down, int timeout_ms); |
b6820926 |
113 | int in_menu_wait_any(int timeout_ms); |
713c9224 |
114 | int in_menu_wait(int interesting, int autorep_delay_ms); |
819ef025 |
115 | int in_config_parse_dev(const char *dev_name); |
093b8a42 |
116 | int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type); |
603c28b3 |
117 | int in_get_config(int dev_id, int what, void *val); |
118 | int in_set_config(int dev_id, int what, const void *val, int size); |
b9574f42 |
119 | int in_get_key_code(int dev_id, const char *key_name); |
603c28b3 |
120 | int in_name_to_id(const char *dev_name); |
37807164 |
121 | int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind); |
122 | void in_unbind_all(int dev_id, int act_mask, int bind_type); |
eb564311 |
123 | void in_clean_binds(void); |
819ef025 |
124 | void in_debug_dump(void); |
125 | |
126 | const int *in_get_dev_binds(int dev_id); |
127 | const int *in_get_dev_def_binds(int dev_id); |
713c9224 |
128 | const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix); |
3427e573 |
129 | const char *in_get_key_name(int dev_id, int keycode); |
603c28b3 |
130 | |
131 | #define in_set_config_int(dev_id, what, v) { \ |
132 | int val_ = v; \ |
133 | in_set_config(dev_id, what, &val_, sizeof(val_)); \ |
134 | } |
1a9c3e2b |
135 | |
136 | #endif /* INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc */ |