diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/evemu-impl.h | 19 | ||||
| -rw-r--r-- | src/evemu.c | 31 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/evemu-impl.h b/src/evemu-impl.h new file mode 100644 index 0000000..2346590 --- /dev/null +++ b/src/evemu-impl.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #ifndef _EVEMU_IMPL_H | ||
| 2 | #define _EVEMU_IMPL_H | ||
| 3 | |||
| 4 | #include <evemu.h> | ||
| 5 | #include <linux/uinput.h> | ||
| 6 | |||
| 7 | #define EVPLAY_NBITS KEY_CNT | ||
| 8 | #define EVPLAY_NBYTES ((EVPLAY_NBITS + 7) / 8) | ||
| 9 | |||
| 10 | struct evemu_device { | ||
| 11 | int version_major, version_minor; | ||
| 12 | char name[UINPUT_MAX_NAME_SIZE]; | ||
| 13 | struct input_id id; | ||
| 14 | unsigned char mask[EV_CNT][EVPLAY_NBYTES]; | ||
| 15 | int bytes[EV_CNT]; | ||
| 16 | struct input_absinfo abs[ABS_CNT]; | ||
| 17 | }; | ||
| 18 | |||
| 19 | #endif | ||
diff --git a/src/evemu.c b/src/evemu.c index 54156aa..53bda86 100644 --- a/src/evemu.c +++ b/src/evemu.c | |||
| @@ -26,7 +26,8 @@ | |||
| 26 | * | 26 | * |
| 27 | ****************************************************************************/ | 27 | ****************************************************************************/ |
| 28 | 28 | ||
| 29 | #include "evemu.h" | 29 | #include "evemu-impl.h" |
| 30 | #include <stdlib.h> | ||
| 30 | #include <string.h> | 31 | #include <string.h> |
| 31 | #include <stdio.h> | 32 | #include <stdio.h> |
| 32 | #include <fcntl.h> | 33 | #include <fcntl.h> |
| @@ -44,6 +45,34 @@ static void copy_bits(unsigned char *mask, const unsigned long *bits, int bytes) | |||
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 48 | struct evemu_device *evemu_new(const char *name) | ||
| 49 | { | ||
| 50 | struct evemu_device *dev = calloc(1, sizeof(struct evemu_device)); | ||
| 51 | |||
| 52 | dev->version_major = EVEMU_VERSION_MAJOR; | ||
| 53 | dev->version_minor = EVEMU_VERSION_MINOR; | ||
| 54 | |||
| 55 | if (name && strlen(name) < sizeof(dev->name)) | ||
| 56 | strcpy(dev->name, name); | ||
| 57 | |||
| 58 | return dev; | ||
| 59 | } | ||
| 60 | |||
| 61 | void evemu_delete(struct evemu_device *dev) | ||
| 62 | { | ||
| 63 | free(dev); | ||
| 64 | } | ||
| 65 | |||
| 66 | const char *evemu_get_name(const struct evemu_device *dev) | ||
| 67 | { | ||
| 68 | return dev->name; | ||
| 69 | } | ||
| 70 | |||
| 71 | int evemu_has(const struct evemu_device *dev, int type, int code) | ||
| 72 | { | ||
| 73 | return (dev->mask[type][code >> 3] >> (code & 7)) & 1; | ||
| 74 | } | ||
| 75 | |||
| 47 | int evemu_extract(struct evemu_device *dev, int fd) | 76 | int evemu_extract(struct evemu_device *dev, int fd) |
| 48 | { | 77 | { |
| 49 | unsigned long bits[64]; | 78 | unsigned long bits[64]; |
