home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / VKBDPDD.H < prev    next >
C/C++ Source or Header  |  1997-04-10  |  16KB  |  441 lines

  1. /***    vkbdpdd.h
  2.  *
  3.  *
  4.  *      Keyboard PDD/VDD shared structures/constants
  5.  *      Copyright (c) 1992 IBM Corporation
  6.  *
  7.  */
  8.  
  9. #pragma checkout( suspend )
  10.    #ifndef __CHKHDR__
  11.       #pragma checkout( suspend )
  12.    #endif
  13. #pragma checkout( resume )
  14.  
  15. #ifndef __VKBDPDD__
  16. #define __VKBDPDD__
  17.  
  18.  
  19. /* KBD PDD component definitions */
  20.  
  21. #define KBD_NAME                "KBD$"
  22.  
  23.  
  24. /***    PDD function commands
  25.  *
  26.  *  Format:
  27.  *      (*fpfnPKVDDProc)(PKBDCMD_*, f16p1, f16p2);
  28.  *
  29.  *  PKBDCMD_REGISTER:
  30.  *      f16p1 == segment of 16:32 VDD entry point
  31.  *      f16p2 ==  offset of 16:32 VDD entry point
  32.  *
  33.  *  PKBDCMD_DEREGISTER:
  34.  *      f16p1 == F16PNULL
  35.  *      f16p2 == F16PNULL
  36.  *
  37.  *  PKBDCMD_VDMCREATED:
  38.  *      f16p1 -> KSGID      (see packet below)
  39.  *      f16p2 == F16PNULL
  40.  *
  41.  *  PKBDCMD_QUERYID:
  42.  *      f16p1 == F16PNULL
  43.  *      f16p2 -> KID        (see packet below)
  44.  *
  45.  *  PKBDCMD_QUERYINHIBIT:
  46.  *      f16p1 == F16PNULL
  47.  *      f16p2 -> KINH       (see packet below)
  48.  *
  49.  *  PKBDCMD_SETLEDS:
  50.  *      f16p1 -> KLEDS      (see packet below)
  51.  *      f16p2 == F16PNULL
  52.  *
  53.  *  PKBDCMD_SETREPEATRATE:
  54.  *      f16p1 -> KRPT       (see packet below)
  55.  *      f16p2 == F16PNULL
  56.  *
  57.  *  PKBDCMD_TRANSLATE:
  58.  *      f16p1 -> KXLT       (see packet below)
  59.  *      f16p2 == F16PNULL
  60.  *
  61.  *  PKBDCMD_VDMTERMINTED:
  62.  *      f16p1 -> KSGID      (see packet below)
  63.  *      f16p2 == F16PNULL
  64.  *
  65.  *  PKBDCMD_FOCUS:
  66.  *      f16p1 -> KFOCUS     (see packet below)
  67.  *      f16p2 == F16PNULL
  68.  *
  69.  *  PKBDCMD_QUERYREVXLATE:
  70.  *      f16p1 -> KQRX       (see packet below)
  71.  *      f16p2 == F16PNULL
  72.  */
  73.  
  74. #define PKBDCMD_REGISTER        PDDCMD_REGISTER      /* register VDD              */
  75. #define PKBDCMD_DEREGISTER      (PKBDCMD_REGISTER+1) /* de-register VDD           */
  76. #define PKBDCMD_VDMCREATED      (PKBDCMD_REGISTER+2) /* notify VDM is created     */
  77. #define PKBDCMD_QUERYID         (PKBDCMD_REGISTER+3) /* query physical kbd ID     */
  78. #define PKBDCMD_QUERYINHIBIT    (PKBDCMD_REGISTER+4) /* query inhibit state       */
  79. #define PKBDCMD_SETLEDS         (PKBDCMD_REGISTER+5) /* set physical LEDs         */
  80. #define PKBDCMD_SETREPEATRATE   (PKBDCMD_REGISTER+6) /* set physical repeat rate  */
  81. #define PKBDCMD_TRANSLATE       (PKBDCMD_REGISTER+7) /* translate a scan code     */
  82. #define PKBDCMD_VDMTERMINATED   (PKBDCMD_REGISTER+8) /* notify VDM termination    */
  83. #define PKBDCMD_KFOCUS          (PKBDCMD_REGISTER+9) /* notify of focus change    */
  84. #define PKBDCMD_QUERYREVXLATE   (PKBDCMD_REGISTER+10)/* query reverse xlate table */
  85. #define PKBDCMD_HOTKEY          (PKBDCMD_REGISTER+11)/* notify of Hot Key setting */
  86.  
  87.  
  88. typedef struct ksgid_s {
  89.     USHORT  ksgid_len;                  /* length of packet (4)*/
  90.     SGID    ksgid_sgid;                 /* screen group ID     */
  91. } KSGID;
  92.  
  93. typedef KSGID *PKSGID;
  94.  
  95. /*c-begin*/
  96. #define KSGID_PKT_LEN   sizeof(KSGID)
  97. /*c-end*/
  98.  
  99.  
  100. typedef struct kid_s {
  101.     USHORT kid_len;                     /* length of packet (4)*/
  102.     USHORT kid_ID;                      /* keyboard ID         */
  103. } KID;
  104.  
  105. typedef KID *PKID;
  106.  
  107. /*c-begin*/
  108. #define KID_PKT_LEN     sizeof(KID)*/
  109. /*c-end*/
  110.  
  111.  
  112. typedef struct kinh_s {
  113.     USHORT kinh_len;                    /* length of packet (3)*/
  114.     BBOOL  kinh_fInhibited;             /* TRUE if inhibited, FALSE if not*/
  115. } KINH;
  116.  
  117. typedef KINH *PKINH;
  118.  
  119. /*c-begin*/
  120. #define KINH_PKT_LEN    sizeof(KINH)
  121. /*c-end*/
  122.  
  123.  
  124. typedef struct kled_s {
  125.     USHORT kled_len;                    /* length of packet (4)*/
  126.     USHORT kled_fsLEDs;                 /* bit0:SCROLL; bit1:NUM; bit2:CAPS*/
  127. } KLEDS;
  128.  
  129. typedef KLEDS *PKLEDS;
  130.  
  131. /*c-begin
  132. #define KLEDS_PKT_LEN   sizeof(KLEDS)
  133. /*c-end*/
  134. /*masm-begin*/
  135. /*KLEDS_PKT_LEN EQU     SIZE kled_s*/
  136. /*masm-end*/
  137.  
  138. typedef struct khotkey_s {
  139.     USHORT khk_len;
  140.     USHORT khk_action;
  141.     ULONG khk_hotkeys;
  142. } KHOTKEYS;
  143.  
  144. typedef KHOTKEYS *PKHOTKEYS;
  145.  
  146. /*c-begin*/
  147. #define KHOTKEYS_PKT_LEN   sizeof(KHOTKEYS)
  148. /*c-end*/
  149.  
  150. typedef struct krpt_s {
  151.     USHORT krpt_len;                    /* length of packet (6)*/
  152.     USHORT krpt_usDelay;                /* delay, in ms. (0 implies default)*/
  153.     USHORT krpt_usRate;                 /* rate, in cps (0 implies default)*/
  154. } KRPT;
  155.  
  156. typedef KRPT *PKRPT;
  157.  
  158. /*c-begin*/
  159. #define KRPT_PKT_LEN    sizeof(KRPT)
  160. /*c-end*/
  161.  
  162. typedef struct kkey_s {
  163.     USHORT key_len;                     /* length of packet (14)                */
  164.     UCHAR  key_chChar;                  /* ASCII code (output)                  */
  165.     UCHAR  key_chScan;                  /* scan code (input)                    */
  166.     UCHAR  key_fbStatus;                /* (output, normally KEYSTATUS_FINAL)   */
  167.     UCHAR  key_bNLSShift;               /* (reserved, set to zero on input)     */
  168.     USHORT key_fsState;                 /* shift states (input/output)          */
  169.     ULONG  key_time;                    /* timestamp (ignored)                  */
  170.     USHORT key_fsDDFlags;               /* device driver/monitor flags (output) */
  171. } KKEY;
  172.  
  173. typedef KKEY *PKKEY;
  174. typedef KKEY FAR16 *F16PKKEY;
  175.  
  176. /*c-begin*/
  177. #define KKEY_PKT_LEN    sizeof(KKEY)
  178. /*c-end*/
  179.  
  180.  
  181. typedef struct kxf_s {
  182.     USHORT kxf_len;                     /* length of packet (9)                 */
  183.     UCHAR  kxf_fbXlate;                 /* translation flags                    */
  184.     UCHAR  kxf_fbKey;                   /* key flags                            */
  185.     UCHAR  kxf_fbSpec;                  /* multi-keypacket events               */
  186.     UCHAR  kxf_fbMode;                  /* input mode                           */
  187.     UCHAR  kxf_fbAltNum;                /* Alt-keypad accumulator               */
  188.     USHORT kxf_fsHotKey;                /* interrupt-time "hot key" shift state */
  189. } KXF;
  190.  
  191. typedef KXF *PKXF;
  192. typedef KXF FAR16 *F16PKXF;
  193.  
  194. /*c-begin*/
  195. #define KXF_PKT_LEN     sizeof(KXF)
  196. /*c-end*/
  197.  
  198.  
  199. typedef struct kxlt_s {
  200.     USHORT   kxlt_len;                  /* length of packet (16)            */
  201.     F16PKKEY kxlt_f16pKey1;             /* pointer to key pkt 1             */
  202.     F16PKKEY kxlt_f16pKey2;             /* pointer to key pkt 2             */
  203.     F16PKXF  kxlt_f16pKxf;              /* pointer to translation flags pkt */
  204.     USHORT   kxlt_usCodePage;           /* codepage to use                  */
  205. } KXLT;
  206.  
  207. typedef KXLT *PKXLT;
  208.  
  209. /*c-begin*/
  210. #define KXLT_PKT_LEN    sizeof(KXLT)
  211. /*c-end*/
  212.  
  213. typedef struct kfocus_s {
  214.     USHORT kf_len;                    /* length of packet (4)*/
  215.     USHORT kf_fsFocus;                /* TRUE (set) FALSE (free) focus*/
  216. } KFOCUS;
  217.  
  218. typedef KFOCUS *PKFOCUS;
  219.  
  220. /*c-begin*/
  221. #define KFOCUS_PKT_LEN sizeof(KFOCUS)
  222. /*c-end*/
  223.  
  224. typedef struct rxentry_s {
  225.     UCHAR   rx_chScan;
  226.     UCHAR   rx_fbRXFlags;
  227. } RXENTRY;
  228.  
  229. typedef RXENTRY *PRX;
  230. typedef RXENTRY FAR16 *F16PRX;
  231.  
  232. typedef struct shentry_s {
  233.     USHORT  sh_fsShift;
  234.     UCHAR   sh_scanShift;
  235.     UCHAR   sh_scanPrefix;
  236. } SHENTRY;
  237.  
  238. typedef SHENTRY *PSH;
  239. typedef SHENTRY FAR16 *F16PSH;
  240.  
  241. /*c-begin*/
  242. #define SHENTRY_SIZE sizeof(SHENTRY)
  243. /*c-end*/
  244.  
  245. typedef UCHAR *PNUM;
  246. typedef UCHAR FAR16 *F16PNUM;
  247.  
  248. #define NUM_RXENTRIES   256     /*max. entries in rev. xlate table */
  249. #define NUM_SHENTRIES   6       /*max. entries in shift table      */
  250. #define NUM_NUMENTRIES  10      /*max. entries in num scan table   */
  251.  
  252. typedef RXENTRY RXTABLE[NUM_RXENTRIES];
  253. typedef SHENTRY SHTABLE[NUM_SHENTRIES];
  254. typedef UCHAR   NUMTABLE[NUM_NUMENTRIES];
  255.  
  256. /* RXFlags equates */
  257.  
  258. #define RXFLAGS_NONKEY          0
  259. #define RXFLAGS_LOWCASE         1
  260. #define RXFLAGS_UPCASE          2
  261. #define RXFLAGS_NOSHIFT         3
  262. #define RXFLAGS_SHIFT           4
  263. #define RXFLAGS_CTRL            5
  264.  
  265. /* Shift Table indexes */
  266.  
  267. #define SHINDX_LSHIFT   0
  268. #define SHINDX_LCTRL    1
  269. #define SHINDX_LALT     2
  270. #define SHINDX_RSHIFT   3
  271. #define SHINDX_RCTRL    4
  272. #define SHINDX_RALT     5
  273.  
  274. typedef struct kqrx_s {
  275.     USHORT  kqrx_len;                   /*length of packet (18)              */
  276.     USHORT  kqrx_usCodePage;            /*code page number                   */
  277.     USHORT  kqrx_hCodePage;             /*codepage table handle              */
  278.     F16PRX  kqrx_f16pRXTable;           /*pointer to rev. xlate table        */
  279.     F16PSH  kqrx_f16pShTable;           /*pointer to shift table             */
  280.     F16PNUM kqrx_f16pNumTable;          /*pointer to table for num pad scans */
  281. } KQRX;
  282.  
  283. typedef KQRX *PKQRX;
  284.  
  285. /*c-begin*/
  286. #define KQRX_PKT_LEN sizeof(KQRX)
  287. /*c-end*/
  288.  
  289.  
  290. /***    VDD function commands
  291.  *
  292.  *  Format:
  293.  *      (*fpfnVKPDDProc)(VKBDCMD_*, f16p1, f16p2);
  294.  *
  295.  *  VKBDCMD_INTEVENT:
  296.  *      f16p1 -> KINT       (see packet below)
  297.  *      f16p2 == NULL
  298.  *
  299.  *  VKBDCMD_CPCHANGED:
  300.  *      f16p1 -> KCPC       (see packet below)
  301.  *      f16p2 == NULL
  302.  *
  303.  *  VKBDCMD_HOTPLUG
  304.  *      f16p1 -> KHP        (see packet below)
  305.  *      f16p2 == NULL
  306.  */
  307.  
  308. #define VKBDCMD_INTEVENT        0x01    /* to notify of a scan code          */
  309. #define VKBDCMD_CPCHANGED       0x02    /* to notify of a codepage changed   */
  310. #define VKBDCMD_HOTPLUG         0x03    /* to notify of a hot plug occurance */
  311. #define VKBDCMD_ALTESC          0x04    /* to nofity of an ALT-ESC hotkey    */
  312.  
  313. typedef struct kint_s {
  314.     USHORT kint_len;                    /* length of packet */
  315.     USHORT kint_chScan;                 /* scan code        */
  316.     USHORT kint_usSGID;                 /* screen group ID  */
  317. } KINT;
  318.  
  319. typedef KINT *PKINT;
  320.  
  321. /*c-begin*/
  322. #define KINT_PKT_LEN    sizeof(KINT)
  323. /*c-end*/
  324.  
  325. typedef struct kcpc_s {
  326.     USHORT kcpc_len;                    /* length of packet        */
  327.     USHORT kcpc_usCodePage;             /* code page being changed */
  328.     USHORT kcpc_hCodePage;              /* code page handle        */
  329. } KCPC;
  330.  
  331. typedef KCPC *PKCPC;
  332.  
  333. /*c-begin*/
  334. #define KCPC_PKT_LEN    sizeof(KCPC)
  335. /*c-end*/
  336.  
  337. typedef struct khp_s {
  338.     USHORT khp_len;                     /* length of packet       */
  339.     USHORT khp_usKbdHWID;               /* current keyboard hw ID */
  340. } KHP;
  341.  
  342. typedef KHP *PKHP;
  343.  
  344. /*c-begin*/
  345. #define KHP_PKT_LEN    sizeof(KHP)
  346. /*c-end*/
  347.  
  348.  
  349. /* Flags for various fields in the XLTPKT structure */
  350.  
  351. #define KEYSTATUS_FINAL         0x40    /* key is final */
  352.  
  353. #define KEYSTATE_RIGHTSHIFT     BIOSKFLAG_RIGHTSHIFT
  354. #define KEYSTATE_LEFTSHIFT      BIOSKFLAG_LEFTSHIFT
  355. #define KEYSTATE_EITHERCTRL     BIOSKFLAG_CTRL
  356. #define KEYSTATE_EITHERALT      BIOSKFLAG_ALT
  357. #define KEYSTATE_SCROLLLOCK     BIOSKFLAG_SCROLLLOCK
  358. #define KEYSTATE_NUMLOCK        BIOSKFLAG_NUMLOCK
  359. #define KEYSTATE_CAPSLOCK       BIOSKFLAG_CAPSLOCK
  360. #define KEYSTATE_INSERT         BIOSKFLAG_INSERT
  361. #define KEYSTATE_LEDMASK        (KEYSTATE_SCROLLLOCK + \
  362.                                  KEYSTATE_NUMLOCK    + \
  363.                                  KEYSTATE_CAPSLOCK)
  364.  
  365. #define KEYSTATE_LEFTCTRL       (BIOSKFLAG1_LEFTCTRL   * 0x0100)
  366. #define KEYSTATE_LEFTALT        (BIOSKFLAG1_LEFTALT    * 0x0100)
  367. #define KEYSTATE_RIGHTCTRL      (BIOSKFLAG3_RIGHTCTRL  * 0x0100)
  368. #define KEYSTATE_RIGHTALT       (BIOSKFLAG3_RIGHTALT   * 0x0100)
  369. #define KEYSTATE_SCROLLDOWN     (BIOSKFLAG1_SCROLLDOWN * 0x0100)
  370. #define KEYSTATE_NUMDOWN        (BIOSKFLAG1_NUMDOWN    * 0x0100)
  371. #define KEYSTATE_CAPSDOWN       (BIOSKFLAG1_CAPSDOWN   * 0x0100)
  372. #define KEYSTATE_SYSREQDOWN     (BIOSKFLAG1_SYSSHIFT   * 0x2000)
  373.  
  374. #define KEYSTATE_LRSHIFTS       (KEYSTATE_LEFTSHIFT + KEYSTATE_RIGHTSHIFT + \
  375.                                  KEYSTATE_LEFTCTRL  + KEYSTATE_RIGHTCTRL  + \
  376.                                  KEYSTATE_LEFTALT   + KEYSTATE_RIGHTALT)
  377.  
  378. #define KEYSTATE_ALLSHIFTS      (KEYSTATE_LRSHIFTS + \
  379.                                  KEYSTATE_EITHERCTRL + KEYSTATE_EITHERALT)
  380.  
  381. #define KEYFLAGS_NORMAL         0x0000  /* any normal key                        */
  382. #define KEYFLAGS_ACK            0x0001  /* eg, SCAN_ACK                          */
  383. #define KEYFLAGS_SECPREFIX      0x0002  /* eg, 0E0h, 0E1h                        */
  384. #define KEYFLAGS_OVERRUN        0x0003  /* eg, SCAN_OVERRUN                      */
  385. #define KEYFLAGS_RESEND         0x0004  /* eg, SCAN_RESEND                       */
  386. #define KEYFLAGS_REBOOT         0x0005  /* never returned (PDD reboots)          */
  387. #define KEYFLAGS_DUMP           0x0006  /* eg, Ctrl-Alt-NumLock (ignore)         */
  388. #define KEYFLAGS_SHIFT          0x0007  /* eg, Shift, Ctrl, CapsLock, etc.       */
  389. #define KEYFLAGS_PAUSE          0x0008  /* eg, Pause or Ctrl-Numlock             */
  390. #define KEYFLAGS_PSPAUSE        0x0009  /* never returned (we're in RAW mode)    */
  391. #define KEYFLAGS_WAKEUP         0x000A  /* only after PAUSE, never PSPAUSE       */
  392. #define KEYFLAGS_BADACCENT      0x000B  /* eg, unaccentable key                  */
  393. #define KEYFLAGS_HOTKEY         0x000C  /*                                       */
  394. #define KEYFLAGS_READPEEK       0x000D  /*                                       */
  395. #define KEYFLAGS_ACCENT         0x0010  /*                                       */
  396. #define KEYFLAGS_BREAK          0x0011  /* eg, Ctrl-Break                        */
  397. #define KEYFLAGS_PSBREAK        0x0012  /* never returned (we're in RAW mode)    */
  398. #define KEYFLAGS_PRTSC          0x0013  /* eg, PrtSc                             */
  399. #define KEYFLAGS_PRTECHO        0x0014  /* eg, Ctrl-PrtSc                        */
  400. #define KEYFLAGS_PSPRTECHO      0x0015  /* never returned (we're in RAW mode)    */
  401. #define KEYFLAGS_PRTFLUSH       0x0016  /* eg, Ctrl-Alt-PrtSc                    */
  402. #define KEYFLAGS_SYSREQ         0x0017  /* eg, SysReq                            */
  403. #define KEYFLAGS_UNDEFINED      0x003F  /* undefined (we map ignored keys here)  */
  404. #define KEYFLAGS_TYPEMASK       0x003F  /* key type mask                         */
  405.  
  406. #define KEYFLAGS_RELEASED       0x0040  /* this was a release, not a press       */
  407. #define KEYFLAGS_SECONDARY      0x0080  /* key was preceded by SECPREFIX         */
  408. #define KEYFLAGS_MULTIMAKE      0x0100  /* ie, repeat of a "toggle" key          */
  409. #define KEYFLAGS_USEDACCENT     0x0200  /* key translated using previous accent  */
  410.  
  411. /* Flags for various fields in the KXF structure */                              rt
  412.  
  413. #define KXFXLATE_ACCENTMASK     0x07    /* previous accent # saved here          */
  414. #define KXFXLATE_SGPAUSED       0x08    /* session currently paused              */
  415. #define KXFXLATE_USECHAR3       0x10    /* use CHAR3 as index into accent tbl    */
  416. #define KXFXLATE_CTRLEMULATED   0x20    /* CTRL key emulated by enhanced kbd     */
  417. #define KXFXLATE_E1PREFIX       0x40    /* E1 prefix just seen                   */
  418. #define KXFXLATE_ACCENTINDEX3   0x80    /* chr3 of XlateTable index accent table */
  419.  
  420. #define KXFKEY_DUMPKEYONCE      0x01    /* dump key sequence has been hit once   */
  421. #define KXFKEY_PRTSCDOWN        0x02    /* PrtSc is down now                     */
  422. #define KXFKEY_SECPREFIX        0x04    /* E0 or E1 prefix just seen             */
  423. #define KXFKEY_NORMALALTDOWN    0x08    /* normal Alt down (not AltGraph)        */
  424.  
  425. #define KXFSPEC_ALT2PAC         0x01    /* alt-pad: use two xlation key packets  */
  426. #define KXFSPEC_E02PAC          0x02    /* E0: use two xlation key packets       */
  427. #define KXFSPEC_ACCENT2PAC      0x04    /* accent: use two xlation key packets   */
  428. #define KXFSPEC_ACCENT1PAC      0x08    /* accent: use one xlation key packets   */
  429. #define KXFSPEC_USE2PAC         0x80    /* use two xlation key packets           */
  430.  
  431. #define KXFMODE_SHIFTREPORT     0x01    /* not needed for VDM support            */
  432. #define KXFMODE_BINARY          0x80    /* set for normal VDM translation        */
  433.  
  434. #endif /* __VKBDPDD__ */
  435.  
  436. #pragma checkout( suspend )
  437.    #ifndef __CHKHDR__
  438.       #pragma checkout( resume )
  439.    #endif
  440. #pragma checkout( resume )
  441.