[NTVDM]
[reactos.git] / reactos / subsystems / mvdm / ntvdm / hardware / keyboard.c
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: keyboard.c
5 * PURPOSE: Keyboard emulation
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #define NDEBUG
12
13 #include "ntvdm.h"
14 #include "keyboard.h"
15 #include "ps2.h"
16
17 /* PRIVATE VARIABLES **********************************************************/
18
19 static BYTE PS2Port = 0;
20
21 /* PRIVATE FUNCTIONS **********************************************************/
22
23 static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
24 {
25 UNIMPLEMENTED;
26 }
27
28 /* PUBLIC FUNCTIONS ***********************************************************/
29
30 VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
31 {
32 WORD i;
33 BYTE ScanCode = (BYTE)KeyEvent->wVirtualScanCode;
34
35 /* If this is a key release, set the highest bit in the scan code */
36 if (!KeyEvent->bKeyDown) ScanCode |= 0x80;
37
38 /* Push the scan code into the PS/2 queue */
39 for (i = 0; i < KeyEvent->wRepeatCount; i++)
40 {
41 PS2QueuePush(PS2Port, ScanCode);
42 }
43
44 DPRINT("Press 0x%X\n", ScanCode);
45 }
46
47 BOOLEAN KeyboardInit(BYTE PS2Connector)
48 {
49 /* Finish to plug the keyboard to the specified PS/2 port */
50 PS2Port = PS2Connector;
51 PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
52
53 return TRUE;
54 }