Diff for /np2/wince/winkbd.cpp between versions 1.2 and 1.6

version 1.2, 2003/11/21 06:51:15 version 1.6, 2005/02/07 14:46:15
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   #if defined(WIN32_PLATFORM_PSPC)
   #include        <gx.h>
   #endif
 #include        "np2.h"  #include        "np2.h"
 #include        "winkbd.h"  #include        "winkbd.h"
 #include        "pccore.h"  #include        "keystat.h"
 #include        "iocore.h"  
   
   
 #define         NC              0xff  #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                          //          ,    ,    ,STOP,    ,    ,    ,             ; 0x00
                                   NC,  NC,  NC,0x60,  NC,  NC,  NC,  NC,                  {                 NC,  NC,  NC,0x60,  NC,  NC,  NC,  NC,
                         //        BS, TAB,    ,    , CLR, ENT,    ,             ; 0x08                          //        BS, TAB,    ,    , CLR, ENT,    ,             ; 0x08
                                 0x0e,0x0f,  NC,  NC,  NC,0x1c,  NC,  NC,                                  0x0e,0x0f,  NC,  NC,  NC,0x1c,  NC,  NC,
                         //       SFT,CTRL, ALT,PAUS,CAPS,KANA,    ,             ; 0x10                          //       SFT,CTRL, ALT,PAUS,CAPS,KANA,    ,             ; 0x10
Line 73  static const BYTE key106[256] = { Line 79  static const BYTE key106[256] = {
                         //          ,    ,    ,    ,    ,    ,    ,             ; 0xf8                          //          ,    ,    ,    ,    ,    ,    ,             ; 0xf8
                                   NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC};                                    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                          //          ,    ,    ,STOP,    ,    ,    ,             ; 0x00
                                   NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC,                  {                 NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC,
                         //        BS, TAB,    ,    , CLR, ENT,    ,             ; 0x08                          //        BS, TAB,    ,    , CLR, ENT,    ,             ; 0x08
                                   NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC,                                    NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC,
                         //       SFT,CTRL, ALT,PAUS,CAPS,KANA,    ,             ; 0x10                          //       SFT,CTRL, ALT,PAUS,CAPS,KANA,    ,             ; 0x10
Line 139  static const BYTE key106ext[256] = { Line 149  static const BYTE key106ext[256] = {
                         //          ,    ,    ,    ,    ,    ,    ,             ; 0xf8                          //          ,    ,    ,    ,    ,    ,    ,             ; 0xf8
                                   NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC};                                    NC,  NC,  NC,  NC,  NC,  NC,  NC,  NC};
   
 static const BYTE f12keys[] = {  static const UINT8 f12keys[] = {
                         0x61, 0x60, 0x4d, 0x4f};                          0x61, 0x60, 0x4d, 0x4f};
   
   
 static BYTE getf12key(void) {  static UINT8 getf12key(void) {
   
         UINT    key;          UINT    key;
   
         key = np2oscfg.F12KEY - 1;          key = np2oscfg.F12KEY - 1;
         if (key < (sizeof(f12keys)/sizeof(BYTE))) {          if (key < NELEMENTS(f12keys)) {
                 return(f12keys[key]);                  return(f12keys[key]);
         }          }
         else {          else {
Line 158  static BYTE getf12key(void) { Line 168  static BYTE getf12key(void) {
   
 void winkbd_keydown(WPARAM wParam, LPARAM lParam) {  void winkbd_keydown(WPARAM wParam, LPARAM lParam) {
   
         BYTE    data;          UINT8   data;
   
         if (wParam != VK_F12) {          if (wParam != VK_F12) {
                 data = key106[wParam & 0xff];                  data = key106[wParam & 0xff];
Line 184  void winkbd_keydown(WPARAM wParam, LPARA Line 194  void winkbd_keydown(WPARAM wParam, LPARA
   
 void winkbd_keyup(WPARAM wParam, LPARAM lParam) {  void winkbd_keyup(WPARAM wParam, LPARAM lParam) {
   
         BYTE    data;          UINT8   data;
   
         if (wParam != VK_F12) {          if (wParam != VK_F12) {
                 data = key106[wParam & 0xff];                  data = key106[wParam & 0xff];
Line 198  void winkbd_keyup(WPARAM wParam, LPARAM  Line 208  void winkbd_keyup(WPARAM wParam, LPARAM 
                         keystat_senddata(0x70 | 0x80);                          // PC/AT only                          keystat_senddata(0x70 | 0x80);                          // PC/AT only
                         data = key106ext[wParam & 0xff];                          data = key106ext[wParam & 0xff];
                 }                  }
                 keystat_senddata((BYTE)(data | 0x80));                  keystat_senddata((UINT8)(data | 0x80));
         }          }
         else {                                                                                          // ver0.28          else {                                                                                          // ver0.28
                 if (wParam == 0x0c) {                  if (wParam == 0x0c) {
Line 212  void winkbd_resetf12(void) { Line 222  void winkbd_resetf12(void) {
   
         UINT    i;          UINT    i;
   
         for (i=0; i<(sizeof(f12keys)/sizeof(BYTE)); i++) {          for (i=0; i<NELEMENTS(f12keys); i++) {
                 keystat_forcerelease(f12keys[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
   

Removed from v.1.2  
changed lines
  Added in v.1.6


RetroPC.NET-CVS <cvs@retropc.net>