LK201/LK401 support for wscons (only decoding for now).
This commit is contained in:
parent
af9cabdaaa
commit
7f72e0eea5
110
sys/dev/dec/lk201_ws.c
Normal file
110
sys/dev/dec/lk201_ws.c
Normal file
@ -0,0 +1,110 @@
|
||||
/* $NetBSD: lk201_ws.c,v 1.1 1998/09/17 20:01:57 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998
|
||||
* Matthias Drochner. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project
|
||||
* by Matthias Drochner.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <dev/dec/lk201reg.h>
|
||||
#include <dev/dec/lk201var.h>
|
||||
#include <dev/dec/wskbdmap_lk201.h> /* for {MIN,MAX}_LK201_KEY */
|
||||
|
||||
void
|
||||
lk201_init_keystate(lks)
|
||||
struct lk201_state *lks;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LK_KLL; i++)
|
||||
lks->down_keys_list[i] = -1;
|
||||
}
|
||||
|
||||
int
|
||||
lk201_decode(lks, datain, type, dataout)
|
||||
struct lk201_state *lks;
|
||||
int datain;
|
||||
u_int *type;
|
||||
int *dataout;
|
||||
{
|
||||
int i, freeslot;
|
||||
|
||||
switch (datain) {
|
||||
case LK_KEY_UP:
|
||||
for (i = 0; i < LK_KLL; i++)
|
||||
lks->down_keys_list[i] = -1;
|
||||
*type = WSCONS_EVENT_ALL_KEYS_UP;
|
||||
return (1);
|
||||
case LK_POWER_UP:
|
||||
printf("lk201_decode: powerup detected\n");
|
||||
/* XXX should reinitialize here */
|
||||
return (0);
|
||||
case LK_KDOWN_ERROR:
|
||||
case LK_POWER_ERROR:
|
||||
case LK_OUTPUT_ERROR:
|
||||
case LK_INPUT_ERROR:
|
||||
printf("lk201_decode: error %x\n", datain);
|
||||
/* FALLTHRU */
|
||||
case LK_KEY_REPEAT: /* autorepeat handled by wskbd */
|
||||
case LK_MODE_CHANGE: /* ignore silently */
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) {
|
||||
printf("lk201_decode: %x\n", datain);
|
||||
return (0);
|
||||
}
|
||||
|
||||
*dataout = datain - MIN_LK201_KEY;
|
||||
|
||||
freeslot = -1;
|
||||
for (i = 0; i < LK_KLL; i++) {
|
||||
if (lks->down_keys_list[i] == datain) {
|
||||
*type = WSCONS_EVENT_KEY_UP;
|
||||
lks->down_keys_list[i] = -1;
|
||||
return (1);
|
||||
}
|
||||
if (lks->down_keys_list[i] == -1 && freeslot == -1)
|
||||
freeslot = i;
|
||||
}
|
||||
|
||||
if (freeslot == -1) {
|
||||
printf("lk201_decode: down(%d) no free slot\n", datain);
|
||||
return (0);
|
||||
}
|
||||
|
||||
*type = WSCONS_EVENT_KEY_DOWN;
|
||||
lks->down_keys_list[freeslot] = datain;
|
||||
return (1);
|
||||
}
|
63
sys/dev/dec/lk201reg.h
Normal file
63
sys/dev/dec/lk201reg.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* $NetBSD: lk201reg.h,v 1.1 1998/09/17 20:01:57 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* command keycodes for Digital LK200/LK400 series keyboards.
|
||||
*/
|
||||
|
||||
/*
|
||||
* special keycodes
|
||||
*/
|
||||
#define LK_POWER_UP 0x01
|
||||
#define LK_KEY_R_SHIFT 0xab
|
||||
#define LK_KEY_SHIFT 0xae
|
||||
#define LK_KEY_LOCK 0xb0
|
||||
#define LK_KEY_CONTROL 0xaf
|
||||
#define LK_KEY_R_ALT 0xb2
|
||||
#define LK_KEY_UP 0xb3
|
||||
#define LK_KEY_REPEAT 0xb4
|
||||
#define LK_KEY_HOLD 0x56 /* F1 */
|
||||
#define LK_KDOWN_ERROR 0x3d /* key down on powerup error */
|
||||
#define LK_POWER_ERROR 0x3e /* keyboard failure on pwrup tst*/
|
||||
#define LK_OUTPUT_ERROR 0xb5 /* keystrokes lost during inhbt */
|
||||
#define LK_INPUT_ERROR 0xb6 /* garbage command to keyboard */
|
||||
#define LK_LOWEST 0x56 /* lowest significant keycode */
|
||||
|
||||
/*
|
||||
* keyboard commands
|
||||
*/
|
||||
#define LK_UPDOWN 0x86 /* bits for setting lk201 modes */
|
||||
#define LK_AUTODOWN 0x82
|
||||
#define LK_DOWN 0x80
|
||||
#define LK_DEFAULTS 0xd3 /* reset mode settings */
|
||||
#define LK_AR_ENABLE 0xe3 /* global auto repeat enable */
|
||||
#define LK_CL_ENABLE 0x1b /* keyclick enable */
|
||||
#define LK_CL_DISABLE 0x99 /* keyclick disable */
|
||||
#define LK_CCL_ENABLE 0xbb /* enable keyclick for CTRL */
|
||||
#define LK_CCL_DISABLE 0xb9 /* disable keyclick for CTRL */
|
||||
#define LK_KBD_ENABLE 0x8b /* keyboard enable */
|
||||
#define LK_BELL_ENABLE 0x23 /* enable the bell */
|
||||
#define LK_BELL_DISABLE 0xa1 /* disable the bell */
|
||||
#define LK_LED_ENABLE 0x13 /* light led */
|
||||
#define LK_LED_DISABLE 0x11 /* turn off led */
|
||||
#define LK_RING_BELL 0xa7 /* ring keyboard bell */
|
||||
#define LK_LED_1 0x81 /* led bits */
|
||||
#define LK_LED_2 0x82
|
||||
#define LK_LED_3 0x84
|
||||
#define LK_LED_4 0x88
|
||||
#define LK_LED_WAIT 0x81
|
||||
#define LK_LED_COMP 0x82
|
||||
#define LK_LED_LOCK 0x84
|
||||
#define LK_LED_HOLD 0x88
|
||||
#define LK_LED_ALL 0x8f
|
||||
#define LK_HELP 0x7c /* help key */
|
||||
#define LK_DO 0x7d /* do key */
|
||||
#define LK_DIV6_START 0xad /* start of div 6 */
|
||||
#define LK_DIV5_END 0xb2 /* end of div 5 */
|
||||
#define LK_ENABLE_401 0xe9 /* turn on LK401 mode */
|
||||
#define LK_MODE_CHANGE 0xba /* mode change ack */
|
||||
|
||||
/* max volume is 0, lowest is 0x7 */
|
||||
#define LK_PARAM_VOLUME(v) (0x80|((v)&0x7))
|
||||
|
||||
/* mode command details */
|
||||
#define LK_CMD_MODE(m,div) ((m)|((div)<<3))
|
9
sys/dev/dec/lk201var.h
Normal file
9
sys/dev/dec/lk201var.h
Normal file
@ -0,0 +1,9 @@
|
||||
/* $NetBSD: lk201var.h,v 1.1 1998/09/17 20:01:57 drochner Exp $ */
|
||||
|
||||
struct lk201_state {
|
||||
#define LK_KLL 8
|
||||
int down_keys_list[LK_KLL];
|
||||
};
|
||||
|
||||
void lk201_init_keystate __P((struct lk201_state *));
|
||||
int lk201_decode __P((struct lk201_state *, int, u_int *, int *));
|
Loading…
Reference in New Issue
Block a user