home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / unikbd.h < prev    next >
C/C++ Source or Header  |  1999-03-15  |  13KB  |  345 lines

  1. /********************************************************************
  2.  *
  3.  * Name: unikbd.h
  4.  *
  5.  * Function:
  6.  *     Declare constants and functions prototypes used in keyboard
  7.  *     translation.
  8.  *
  9.  * Copyright:
  10.  *     Copyright (C) IBM Corp. 1996
  11.  *
  12.  * Notes:
  13.  *
  14.  *
  15.  *
  16.  ********************************************************************/
  17.  
  18. #ifndef __UNIKBD_INCLUDED__
  19.   #define __UNIKBD_INCLUDED__
  20.  
  21.   #ifdef __cplusplus
  22.   extern "C" {
  23.   #endif
  24.  
  25.   #include <unidef.h>
  26.  
  27.   #define KBDLINK  CALLCONV
  28.  
  29.   /*
  30.    * This should work from either OS/2 or CPS, so we need to declare
  31.    * some OS/2 like constants, but only if OS2DEF is not already
  32.    * included.
  33.    */
  34.   #ifndef OS2DEF_INCLUDED
  35.     typedef unsigned short USHORT;
  36.     typedef unsigned long  ULONG;
  37.     typedef unsigned int   UINT;
  38.     typedef unsigned int   APIRET;
  39.     typedef unsigned char  BYTE;
  40.     #define LOBYTE(w)      LOUCHAR(w)
  41.     #define HIBYTE(w)      HIUCHAR(w)
  42.     #define LOUCHAR(w)     ((UCHAR)(USHORT)(w))
  43.     #define HIUCHAR(w)     ((UCHAR)(((USHORT)(w) >> 8) & 0xff))
  44.     #define MAKEULONG(l,h) ((ULONG)(((USHORT)(l)) | ((ULONG)((USHORT)(h)))<<16))
  45.   #endif
  46.  
  47.   /*
  48.    * Simple types
  49.    */
  50.   typedef unsigned int    KHAND;   /* Handle to translate table */
  51.   typedef unsigned char   VSCAN;   /* Virtual scan code */
  52.   typedef unsigned short  VDKEY;   /* Virtual/Dead key  */
  53.   typedef UniChar         KBDNAME; /* Keyboard name (UniChar) */
  54.  
  55.  
  56.   /*
  57.    * Define virtual keys.  This is mostly unnecessary if PMWIN is included
  58.    */
  59.   #ifndef INCL_WININPUT
  60.     #define INCL_WININPUT
  61.     #define  VK_BREAK            0x0004
  62.     #define  VK_BACKSPACE        0x0005
  63.     #define  VK_TAB              0x0006
  64.     #define  VK_BACKTAB          0x0007
  65.     #define  VK_NEWLINE          0x0008
  66.     #define  VK_SHIFT            0x0009
  67.     #define  VK_CTRL             0x000A
  68.     #define  VK_ALT              0x000B
  69.     #define  VK_ALTGRAF          0x000C
  70.     #define  VK_PAUSE            0x000D
  71.     #define  VK_CAPSLOCK         0x000E
  72.     #define  VK_ESC              0x000F
  73.     #define  VK_SPACE            0x0010
  74.     #define  VK_PAGEUP           0x0011
  75.     #define  VK_PAGEDOWN         0x0012
  76.     #define  VK_END              0x0013
  77.     #define  VK_HOME             0x0014
  78.     #define  VK_LEFT             0x0015
  79.     #define  VK_UP               0x0016
  80.     #define  VK_RIGHT            0x0017
  81.     #define  VK_DOWN             0x0018
  82.     #define  VK_PRINTSCRN        0x0019
  83.     #define  VK_INSERT           0x001A
  84.     #define  VK_DELETE           0x001B
  85.     #define  VK_SCRLLOCK         0x001C
  86.     #define  VK_NUMLOCK          0x001D
  87.     #define  VK_ENTER            0x001E
  88.     #define  VK_SYSRQ            0x001F
  89.     #define  VK_F1               0x0020
  90.     #define  VK_F2               0x0021
  91.     #define  VK_F3               0x0022
  92.     #define  VK_F4               0x0023
  93.     #define  VK_F5               0x0024
  94.     #define  VK_F6               0x0025
  95.     #define  VK_F7               0x0026
  96.     #define  VK_F8               0x0027
  97.     #define  VK_F9               0x0028
  98.     #define  VK_F10              0x0029
  99.     #define  VK_F11              0x002A
  100.     #define  VK_F12              0x002B
  101.     #define  VK_F13              0x002C
  102.     #define  VK_F14              0x002D
  103.     #define  VK_F15              0x002E
  104.     #define  VK_F16              0x002F
  105.     #define  VK_F17              0x0030
  106.     #define  VK_F18              0x0031
  107.     #define  VK_F19              0x0032
  108.     #define  VK_F20              0x0033
  109.     #define  VK_F21              0x0034
  110.     #define  VK_F22              0x0035
  111.     #define  VK_F23              0x0036
  112.     #define  VK_F24              0x0037
  113.     #define  VK_CLEAR            0x0039
  114.     #define  VK_EREOF            0x003A
  115.     #define  VK_PA1              0x003B
  116.     #define  VK_ATTN             0x003C
  117.     #define  VK_CRSEL            0x003D
  118.     #define  VK_EXSEL            0x003E
  119.     #define  VK_COPY             0x003F
  120.     #define  VK_BLK1             0x0040
  121.     #define  VK_BLK2             0x0041
  122.   #endif
  123.  
  124.   /* Additional vkeys not defined by PMWIN */
  125.   #define  VK_PA2              0x0050
  126.   #define  VK_PA3              0x0051
  127.   #define  VK_GROUP            0x0052
  128.   #define  VK_GROUPLOCK        0x0053
  129.   #define  VK_APPL             0x0054
  130.   #define  VK_WINLEFT          0x0055
  131.   #define  VK_WINRIGHT         0x0056
  132.   #define  VK_M_DOWNLEFT       0x0061
  133.   #define  VK_M_DOWN           0x0062
  134.   #define  VK_M_DOWNRIGHT      0x0063
  135.   #define  VK_M_LEFT           0x0064
  136.   #define  VK_M_CENTER         0x0065
  137.   #define  VK_M_RIGHT          0x0066
  138.   #define  VK_M_UPLEFT         0x0067
  139.   #define  VK_M_UP             0x0068
  140.   #define  VK_M_UPRIGHT        0x0069
  141.   #define  VK_M_BUTTONLOCK     0x006A
  142.   #define  VK_M_BUTTONRELEASE  0x006B
  143.   #define  VK_M_DOUBLECLICK    0x006C
  144.   /* There are additional NLS vkeys */
  145.  
  146.  
  147.   /*
  148.    * Deadkey mappings
  149.    */
  150.   #define  DK_MIN              0x1000    /* Min deadkey */
  151.   #define  DK_ACUTE            0x1001
  152.   #define  DK_GRAVE            0x1002
  153.   #define  DK_DIERESIS         0x1003
  154.   #define  DK_UMLAUT           0x1003    /* Alternate name */
  155.   #define  DK_CIRCUMFLEX       0x1004
  156.   #define  DK_TILDE            0x1005
  157.   #define  DK_CEDILLA          0x1006
  158.   #define  DK_MACRON           0x1007
  159.   #define  DK_BREVE            0x1008
  160.   #define  DK_OGONEK           0x1009
  161.   #define  DK_DOT              0x100a
  162.   #define  DK_BAR              0x100b
  163.   #define  DK_RING             0x100c
  164.   #define  DK_CARON            0x100d
  165.   #define  DK_HACEK            0x100d             /* Alternate name */
  166.   #define  DK_HUNGARUMLAUT     0x100e
  167.   #define  DK_ACUTEDIA         0x100f
  168.   #define  DK_PSILI            0x1010
  169.   #define  DK_DASIA            0x1011
  170.   #define  DK_OVERLINE         0x1012
  171.   #define  DK_UNDERDOT         0x1013
  172.  
  173.   #define  DK_MAX              0x1fff    /* Max deadkey */
  174.  
  175.   /*
  176.    * Shift states
  177.    */
  178.   typedef struct  {             /* Keyboard shift state object */
  179.       ULONG  Shift;             /* Actual shift and lock state */
  180.       ULONG  Effective;         /* Effective shift and lock state */
  181.       ULONG  Led;               /* Keyboard indicators */
  182.   } USHIFTSTATE;
  183.  
  184.   /* Both Shift and Effective */
  185.   #define KBD_SHIFT            0x00000001
  186.   #define KBD_CONTROL          0x00000002
  187.   #define KBD_ALT              0x00000004
  188.   #define KBD_ALTCTRLSHIFT     0x00000007
  189.   #define KBD_ALTGR            0x00000008
  190.   #define KBD_NLS1             0x00000010     /* NLS lock states */
  191.   #define KBD_NLS2             0x00000020
  192.   #define KBD_NLS3             0x00000040
  193.   #define KBD_NLS4             0x00000080
  194.  
  195.   /* Japanese use of NLS shifts */
  196.   #define KBD_WIDE             KBD_NLS1
  197.   #define KBD_KATAKANA         KBD_NLS2
  198.   #define KBD_HIRAGANA         KBD_NLS3
  199.   #define KBD_ROMANJI          KBD_NLS4
  200.   /* Korean use of NLS shifts */
  201.   #define KBD_JAMO             KBD_NLS2
  202.   #define KBD_HANGEUL          KBD_NLS3
  203.   #define KBD_HANJACSR         KBD_NLS4
  204.   /* Taiwan use of NLS shifts */
  205.   #define KBD_PHONETIC         KBD_NLS2
  206.   #define KBD_TSANGJYE         KBD_NLS3
  207.  
  208.   /* Lock states */
  209.   #define KBD_SCROLLLOCK       0x00000100
  210.   #define KBD_NUMLOCK          0x00000200
  211.   #define KBD_CAPSLOCK         0x00000400
  212.   #define KBD_EXTRALOCK        0x00000800
  213.   #define KBD_APPL             0x00001000     /* MS Application key */
  214.   #define KBD_DBCS             0x00008000     /* DBCS active        */
  215.  
  216.   #define KBD_EFFECTIVE        0x0000ffff
  217.  
  218.   /* Left/Right shift separation */
  219.   #define KBD_LEFTSHIFT        0x00010000
  220.   #define KBD_RIGHTSHIFT       0x00020000
  221.   #define KBD_LEFTCONTROL      0x00040000
  222.   #define KBD_RIGHTCONTROL     0x00080000
  223.   #define KBD_LEFTALT          0x00100000
  224.   #define KBD_RIGHTALT         0x00200000
  225.   #define KBD_LEFTWINDOWS      0x00400000
  226.   #define KBD_RIGHTWINDOWS     0x00800000
  227.  
  228.   /* Status bits and additional LEDs */
  229.   #define KBD_NOROMANJI        0x04000000
  230.   #define KBD_KANJI            0x08000000
  231.   #define KBD_DEADKEY          0x10000000
  232.   #define KBD_WAIT             0x20000000
  233.   #define KBD_HOLD             0x40000000
  234.   #define KBD_LOCK             0x80000000
  235.  
  236.   /*
  237.    * Define Make/Break constants
  238.    */
  239.   #define KEYEV_MAKEBREAK 0     /* Both make and break */
  240.   #define KEYEV_MAKE      1     /* Key down            */
  241.   #define KEYEV_BREAK     2     /* Key up              */
  242.   #define KEYEV_REPEAT    3     /* Repeat key          */
  243.  
  244.   /*
  245.    *  Virtual key event.
  246.    */
  247.   typedef struct {
  248.       USHORT ldev;             /* Logical device 0=real */
  249.       BYTE   makebreak;        /* Make/break indicator  */
  250.       VSCAN  scan;             /* Virtual scan code     */
  251.       ULONG  time;             /* Timestamp             */
  252.   } INKEYEVENT;
  253.  
  254.   /*
  255.    * Query keyboard structure
  256.    */
  257.   typedef struct {
  258.       ULONG   len;             /* Length of structrue */
  259.       USHORT  kbid;            /* Keyboard architecture id */
  260.       USHORT  version;         /* Version number */
  261.       BYTE    language[2];     /* Normal language          */
  262.       BYTE    country[2];      /* Normal country           */
  263.       USHORT  flags;           /* Flags (KBDF_)  */
  264.       USHORT  resv;            /* Reserved       */
  265.       UniChar description[32]; /* Description of keyboard */
  266.   } KEYBOARDINFO;
  267.  
  268.   /*
  269.    * Query keyboard flags
  270.    */
  271.   #define  KBDF_DEFAULTVKEY    0x0001    /* Use default VKEYs */
  272.   #define  KBDF_NOCTRLSHIFT    0x0002    /* Ctrl+Shift equals Ctrl */
  273.   #define  KBDF_NOALTGR        0x0004    /* Alt graphics is not used */
  274.   #define  KBDF_SHIFTALTGR     0x0010    /* Altgr, shift-altgr separate */
  275.   #define  KBDF_DEADGOOD       0x0020    /* Invalid dead use second char*/
  276.   #define  KBDF_DEADPRIVATE    0x0040    /* Use only private dead keys  */
  277.  
  278.   #define  KBDF_SYSTEM         0x8000    /* System supplied keyboard */
  279.   #define  KBDF_INTERNATIONAL  0x4000    /* Full-range character set */
  280.   #define  KBDF_DVORAK         0x2000    /* Alternate letter keys */
  281.   #define  KBDF_NATIONAL       0x1000    /* National letter keys */
  282.   #define  KBDF_LETTERKEYS     0x3000    /* Letter key type */
  283.   #define  KBDF_ISOKEYS        0x0800    /* Use ISO icons for key names */
  284.  
  285.   /* These layouts are advisory only */
  286.   #define  KBDF_LAYOUT101      0x0000    /* Normal layout is 84/101 */
  287.   #define  KBDF_LAYOUT102      0x0100    /* Normal layout is 85/102 */
  288.   #define  KBDF_LAYOUT106      0x0200    /* Normal layout is 89/106 */
  289.   #define  KBDF_LAYOUT103      0x0300    /* Normal layout is 86/103 */
  290.   #define  KBDF_LAYOUT100      0x0400    /* Normal layout is 83/100 */
  291.   #define  KBDF_LAYOUTS        0x0700    /* Layout related bits     */
  292.   /*
  293.    * Reset ShiftState types
  294.    */
  295.   #define KEYEV_SET      0     /* Set to specified value */
  296.   #define KEYEV_RELEASE  1     /* Release all pressed keys */
  297.   #define KEYEV_ZERO     2     /* Release all pressed and locked keys */
  298.  
  299.  
  300.   /*
  301.    *  Unicode keyboard API function prototypes
  302.    */
  303.   APIRET  CALLCONV UniCreateKeyboard(KHAND   * pkhand,
  304.                                     KBDNAME * name,
  305.                                     ULONG     mode);
  306.  
  307.   APIRET  CALLCONV UniDestroyKeyboard(KHAND khand);
  308.  
  309.   APIRET  CALLCONV UniQueryKeyboard(KHAND          khand,
  310.                                    KEYBOARDINFO * kbdinfo);
  311.  
  312.   APIRET  CALLCONV UniResetShiftState(KHAND        khand,
  313.                                      USHIFTSTATE * state,
  314.                                      ULONG        type);
  315.  
  316.   APIRET  CALLCONV UniUpdateShiftState(KHAND        khand,
  317.                                       USHIFTSTATE * state,
  318.                                       VSCAN        scan,
  319.                                       BYTE         makebreak);
  320.  
  321.   APIRET  CALLCONV UniTranslateKey(KHAND      khand,
  322.                                   ULONG      eshift,
  323.                                   VSCAN      scan,
  324.                                   UniChar  * unichar,
  325.                                   VDKEY    * vdkey,
  326.                                   BYTE     * bscan);
  327.  
  328.   APIRET  CALLCONV UniTranslateDeadkey(KHAND      khand,
  329.                                       VDKEY      dead,
  330.                                       UniChar    inchar,
  331.                                       UniChar  * outchar,
  332.                                       VDKEY    * newdeadkey);
  333.  
  334.   APIRET  CALLCONV UniUntranslateKey(KHAND    khand,
  335.                                     UniChar  unichar,
  336.                                     VDKEY    vdkey,
  337.                                     VSCAN  * pscan,
  338.                                     ULONG  * eshift);
  339.  
  340.   #ifdef __cplusplus
  341.   }
  342.   #endif
  343. #endif
  344.  
  345.