You should check the return for open to avoid
confusing errormessages from the following ioctl.
You can make the following ioctl a set_version() function as it
can be merged with patch 12

re,
 wh

Am 29.07.2013 23:23, schrieb Thomas Klausner:
> 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 <[email protected]>
> Signed-off-by: Thomas Klausner <[email protected]>
> Reviewed-by: Matthieu Herrb <[email protected]>
> ---
>  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 1048a13..d629565 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;
>  
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to