|
|
| version 1.5, 2004/02/21 04:48:35 | version 1.6, 2004/03/28 10:50:16 |
|---|---|
| Line 8 | Line 8 |
| typedef struct { | typedef struct { |
| UINT8 ref[0x80]; | UINT8 ref[NKEY_SYSTEM]; |
| UINT8 extkey; | UINT8 extkey; |
| UINT8 mouselast; | UINT8 mouselast; |
| UINT8 padding; | UINT8 padding; |
| Line 43 void keystat_tblreset(void) { | Line 43 void keystat_tblreset(void) { |
| nkeytbl.key[i].keys = 1; | nkeytbl.key[i].keys = 1; |
| nkeytbl.key[i].key[0] = (UINT8)i; | nkeytbl.key[i].key[0] = (UINT8)i; |
| } | } |
| for (i=0; i<0x10; i++) { | |
| nkeytbl.key[i+0x80].keys = 1; | |
| nkeytbl.key[i+0x80].key[0] = (UINT8)(i + 0xf0); | |
| } | |
| } | } |
| void keystat_tblset(REG8 ref, const UINT8 *key, UINT cnt) { | void keystat_tblset(REG8 ref, const UINT8 *key, UINT cnt) { |
| UINT8 keycode; | |
| NKEYM *nkey; | NKEYM *nkey; |
| keycode = ref & 0x7f; | if ((ref >= NKEY_USER) && (ref < (NKEY_USER + NKEY_USERKEYS))) { |
| if ((keycode != NKEY_USER1) && (keycode != NKEY_USER2)) { | nkey = (NKEYM *)(nkeytbl.user + (ref - NKEY_USER)); |
| nkey = (NKEYM *)(nkeytbl.key + keycode); | cnt = min(cnt, 15); |
| } | |
| else if (ref < NKEY_SYSTEM) { | |
| nkey = (NKEYM *)(nkeytbl.key + ref); | |
| cnt = min(cnt, 3); | |
| } | } |
| else { | else { |
| nkey = (NKEYM *)(nkeytbl.user + (keycode - NKEY_USER1)); | return; |
| cnt = min(cnt, 15); | |
| } | } |
| cnt = min(cnt, 3); | |
| nkey->keys = (UINT8)cnt; | nkey->keys = (UINT8)cnt; |
| if (cnt) { | if (cnt) { |
| CopyMemory(nkey->key, key, cnt); | CopyMemory(nkey->key, key, cnt); |
| Line 86 const KEYNAME *nterm; | Line 91 const KEYNAME *nterm; |
| } | } |
| if (user) { | if (user) { |
| if (!milstr_cmp(str_userkey1, str)) { | if (!milstr_cmp(str_userkey1, str)) { |
| return(NKEY_USER1); | return(NKEY_USER + 0); |
| } | } |
| if (!milstr_cmp(str_userkey2, str)) { | if (!milstr_cmp(str_userkey2, str)) { |
| return(NKEY_USER2); | return(NKEY_USER + 1); |
| } | } |
| } | } |
| return(0xff); | return(0xff); |
| Line 153 kstbl_err: | Line 158 kstbl_err: |
| void keystat_down(const UINT8 *key, REG8 keys, REG8 ref) { | void keystat_down(const UINT8 *key, REG8 keys, REG8 ref) { |
| UINT8 keydata; | |
| UINT8 keycode; | UINT8 keycode; |
| UINT8 shift; | |
| REG8 data; | REG8 data; |
| while(keys--) { | while(keys--) { |
| keycode = *key++; | keydata = *key++; |
| keycode = (keycode & 0x7f); | keycode = (keydata & 0x7f); |
| if (keycode < 0x70) { | if (keycode < 0x70) { |
| if ((keystat.ref[keycode] == NKEYREF_NC) || | if ((keystat.ref[keycode] == NKEYREF_NC) || |
| (!(kbexflag[keycode] & KBEX_NONREP))) { | (!(kbexflag[keycode] & KBEX_NONREP))) { |
| Line 172 void keystat_down(const UINT8 *key, REG8 | Line 177 void keystat_down(const UINT8 *key, REG8 |
| (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || | (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || |
| ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || | ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || |
| ((keycode == 0x73) && (np2cfg.XSHIFT & 4)))) { | ((keycode == 0x73) && (np2cfg.XSHIFT & 4)))) { |
| keycode |= 8; | keydata |= 0x80; |
| } | } |
| shift = keycode & 0x07; | if (!(keydata & 0x80)) { // シフト |
| if (!(keycode & 8)) { // シフト | if ((keystat.ref[keycode + 0x00] == NKEYREF_NC) && |
| if ((keystat.ref[0x70 + shift] == NKEYREF_NC) && | (keystat.ref[keycode + 0x10] == NKEYREF_NC)) { |
| (keystat.ref[0x78 + shift] == NKEYREF_NC)) { | keyboard_send(keycode); |
| keyboard_send((REG8)(0x70 + shift)); | |
| } | } |
| if (keystat.ref[0x70 + shift] > ref) { | if (keystat.ref[keycode] > ref) { |
| keystat.ref[0x70 + shift] = ref; | keystat.ref[keycode] = ref; |
| } | } |
| } | } |
| else { // シフトメカニカル処理 | else { // シフトメカニカル処理 |
| if (keystat.ref[0x78 + shift] == NKEYREF_NC) { | if (keystat.ref[keycode + 0x10] == NKEYREF_NC) { |
| keystat.ref[0x78 + shift] = ref; | keystat.ref[keycode + 0x10] = ref; |
| data = (REG8)(0x70 + shift); | data = keycode; |
| } | } |
| else { | else { |
| keystat.ref[0x78 + shift] = NKEYREF_NC; | keystat.ref[keycode + 0x10] = NKEYREF_NC; |
| data = (REG8)(0xf0 + shift); | data = (REG8)(keycode + 0x80); |
| } | } |
| if (keystat.ref[0x70 + shift] == NKEYREF_NC) { | if (keystat.ref[keycode] == NKEYREF_NC) { |
| keyboard_send(data); | keyboard_send(data); |
| } | } |
| } | } |
| Line 203 void keystat_down(const UINT8 *key, REG8 | Line 207 void keystat_down(const UINT8 *key, REG8 |
| void keystat_up(const UINT8 *key, REG8 keys, REG8 ref) { | void keystat_up(const UINT8 *key, REG8 keys, REG8 ref) { |
| UINT8 keydata; | |
| UINT8 keycode; | UINT8 keycode; |
| UINT8 shift; | |
| while(keys--) { | while(keys--) { |
| keycode = *key++; | keydata = *key++; |
| keycode = (keycode & 0x7f); | keycode = (keydata & 0x7f); |
| if (keycode < 0x70) { | if (keycode < 0x70) { |
| if (keystat.ref[keycode] == ref) { | if (keystat.ref[keycode] == ref) { |
| keystat.ref[keycode] = NKEYREF_NC; | keystat.ref[keycode] = NKEYREF_NC; |
| Line 220 void keystat_up(const UINT8 *key, REG8 k | Line 224 void keystat_up(const UINT8 *key, REG8 k |
| (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || | (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) || |
| ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || | ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) || |
| ((keycode == 0x73) && (np2cfg.XSHIFT & 4)))) { | ((keycode == 0x73) && (np2cfg.XSHIFT & 4)))) { |
| keycode |= 8; | keydata |= 0x80; |
| } | } |
| shift = keycode & 0x07; | if (!(keydata & 0x80)) { // シフト |
| if (!(keycode & 8)) { // シフト | if (keystat.ref[keycode] == ref) { |
| if (keystat.ref[0x70 + shift] == ref) { | keystat.ref[keycode] = NKEYREF_NC; |
| keystat.ref[0x70 + shift] = NKEYREF_NC; | if (keystat.ref[keycode + 0x10] == NKEYREF_NC) { |
| if (keystat.ref[0x78 + shift] == NKEYREF_NC) { | keyboard_send((REG8)(keycode + 0x80)); |
| keyboard_send((REG8)(shift + 0xf0)); | |
| } | } |
| } | } |
| } | } |
| Line 244 void keystat_resendstat(void) { | Line 247 void keystat_resendstat(void) { |
| keyboard_send(i); | keyboard_send(i); |
| } | } |
| } | } |
| for (i=0; i<8; i++) { | for (i=0; i<0x10; i++) { |
| if ((keystat.ref[0x70 + i] != NKEYREF_NC) || | if ((keystat.ref[0x70 + i] != NKEYREF_NC) || |
| (keystat.ref[0x78 + i] != NKEYREF_NC)) { | (keystat.ref[0x80 + i] != NKEYREF_NC)) { |
| keyboard_send((REG8)(i + 0x70)); | keyboard_send((REG8)(i + 0x70)); |
| } | } |
| } | } |
| Line 257 void keystat_resendstat(void) { | Line 260 void keystat_resendstat(void) { |
| void keystat_keydown(REG8 ref) { | void keystat_keydown(REG8 ref) { |
| UINT8 keycode; | |
| UINT8 shift; | UINT8 shift; |
| const NKEYM *nkey; | const NKEYM *nkey; |
| keycode = ref & 0x7f; | if ((ref >= NKEY_USER) && (ref < (NKEY_USER + NKEY_USERKEYS))) { |
| if (np2cfg.KEY_MODE) { | nkey = (NKEYM *)(nkeytbl.user + (ref - NKEY_USER)); |
| shift = kbexflag[keycode]; | |
| if (shift & KBEX_JOYKEY) { | |
| keystat.extkey |= (1 << (shift & 7)); | |
| return; | |
| } | |
| } | |
| if ((keycode != NKEY_USER1) && (keycode != NKEY_USER2)) { | |
| nkey = (NKEYM *)(nkeytbl.key + keycode); | |
| keystat_down(nkey->key, nkey->keys, keycode); | |
| } | |
| else { | |
| nkey = (NKEYM *)(nkeytbl.user + (keycode - NKEY_USER1)); | |
| keystat_down(nkey->key, nkey->keys, NKEYREF_USER); | keystat_down(nkey->key, nkey->keys, NKEYREF_USER); |
| } | } |
| else if (ref < NKEY_SYSTEM) { | |
| if (np2cfg.KEY_MODE) { | |
| shift = kbexflag[ref]; | |
| if (shift & KBEX_JOYKEY) { | |
| keystat.extkey |= (1 << (shift & 7)); | |
| return; | |
| } | |
| } | |
| nkey = (NKEYM *)(nkeytbl.key + ref); | |
| keystat_down(nkey->key, nkey->keys, ref); | |
| } | |
| } | } |
| void keystat_keyup(REG8 ref) { | void keystat_keyup(REG8 ref) { |
| UINT8 keycode; | |
| UINT8 shift; | UINT8 shift; |
| const NKEYM *nkey; | const NKEYM *nkey; |
| keycode = ref & 0x7f; | if ((ref >= NKEY_USER) && (ref < (NKEY_USER + NKEY_USERKEYS))) { |
| if (np2cfg.KEY_MODE) { | nkey = (NKEYM *)(nkeytbl.user + (ref - NKEY_USER)); |
| shift = kbexflag[keycode]; | |
| if (shift & KBEX_JOYKEY) { | |
| keystat.extkey &= ~(1 << (shift & 7)); | |
| return; | |
| } | |
| } | |
| if ((keycode != NKEY_USER1) && (keycode != NKEY_USER2)) { | |
| nkey = (NKEYM *)(nkeytbl.key + keycode); | |
| keystat_up(nkey->key, nkey->keys, keycode); | |
| } | |
| else { | |
| nkey = (NKEYM *)(nkeytbl.user + (keycode - NKEY_USER1)); | |
| keystat_up(nkey->key, nkey->keys, NKEYREF_USER); | keystat_up(nkey->key, nkey->keys, NKEYREF_USER); |
| } | } |
| else if (ref < NKEY_SYSTEM) { | |
| if (np2cfg.KEY_MODE) { | |
| shift = kbexflag[ref]; | |
| if (shift & KBEX_JOYKEY) { | |
| keystat.extkey &= ~(1 << (shift & 7)); | |
| return; | |
| } | |
| } | |
| nkey = (NKEYM *)(nkeytbl.key + ref); | |
| keystat_up(nkey->key, nkey->keys, ref); | |
| } | |
| } | } |
| void keystat_releaseref(REG8 ref) { | void keystat_releaseref(REG8 ref) { |
| Line 316 void keystat_releaseref(REG8 ref) { | Line 315 void keystat_releaseref(REG8 ref) { |
| for (i=0; i<0x10; i++) { | for (i=0; i<0x10; i++) { |
| if (keystat.ref[0x70 + i] == ref) { | if (keystat.ref[0x70 + i] == ref) { |
| keystat.ref[0x70 + i] = NKEYREF_NC; | keystat.ref[0x70 + i] = NKEYREF_NC; |
| if (keystat.ref[0x78 ^ i] == NKEYREF_NC) { | if (keystat.ref[0x80 + i] == NKEYREF_NC) { |
| keyboard_send((REG8)((i & 7) + 0xe0)); | keyboard_send((REG8)(0xf0 + i)); |
| } | |
| } | |
| if (keystat.ref[0x80 + i] == ref) { | |
| keystat.ref[0x80 + i] = NKEYREF_NC; | |
| if (keystat.ref[0x70 + i] == NKEYREF_NC) { | |
| keyboard_send((REG8)(0xf0 + i)); | |
| } | } |
| } | } |
| } | } |
| Line 346 void keystat_releasekey(REG8 key) { | Line 351 void keystat_releasekey(REG8 key) { |
| } | } |
| } | } |
| else { | else { |
| key &= 0x07; | if ((keystat.ref[key + 0x00] != NKEYREF_NC) || |
| if ((keystat.ref[0x70 + key] != NKEYREF_NC) || | (keystat.ref[key + 0x10] != NKEYREF_NC)) { |
| (keystat.ref[0x78 + key] != NKEYREF_NC)) { | keystat.ref[key + 0x00] = NKEYREF_NC; |
| keystat.ref[0x70 + key] = NKEYREF_NC; | keystat.ref[key + 0x10] = NKEYREF_NC; |
| keystat.ref[0x78 + key] = NKEYREF_NC; | keyboard_send((REG8)(key + 0x80)); |
| keyboard_send((REG8)(key + 0xf0)); | |
| } | } |
| } | } |
| } | } |
| Line 360 void keystat_allrelease(void) { | Line 364 void keystat_allrelease(void) { |
| REG8 i; | REG8 i; |
| for (i=0; i<0x78; i++) { | for (i=0; i<0x80; i++) { |
| keystat_releasekey(i); | keystat_releasekey(i); |
| } | } |
| } | } |
| Line 440 REG8 keystat_getmouse(SINT16 *x, SINT16 | Line 444 REG8 keystat_getmouse(SINT16 *x, SINT16 |
| // ---- | // ---- |
| void keystat_senddata(REG8 data) { | // キーコード変更 |
| UINT8 keycode; | static REG8 cnvnewcode(REG8 oldcode) { |
| switch(oldcode) { | |
| case 0x71: // 通常caps | |
| return(0x81); | |
| case 0x72: // 通常カナ | |
| return(0x82); | |
| case 0x79: // メカニカルロックcaps | |
| return(0x71); | |
| case 0x7a: // メカニカルロックcaps | |
| return(0x72); | |
| keycode = data & 0x7f; | case 0x76: |
| if ((keycode == 0x71) || (keycode == 0x72) || | return(0x90); // NKEY_USER + 0 |
| (keycode == 0x79) || (keycode == 0x7a)) { | |
| keycode ^= 8; | case 0x77: |
| return(0x91); // NKEY_USER + 1 | |
| default: | |
| return(oldcode); | |
| } | } |
| } | |
| void keystat_senddata(REG8 data) { | |
| REG8 keycode; | |
| keycode = cnvnewcode((REG8)(data & 0x7f)); | |
| if (!(data & 0x80)) { | if (!(data & 0x80)) { |
| keystat_keydown(keycode); | keystat_keydown(keycode); |
| } | } |
| Line 457 void keystat_senddata(REG8 data) { | Line 485 void keystat_senddata(REG8 data) { |
| } | } |
| } | } |
| void keystat_forcerelease(REG8 data) { | |
| REG8 keycode; | |
| keycode = cnvnewcode((REG8)(data & 0x7f)); | |
| keystat_releasekey(keycode); | |
| } | |