aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2009-05-23 14:15:57 +0200
committerdakkar <dakkar@thenautilus.net>2010-04-25 13:41:25 +0100
commit429196248e0082b70d42369ea36ac8897d4363d0 (patch)
tree2530e84dd84d200c6321a1efbac866e637f53ef1
parentevdev 2.3.2 (diff)
downloadxf86-input-evdev-429196248e0082b70d42369ea36ac8897d4363d0.tar.gz
xf86-input-evdev-429196248e0082b70d42369ea36ac8897d4363d0.tar.bz2
xf86-input-evdev-429196248e0082b70d42369ea36ac8897d4363d0.zip
remap table and functions; TODO: init it
-rw-r--r--src/evdev.c28
-rw-r--r--src/evdev.h5
2 files changed, 33 insertions, 0 deletions
diff --git a/src/evdev.c b/src/evdev.c
index faab8f3..f87b648 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -132,6 +132,33 @@ static Atom prop_axis_label = 0;
static Atom prop_btn_label = 0;
#endif
+#define remapKey(ev,x) (ev->keyremap && ev->keyremap->sl[(x)/256] ? ev->keyremap->sl[(x)/256]->cd[(x)%256] : (x))
+
+void addRemap(EvdevPtr ev,uint16_t code,uint8_t value) {
+ uint8_t slice=code/256;
+ uint8_t offs=code%256;
+ if (!ev->map) {
+ ev->map=(EvdevKeyRemapPtr)malloc(sizeof(EvdevKeyRemap));
+ memset(ev->map,0,sizeof(EvdevKeyRemap));
+ }
+ if (!ev->map->sl[slice]) {
+ ev->map->sl[slice]=(EvdevKeyRemapSlice*)malloc(sizeof(EvdevKeyRemapSlice));
+ memset(ev->map->sl[slice],0,sizeof(EvdevKeyRemapSlice));
+ }
+ ev->map->sl[slice]->cd[offs]=value;
+}
+
+void freeRemap(EvdevPtr ev) {
+ uint16_t slice;
+ if (!ev->map) return;
+ for (slice=0;slice<256;++slice) {
+ if (!ev->map->sl[slice]) continue;
+ free(ev->map->sl[slice]);
+ }
+ free(ev->map);
+ ev->map=0;
+}
+
/* All devices the evdev driver has allocated and knows about.
* MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
* cannot be used by evdev, leaving us with a space of 2 at the end. */
@@ -274,6 +301,7 @@ EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
)
return;
+ code=remapKey((EvdevPtr)pInfo->private,code);
if (code > 255)
{
if (ev->code <= KEY_MAX && !warned[ev->code])
diff --git a/src/evdev.h b/src/evdev.h
index 38adeaf..53d32cf 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -99,6 +99,9 @@ typedef struct {
int val; /* State of the key/button; pressed or released. */
} EventQueueRec, *EventQueuePtr;
+typedef struct {uint8_t cd[256];} EvdevKeyRemapSlice;
+typedef struct {EvdevKeyRemapSlice* sl[256];} EvdevKeyRemap, *EvdevKeyRemapPtr;
+
typedef struct {
const char *device;
int grabDevice; /* grab the event device? */
@@ -159,6 +162,8 @@ typedef struct {
unsigned char btnmap[32]; /* config-file specified button mapping */
+ EvdevKeyRemapPtr keyremap;
+
int reopen_attempts; /* max attempts to re-open after read failure */
int reopen_left; /* number of attempts left to re-open the device */
OsTimerPtr reopen_timer;