diff options
Diffstat (limited to 'sensors/input.c')
-rw-r--r-- | sensors/input.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sensors/input.c b/sensors/input.c index 5199b28..a370807 100644 --- a/sensors/input.c +++ b/sensors/input.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <errno.h> #include <dirent.h> +#include <string.h> #include <linux/ioctl.h> #include <linux/input.h> #include <linux/uinput.h> @@ -44,7 +45,7 @@ void input_event_set(struct input_event *event, int type, int code, int value) gettimeofday(&event->time, NULL); } -long int timestamp(struct timeval *time) +int64_t timestamp(struct timeval *time) { if (time == NULL) return -1; @@ -52,7 +53,7 @@ long int timestamp(struct timeval *time) return time->tv_sec * 1000000000LL + time->tv_usec * 1000; } -long int input_timestamp(struct input_event *event) +int64_t input_timestamp(struct input_event *event) { if (event == NULL) return -1; @@ -88,6 +89,7 @@ int uinput_rel_create(const char *name) rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X); rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y); rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z); + rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_MISC); rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN); if (rc < 0) { @@ -213,10 +215,10 @@ int sysfs_path_prefix(char *name, char *path_prefix) return -1; } -int sysfs_value_read(char *path) +int64_t sysfs_value_read(char *path) { char buffer[100]; - int value; + int64_t value; int fd = -1; int rc; int i; @@ -236,7 +238,7 @@ int sysfs_value_read(char *path) while (buffer[i] == ' ' || buffer[i] == '\t') i++; - value = atoi(&buffer[i]); + value = (int64_t)strtoimax(&buffer[i], NULL, 10); goto complete; error: @@ -249,7 +251,7 @@ complete: return value; } -int sysfs_value_write(char *path, int value) +int sysfs_value_write(char *path, int64_t value) { char buffer[100]; int fd = -1; @@ -262,7 +264,7 @@ int sysfs_value_write(char *path, int value) if (fd < 0) goto error; - snprintf((char *) &buffer, sizeof(buffer), "%d\n", value); + snprintf((char *) &buffer, sizeof(buffer), "%" PRId64 "\n", value); rc = write(fd, buffer, strlen(buffer)); if (rc < (int) strlen(buffer)) |