mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
spark input device handling: add function for reopening
Origin commit data
------------------
Branch: master
Commit: 53e9396bc1
Author: martii <you@example.com>
Date: 2012-09-18 (Tue, 18 Sep 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -37,8 +37,8 @@ typedef struct {
|
|||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
int fd;
|
int fd;
|
||||||
int major;
|
unsigned int major;
|
||||||
int minor;
|
unsigned int minor;
|
||||||
time_t next_discovery;
|
time_t next_discovery;
|
||||||
} input_device_t;
|
} input_device_t;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ static input_device_t input_device[] = {
|
|||||||
|
|
||||||
static int number_of_input_devices = 0;
|
static int number_of_input_devices = 0;
|
||||||
|
|
||||||
static int do_mknod(int i, char *d_name) {
|
static void do_mknod(int i, char *d_name) {
|
||||||
char name[255];
|
char name[255];
|
||||||
int dev = -1;
|
int dev = -1;
|
||||||
// I've no idea how the event device number is actually calculated. Just loop. --martii
|
// I've no idea how the event device number is actually calculated. Just loop. --martii
|
||||||
@@ -152,6 +152,26 @@ static void open_input_devices(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reopen_input_devices(void) {
|
||||||
|
create_input_devices();
|
||||||
|
time_t now = time(NULL);
|
||||||
|
for (int i = 0; i < number_of_input_devices; i++) {
|
||||||
|
input_device[i].next_discovery = now + 60;
|
||||||
|
int fd = open(input_device[i].name, O_RDWR | O_NONBLOCK);
|
||||||
|
if (fd > -1) {
|
||||||
|
if (input_device[i].fd > -1) {
|
||||||
|
dup2(fd, input_device[i].fd);
|
||||||
|
close (fd);
|
||||||
|
} else {
|
||||||
|
input_device[i].fd = fd;
|
||||||
|
}
|
||||||
|
} else if (input_device[i].fd > -1) {
|
||||||
|
close (input_device[i].fd);
|
||||||
|
input_device[i].fd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void close_input_devices(void) {
|
static void close_input_devices(void) {
|
||||||
for (int i = 0; i < number_of_input_devices; i++)
|
for (int i = 0; i < number_of_input_devices; i++)
|
||||||
if (input_device[i].fd > -1) {
|
if (input_device[i].fd > -1) {
|
||||||
@@ -267,6 +287,10 @@ void init_td_api()
|
|||||||
start_inmux_thread();
|
start_inmux_thread();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef MARTII
|
||||||
|
else
|
||||||
|
reopen_input_devices();
|
||||||
|
#endif
|
||||||
initialized = true;
|
initialized = true;
|
||||||
lt_info("%s end\n", __FUNCTION__);
|
lt_info("%s end\n", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user