[PATCH] aiptek: Generate keyboard events for XInput ABI >=7
Olivier Samyn
code at oleastre.be
Sun Aug 15 11:24:01 PDT 2010
This patch modifies the driver behaviour when XInput ABI s >= 7:
It adds initialization code and generates keyboard events using
xf86PostKeyboardEvent instead of xf86PostKeyEvent.
It also skips the existing keysym tranlation code; this will be replaced by
a following patch.
Signed-off-by: Olivier Samyn <code at oleastre.be>
---
src/xf86Aiptek.c | 32 +++++++++++++++++++++++++++-----
src/xf86Aiptek.h | 1 +
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/xf86Aiptek.c b/src/xf86Aiptek.c
index c282bf3..bbda26b 100644
--- a/src/xf86Aiptek.c
+++ b/src/xf86Aiptek.c
@@ -155,6 +155,7 @@ _X_EXPORT InputDriverRec AIPTEK =
* XK_whatever...
*/
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7
static int linux_inputDevice_keyMap[] =
{
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8,
@@ -164,7 +165,6 @@ static int linux_inputDevice_keyMap[] =
KEY_OPEN, KEY_PASTE
};
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7
/*
* Function/Macro keys variables.
*
@@ -431,6 +431,11 @@ xf86AiptekSendEvents(LocalDevicePtr local, int r_z)
*/
if (common->currentValues.macroKey != VALUE_NA)
{
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+ xf86PostKeyboardEvent(local->dev,
+ common->currentValues.macroKey+8,
+ common->currentValues.macroVal);
+#else
int i;
/* This is a little silly, but: The Linux Event Input
@@ -468,6 +473,7 @@ xf86AiptekSendEvents(LocalDevicePtr local, int r_z)
}
}
+#endif
}
/* As the coordinates are ready, we can send events to X */
@@ -863,6 +869,7 @@ xf86AiptekHIDReadInput(LocalDevicePtr local)
{
++eventsInMessage;
common->currentValues.macroKey = event->code;
+ common->currentValues.macroVal = event->value;
}
break;
}
@@ -928,12 +935,14 @@ xf86AiptekHIDReadInput(LocalDevicePtr local)
<= device->xTiltThreshold &&
ABS(common->currentValues.yTilt - common->previousValues.yTilt)
<= device->yTiltThreshold &&
- common->currentValues.proximity ==
+ common->currentValues.proximity ==
common->previousValues.proximity &&
common->currentValues.button ==
common->previousValues.button &&
common->currentValues.macroKey ==
- common->previousValues.macroKey)
+ common->previousValues.macroKey &&
+ common->currentValues.macroVal ==
+ common->previousValues.macroVal)
{
DBG(10, ErrorF("Event Filtered Out by Thresholds\n"));
continue;
@@ -999,12 +1008,14 @@ xf86AiptekHIDReadInput(LocalDevicePtr local)
common->previousValues.proximity = common->currentValues.proximity;
common->previousValues.button = common->currentValues.button;
common->previousValues.macroKey = common->currentValues.macroKey;
+ common->previousValues.macroVal = common->currentValues.macroVal;
common->previousValues.xTilt = common->currentValues.xTilt;
common->previousValues.yTilt = common->currentValues.yTilt;
common->previousValues.distance = common->currentValues.distance;
common->previousValues.wheel = common->currentValues.wheel;
common->currentValues.macroKey = VALUE_NA;
+ common->currentValues.macroVal = -1;
}
}
@@ -1564,6 +1575,7 @@ xf86AiptekOpenDevice(DeviceIntPtr pDriver)
return (local->fd != -1);
}
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7
/*
* xf86AiptekBellCallback
*/
@@ -1571,6 +1583,7 @@ static void
xf86AiptekBellCallback(int pct, DeviceIntPtr di, pointer ctrl, int x)
{
}
+#endif
/*
* xf86AiptekKbdCtrlCallback
@@ -1669,7 +1682,13 @@ xf86AiptekProc(DeviceIntPtr pAiptek, int requestCode)
ErrorF("Unable to init Keyboard Feedback Class Device\n");
return !Success;
}
-
+#elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+ if (InitKeyboardDeviceStruct(pAiptek, NULL, NULL,
+ xf86AiptekKbdCtrlCallback) == FALSE )
+ {
+ ErrorF("Unable to init Key Class Device\n");
+ return !Success;
+ }
#endif
/* we don't label the axes here, done later in
@@ -1943,6 +1963,7 @@ xf86AiptekAllocate(char* name,
common->currentValues.yTilt = 0; /* YTilt */
common->currentValues.proximity = 0; /* proximity bit */
common->currentValues.macroKey = VALUE_NA; /* tablet macro key code */
+ common->currentValues.macroVal = -1; /* tablet macro key value */
common->currentValues.button = 0; /* bitmask of buttons pressed */
common->currentValues.distance = 0; /* currently unsupported */
common->currentValues.wheel = 0; /* likewise */
@@ -1956,6 +1977,7 @@ xf86AiptekAllocate(char* name,
common->previousValues.yTilt = 0;
common->previousValues.proximity = 0;
common->previousValues.macroKey = VALUE_NA;
+ common->previousValues.macroVal = -1;
common->previousValues.button = 0;
common->previousValues.distance = 0;
common->previousValues.wheel = 0;
@@ -2510,7 +2532,7 @@ xf86AiptekInit(InputDriverPtr drv,
xf86Msg(X_CONFIG, "%s: xf86AiptekInit() finished\n", dev->identifier);
/* Mark the device as configured */
- local->flags |= XI86_POINTER_CAPABLE | XI86_CONFIGURED;
+ local->flags |= XI86_KEYBOARD_CAPABLE | XI86_POINTER_CAPABLE | XI86_CONFIGURED;
/* return the LocalDevice */
return (local);
diff --git a/src/xf86Aiptek.h b/src/xf86Aiptek.h
index 8a8b5cc..9663a1e 100644
--- a/src/xf86Aiptek.h
+++ b/src/xf86Aiptek.h
@@ -205,6 +205,7 @@ typedef struct
int yTilt; /* Angle at which stylus is held, Y coord */
int proximity; /* Stylus proximity bit. */
int macroKey; /* Macrokey read from tablet */
+ int macroVal; /* Macro value(key press/release) */
int button; /* Button bitmask */
int distance; /* Future capacity */
int wheel; /* Future capacity */
--
1.7.0.4
More information about the xorg-devel
mailing list