|
|
| version 1.8, 2004/03/30 07:12:02 | version 1.18, 2005/03/18 09:23:10 |
|---|---|
| Line 5 | Line 5 |
| #include "iocore.h" | #include "iocore.h" |
| #include "keystat.h" | #include "keystat.h" |
| #include "keystat.tbl" | #include "keystat.tbl" |
| #include "softkbd.h" | |
| typedef struct { | typedef struct { |
| Line 18 typedef struct { | Line 19 typedef struct { |
| UINT8 d_rt; | UINT8 d_rt; |
| } KEYSTAT; | } KEYSTAT; |
| NKEYTBL nkeytbl; | NKEYTBL nkeytbl; |
| KEYCTRL keyctrl; | KEYCTRL keyctrl; |
| static KEYSTAT keystat; | static KEYSTAT keystat; |
| Line 26 static KEYSTAT keystat; | Line 26 static KEYSTAT keystat; |
| void keystat_initialize(void) { | void keystat_initialize(void) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| ZeroMemory(&keyctrl, sizeof(keyctrl)); | |
| keyctrl.keyrep = 0x21; | |
| keyctrl.capsref = NKEYREF_NC; | |
| keyctrl.kanaref = NKEYREF_NC; | |
| ZeroMemory(&keystat, sizeof(keystat)); | ZeroMemory(&keystat, sizeof(keystat)); |
| FillMemory(keystat.ref, sizeof(keystat.ref), NKEYREF_NC); | FillMemory(keystat.ref, sizeof(keystat.ref), NKEYREF_NC); |
| keystat_tblreset(); | keystat_tblreset(); |
| getbiospath(path, "key.txt", sizeof(path)); | getbiospath(path, OEMTEXT("key.txt"), NELEMENTS(path)); |
| keystat_tblload(path); | keystat_tblload(path); |
| } | } |
| Line 74 void keystat_tblset(REG8 ref, const UINT | Line 79 void keystat_tblset(REG8 ref, const UINT |
| // ---- config... | // ---- config... |
| static const char str_userkey1[] = "userkey1"; | static const OEMCHAR str_userkey1[] = OEMTEXT("userkey1"); |
| static const char str_userkey2[] = "userkey2"; | static const OEMCHAR str_userkey2[] = OEMTEXT("userkey2"); |
| static REG8 searchkeynum(const char *str, BOOL user) { | static REG8 searchkeynum(const OEMCHAR *str, BOOL user) { |
| const KEYNAME *n; | const KEYNAME *n; |
| const KEYNAME *nterm; | const KEYNAME *nterm; |
| n = keyname; | n = keyname; |
| nterm = keyname + (sizeof(keyname) / sizeof(KEYNAME)); | nterm = keyname + NELEMENTS(keyname); |
| while(n < nterm) { | while(n < nterm) { |
| if (!milstr_cmp(n->str, str)) { | if (!milstr_cmp(n->str, str)) { |
| return(n->num); | return(n->num); |
| Line 101 const KEYNAME *nterm; | Line 106 const KEYNAME *nterm; |
| return(0xff); | return(0xff); |
| } | } |
| void keystat_tblload(const char *filename) { | void keystat_tblload(const OEMCHAR *filename) { |
| TEXTFILEH tfh; | TEXTFILEH tfh; |
| char work[256]; | OEMCHAR work[256]; |
| char *p; | OEMCHAR *p; |
| char *q; | OEMCHAR *q; |
| char *r; | OEMCHAR *r; |
| UINT8 ref; | UINT8 ref; |
| UINT8 key[15]; | UINT8 key[15]; |
| UINT cnt; | UINT cnt; |
| Line 116 void keystat_tblload(const char *filenam | Line 121 void keystat_tblload(const char *filenam |
| if (tfh == NULL) { | if (tfh == NULL) { |
| goto kstbl_err; | goto kstbl_err; |
| } | } |
| while(textfile_read(tfh, work, sizeof(work)) == SUCCESS) { | while(textfile_read(tfh, work, NELEMENTS(work)) == SUCCESS) { |
| p = milstr_nextword(work); | p = milstr_nextword(work); |
| q = milstr_chr(p, '\t'); | q = milstr_chr(p, '\t'); |
| if (q == NULL) { | if (q == NULL) { |
| Line 157 kstbl_err: | Line 162 kstbl_err: |
| // ---- | // ---- |
| void keystat_ctrl(REG8 dat) { | static REG8 getledstat(void) { |
| 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) { | |
| if (!keyctrl.reqparam) { | if (!keyctrl.reqparam) { |
| keyctrl.mode = dat; | keyctrl.mode = dat; |
| Line 195 void keystat_ctrl(REG8 dat) { | Line 233 void keystat_ctrl(REG8 dat) { |
| #if defined(SUPPORT_PC9801_119) | #if defined(SUPPORT_PC9801_119) |
| case 0x95: | case 0x95: |
| keyctrl.kbdtype = dat; | keyctrl.kbdtype = dat; |
| keyboard_ctrl(0xfa); | |
| break; | break; |
| #endif | #endif |
| case 0x9d: | case 0x9c: |
| keyboard_ctrl(0xfa); | |
| break; | break; |
| case 0x9e: | 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; | break; |
| } | } |
| keyctrl.reqparam = 0; | keyctrl.reqparam = 0; |
| Line 220 void keystat_down(const UINT8 *key, REG8 | Line 270 void keystat_down(const UINT8 *key, REG8 |
| keydata = *key++; | keydata = *key++; |
| keycode = (keydata & 0x7f); | keycode = (keydata & 0x7f); |
| if (keycode < 0x70) { | if (keycode < 0x70) { |
| #if 1 // 05/02/04 | |
| if (keystat.ref[keycode] != NKEYREF_NC) { | |
| if (!(kbexflag[keycode] & KBEX_NONREP)) { | |
| keyboard_send((REG8)(keycode + 0x80)); | |
| keystat.ref[keycode] = NKEYREF_NC; | |
| } | |
| } | |
| if (keystat.ref[keycode] == NKEYREF_NC) { | |
| keyboard_send(keycode); | |
| } | |
| #else | |
| if ((keystat.ref[keycode] == NKEYREF_NC) || | if ((keystat.ref[keycode] == NKEYREF_NC) || |
| (!(kbexflag[keycode] & KBEX_NONREP))) { | (!(kbexflag[keycode] & KBEX_NONREP))) { |
| keyboard_send(keycode); | keyboard_send(keycode); |
| } | } |
| #endif | |
| keystat.ref[keycode] = ref; | keystat.ref[keycode] = ref; |
| } | } |
| else { | else { |
| #if defined(SUPPORT_PC9801_119) | #if defined(SUPPORT_PC9801_119) |
| if ((keyctrl.kbdtype != 0x03) && (keycode >= 0x75)) { | if (keyctrl.kbdtype != 0x03) |
| continue; | |
| } | |
| #else | |
| if (keycode >= 0x75) { | |
| continue; | |
| } | |
| #endif | #endif |
| { | |
| if (keycode == 0x7d) { | |
| keycode = 0x70; | |
| } | |
| else if (keycode >= 0x75) { | |
| continue; | |
| } | |
| } | |
| if ((np2cfg.XSHIFT) && | if ((np2cfg.XSHIFT) && |
| (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || | (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || |
| ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || | ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || |
| Line 259 void keystat_down(const UINT8 *key, REG8 | Line 323 void keystat_down(const UINT8 *key, REG8 |
| } | } |
| keyboard_send(data); | keyboard_send(data); |
| } | } |
| if ((keycode == 0x71) || (keycode == 0x72)) { | |
| reloadled(); | |
| } | |
| } | } |
| } | } |
| } | } |
| Line 279 void keystat_up(const UINT8 *key, REG8 k | Line 346 void keystat_up(const UINT8 *key, REG8 k |
| } | } |
| else { | else { |
| #if defined(SUPPORT_PC9801_119) | #if defined(SUPPORT_PC9801_119) |
| if ((keyctrl.kbdtype != 0x03) && (keycode >= 0x75)) { | if (keyctrl.kbdtype != 0x03) |
| continue; | |
| } | |
| #else | |
| if (keycode >= 0x75) { | |
| continue; | |
| } | |
| #endif | #endif |
| { | |
| if (keycode == 0x7d) { | |
| keycode = 0x70; | |
| } | |
| else if (keycode >= 0x75) { | |
| continue; | |
| } | |
| } | |
| if ((np2cfg.XSHIFT) && | if ((np2cfg.XSHIFT) && |
| (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || | (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || |
| ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || | ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || |
| Line 297 void keystat_up(const UINT8 *key, REG8 k | Line 366 void keystat_up(const UINT8 *key, REG8 k |
| if (keystat.ref[keycode] != NKEYREF_NC) { | if (keystat.ref[keycode] != NKEYREF_NC) { |
| keystat.ref[keycode] = NKEYREF_NC; | keystat.ref[keycode] = NKEYREF_NC; |
| keyboard_send((REG8)(keycode + 0x80)); | keyboard_send((REG8)(keycode + 0x80)); |
| if ((keycode == 0x71) || (keycode == 0x72)) { | |
| reloadled(); | |
| } | |
| } | } |
| } | } |
| } | } |
| Line 389 void keystat_resetjoykey(void) { | Line 461 void keystat_resetjoykey(void) { |
| void keystat_releasekey(REG8 key) { | void keystat_releasekey(REG8 key) { |
| key &= 0x7f; | key &= 0x7f; |
| if (keystat.ref[key] != NKEYREF_NC) { | if ((key != 0x71) && (key != 0x72)) { |
| keystat.ref[key] = NKEYREF_NC; | if (keystat.ref[key] != NKEYREF_NC) { |
| keyboard_send((REG8)(key + 0x80)); | keystat.ref[key] = NKEYREF_NC; |
| keyboard_send((REG8)(key + 0x80)); | |
| } | |
| } | } |
| } | } |