[PATCH:xf86-input-keyboard 18/21] Fix wskbd handling when VT switching.
Thomas Klausner
wiz at NetBSD.org
Fri Jul 26 14:24:13 PDT 2013
When using /dev/wskbd* we need to close the device when VT switching
out of X, and open it again when switching back.
>From Michael Lorenz <macallan at NetBSD.org>
Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
---
src/bsd_kbd.c | 35 ++++++++++++++++++++++++++++++++++-
src/xf86OSKbd.h | 1 +
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/src/bsd_kbd.c b/src/bsd_kbd.c
index 70a3ff1..0615cf2 100644
--- a/src/bsd_kbd.c
+++ b/src/bsd_kbd.c
@@ -204,6 +204,24 @@ KbdOn(InputInfoPtr pInfo, int what)
break;
#endif
}
+ } else {
+ switch (pKbd->consType) {
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if ((pKbd->wsKbdDev[0] != 0) && (pInfo->fd == -1)) {
+ xf86Msg(X_INFO, "opening %s\n", pKbd->wsKbdDev);
+ pInfo->fd = open(pKbd->wsKbdDev, O_RDONLY | O_NONBLOCK | O_EXCL);
+#ifdef WSKBDIO_SETVERSION
+ int version = WSKBDIO_EVENT_VERSION;
+ if (ioctl(pInfo->fd, WSKBDIO_SETVERSION, &version) == -1) {
+ xf86Msg(X_WARNING, "%s: cannot set version\n", pInfo->name);
+ return FALSE;
+ }
+#endif
+ }
+ break;
+#endif
+ }
}
return Success;
}
@@ -238,7 +256,20 @@ KbdOff(InputInfoPtr pInfo, int what)
break;
#endif
}
- }
+ } else {
+ switch (pKbd->consType) {
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if ((pKbd->wsKbdDev[0] != 0) && (pInfo->fd != -1)) {
+ xf86Msg(X_INFO, "closing %s\n", pKbd->wsKbdDev);
+ /* need to close the fd while we're gone */
+ close(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ break;
+#endif
+ }
+ }
return Success;
}
@@ -368,6 +399,7 @@ OpenKeyboard(InputInfoPtr pInfo)
pInfo->fd = xf86Info.consoleFd;
pKbd->isConsole = TRUE;
pKbd->consType = xf86Info.consType;
+ pKbd->wsKbdDev[0] = 0;
} else {
pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
if (pInfo->fd == -1) {
@@ -376,6 +408,7 @@ OpenKeyboard(InputInfoPtr pInfo)
return FALSE;
}
pKbd->isConsole = FALSE;
+ strncpy(pKbd->wsKbdDev, s, 256);
pKbd->consType = xf86Info.consType;
free(s);
}
diff --git a/src/xf86OSKbd.h b/src/xf86OSKbd.h
index 0d8792d..86df0f5 100644
--- a/src/xf86OSKbd.h
+++ b/src/xf86OSKbd.h
@@ -82,6 +82,7 @@ typedef struct {
pointer private;
int consType;
int wsKbdType;
+ char wsKbdDev[256];
} KbdDevRec, *KbdDevPtr;
--
1.8.3.3
More information about the xorg-devel
mailing list