--- np2/keystat.c 2004/03/31 11:59:17 1.11 +++ np2/keystat.c 2004/04/07 14:55:46 1.15 @@ -5,6 +5,7 @@ #include "iocore.h" #include "keystat.h" #include "keystat.tbl" +#include "softkbd.h" typedef struct { @@ -18,7 +19,6 @@ typedef struct { UINT8 d_rt; } KEYSTAT; - NKEYTBL nkeytbl; KEYCTRL keyctrl; static KEYSTAT keystat; @@ -28,6 +28,11 @@ void keystat_initialize(void) { char path[MAX_PATH]; + ZeroMemory(&keyctrl, sizeof(keyctrl)); + keyctrl.keyrep = 0x21; + keyctrl.capsref = NKEYREF_NC; + keyctrl.kanaref = NKEYREF_NC; + ZeroMemory(&keystat, sizeof(keystat)); FillMemory(keystat.ref, sizeof(keystat.ref), NKEYREF_NC); keystat_tblreset(); @@ -157,20 +162,41 @@ kstbl_err: // ---- -void keystat_ctrlinit(void) { +static REG8 getledstat(void) { - ZeroMemory(&keyctrl, sizeof(keyctrl)); + REG8 ret; + + ret = 0; + if (keyctrl.kanaref != NKEYREF_NC) { + ret |= 8; + } + if (keyctrl.capsref != NKEYREF_NC) { + ret |= 4; + } + return(ret); +} + +static void reloadled(void) { + + keyctrl.kanaref = keystat.ref[0x72]; + keyctrl.capsref = keystat.ref[0x71]; +#if defined(SUPPORT_SOFTKBD) + softkbd_led(getledstat()); +#endif } void keystat_ctrlreset(void) { keyctrl.reqparam = 0; + keystat.ref[0x72] = keyctrl.kanaref; + keystat.ref[0x71] = keyctrl.capsref; +#if defined(SUPPORT_SOFTKBD) + softkbd_led(getledstat()); +#endif } void keystat_ctrlsend(REG8 dat) { -// return; // まだテスト - if (!keyctrl.reqparam) { keyctrl.mode = dat; switch(dat) { @@ -213,6 +239,19 @@ void keystat_ctrlsend(REG8 dat) { case 0x9c: keyboard_ctrl(0xfa); break; + + case 0x9d: + if (dat == 0x60) { + keyboard_ctrl(0xfa); + keyboard_ctrl((REG8)(0x70 + getledstat())); + } + else if ((dat & 0xf0) == 0x70) { + keyboard_ctrl(0xfa); + keystat.ref[0x72] = (dat & 8)?NKEYREF_uPD8255:NKEYREF_NC; + keystat.ref[0x71] = (dat & 4)?NKEYREF_uPD8255:NKEYREF_NC; + reloadled(); + } + break; } keyctrl.reqparam = 0; } @@ -272,6 +311,9 @@ void keystat_down(const UINT8 *key, REG8 } keyboard_send(data); } + if ((keycode == 0x71) || (keycode == 0x72)) { + reloadled(); + } } } } @@ -312,6 +354,9 @@ void keystat_up(const UINT8 *key, REG8 k if (keystat.ref[keycode] != NKEYREF_NC) { keystat.ref[keycode] = NKEYREF_NC; keyboard_send((REG8)(keycode + 0x80)); + if ((keycode == 0x71) || (keycode == 0x72)) { + reloadled(); + } } } } @@ -404,9 +449,11 @@ void keystat_resetjoykey(void) { void keystat_releasekey(REG8 key) { key &= 0x7f; - if (keystat.ref[key] != NKEYREF_NC) { - keystat.ref[key] = NKEYREF_NC; - keyboard_send((REG8)(key + 0x80)); + if ((key != 0x71) && (key != 0x72)) { + if (keystat.ref[key] != NKEYREF_NC) { + keystat.ref[key] = NKEYREF_NC; + keyboard_send((REG8)(key + 0x80)); + } } }