ReactOS 0.4.16-dev-321-g63bb46a
keyboard.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "keyboard.h"
#include "ps2.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID WINAPI KeyboardCommand (LPVOID Param, BYTE Command)
 
VOID KeyboardEventHandler (PKEY_EVENT_RECORD KeyEvent)
 
BOOLEAN KeyboardInit (BYTE PS2Connector)
 

Variables

static BOOLEAN KeyboardReporting = FALSE
 
static BYTE KeyboardId = 0
 
static BYTE KbdDataByteWait = 0
 
static BYTE KbdPS2Port = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file keyboard.c.

Function Documentation

◆ KeyboardCommand()

static VOID WINAPI KeyboardCommand ( LPVOID  Param,
BYTE  Command 
)
static

Definition at line 29 of file keyboard.c.

30{
31 /* Check if we were waiting for a data byte */
33 {
35
36 switch (KbdDataByteWait)
37 {
38 /* Set/Reset Mode Indicators */
39 case 0xED:
40 {
41 // Ignore setting the keyboard LEDs
42 break;
43 }
44
45 /* PS/2 Select/Read Alternate Scan Code Sets */
46 case 0xF0:
47 /* Set Typematic Rate/Delay */
48 case 0xF3:
49 {
50 // FIXME: UNIMPLEMENTED; just return ACKnowledge.
51 // This unblocks some programs that want to initialize
52 // the keyboard by sending keyboard commands and then
53 // performing polling on the port until "valid" data
54 // comes out.
55 DPRINT1("KeyboardCommand(0x%02X) NOT IMPLEMENTED\n", KbdDataByteWait);
56 break;
57 }
58
59 default:
60 {
61 /* Shouldn't happen */
63 }
64 }
65
67 return;
68 }
69
70 switch (Command)
71 {
72 /* Set/Reset Mode Indicators */
73 case 0xED:
74 /* PS/2 Select/Read Alternate Scan Code Sets */
75 case 0xF0:
76 /* Set Typematic Rate/Delay */
77 case 0xF3:
78 {
81 break;
82 }
83
84 /* Echo test command */
85 case 0xEE:
86 {
88 break;
89 }
90
91 /* Get Keyboard ID */
92 case 0xF2:
93 {
96 break;
97 }
98
99 /* Enable Reporting */
100 case 0xF4:
101 {
104 break;
105 }
106
107 /* Disable Reporting */
108 case 0xF5:
109 {
112 break;
113 }
114
115 /* Set Defaults */
116 case 0xF6:
117 {
118 // So far, nothing to reset
120 break;
121 }
122
123 /* PS/2 Typematic & Make/Break key modes */
124 case 0xF7: case 0xF8: case 0xF9:
125 case 0xFA: case 0xFB: case 0xFC: case 0xFD:
126 {
127 /*
128 * Unsupported on PC-AT, they are just ignored
129 * and acknowledged as discussed in:
130 * http://stanislavs.org/helppc/keyboard_commands.html
131 */
133 }
134
135 /* Resend */
136 case 0xFE:
137 {
140 break;
141 }
142
143 /* Reset */
144 case 0xFF:
145 {
146 /* Send ACKnowledge */
148
149 // So far, nothing to reset
150
151 /* Send the Basic Assurance Test success code and the device ID */
154 break;
155 }
156
157 /* Unknown command */
158 default:
159 {
161 }
162 }
163}
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data)
Definition: ps2.c:486
Definition: shell.h:41
static BYTE KeyboardId
Definition: keyboard.c:22
static BOOLEAN KeyboardReporting
Definition: keyboard.c:21
static BYTE KbdPS2Port
Definition: keyboard.c:25
static BYTE KbdDataByteWait
Definition: keyboard.c:23
#define KEYBOARD_ACK
Definition: keyboard.h:16
#define KEYBOARD_ERROR
Definition: keyboard.h:17
#define KEYBOARD_BAT_SUCCESS
Definition: keyboard.h:15

Referenced by KeyboardInit().

◆ KeyboardEventHandler()

VOID KeyboardEventHandler ( PKEY_EVENT_RECORD  KeyEvent)

Definition at line 167 of file keyboard.c.

168{
169 WORD i;
170 BYTE ScanCode = (BYTE)KeyEvent->wVirtualScanCode;
171
172 /* Check if we're not reporting */
173 if (!KeyboardReporting) return;
174
175 /* If this is a key release, set the highest bit in the scan code */
176 if (!KeyEvent->bKeyDown) ScanCode |= 0x80;
177
178 /* Push the scan code into the PS/2 queue */
179 for (i = 0; i < KeyEvent->wRepeatCount; i++)
180 {
183 }
184
185 DPRINT("Press 0x%X\n", ScanCode);
186}
UINT ScanCode
Definition: VirtualKey.c:24
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
if(dx< 0)
Definition: linetemp.h:194
#define DPRINT
Definition: sndvol32.h:73
WORD wVirtualScanCode
Definition: wincon.h:243
DWORD dwControlKeyState
Definition: wincon.h:248
WORD wRepeatCount
Definition: wincon.h:241
#define ENHANCED_KEY
Definition: wincon.h:145
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ConsoleEventThread().

◆ KeyboardInit()

BOOLEAN KeyboardInit ( BYTE  PS2Connector)

Definition at line 188 of file keyboard.c.

189{
190 /* Finish to plug the keyboard to the specified PS/2 port */
191 KbdPS2Port = PS2Connector;
193 return TRUE;
194}
#define NULL
Definition: types.h:112
VOID PS2SetDeviceCmdProc(BYTE PS2Port, LPVOID Param, PS2_DEVICE_CMDPROC DeviceCommand)
Definition: ps2.c:478
static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
Definition: keyboard.c:29

Referenced by EmulatorInitialize().

Variable Documentation

◆ KbdDataByteWait

BYTE KbdDataByteWait = 0
static

Definition at line 23 of file keyboard.c.

Referenced by KeyboardCommand().

◆ KbdPS2Port

BYTE KbdPS2Port = 0
static

Definition at line 25 of file keyboard.c.

Referenced by KeyboardCommand(), KeyboardEventHandler(), and KeyboardInit().

◆ KeyboardId

BYTE KeyboardId = 0
static

Definition at line 22 of file keyboard.c.

Referenced by KeyboardCommand().

◆ KeyboardReporting

BOOLEAN KeyboardReporting = FALSE
static

Definition at line 21 of file keyboard.c.

Referenced by KeyboardCommand(), and KeyboardEventHandler().