timer timeout to evdev
This commit is contained in:
parent
6eb6847444
commit
ea5f026e04
3 changed files with 68 additions and 2 deletions
30
dev_in.c
30
dev_in.c
|
|
@ -56,6 +56,8 @@ typedef struct dev_in_timer {
|
||||||
|
|
||||||
dev_timer_t* timer;
|
dev_timer_t* timer;
|
||||||
|
|
||||||
|
const char* name;
|
||||||
|
|
||||||
timer_callbacks_t callbacks;
|
timer_callbacks_t callbacks;
|
||||||
|
|
||||||
void* user_data;
|
void* user_data;
|
||||||
|
|
@ -384,6 +386,25 @@ static void handle_leds(const dev_in_settings_t *const conf, dev_in_t *const in_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_timeout(
|
||||||
|
const dev_in_settings_t *const conf,
|
||||||
|
dev_in_t *const in_devs,
|
||||||
|
size_t in_devs_count,
|
||||||
|
const char* name,
|
||||||
|
uint64_t expirations
|
||||||
|
) {
|
||||||
|
for (size_t i = 0; i < in_devs_count; ++i) {
|
||||||
|
if (in_devs[i].type == DEV_IN_TYPE_EV) {
|
||||||
|
in_devs[i].dev.hidraw.callbacks.timeout_callback(
|
||||||
|
conf,
|
||||||
|
name,
|
||||||
|
expirations,
|
||||||
|
in_devs[i].dev.evdev.user_data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int open_socket(struct sockaddr_un *serveraddr) {
|
static int open_socket(struct sockaddr_un *serveraddr) {
|
||||||
int res = -ENODEV;
|
int res = -ENODEV;
|
||||||
|
|
||||||
|
|
@ -531,6 +552,7 @@ void* dev_in_thread_func(void *ptr) {
|
||||||
if (open_res == 0) {
|
if (open_res == 0) {
|
||||||
devices[i].dev.timer.callbacks = dev_in_data->input_dev_decl->dev[i]->map.timer_callbacks;
|
devices[i].dev.timer.callbacks = dev_in_data->input_dev_decl->dev[i]->map.timer_callbacks;
|
||||||
devices[i].dev.timer.user_data = dev_in_data->input_dev_decl->dev[i]->user_data;
|
devices[i].dev.timer.user_data = dev_in_data->input_dev_decl->dev[i]->user_data;
|
||||||
|
devices[i].dev.timer.name = dev_in_data->input_dev_decl->dev[i]->filters.timer.name;
|
||||||
devices[i].type = DEV_IN_TYPE_TIMER;
|
devices[i].type = DEV_IN_TYPE_TIMER;
|
||||||
|
|
||||||
// device is now connected, query it in select
|
// device is now connected, query it in select
|
||||||
|
|
@ -686,6 +708,14 @@ void* dev_in_thread_func(void *ptr) {
|
||||||
devices[i].type = DEV_IN_TYPE_NONE;
|
devices[i].type = DEV_IN_TYPE_NONE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_timeout(
|
||||||
|
&dev_in_data->settings,
|
||||||
|
devices,
|
||||||
|
max_devices,
|
||||||
|
devices[i].dev.timer.name,
|
||||||
|
expirations
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send messages (if any)
|
// send messages (if any)
|
||||||
|
|
|
||||||
16
input_dev.h
16
input_dev.h
|
|
@ -18,7 +18,19 @@ typedef struct evdev_collected {
|
||||||
* A function with this signature grapbs input_event data and sends to the pipe messages
|
* A function with this signature grapbs input_event data and sends to the pipe messages
|
||||||
* constructed from that data.
|
* constructed from that data.
|
||||||
*/
|
*/
|
||||||
typedef int (*ev_map)(const dev_in_settings_t *const conf, const evdev_collected_t *const e, in_message_t *const messages, size_t messages_len, void* user_data);
|
typedef int (*ev_map)(
|
||||||
|
const dev_in_settings_t *const conf,
|
||||||
|
const evdev_collected_t *const e,
|
||||||
|
in_message_t *const messages,
|
||||||
|
size_t messages_len,
|
||||||
|
void* user_data
|
||||||
|
);
|
||||||
|
typedef void (*ev_timer)(
|
||||||
|
const dev_in_settings_t *const conf,
|
||||||
|
const char* const timer_name,
|
||||||
|
uint64_t expired,
|
||||||
|
void* user_data
|
||||||
|
);
|
||||||
|
|
||||||
typedef enum input_dev_type {
|
typedef enum input_dev_type {
|
||||||
input_dev_type_uinput,
|
input_dev_type_uinput,
|
||||||
|
|
@ -49,6 +61,7 @@ typedef struct hidraw_callbacks {
|
||||||
hidraw_set_leds leds_callback;
|
hidraw_set_leds leds_callback;
|
||||||
hidraw_rumble rumble_callback;
|
hidraw_rumble rumble_callback;
|
||||||
hidraw_map map_callback;
|
hidraw_map map_callback;
|
||||||
|
ev_timer timeout_callback;
|
||||||
} hidraw_callbacks_t;
|
} hidraw_callbacks_t;
|
||||||
|
|
||||||
typedef struct iio_settings {
|
typedef struct iio_settings {
|
||||||
|
|
@ -64,6 +77,7 @@ typedef struct timer_callbacks {
|
||||||
|
|
||||||
typedef struct ev_callbacks {
|
typedef struct ev_callbacks {
|
||||||
ev_map input_map_fn;
|
ev_map input_map_fn;
|
||||||
|
ev_timer timeout_callback;
|
||||||
} ev_callbacks_t;
|
} ev_callbacks_t;
|
||||||
|
|
||||||
typedef struct timer_filters {
|
typedef struct timer_filters {
|
||||||
|
|
|
||||||
24
rog_ally.c
24
rog_ally.c
|
|
@ -844,6 +844,15 @@ static input_dev_t in_iio_dev = {
|
||||||
//.input_filter_fn = input_filter_imu_identity,
|
//.input_filter_fn = input_filter_imu_identity,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void rc71l_timer_asus_kbd(
|
||||||
|
const dev_in_settings_t *const conf,
|
||||||
|
const char* const timer_name,
|
||||||
|
uint64_t expired,
|
||||||
|
void* user_data
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static input_dev_t in_asus_kb_1_dev = {
|
static input_dev_t in_asus_kb_1_dev = {
|
||||||
.dev_type = input_dev_type_uinput,
|
.dev_type = input_dev_type_uinput,
|
||||||
.filters = {
|
.filters = {
|
||||||
|
|
@ -855,6 +864,7 @@ static input_dev_t in_asus_kb_1_dev = {
|
||||||
.map = {
|
.map = {
|
||||||
.ev_callbacks = {
|
.ev_callbacks = {
|
||||||
.input_map_fn = asus_kbd_ev_map,
|
.input_map_fn = asus_kbd_ev_map,
|
||||||
|
.timeout_callback = rc71l_timer_asus_kbd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -870,6 +880,7 @@ static input_dev_t in_asus_kb_2_dev = {
|
||||||
.map = {
|
.map = {
|
||||||
.ev_callbacks = {
|
.ev_callbacks = {
|
||||||
.input_map_fn = asus_kbd_ev_map,
|
.input_map_fn = asus_kbd_ev_map,
|
||||||
|
.timeout_callback = rc71l_timer_asus_kbd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -885,10 +896,20 @@ static input_dev_t in_asus_kb_3_dev = {
|
||||||
.map = {
|
.map = {
|
||||||
.ev_callbacks = {
|
.ev_callbacks = {
|
||||||
.input_map_fn = asus_kbd_ev_map,
|
.input_map_fn = asus_kbd_ev_map,
|
||||||
|
.timeout_callback = rc71l_timer_asus_kbd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void rc71l_timer_xbox360(
|
||||||
|
const dev_in_settings_t *const conf,
|
||||||
|
const char* const timer_name,
|
||||||
|
uint64_t expired,
|
||||||
|
void* user_data
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static input_dev_t in_xbox_dev = {
|
static input_dev_t in_xbox_dev = {
|
||||||
.dev_type = input_dev_type_uinput,
|
.dev_type = input_dev_type_uinput,
|
||||||
.filters = {
|
.filters = {
|
||||||
|
|
@ -899,6 +920,7 @@ static input_dev_t in_xbox_dev = {
|
||||||
.map = {
|
.map = {
|
||||||
.ev_callbacks = {
|
.ev_callbacks = {
|
||||||
.input_map_fn = xbox360_ev_map,
|
.input_map_fn = xbox360_ev_map,
|
||||||
|
.timeout_callback = rc71l_timer_xbox360,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1006,7 +1028,7 @@ input_dev_t timer_dev = {
|
||||||
.filters = {
|
.filters = {
|
||||||
.timer = {
|
.timer = {
|
||||||
.name = "RC71L_timer",
|
.name = "RC71L_timer",
|
||||||
.ticktime_ms = 650,
|
.ticktime_ms = 150,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.user_data = NULL,
|
.user_data = NULL,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue