Beispiel #1
0
static void
adbkbd_cngetc(void *v, u_int *type, int *data)
{
	struct adbkbd_softc *sc = v;
	int key, press, val;
	int s;

	s = splhigh();

	KASSERT(sc->sc_poll);

	DPRINTF("polling...");
	while (sc->sc_polled_chars == 0) {
		sc->sc_ops->poll(sc->sc_ops->cookie);
	}
	DPRINTF(" got one\n");
	splx(s);

	key = sc->sc_pollbuf[0];
	sc->sc_polled_chars--;
	memmove(sc->sc_pollbuf, sc->sc_pollbuf + 1,
		sc->sc_polled_chars);

	press = ADBK_PRESS(key);
	val = ADBK_KEYVAL(key);

	*data = val;
	*type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
}
Beispiel #2
0
static void
adbkbd_powerbutton(void *cookie)
{
	struct adbkbd_softc *sc = cookie;

	sysmon_pswitch_event(&sc->sc_sm_pbutton, 
	    ADBK_PRESS(sc->sc_pe) ? PSWITCH_EVENT_PRESSED :
	    PSWITCH_EVENT_RELEASED);
}
Beispiel #3
0
void
akbd_input(struct akbd_softc *sc, int key)
{
	int press, val;
	int type;

	press = ADBK_PRESS(key);
	val = ADBK_KEYVAL(key);

	type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;

	if (adb_polling) {
		adb_polledkey = key;
#ifdef WSDISPLAY_COMPAT_RAWKBD
	} else if (sc->sc_rawkbd) {
		char cbuf[MAXKEYS *2];
		int c, j, s;
		int npress;

		j = npress = 0;

		c = keyboard[val];
		if (c == 0) {
			return; /* XXX */
		}
		if (c & 0x80)
			cbuf[j++] = 0xe0;
		cbuf[j] = c & 0x7f;
		if (type == WSCONS_EVENT_KEY_UP) {
			cbuf[j] |= 0x80;
		} else {
			/* this only records last key pressed */
			if (c & 0x80)
				sc->sc_rep[npress++] = 0xe0;
			sc->sc_rep[npress++] = c & 0x7f;
		}
		j++;
		s = spltty();
		wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
		splx(s);
		timeout_del(&sc->sc_rawrepeat_ch);
		sc->sc_nrep = npress;
		if (npress != 0)
			timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAY1/1000);
#endif
	} else {
		wskbd_input(sc->sc_wskbddev, type, val);
	}
}
Beispiel #4
0
void
akbd_input(struct akbd_softc *sc, int key)
{
	int press, val;
	int type;

	press = ADBK_PRESS(key);
	val = ADBK_KEYVAL(key);

	if (sc->sc_iso)
		val = akbd_iso_swap(val);

	type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;

	if (adb_polling) {
		adb_polledkey = key;
#ifdef WSDISPLAY_COMPAT_RAWKBD
	} else if (sc->sc_rawkbd) {
		char cbuf[2];
		int c, j, s;

		j = 0;

		c = keyboard[val];
		if (c == 0) {
			return; /* XXX */
		}
		if (c & 0x80)
			cbuf[j++] = 0xe0;
		cbuf[j] = c & 0x7f;
		if (type == WSCONS_EVENT_KEY_UP)
			cbuf[j] |= 0x80;
		j++;
		s = spltty();
		wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
		splx(s);
#endif
	} else {
		wskbd_input(sc->sc_wskbddev, type, val);
	}
}
Beispiel #5
0
/*
 * Cancels the currently repeating key event if there is one, schedules
 * a new repeating key event if needed, and hands the event off to the
 * appropriate subsystem.
 */
static void 
aed_dokeyupdown(adb_event_t *event)
{
	int kbd_key;

	kbd_key = ADBK_KEYVAL(event->u.k.key);
	if (ADBK_PRESS(event->u.k.key) && keyboard[kbd_key][0] != 0) {
		/* ignore shift & control */
		if (aed_sc->sc_repeating != -1) {
			callout_stop(&aed_sc->sc_repeat_ch);
		}
		aed_sc->sc_rptevent = *event;
		aed_sc->sc_repeating = kbd_key;
		callout_reset(&aed_sc->sc_repeat_ch, aed_sc->sc_rptdelay,
		    aed_kbdrpt, (void *)aed_sc);
	} else {
		if (aed_sc->sc_repeating != -1) {
			aed_sc->sc_repeating = -1;
			callout_stop(&aed_sc->sc_repeat_ch);
		}
		aed_sc->sc_rptevent = *event;
	}
	aed_handoff(event);
}
void
akbd_cngetc(void *v, u_int *type, int *data)
{
	int intbits, key, press, val;
	int s;
	extern int adb_intr(void *);
	extern void pm_intr(void *);

	s = splhigh();

	adb_polledkey = -1;
	adb_polling = 1;

	while (adb_polledkey == -1) {
		intbits = via_reg(VIA1, vIFR);

		if (intbits & V1IF_ADBRDY) {
			adb_intr(NULL);
			via_reg(VIA1, vIFR) = V1IF_ADBRDY;
		}
		if (intbits & V1IF_ADBCLK) {
			pm_intr(NULL);
			via_reg(VIA1, vIFR) = 0x10;
		}
	}

	adb_polling = 0;
	splx(s);

	key = adb_polledkey;
	press = ADBK_PRESS(key);
	val = ADBK_KEYVAL(key);

	*data = val;
	*type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
}
Beispiel #7
0
static inline void
adbkbd_key(struct adbkbd_softc *sc, uint8_t k)
{

	if (sc->sc_poll) {
		if (sc->sc_polled_chars >= 16) {
			aprint_error_dev(sc->sc_dev,"polling buffer is full\n");
		}
		sc->sc_pollbuf[sc->sc_polled_chars] = k;
		sc->sc_polled_chars++;
		return;
	}

#if NWSMOUSE > 0
	/* translate some keys to mouse events */
	if (sc->sc_wsmousedev != NULL) {
		if (ADBK_KEYVAL(k) == sc->sc_trans[1]) {
			wsmouse_input(sc->sc_wsmousedev, ADBK_PRESS(k) ? 2 : 0,
			      0, 0, 0, 0,
			      WSMOUSE_INPUT_DELTA);
			return;
		}			
		if (ADBK_KEYVAL(k) == sc->sc_trans[2]) {
			wsmouse_input(sc->sc_wsmousedev, ADBK_PRESS(k) ? 4 : 0,
			      0, 0, 0, 0,
			      WSMOUSE_INPUT_DELTA);
			return;
		}			
	}
#endif

#ifdef WSDISPLAY_COMPAT_RAWKBD
	if (sc->sc_rawkbd) {
		char cbuf[2];
		int s;

		cbuf[0] = k;

		s = spltty();
		wskbd_rawinput(sc->sc_wskbddev, cbuf, 1);
		splx(s);
	} else {
#endif

	if (ADBK_KEYVAL(k) == 0x39) {
		/* caps lock - send up and down */
		if (ADBK_PRESS(k) != sc->sc_capslock) {
			sc->sc_capslock = ADBK_PRESS(k);
			wskbd_input(sc->sc_wskbddev,
			    WSCONS_EVENT_KEY_DOWN, 0x39);
			wskbd_input(sc->sc_wskbddev,
			    WSCONS_EVENT_KEY_UP, 0x39);
		}
	} else {
		/* normal event */
		int type;

		type = ADBK_PRESS(k) ? 
		    WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
		wskbd_input(sc->sc_wskbddev, type, ADBK_KEYVAL(k));
	}
#ifdef WSDISPLAY_COMPAT_RAWKBD
	}
#endif
}
Beispiel #8
0
/*
 * Take care of storing keydown and keyup,
 * take care of flower/command keys, which control VTs and GRFs
 * directly, and also take care of distinguishing RAW from COOKED
 * key strokes, if the keypress can be sent on to VT.
 */
void 
kbd_doevent(
    int key)
{
	int     numchars;
	u_char  chars[256];
	u_char  ochar = 0;
	int     i;

	kbd_setkeybits(key);

	if (!ADBK_PRESS(key)) {
		/* Key up... */
		return;
	}
	numchars = kbd_scantokey(key, chars);

	if (ISKEYDOWN(ADBK_FLOWER)) {	/* flower/command */
		switch (key) {
		case ADBK_F:	/* font change */
			mux_changefont();
			break;

		case ADBK_P:	/* pointer */
			mouse_on = !mouse_on;
			mux_mouseon(mouse_on);
#ifdef HIDE_MOUSE
			mouse_vis = 1;	/* make sure we show the pointer when
					 * it's turned on */
#endif				/* HIDE_MOUSE */
			break;

		case ADBK_O:	/* open new vt */
			main_newvt();
			break;

		case ADBK_X:	/* old paste */
			mux_paste();
			break;

		case ADBK_C:	/* copy, mac-style */
			mux_copy();
			break;

		case ADBK_V:	/* paste, mac-style */
			mux_realpaste();
			break;

			/* Digits: */
		case ADBK_1:
		case ADBK_2:
		case ADBK_3:
		case ADBK_4:
		case ADBK_5:
		case ADBK_6:
		case ADBK_7:
		case ADBK_8:
		case ADBK_9:
			i = keyboard[key][0] - '1';
			if (ISKEYDOWN(ADBK_SHIFT)) {
				mux_vttogrf(i);
			} else {
				mux_switchtovt(i);
			}
			break;

		case ADBK_UP:	/* up */
			mux_vtscroll(1);
			break;
		case ADBK_DOWN:/* dn */
			mux_vtscroll(-1);
			break;
		case ADBK_PGUP:/* pgup */
			mux_vtpage(1);
			break;
		case ADBK_PGDN:/* pgdn */
			mux_vtpage(-1);
			break;
		case ADBK_END:	/* end */
			mux_vtbottom();
			break;
		case ADBK_HOME:/* home */
			mux_vttop();
			break;
		}
		return;
	}
#ifdef HIDE_MOUSE
	if (mouse_on && mouse_vis && numchars) {	/* we have actual
							 * typing, hide the
							 * mouse */
		mux_mouseon(!mouse_on);
		mouse_vis = 0;
	}
#endif				/* HIDE_MOUSE */

	for (i = 0; i < numchars; i++) {
		if (indig) {
			if (chars[i] != ' ')
				ochar = chars[i];
			else
				ochar = 0;
			chars[i] = dodig(chars[i], &ochar);
			goto hoppari;
		}		/* process a digraph */
		if ((indig = isdig(chars[i])))
			continue;	/* if we got a digraph key, don't say
					 * it yet */
hoppari:			/* I'm becoming a serious goto-user */
		main_keyhit(mux_curvt, chars[i]);
		if (ochar) {
			main_keyhit(mux_curvt, ochar);
			ochar = 0;
		}
	}
}