aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2009-05-23 16:07:36 +0200
committerdakkar <dakkar@thenautilus.net>2010-04-25 13:41:25 +0100
commita6f14f10ec0218fd0ad8321993db556e89bbba97 (patch)
tree58bf8395b6c1eb451ce8445beaf91ff5e5d2515a
parentdocumentation (diff)
downloadxf86-input-evdev-a6f14f10ec0218fd0ad8321993db556e89bbba97.tar.gz
xf86-input-evdev-a6f14f10ec0218fd0ad8321993db556e89bbba97.tar.bz2
xf86-input-evdev-a6f14f10ec0218fd0ad8321993db556e89bbba97.zip
aligned to Xorg coding style
-rw-r--r--src/evdev.c107
-rw-r--r--src/evdev.h10
2 files changed, 61 insertions, 56 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 4b7f58b..c826fa0 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -135,40 +135,41 @@ static Atom prop_btn_label = 0;
static uint16_t
remapKey(EvdevPtr ev, uint16_t code)
{
- uint8_t slice=code/256;
- uint8_t offs=code%256;
+ uint8_t slice=code/256;
+ uint8_t offs=code%256;
- if (!ev->keyremap) return code;
- if (!(ev->keyremap->sl[slice])) return code;
- if (!(ev->keyremap->sl[slice]->cd[offs])) return code;
- return ev->keyremap->sl[slice]->cd[offs];
+ if (!ev->keyremap) return code;
+ if (!(ev->keyremap->sl[slice])) return code;
+ if (!(ev->keyremap->sl[slice]->cd[offs])) return code;
+ return ev->keyremap->sl[slice]->cd[offs];
}
static void
addRemap(EvdevPtr ev,uint16_t code,uint8_t value)
{
- uint8_t slice=code/256;
- uint8_t offs=code%256;
- if (!ev->keyremap) {
- ev->keyremap=(EvdevKeyRemapPtr)xcalloc(1,sizeof(EvdevKeyRemap));
- }
- if (!ev->keyremap->sl[slice]) {
- ev->keyremap->sl[slice]=(EvdevKeyRemapSlice*)xcalloc(1,sizeof(EvdevKeyRemapSlice));
- }
- ev->keyremap->sl[slice]->cd[offs]=value;
+ uint8_t slice=code/256;
+ uint8_t offs=code%256;
+
+ if (!ev->keyremap) {
+ ev->keyremap=(EvdevKeyRemapPtr)xcalloc(1,sizeof(EvdevKeyRemap));
+ }
+ if (!ev->keyremap->sl[slice]) {
+ ev->keyremap->sl[slice]=(EvdevKeyRemapSlice*)xcalloc(1,sizeof(EvdevKeyRemapSlice));
+ }
+ ev->keyremap->sl[slice]->cd[offs]=value;
}
static void
freeRemap(EvdevPtr ev)
{
- uint16_t slice;
- if (!ev->keyremap) return;
- for (slice=0;slice<256;++slice) {
- if (!ev->keyremap->sl[slice]) continue;
- xfree(ev->keyremap->sl[slice]);
- }
- xfree(ev->keyremap);
- ev->keyremap=0;
+ uint16_t slice;
+ if (!ev->keyremap) return;
+ for (slice=0;slice<256;++slice) {
+ if (!ev->keyremap->sl[slice]) continue;
+ xfree(ev->keyremap->sl[slice]);
+ }
+ xfree(ev->keyremap);
+ ev->keyremap=0;
}
/* All devices the evdev driver has allocated and knows about.
@@ -289,36 +290,36 @@ SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
static void
SetRemapOption(InputInfoPtr pInfo,const char* name,EvdevPtr ev)
{
- char *s,*c;
- unsigned long int code,value;
- int consumed;
-
- s = xf86SetStrOption(pInfo->options, name, NULL);
- if (!s) return;
- if (!s[0]) {
- xfree(s);
- return;
- }
-
- c=s;
- while (sscanf(c," %li = %li %n",&code,&value,&consumed) > 1) {
- if (code < 0 || code > 65535L) {
- xf86Msg(X_ERROR,"%s: input code %ld out of range for option \"event_key_remap\", ignoring.\n",pInfo->name,code);
- continue;
- }
- if (value < MIN_KEYCODE || value > 255) {
- xf86Msg(X_ERROR,"%s: output value %ld out of range for option \"event_key_remap\", ignoring.\n",pInfo->name,code);
- continue;
- }
- xf86Msg(X_INFO,"%s: remapping %ld into %ld.\n",pInfo->name,code,value);
- addRemap(ev,code,value-MIN_KEYCODE);
- c+=consumed;
- }
-
- if (*c!='\0') {
- xf86Msg(X_ERROR, "%s: invalid input for option \"event_key_remap\" starting at '%s', ignoring.\n",
- pInfo->name, c);
- }
+ char *s,*c;
+ unsigned long int code,value;
+ int consumed;
+
+ s = xf86SetStrOption(pInfo->options, name, NULL);
+ if (!s) return;
+ if (!s[0]) {
+ xfree(s);
+ return;
+ }
+
+ c=s;
+ while (sscanf(c," %li = %li %n",&code,&value,&consumed) > 1) {
+ if (code < 0 || code > 65535L) {
+ xf86Msg(X_ERROR,"%s: input code %ld out of range for option \"event_key_remap\", ignoring.\n",pInfo->name,code);
+ continue;
+ }
+ if (value < MIN_KEYCODE || value > 255) {
+ xf86Msg(X_ERROR,"%s: output value %ld out of range for option \"event_key_remap\", ignoring.\n",pInfo->name,code);
+ continue;
+ }
+ xf86Msg(X_INFO,"%s: remapping %ld into %ld.\n",pInfo->name,code,value);
+ addRemap(ev,code,value-MIN_KEYCODE);
+ c+=consumed;
+ }
+
+ if (*c!='\0') {
+ xf86Msg(X_ERROR, "%s: invalid input for option \"event_key_remap\" starting at '%s', ignoring.\n",
+ pInfo->name, c);
+ }
}
static int wheel_up_button = 4;
diff --git a/src/evdev.h b/src/evdev.h
index 53d32cf..af92b21 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -99,8 +99,12 @@ 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 {
+ uint8_t cd[256];
+} EvdevKeyRemapSlice;
+typedef struct {
+ EvdevKeyRemapSlice* sl[256];
+} EvdevKeyRemap, *EvdevKeyRemapPtr;
typedef struct {
const char *device;
@@ -162,7 +166,7 @@ typedef struct {
unsigned char btnmap[32]; /* config-file specified button mapping */
- EvdevKeyRemapPtr keyremap;
+ 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 */