summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/sun/sunkbd.c79
-rw-r--r--sys/dev/sun/sunkbdmap.c141
-rw-r--r--sys/dev/sun/sunkbdvar.h12
-rw-r--r--sys/dev/wscons/wskbdraw.h4
4 files changed, 229 insertions, 7 deletions
diff --git a/sys/dev/sun/sunkbd.c b/sys/dev/sun/sunkbd.c
index 4ad9e80bc9e..83764933fe6 100644
--- a/sys/dev/sun/sunkbd.c
+++ b/sys/dev/sun/sunkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunkbd.c,v 1.22 2009/01/11 15:53:58 miod Exp $ */
+/* $OpenBSD: sunkbd.c,v 1.23 2009/01/11 18:59:54 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -39,6 +39,9 @@
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wskbdvar.h>
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+#include <dev/wscons/wskbdraw.h>
+#endif
#include <dev/sun/sunkbdreg.h>
#include <dev/sun/sunkbdvar.h>
@@ -69,6 +72,10 @@ struct wskbd_accessops sunkbd_accessops = {
void
sunkbd_attach(struct sunkbd_softc *sc, struct wskbddev_attach_args *waa)
{
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ timeout_set(&sc->sc_rawrepeat_tmo, sunkbd_rawrepeat, sc);
+#endif
+
sc->sc_wskbddev = config_found((struct device *)sc, waa,
wskbddevprint);
}
@@ -155,10 +162,54 @@ sunkbd_input(struct sunkbd_softc *sc, u_int8_t *buf, u_int buflen)
{
u_int type;
int value;
+ int s;
+
+ if (sc->sc_wskbddev == NULL)
+ return; /* why bother */
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ if (sc->sc_rawkbd) {
+ u_char rbuf[SUNKBD_MAX_INPUT_SIZE * 2];
+ int c, rlen, npress;
+
+ timeout_del(&sc->sc_rawrepeat_tmo);
+
+ npress = rlen = 0;
+ while (buflen-- != 0) {
+ sunkbd_decode(*buf++, &type, &value);
+ c = sunkbd_rawmap[value];
+ if (c == RAWKEY_Null)
+ continue;
+ /* fake extended scancode if necessary */
+ if (c & 0x80)
+ rbuf[rlen++] = 0xe0;
+ rbuf[rlen] = c & 0x7f;
+ if (type == WSCONS_EVENT_KEY_UP)
+ rbuf[rlen] |= 0x80;
+ else {
+ /* remember down keys for autorepeat */
+ if (c & 0x80)
+ sc->sc_rep[npress++] = 0xe0;
+ sc->sc_rep[npress++] = c & 0x7f;
+ }
+ rlen++;
+ }
- while (buflen-- != 0) {
- sunkbd_decode(*buf++, &type, &value);
- wskbd_input(sc->sc_wskbddev, type, value);
+ s = spltty();
+ wskbd_rawinput(sc->sc_wskbddev, rbuf, rlen);
+ splx(s);
+ sc->sc_nrep = npress;
+ if (npress != 0)
+ timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAY1);
+ } else
+#endif
+ {
+ s = spltty();
+ while (buflen-- != 0) {
+ sunkbd_decode(*buf++, &type, &value);
+ wskbd_input(sc->sc_wskbddev, type, value);
+ }
+ splx(s);
}
}
@@ -186,6 +237,12 @@ sunkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
case WSKBDIO_COMPLEXBELL:
sunkbd_bell(sc, d_bell->period, d_bell->pitch, d_bell->volume);
return (0);
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ case WSKBDIO_SETMODE:
+ sc->sc_rawkbd = *(int *)data == WSKBD_RAW;
+ timeout_del(&sc->sc_rawrepeat_tmo);
+ return (0);
+#endif
}
return (-1);
@@ -233,6 +290,20 @@ sunkbd_raw(struct sunkbd_softc *sc, u_int8_t c)
}
}
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+void
+sunkbd_rawrepeat(void *v)
+{
+ struct sunkbd_softc *sc = v;
+ int s;
+
+ s = spltty();
+ wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep);
+ splx(s);
+ timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAYN);
+}
+#endif
+
int
sunkbd_setclick(struct sunkbd_softc *sc, int click)
{
diff --git a/sys/dev/sun/sunkbdmap.c b/sys/dev/sun/sunkbdmap.c
index e4c3cc75f17..b35c57e3c0b 100644
--- a/sys/dev/sun/sunkbdmap.c
+++ b/sys/dev/sun/sunkbdmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunkbdmap.c,v 1.1 2005/05/14 15:25:20 miod Exp $ */
+/* $OpenBSD: sunkbdmap.c,v 1.2 2009/01/11 18:59:54 miod Exp $ */
/*
* Copyright (c) 2002, 2003 Miodrag Vallat.
@@ -46,6 +46,145 @@
#include <dev/sun/sunkbdreg.h>
#include <dev/sun/sunkbdvar.h>
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+#include <dev/wscons/wskbdraw.h>
+
+/*
+ * Translate Sun keycodes to US keyboard XT scancodes, for proper
+ * X11-over-wsmux operation.
+ */
+const u_int8_t sunkbd_rawmap[0x80] = {
+ RAWKEY_Null,
+ RAWKEY_L1,
+ RAWKEY_AudioLower,
+ RAWKEY_L2,
+ RAWKEY_AudioRaise,
+ RAWKEY_f1,
+ RAWKEY_f2,
+ RAWKEY_f10,
+ RAWKEY_f3,
+ RAWKEY_f11,
+ RAWKEY_f4,
+ RAWKEY_f12,
+ RAWKEY_f5,
+ RAWKEY_Alt_R,
+ RAWKEY_f6,
+ RAWKEY_Null,
+ RAWKEY_f7,
+ RAWKEY_f8,
+ RAWKEY_f9,
+ RAWKEY_Alt_L,
+ RAWKEY_Up,
+ RAWKEY_Pause,
+ RAWKEY_Print_Screen,
+ RAWKEY_Hold_Screen,
+ RAWKEY_Left,
+ RAWKEY_L3,
+ RAWKEY_L4,
+ RAWKEY_Down,
+ RAWKEY_Right,
+ RAWKEY_Escape,
+ RAWKEY_1,
+ RAWKEY_2,
+ RAWKEY_3,
+ RAWKEY_4,
+ RAWKEY_5,
+ RAWKEY_6,
+ RAWKEY_7,
+ RAWKEY_8,
+ RAWKEY_9,
+ RAWKEY_0,
+ RAWKEY_minus,
+ RAWKEY_equal,
+ RAWKEY_grave,
+ RAWKEY_BackSpace,
+ RAWKEY_Insert,
+ RAWKEY_KP_Equal,
+ RAWKEY_KP_Divide,
+ RAWKEY_KP_Multiply,
+ RAWKEY_Null,
+ RAWKEY_L5,
+ RAWKEY_KP_Delete,
+ RAWKEY_L6,
+ RAWKEY_Home,
+ RAWKEY_Tab,
+ RAWKEY_q,
+ RAWKEY_w,
+ RAWKEY_e,
+ RAWKEY_r,
+ RAWKEY_t,
+ RAWKEY_y,
+ RAWKEY_u,
+ RAWKEY_i,
+ RAWKEY_o,
+ RAWKEY_p,
+ RAWKEY_bracketleft,
+ RAWKEY_bracketright,
+ RAWKEY_Delete,
+ RAWKEY_Alt_R,
+ RAWKEY_KP_Home,
+ RAWKEY_KP_Up,
+ RAWKEY_KP_Prior,
+ RAWKEY_KP_Subtract,
+ RAWKEY_L7,
+ RAWKEY_L8,
+ RAWKEY_End,
+ RAWKEY_Null,
+ RAWKEY_Control_L,
+ RAWKEY_a,
+ RAWKEY_s,
+ RAWKEY_d,
+ RAWKEY_f,
+ RAWKEY_g,
+ RAWKEY_h,
+ RAWKEY_j,
+ RAWKEY_k,
+ RAWKEY_l,
+ RAWKEY_semicolon,
+ RAWKEY_apostrophe,
+ RAWKEY_backslash,
+ RAWKEY_Return,
+ RAWKEY_KP_Enter,
+ RAWKEY_KP_Left,
+ RAWKEY_KP_Begin,
+ RAWKEY_KP_Right,
+ RAWKEY_KP_Insert,
+ RAWKEY_L9,
+ RAWKEY_Prior,
+ RAWKEY_L10,
+ RAWKEY_Num_Lock,
+ RAWKEY_Shift_L,
+ RAWKEY_z,
+ RAWKEY_x,
+ RAWKEY_c,
+ RAWKEY_v,
+ RAWKEY_b,
+ RAWKEY_n,
+ RAWKEY_m,
+ RAWKEY_comma,
+ RAWKEY_period,
+ RAWKEY_slash,
+ RAWKEY_Shift_R,
+ RAWKEY_Null, /* KS_Linefeed on type 3/4 */
+ RAWKEY_KP_End,
+ RAWKEY_KP_Down,
+ RAWKEY_KP_Next,
+ RAWKEY_Null,
+ RAWKEY_Null,
+ RAWKEY_Null,
+ RAWKEY_Help,
+ RAWKEY_Caps_Lock,
+ RAWKEY_Meta_L,
+ RAWKEY_space,
+ RAWKEY_Meta_R,
+ RAWKEY_Next,
+ RAWKEY_Null,
+ RAWKEY_KP_Add,
+ RAWKEY_Null,
+ RAWKEY_Null
+};
+#endif
+
#define KC(n) KS_KEYCODE(n)
/* 000/021/022 US English type 4/5 keyboard */
diff --git a/sys/dev/sun/sunkbdvar.h b/sys/dev/sun/sunkbdvar.h
index db0f1efdb3f..280f4798146 100644
--- a/sys/dev/sun/sunkbdvar.h
+++ b/sys/dev/sun/sunkbdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunkbdvar.h,v 1.12 2009/01/11 16:12:15 miod Exp $ */
+/* $OpenBSD: sunkbdvar.h,v 1.13 2009/01/11 18:59:54 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -48,6 +48,15 @@ struct sunkbd_softc {
struct timeout sc_bellto;
struct device *sc_wskbddev;
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ int sc_rawkbd;
+ int sc_nrep;
+ char sc_rep[SUNKBD_MAX_INPUT_SIZE * 2];
+ struct timeout sc_rawrepeat_tmo;
+#define REP_DELAY1 400
+#define REP_DELAYN 100
+#endif
};
extern struct wskbd_accessops sunkbd_accessops;
@@ -75,3 +84,4 @@ extern struct wskbd_mapdata sunkbd5_keymapdata;
#define MAXSUNLAYOUT 0x062
extern const int sunkbd_layouts[MAXSUNLAYOUT];
+extern const u_int8_t sunkbd_rawmap[0x80];
diff --git a/sys/dev/wscons/wskbdraw.h b/sys/dev/wscons/wskbdraw.h
index 3cdfebb27e9..1d38fa139e4 100644
--- a/sys/dev/wscons/wskbdraw.h
+++ b/sys/dev/wscons/wskbdraw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbdraw.h,v 1.1 2005/01/18 18:52:32 miod Exp $ */
+/* $OpenBSD: wskbdraw.h,v 1.2 2009/01/11 18:59:57 miod Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -122,6 +122,8 @@
#define RAWKEY_f12 0x58
#define RAWKEY_Print_Screen 0x67
#define RAWKEY_Pause 0x6a
+#define RAWKEY_Meta_L 0x73
+#define RAWKEY_Meta_R 0x74
#define RAWKEY_KP_Equal 0x76
#define RAWKEY_KP_Enter 0x9c
#define RAWKEY_Control_R 0x9d