aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephaniah E. Hull <warp@aehallh.com>2006-02-27 13:22:35 +0000
committerZephaniah E. Hull <warp@aehallh.com>2006-02-27 13:22:35 +0000
commit9972f2b1c77eefe5fb6a2ba7baacaf6b273228a8 (patch)
tree7e0fd3b5a134fda32eb8d4ceaa86bceee629a2be
parentBetter error reporting if the read fails. (diff)
downloadxf86-input-evdev-9972f2b1c77eefe5fb6a2ba7baacaf6b273228a8.tar.gz
xf86-input-evdev-9972f2b1c77eefe5fb6a2ba7baacaf6b273228a8.tar.bz2
xf86-input-evdev-9972f2b1c77eefe5fb6a2ba7baacaf6b273228a8.zip
Don't leave keys in the down state when we get turned off. (VT switching,
getting unplugged, that sort of stuff.)
-rw-r--r--ChangeLog8
-rw-r--r--src/evdev_key.c29
2 files changed, 36 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 751e1c3..2ba0116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2006-02-27 Zephaniah E. Hull,,, <warp@aehallh.com>
+2006-02-27 Zephaniah E. Hull <warp@aehallh.com>
+
+ * src/evdev_key.c: (EvdevKeyOff):
+ Don't leave keys in the down state when we get turned off.
+ (VT switching, getting unplugged, that sort of stuff.)
+
+2006-02-27 Zephaniah E. Hull <warp@aehallh.com>
* src/evdev.c: (EvdevReadInput):
Better error reporting if the read fails.
diff --git a/src/evdev_key.c b/src/evdev_key.c
index 6e80602..e9d4518 100644
--- a/src/evdev_key.c
+++ b/src/evdev_key.c
@@ -405,6 +405,35 @@ EvdevKeyOn (DeviceIntPtr device)
int
EvdevKeyOff (DeviceIntPtr device)
{
+ unsigned int i;
+ KeyClassRec *keyc = device->key;
+ KeySym *map = keyc->curKeySyms.map;
+
+ /*
+ * A bit of a hack, vaguely stolen from xf86-input-keyboard.
+ *
+ * Don't leave any keys in the down state if we are getting turned
+ * off, as they are likely to be released before we are turned back
+ * on.
+ * (For example, if the user switches VTs, or if we are unplugged.)
+ */
+ for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+ i < keyc->curKeySyms.maxKeyCode;
+ i++, map += keyc->curKeySyms.mapWidth)
+ if ((keyc->down[i >> 3] & (1 << (i & 7))))
+ {
+ switch (*map) {
+ /* Don't release the lock keys */
+ case XK_Caps_Lock:
+ case XK_Shift_Lock:
+ case XK_Num_Lock:
+ case XK_Scroll_Lock:
+ case XK_Kana_Lock:
+ break;
+ default:
+ xf86PostKeyboardEvent(device, i, 0);
+ }
+ }
return Success;
}