--- np2/wince/winkbd.cpp 2003/11/21 06:51:15 1.2 +++ np2/wince/winkbd.cpp 2004/06/21 03:18:04 1.5 @@ -1,15 +1,21 @@ #include "compiler.h" +#if defined(WIN32_PLATFORM_PSPC) +#include +#endif #include "np2.h" #include "winkbd.h" -#include "pccore.h" -#include "iocore.h" +#include "keystat.h" #define NC 0xff -static const BYTE key106[256] = { +#if defined(WIN32_PLATFORM_PSPC) +static UINT8 key106[256] = +#else +static const UINT8 key106[256] = +#endif // , , ,STOP, , , , ; 0x00 - NC, NC, NC,0x60, NC, NC, NC, NC, + { NC, NC, NC,0x60, NC, NC, NC, NC, // BS, TAB, , , CLR, ENT, , ; 0x08 0x0e,0x0f, NC, NC, NC,0x1c, NC, NC, // SFT,CTRL, ALT,PAUS,CAPS,KANA, , ; 0x10 @@ -73,9 +79,13 @@ static const BYTE key106[256] = { // , , , , , , , ; 0xf8 NC, NC, NC, NC, NC, NC, NC, NC}; -static const BYTE key106ext[256] = { +#if defined(WIN32_PLATFORM_PSPC) +static UINT8 key106ext[256] = +#else +static const UINT8 key106ext[256] = +#endif // , , ,STOP, , , , ; 0x00 - NC, NC, NC, NC, NC, NC, NC, NC, + { NC, NC, NC, NC, NC, NC, NC, NC, // BS, TAB, , , CLR, ENT, , ; 0x08 NC, NC, NC, NC, NC, NC, NC, NC, // SFT,CTRL, ALT,PAUS,CAPS,KANA, , ; 0x10 @@ -139,16 +149,16 @@ static const BYTE key106ext[256] = { // , , , , , , , ; 0xf8 NC, NC, NC, NC, NC, NC, NC, NC}; -static const BYTE f12keys[] = { +static const UINT8 f12keys[] = { 0x61, 0x60, 0x4d, 0x4f}; -static BYTE getf12key(void) { +static UINT8 getf12key(void) { UINT key; key = np2oscfg.F12KEY - 1; - if (key < (sizeof(f12keys)/sizeof(BYTE))) { + if (key < (sizeof(f12keys)/sizeof(UINT8))) { return(f12keys[key]); } else { @@ -158,7 +168,7 @@ static BYTE getf12key(void) { void winkbd_keydown(WPARAM wParam, LPARAM lParam) { - BYTE data; + UINT8 data; if (wParam != VK_F12) { data = key106[wParam & 0xff]; @@ -184,7 +194,7 @@ void winkbd_keydown(WPARAM wParam, LPARA void winkbd_keyup(WPARAM wParam, LPARAM lParam) { - BYTE data; + UINT8 data; if (wParam != VK_F12) { data = key106[wParam & 0xff]; @@ -198,7 +208,7 @@ void winkbd_keyup(WPARAM wParam, LPARAM keystat_senddata(0x70 | 0x80); // PC/AT only data = key106ext[wParam & 0xff]; } - keystat_senddata((BYTE)(data | 0x80)); + keystat_senddata((UINT8)(data | 0x80)); } else { // ver0.28 if (wParam == 0x0c) { @@ -212,8 +222,125 @@ void winkbd_resetf12(void) { UINT i; - for (i=0; i<(sizeof(f12keys)/sizeof(BYTE)); i++) { + for (i=0; i<(sizeof(f12keys)/sizeof(UINT8)); i++) { keystat_forcerelease(f12keys[i]); } } + +// ---- PocketPC keys + +#if defined(WIN32_PLATFORM_PSPC) + +extern GXKeyList gx_keylist; + +typedef struct { + short *ptr[4]; +} KEYADRS; + +typedef struct { + UINT8 key[4]; +} KEYSET; + +typedef struct { + KEYADRS curadrs; + KEYADRS btnadrs; + KEYSET curset[2]; + KEYSET btnset[2]; +} PPCBTNTBL; + +typedef struct { + KEYSET cur; + KEYSET btn; +} PPCBTNDEF; + + +static const PPCBTNTBL ppcbtntbl = { + {&gx_keylist.vkUp, &gx_keylist.vkDown, + &gx_keylist.vkLeft, &gx_keylist.vkRight}, + + {&gx_keylist.vkA, &gx_keylist.vkB, + &gx_keylist.vkC, &gx_keylist.vkStart}, + + {{0x3a, 0x3d, 0x3b, 0x3c}, // cur + {0x43, 0x4b, 0x46, 0x48}}, // tenkey + + {{0x1c, 0x34, NC, NC}, // RET/SP + {0x29, 0x2a, NC, NC}}}; // ZX + +static PPCBTNDEF ppcbtndef; + +static void getbind(KEYSET *bind, const UINT8 *tbl, const KEYADRS *adrs) { + + int i; + int key; + + for (i=0; i<4; i++) { + key = (*adrs->ptr[i]) & 0xff; + bind->key[i] = tbl[key]; + } +} + +static void setbind(UINT8 *tbl, const KEYSET *bind, const KEYADRS *adrs) { + + int i; + int key; + + for (i=0; i<4; i++) { + key = (*adrs->ptr[i]) & 0xff; + if (tbl[key] != NC) { + keystat_forcerelease(tbl[key]); + } + tbl[key] = bind->key[i]; + } +} + +void winkbd_bindinit(void) { + + getbind(&ppcbtndef.cur, key106ext, &ppcbtntbl.curadrs); + getbind(&ppcbtndef.btn, key106, &ppcbtntbl.btnadrs); +} + +void winkbd_bindcur(UINT type) { + +const KEYSET *bind; + + switch(type) { + case 0: + default: + bind = &ppcbtndef.cur; + break; + + case 1: + bind = ppcbtntbl.curset + 0; + break; + + case 2: + bind = ppcbtntbl.curset + 1; + break; + } + setbind(key106ext, bind, &ppcbtntbl.curadrs); +} + +void winkbd_bindbtn(UINT type) { + +const KEYSET *bind; + + switch(type) { + case 0: + default: + bind = &ppcbtndef.btn; + break; + + case 1: + bind = ppcbtntbl.btnset + 0; + break; + + case 2: + bind = ppcbtntbl.btnset + 1; + break; + } + setbind(key106, bind, &ppcbtntbl.btnadrs); +} +#endif +