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