diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-09-30 12:05:47 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-09-30 12:05:47 +0000 |
commit | 94cbdbb52f62dff9c72693edc4ad4bf289207f02 (patch) | |
tree | 7bdcf7e8e98d36f99273c18ecd34dcc96eb10f10 /sys | |
parent | 34e7ea606a2a7c495e17bc87fd503fe38c88342f (diff) |
Add a WSKBDIO_GETENCODINGS ioctl that returns the supported keyboard
encodings.
ok deraadt@, jca@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/wscons/wsconsio.h | 8 | ||||
-rw-r--r-- | sys/dev/wscons/wskbd.c | 18 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h index 5eb555f238b..777f22a2d7e 100644 --- a/sys/dev/wscons/wsconsio.h +++ b/sys/dev/wscons/wsconsio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsio.h,v 1.75 2016/09/14 03:25:51 jcs Exp $ */ +/* $OpenBSD: wsconsio.h,v 1.76 2016/09/30 12:05:46 kettenis Exp $ */ /* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */ /* @@ -207,6 +207,12 @@ struct wskbd_backlight { #define WSKBD_TRANSLATED 0 #define WSKBD_RAW 1 +struct wskbd_encoding_data { + int nencodings; + kbd_t *encodings; +}; +#define WSKBDIO_GETENCODINGS _IOWR('W', 21, struct wskbd_encoding_data) + /* * Mouse ioctls (32 - 63) */ diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index a822b663100..8320ec66cb7 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbd.c,v 1.83 2015/12/12 12:30:18 jung Exp $ */ +/* $OpenBSD: wskbd.c,v 1.84 2016/09/30 12:05:46 kettenis Exp $ */ /* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */ /* @@ -1001,9 +1001,11 @@ wskbd_displayioctl(struct device *dev, u_long cmd, caddr_t data, int flag, struct wskbd_bell_data *ubdp, *kbdp; struct wskbd_keyrepeat_data *ukdp, *kkdp; struct wskbd_map_data *umdp; + struct wskbd_encoding_data *uedp; kbd_t enc; void *buf; int len, error; + int count, i; switch (cmd) { case WSKBDIO_BELL: @@ -1160,6 +1162,20 @@ getkeyrepeat: #endif return (0); + case WSKBDIO_GETENCODINGS: + uedp = (struct wskbd_encoding_data *)data; + for (count = 0; sc->id->t_keymap.keydesc[count].name; count++) + ; + if (uedp->nencodings > count) + uedp->nencodings = count; + for (i = 0; i < uedp->nencodings; i++) { + error = copyout(&sc->id->t_keymap.keydesc[i].name, + &uedp->encodings[i], sizeof(kbd_t)); + if (error) + return (error); + } + return (0); + case WSKBDIO_GETBACKLIGHT: if (wskbd_get_backlight != NULL) return (*wskbd_get_backlight)((struct wskbd_backlight *)data); |