return ret;
}
+static in_dev_t *get_dev(int dev_id)
+{
+ if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ return NULL;
+
+ return &in_devices[dev_id];
+}
+
+int in_update_analog(int dev_id, int axis_id, int *result)
+{
+ in_dev_t *dev = get_dev(dev_id);
+
+ if (dev == NULL || !dev->probed)
+ return -1;
+
+ return DRV(dev->drv_id).update_analog(dev->drv_data, axis_id, result);
+}
+
static int in_update_kc_async(int *dev_id_out, int *is_down_out, int timeout_ms)
{
int i, is_down, result;
const int *in_get_dev_binds(int dev_id)
{
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
- return NULL;
+ in_dev_t *dev = get_dev(dev_id);
- return in_devices[dev_id].binds;
+ return dev ? dev->binds : NULL;
}
const int *in_get_dev_def_binds(int dev_id)
{
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ in_dev_t *dev = get_dev(dev_id);
+ if (dev == NULL)
return NULL;
- return in_devices[dev_id].binds + in_devices[dev_id].key_count * IN_BINDTYPE_COUNT;
+ return dev->binds + dev->key_count * IN_BINDTYPE_COUNT;
}
int in_get_config(int dev_id, int what, void *val)
int *ival = val;
in_dev_t *dev;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS || val == NULL)
+ dev = get_dev(dev_id);
+ if (dev == NULL || val == NULL)
return -1;
- dev = &in_devices[dev_id];
switch (what) {
case IN_CFG_BIND_COUNT:
*ival = dev->key_count;
if (what == IN_CFG_BLOCKING)
return in_set_blocking(*ival);
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ dev = get_dev(dev_id);
+ if (dev == NULL)
return -1;
- dev = &in_devices[dev_id];
if (what == IN_CFG_KEY_NAMES) {
const char * const *names = val;
int count = size / sizeof(names[0]);
const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix)
{
const char *name, *tmp;
+ in_dev_t *dev;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ dev = get_dev(dev_id);
+ if (dev == NULL)
return NULL;
- if (must_be_active && !in_devices[dev_id].probed)
+ if (must_be_active && !dev->probed)
return NULL;
- name = in_devices[dev_id].name;
+ name = dev->name;
if (name == NULL || !skip_pfix)
return name;
if (dev_id < 0) /* want last used dev? */
dev_id = menu_last_used_dev;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ dev = get_dev(dev_id);
+ if (dev == NULL)
return "Unkn0";
- dev = &in_devices[dev_id];
drv = &DRV(dev->drv_id);
if (keycode < 0) /* want name for menu key? */
keycode = drv->menu_translate(dev->drv_data, keycode);
if (dev_id < 0) /* want last used dev? */
dev_id = menu_last_used_dev;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
+ dev = get_dev(dev_id);
+ if (dev == NULL)
return -1;
- dev = &in_devices[dev_id];
if (dev->key_names == NULL)
return -1;
int ret, count;
in_dev_t *dev;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS || bind_type >= IN_BINDTYPE_COUNT)
+ dev = get_dev(dev_id);
+ if (dev == NULL || bind_type >= IN_BINDTYPE_COUNT)
return -1;
- dev = &in_devices[dev_id];
count = dev->key_count;
if (dev->binds == NULL) {
in_dev_t *dev;
int i, offs, kc;
- if (dev_id < 0 || dev_id >= IN_MAX_DEVS || bind_type >= IN_BINDTYPE_COUNT)
+ dev = get_dev(dev_id);
+ if (dev == NULL || bind_type >= IN_BINDTYPE_COUNT)
return -1;
- dev = &in_devices[dev_id];
/* maybe a raw code? */
if (key[0] == '\\' && key[1] == 'x') {
static int in_def_clean_binds(void *drv_data, int *b, int *db) { return 1; }
static int in_def_get_config(void *drv_data, int what, int *val) { return -1; }
static int in_def_set_config(void *drv_data, int what, int val) { return -1; }
+static int in_def_update_analog(void *drv_data, int axis_id, int *result) { return -1; }
static int in_def_update_keycode(void *drv_data, int *is_down) { return 0; }
static int in_def_menu_translate(void *drv_data, int keycode) { return 0; }
static int in_def_get_key_code(const char *key_name) { return -1; }
CHECK_ADD_STUB(new_drivers[in_driver_count], clean_binds);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_config);
CHECK_ADD_STUB(new_drivers[in_driver_count], set_config);
+ CHECK_ADD_STUB(new_drivers[in_driver_count], update_analog);
CHECK_ADD_STUB(new_drivers[in_driver_count], update_keycode);
CHECK_ADD_STUB(new_drivers[in_driver_count], menu_translate);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_code);
#define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1
#define IN_MAX_DEVS 10
+#define IN_ABS_RANGE 1024 /* abs must be centered at 0, move upto +- this */
/* unified menu keys */
#define PBTN_UP (1 << 0)
IN_CFG_DOES_COMBOS,
IN_CFG_BLOCKING,
IN_CFG_KEY_NAMES,
- IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */
+ IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */
+ IN_CFG_ABS_AXIS_COUNT, /* number of abs axes (ro) */
};
enum {
int (*get_config)(void *drv_data, int what, int *val);
int (*set_config)(void *drv_data, int what, int val);
int (*update)(void *drv_data, const int *binds, int *result);
+ int (*update_analog)(void *drv_data, int axis_id, int *result);
/* return -1 on no event, -2 on error */
int (*update_keycode)(void *drv_data, int *is_down);
int (*menu_translate)(void *drv_data, int keycode);
void in_init(void);
void in_probe(void);
int in_update(int *result);
+int in_update_analog(int dev_id, int axis_id, int *value);
int in_update_keycode(int *dev_id, int *is_down, int timeout_ms);
int in_menu_wait_any(int timeout_ms);
int in_menu_wait(int interesting, int autorep_delay_ms);