75b18496 |
1 | #ifndef INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc |
2 | #define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1 |
3 | |
da767bd5 |
4 | #define IN_MAX_DEVS 10 |
5 | |
82abf46f |
6 | /* unified menu keys */ |
7 | #define PBTN_UP (1 << 0) |
8 | #define PBTN_DOWN (1 << 1) |
9 | #define PBTN_LEFT (1 << 2) |
10 | #define PBTN_RIGHT (1 << 3) |
11 | |
12 | #define PBTN_MOK (1 << 4) |
13 | #define PBTN_MBACK (1 << 5) |
14 | #define PBTN_MA2 (1 << 6) /* menu action 2 */ |
15 | #define PBTN_MA3 (1 << 7) |
16 | |
17 | #define PBTN_L (1 << 8) |
18 | #define PBTN_R (1 << 9) |
19 | |
20 | #define PBTN_MENU (1 << 10) |
21 | |
388947f3 |
22 | /* ui events */ |
23 | #define PEVB_VOL_DOWN 30 |
24 | #define PEVB_VOL_UP 29 |
25 | #define PEVB_STATE_LOAD 28 |
26 | #define PEVB_STATE_SAVE 27 |
27 | #define PEVB_SWITCH_RND 26 |
28 | #define PEVB_SSLOT_PREV 25 |
29 | #define PEVB_SSLOT_NEXT 24 |
30 | #define PEVB_MENU 23 |
31 | #define PEVB_FF 22 |
93c18cb4 |
32 | #define PEVB_PICO_PNEXT 21 |
33 | #define PEVB_PICO_PPREV 20 |
34 | #define PEVB_PICO_SWINP 19 |
388947f3 |
35 | |
36 | #define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN) |
37 | #define PEV_VOL_UP (1 << PEVB_VOL_UP) |
38 | #define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD) |
39 | #define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE) |
40 | #define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND) |
41 | #define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV) |
42 | #define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT) |
43 | #define PEV_MENU (1 << PEVB_MENU) |
44 | #define PEV_FF (1 << PEVB_FF) |
93c18cb4 |
45 | #define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT) |
46 | #define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV) |
47 | #define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP) |
388947f3 |
48 | |
93c18cb4 |
49 | #define PEV_MASK 0x7ff80000 |
388947f3 |
50 | |
51 | |
34581c95 |
52 | enum { |
da767bd5 |
53 | IN_DRVID_UNKNOWN = 0, |
7f022a8d |
54 | IN_DRVID_GP2X, |
13b692eb |
55 | IN_DRVID_EVDEV, |
8ced8d2b |
56 | IN_DRVID_VK, |
2c600560 |
57 | IN_DRVID_COUNT, |
58 | }; |
59 | |
60 | enum { |
e9b29264 |
61 | IN_CFG_BIND_COUNT = 0, |
62 | IN_CFG_DOES_COMBOS, |
63 | IN_CFG_BLOCKING, |
64 | IN_CFG_KEY_NAMES, |
65 | IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */ |
34581c95 |
66 | }; |
2258f158 |
67 | |
8e77275e |
68 | enum { |
69 | IN_BINDTYPE_NONE = -1, |
70 | IN_BINDTYPE_EMU = 0, |
71 | IN_BINDTYPE_PLAYER12, |
72 | IN_BINDTYPE_COUNT |
73 | }; |
74 | |
75 | #define IN_BIND_OFFS(key, btype) \ |
76 | ((key) * IN_BINDTYPE_COUNT + (btype)) |
77 | |
da767bd5 |
78 | typedef struct { |
79 | const char *prefix; |
80 | void (*probe)(void); |
81 | void (*free)(void *drv_data); |
82 | int (*get_bind_count)(void); |
23fb16c8 |
83 | const char * const * |
84 | (*get_key_names)(int *count); |
da767bd5 |
85 | void (*get_def_binds)(int *binds); |
8e77275e |
86 | int (*clean_binds)(void *drv_data, int *binds, int *def_finds); |
e9b29264 |
87 | int (*get_config)(void *drv_data, int what, int *val); |
88 | int (*set_config)(void *drv_data, int what, int val); |
23fb16c8 |
89 | /* return -1 on no event, -2 on error */ |
7f022a8d |
90 | int (*update_keycode)(void *drv_data, int *is_down); |
e9b29264 |
91 | int (*menu_translate)(void *drv_data, int keycode); |
da767bd5 |
92 | int (*get_key_code)(const char *key_name); |
93 | const char * (*get_key_name)(int keycode); |
94 | } in_drv_t; |
95 | |
4c918681 |
96 | struct in_default_bind { |
97 | unsigned short code; |
98 | unsigned char btype; /* IN_BINDTYPE_* */ |
99 | unsigned char bit; |
100 | }; |
da767bd5 |
101 | |
2258f158 |
102 | /* to be called by drivers */ |
8e77275e |
103 | void in_register(const char *nname, int drv_id, int drv_fd_hnd, void *drv_data, |
e9b29264 |
104 | int key_count, const char * const *key_names, int combos); |
8e77275e |
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); |
2258f158 |
107 | |
108 | void in_init(void); |
109 | void in_probe(void); |
8e77275e |
110 | int in_update(int *result); |
906bdc9f |
111 | int in_update_keycode(int *dev_id, int *is_down, int timeout_ms); |
fce20e73 |
112 | int in_menu_wait_any(int timeout_ms); |
049a6b3e |
113 | int in_menu_wait(int interesting, int autorep_delay_ms); |
da767bd5 |
114 | int in_config_parse_dev(const char *dev_name); |
8e77275e |
115 | int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type); |
e9b29264 |
116 | int in_get_config(int dev_id, int what, void *val); |
117 | int in_set_config(int dev_id, int what, const void *val, int size); |
d166ceb6 |
118 | int in_get_key_code(int dev_id, const char *key_name); |
e9b29264 |
119 | int in_name_to_id(const char *dev_name); |
92068389 |
120 | int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind); |
121 | void in_unbind_all(int dev_id, int act_mask, int bind_type); |
45a39652 |
122 | void in_clean_binds(void); |
da767bd5 |
123 | void in_debug_dump(void); |
124 | |
125 | const int *in_get_dev_binds(int dev_id); |
126 | const int *in_get_dev_def_binds(int dev_id); |
049a6b3e |
127 | const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix); |
595491c4 |
128 | const char *in_get_key_name(int dev_id, int keycode); |
e9b29264 |
129 | |
130 | #define in_set_config_int(dev_id, what, v) { \ |
131 | int val_ = v; \ |
132 | in_set_config(dev_id, what, &val_, sizeof(val_)); \ |
133 | } |
75b18496 |
134 | |
135 | #endif /* INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc */ |