Module Name:    src
Committed By:   macallan
Date:           Wed Aug 29 02:38:31 UTC 2012

Modified Files:
        src/sys/dev/wscons: wskbd.c wskbdvar.h

Log Message:
support an optional table to translate scancodes when in event mode


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/wscons/wskbd.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/wscons/wskbdvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wscons/wskbd.c
diff -u src/sys/dev/wscons/wskbd.c:1.131 src/sys/dev/wscons/wskbd.c:1.132
--- src/sys/dev/wscons/wskbd.c:1.131	Tue Mar 13 18:40:34 2012
+++ src/sys/dev/wscons/wskbd.c	Wed Aug 29 02:38:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbd.c,v 1.131 2012/03/13 18:40:34 elad Exp $ */
+/* $NetBSD: wskbd.c,v 1.132 2012/08/29 02:38:31 macallan Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -105,7 +105,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.131 2012/03/13 18:40:34 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.132 2012/08/29 02:38:31 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -207,6 +207,10 @@ struct wskbd_softc {
 
 	wskbd_hotkey_plugin *sc_hotkey;
 	void *sc_hotkeycookie;
+
+	/* optional table to translate scancodes in event mode */
+	int		sc_evtrans_len;
+	keysym_t	*sc_evtrans;
 };
 
 #define MOD_SHIFT_L		(1 << 0)
@@ -418,6 +422,8 @@ wskbd_attach(device_t parent, device_t s
 	sc->sc_isconsole = ap->console;
 	sc->sc_hotkey = NULL;
 	sc->sc_hotkeycookie = NULL;
+	sc->sc_evtrans_len = 0;
+	sc->sc_evtrans = NULL;
 
 #if NWSMUX > 0 || NWSDISPLAY > 0
 	sc->sc_base.me_ops = &wskbd_srcops;
@@ -744,7 +750,17 @@ wskbd_deliver_event(struct wskbd_softc *
 #endif
 
 	event.type = type;
-	event.value = value;
+	event.value = 0;
+	DPRINTF(("%d ->", value));
+	if (sc->sc_evtrans_len > 0) {
+		if (sc->sc_evtrans_len > value) {
+			DPRINTF(("%d", sc->sc_evtrans[value]));
+			event.value = sc->sc_evtrans[value];
+		}
+	} else {
+		event.value = value;
+	}
+	DPRINTF(("\n"));
 	if (wsevent_inject(evar, &event, 1) != 0)
 		log(LOG_WARNING, "%s: event queue overflow\n",
 		    device_xname(sc->sc_base.me_dv));
@@ -1878,3 +1894,13 @@ wskbd_translate(struct wskbd_internal *i
 	id->t_symbols[0] = res;
 	return (1);
 }
+
+void
+wskbd_set_evtrans(device_t dev, keysym_t *tab, int len)
+{
+	struct wskbd_softc *sc = device_private(dev);
+
+	sc->sc_evtrans_len = len;
+	sc->sc_evtrans = tab;
+}
+

Index: src/sys/dev/wscons/wskbdvar.h
diff -u src/sys/dev/wscons/wskbdvar.h:1.17 src/sys/dev/wscons/wskbdvar.h:1.18
--- src/sys/dev/wscons/wskbdvar.h:1.17	Tue Oct 26 05:12:34 2010
+++ src/sys/dev/wscons/wskbdvar.h	Wed Aug 29 02:38:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbdvar.h,v 1.17 2010/10/26 05:12:34 jruoho Exp $ */
+/* $NetBSD: wskbdvar.h,v 1.18 2012/08/29 02:38:31 macallan Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -103,6 +103,13 @@ device_t wskbd_hotkey_register(device_t,
 void	 wskbd_hotkey_deregister(device_t);
 
 /*
+ * set a translation table for scancodes in event mode
+ * parameters are a pointer to the table and its length
+ * pass length zero to turn translation off
+ */
+void	wskbd_set_evtrans(device_t, keysym_t *, int);
+
+/*
  * Console interface.
  */
 int	wskbd_cngetc(dev_t);

Reply via email to