1 static char RCSId
[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $";
2 static char Copyright
[] = "Copyright Scott A. Laird, Erik Bos 1993, 1994";
6 #include "prototypes.h"
10 int ToAscii(WORD wVirtKey
, WORD wScanCode
, LPSTR lpKeyState
,
11 LPVOID lpChar
, WORD wFlags
)
15 printf("ToAscii (%d,%d)\n",wVirtKey
, wScanCode
);
17 /* FIXME: this is not sufficient but better than returing -1 */
19 for (i
= 0 ; i
!= KeyTableSize
; i
++)
20 if (KeyTable
[i
].virtualkey
== wVirtKey
) {
21 *(BYTE
*)lpChar
++ = *KeyTable
[i
].name
;
30 DWORD
OemKeyScan(WORD wOemChar
)
32 printf("*OemKeyScan (%d)\n",wOemChar
);
37 /* VkKeyScan translates an ANSI character to a virtual-key and shift code
38 * for the current keyboard. */
40 WORD
VkKeyScan(WORD cChar
)
44 printf("VkKeyScan (%d)\n",cChar
);
46 for (i
= 0 ; i
!= KeyTableSize
; i
++)
47 if (KeyTable
[i
].ASCII
== cChar
)
48 return KeyTable
[i
].virtualkey
;
53 int GetKeyboardType(int nTypeFlag
)
55 printf("GetKeyboardType(%d)\n",nTypeFlag
);
58 case 0: /* Keyboard type */
59 return 4; /* AT-101 */
61 case 1: /* Keyboard Subtype */
62 return 0; /* There are no defined subtypes */
64 case 2: /* Number of F-keys */
65 return 12; /* We're doing an 101 for now, so return 12 F-keys */
68 fprintf(stderr
, "Unknown type on GetKeyboardType\n");
69 return 0; /* The book says 0 here, so 0 */
73 /* MapVirtualKey translates keycodes from one format to another. */
75 WORD
MapVirtualKey(WORD wCode
, WORD wMapType
)
81 for (i
= 0 ; i
!= KeyTableSize
; i
++)
82 if (KeyTable
[i
].virtualkey
== wCode
)
83 return KeyTable
[i
].scancode
;
87 for (i
= 0 ; i
!= KeyTableSize
; i
++)
88 if (KeyTable
[i
].scancode
== wCode
)
89 return KeyTable
[i
].virtualkey
;
93 for (i
= 0 ; i
!= KeyTableSize
; i
++)
94 if (KeyTable
[i
].virtualkey
== wCode
)
95 return KeyTable
[i
].ASCII
;
99 fprintf(stderr
, "MapVirtualKey: unknown wMapType!\n");
105 int GetKbCodePage(void)
107 printf("GetKbCodePage()\n");
111 int GetKeyNameText(LONG lParam
, LPSTR lpBuffer
, int nSize
)
115 printf("GetKeyNameText(%d,<ptr>, %d)\n",lParam
,nSize
);
120 for (i
= 0 ; i
!= KeyTableSize
; i
++)
121 if (KeyTable
[i
].scancode
== lParam
) {
122 strncpy(lpBuffer
, KeyTable
[i
].name
, nSize
);
123 return strlen(lpBuffer
);