diff options
author | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2013-11-11 16:52:01 +0000 |
---|---|---|
committer | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2013-11-11 16:52:01 +0000 |
commit | 68b039991d2bc85fee8fdb84e837da7962428597 (patch) | |
tree | e0727fff9b236318cf377acfb6f613b4ba689f76 /driver/xf86-input-keyboard/src/bsd_kbd.c | |
parent | 4c6d0b04105955e514d880418ca8d8cae9f873bb (diff) |
Update to xf86-input-keyboard 1.8.0.
ok matthieu@
Diffstat (limited to 'driver/xf86-input-keyboard/src/bsd_kbd.c')
-rw-r--r-- | driver/xf86-input-keyboard/src/bsd_kbd.c | 124 |
1 files changed, 93 insertions, 31 deletions
diff --git a/driver/xf86-input-keyboard/src/bsd_kbd.c b/driver/xf86-input-keyboard/src/bsd_kbd.c index 24ee3d9a8..987dde503 100644 --- a/driver/xf86-input-keyboard/src/bsd_kbd.c +++ b/driver/xf86-input-keyboard/src/bsd_kbd.c @@ -41,6 +41,21 @@ typedef struct { struct termios kbdtty; } BsdKbdPrivRec, *BsdKbdPrivPtr; +#ifdef WSCONS_SUPPORT +static Bool +WSSetVersion(int fd, const char *name) +{ +#ifdef WSKBDIO_SETVERSION + int version = WSKBDIO_EVENT_VERSION; + if (ioctl(fd, WSKBDIO_SETVERSION, &version) == -1) { + xf86Msg(X_WARNING, "%s: cannot set version\n", name); + return FALSE; + } +#endif + return TRUE; +} +#endif + static int KbdInit(InputInfoPtr pInfo, int what) { @@ -56,7 +71,7 @@ int KbdInit(InputInfoPtr pInfo, int what) #if defined WSCONS_SUPPORT case WSCONS: #endif - tcgetattr(pInfo->fd, &(priv->kbdtty)); + tcgetattr(pInfo->fd, &(priv->kbdtty)); #endif break; } @@ -175,8 +190,8 @@ KbdOn(InputInfoPtr pInfo, int what) xf86Msg(X_ERROR, "KbdOn: tcsetattr: %s\n", strerror(errno)); } - break; -#endif + break; +#endif } #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT) switch (pKbd->consType) { @@ -191,7 +206,6 @@ KbdOn(InputInfoPtr pInfo, int what) ioctl(pInfo->fd, KDSKBMODE, K_RAW); #endif break; -#endif #ifdef WSCONS_SUPPORT case WSCONS: option = WSKBD_RAW; @@ -206,6 +220,24 @@ KbdOn(InputInfoPtr pInfo, int what) break; #endif } +#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); + if (pInfo->fd == -1) { + xf86Msg(X_ERROR, "cannot open \"%s\"\n", pKbd->wsKbdDev); + return FALSE; + } + if (WSSetVersion(pInfo->fd, pInfo->name) == FALSE) + return FALSE; + } + break; +#endif + } } return Success; } @@ -240,6 +272,19 @@ 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; } @@ -253,7 +298,7 @@ SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) #endif if (loudness && pitch) { - switch (pKbd->consType) { + switch (pKbd->consType) { #ifdef PCCONS_SUPPORT case PCCONS: { int data[2]; @@ -323,9 +368,9 @@ WSReadInput(InputInfoPtr pInfo) } static void -printWsType(char *type, char *devname) +printWsType(const char *type, const char *name) { - xf86Msg(X_PROBED, "%s: Keyboard type: %s\n", devname, type); + xf86Msg(X_PROBED, "%s: Keyboard type: %s\n", name, type); } #endif @@ -346,7 +391,7 @@ OpenKeyboard(InputInfoPtr pInfo) } switch (prot) { - case PROT_STD: + case PROT_STD: pInfo->read_input = stdReadInput; break; #ifdef WSCONS_SUPPORT @@ -361,29 +406,29 @@ OpenKeyboard(InputInfoPtr pInfo) } free(s); - s = xf86SetStrOption(pInfo->options, "Device", NULL); + if (prot == PROT_WSCONS) + s = xf86SetStrOption(pInfo->options, "Device", "/dev/wskbd"); + else + s = xf86SetStrOption(pInfo->options, "Device", NULL); + if (s == NULL) { - if (prot == PROT_WSCONS) { - xf86Msg(X_ERROR,"A \"device\" option is required with" - " the \"wskbd\" keyboard protocol\n"); - return FALSE; - } else { - pInfo->fd = xf86Info.consoleFd; - pKbd->isConsole = TRUE; - pKbd->consType = xf86Info.consType; - } + pInfo->fd = xf86Info.consoleFd; + pKbd->isConsole = TRUE; + pKbd->consType = xf86Info.consType; + pKbd->wsKbdDev[0] = 0; } else { #ifndef X_PRIVSEP - pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); #else - pInfo->fd = priv_open_device(s); + pInfo->fd = priv_open_device(s); #endif - if (pInfo->fd == -1) { + if (pInfo->fd == -1) { xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s); free(s); return FALSE; } pKbd->isConsole = FALSE; + strncpy(pKbd->wsKbdDev, s, 256); pKbd->consType = xf86Info.consType; free(s); } @@ -391,6 +436,8 @@ OpenKeyboard(InputInfoPtr pInfo) #ifdef WSCONS_SUPPORT if (prot == PROT_WSCONS) { pKbd->consType = WSCONS; + if (WSSetVersion(pInfo->fd, pInfo->name) == FALSE) + return FALSE; /* Find out keyboard type */ if (ioctl(pInfo->fd, WSKBDIO_GTYPE, &(pKbd->wsKbdType)) == -1) { xf86Msg(X_ERROR, "%s: cannot get keyboard type", pInfo->name); @@ -404,6 +451,12 @@ OpenKeyboard(InputInfoPtr pInfo) case WSKBD_TYPE_PC_AT: printWsType("AT", pInfo->name); break; + case 0: + /* If wsKbdType==0, no keyboard attached to the mux. Assume USB. */ + xf86Msg(X_WARNING, "%s: No keyboard attached, assuming USB\n", + pInfo->name); + pKbd->wsKbdType = WSKBD_TYPE_USB; + /* FALLTHROUGH */ case WSKBD_TYPE_USB: printWsType("USB", pInfo->name); break; @@ -412,6 +465,21 @@ OpenKeyboard(InputInfoPtr pInfo) printWsType("ADB", pInfo->name); break; #endif +#ifdef WSKBD_TYPE_LK201 + case WSKBD_TYPE_LK201: + printWsType("LK201", pInfo->name); + break; +#endif +#ifdef WSKBD_TYPE_LK401 + case WSKBD_TYPE_LK401: + printWsType("LK-401", pInfo->name); + break; +#endif +#ifdef WSKBD_TYPE_MAPLE + case WSKBD_TYPE_MAPLE: + printWsType("Maple", pInfo->name); + break; +#endif #ifdef WSKBD_TYPE_SUN case WSKBD_TYPE_SUN: printWsType("Sun", pInfo->name); @@ -422,17 +490,11 @@ OpenKeyboard(InputInfoPtr pInfo) printWsType("Sun5", pInfo->name); break; #endif - case WSKBD_TYPE_LK201: - printWsType("LK-201", pInfo->name); - break; - case WSKBD_TYPE_LK401: - printWsType("LK-401", pInfo->name); - break; default: - xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"", - pInfo->name, pKbd->wsKbdType); - close(pInfo->fd); - return FALSE; + xf86Msg(X_WARNING, "%s: Unsupported wskbd type \"%d\"\n", + pInfo->name, pKbd->wsKbdType); + printWsType("Unknown wskbd", pInfo->name); + break; } } #endif |