diff --git a/dev_in.c b/dev_in.c index d3751c0..1fe6e32 100644 --- a/dev_in.c +++ b/dev_in.c @@ -232,8 +232,6 @@ void* dev_in_thread_func(void *ptr) { } for (;;) { - - FD_ZERO(&read_fds); FD_SET(devs->in_message_pipe_fd, &read_fds); for (size_t i = 0; i < devs->input_dev_cnt; ++i) { @@ -245,10 +243,10 @@ void* dev_in_thread_func(void *ptr) { } else if (devices[i].type == DEV_IN_TYPE_NONE) { - if (devs->input_dev_decl[i].dev_type == input_dev_type_uinput) { - fprintf(stderr, "Device (evdev) %zu not found -- Attempt reconnection for device named %s\n", i, devs->input_dev_decl[i].filters.ev.name); + if ((*devs->input_dev_decl)[i].dev_type == input_dev_type_uinput) { + fprintf(stderr, "Device (evdev) %zu not found -- Attempt reconnection for device named %s\n", i, (*devs->input_dev_decl)[i].filters.ev.name); - const int open_res = open_device(&devs->input_dev_decl[i].filters.ev, &devices[i].dev.evdev); + const int open_res = open_device(&(*devs->input_dev_decl)[i].filters.ev, &devices[i].dev.evdev); if (open_res == 0) { devices[i].type = DEV_IN_TYPE_EV; @@ -312,7 +310,7 @@ void* dev_in_thread_func(void *ptr) { fprintf(stderr, "Unable to fill input_event(s) for device %zd: %d\n", i, fill_res); continue; } else { - devs->input_dev_decl[i].ev_input_map_fn(&coll, devs->in_message_pipe_fd, devs->input_dev_decl[i].user_data); + (*devs->input_dev_decl)[i].ev_input_map_fn(&coll, devs->in_message_pipe_fd, (*devs->input_dev_decl)[i].user_data); } } else if (devices[i].type == DEV_IN_TYPE_EV) { // TODO: implement IIO diff --git a/dev_in.h b/dev_in.h index 6172b8f..deeb7ab 100644 --- a/dev_in.h +++ b/dev_in.h @@ -10,7 +10,7 @@ typedef struct dev_in_data { uint64_t timeout_ms; // declarations of devices to monitor - input_dev_t *input_dev_decl; + input_dev_t **input_dev_decl; // number of devices to monitor size_t input_dev_cnt; diff --git a/main.c b/main.c index 25168dc..d33aa68 100644 --- a/main.c +++ b/main.c @@ -59,7 +59,7 @@ int main(int argc, char ** argv) { dev_in_thread_data.timeout_ms = 400; dev_in_thread_data.in_message_pipe_fd = in_message_pipes[1]; dev_in_thread_data.out_message_pipe_fd = out_message_pipes[0]; - dev_in_thread_data.input_dev_decl = *in_devs; + dev_in_thread_data.input_dev_decl = in_devs; dev_in_thread_data.input_dev_cnt = in_devs_sz; // populate the output device thread data