4 * i8042 IOCTL interface.
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 #pragma GCC system_header
38 #define IOCTL_INTERNAL_I8042_CONTROLLER_WRITE_BUFFER \
39 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF2, METHOD_NEITHER, FILE_ANY_ACCESS)
41 #define IOCTL_INTERNAL_I8042_HOOK_KEYBOARD \
42 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF0, METHOD_NEITHER, FILE_ANY_ACCESS)
44 #define IOCTL_INTERNAL_I8042_KEYBOARD_START_INFORMATION \
45 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF3, METHOD_NEITHER, FILE_ANY_ACCESS)
47 #define IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER \
48 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF1, METHOD_NEITHER, FILE_ANY_ACCESS)
50 #define IOCTL_INTERNAL_I8042_HOOK_MOUSE \
51 CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF0, METHOD_NEITHER, FILE_ANY_ACCESS)
53 #define IOCTL_INTERNAL_I8042_MOUSE_START_INFORMATION \
54 CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF3, METHOD_NEITHER, FILE_ANY_ACCESS)
56 #define IOCTL_INTERNAL_I8042_MOUSE_WRITE_BUFFER \
57 CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF1, METHOD_NEITHER, FILE_ANY_ACCESS)
59 #define I8042_POWER_SYS_BUTTON 0x0001
60 #define I8042_SLEEP_SYS_BUTTON 0x0002
61 #define I8042_WAKE_SYS_BUTTON 0x0004
62 #define I8042_SYS_BUTTONS (I8042_POWER_SYS_BUTTON | \
63 I8042_SLEEP_SYS_BUTTON | \
64 I8042_WAKE_SYS_BUTTON)
66 typedef enum _TRANSMIT_STATE
{
71 typedef struct _OUTPUT_PACKET
{
76 } OUTPUT_PACKET
, *POUTPUT_PACKET
;
78 typedef enum _KEYBOARD_SCAN_STATE
{
82 } KEYBOARD_SCAN_STATE
, *PKEYBOARD_SCAN_STATE
;
84 typedef enum _MOUSE_STATE
{
91 } MOUSE_STATE
, *PMOUSE_STATE
;
93 typedef enum _MOUSE_RESET_SUBSTATE
{
96 ExpectingGetDeviceIdACK
,
97 ExpectingGetDeviceIdValue
,
98 ExpectingSetResolutionDefaultACK
,
99 ExpectingSetResolutionDefaultValueACK
,
100 ExpectingSetResolutionACK
,
101 ExpectingSetResolutionValueACK
,
102 ExpectingSetScaling1to1ACK
,
103 ExpectingSetScaling1to1ACK2
,
104 ExpectingSetScaling1to1ACK3
,
105 ExpectingReadMouseStatusACK
,
106 ExpectingReadMouseStatusByte1
,
107 ExpectingReadMouseStatusByte2
,
108 ExpectingReadMouseStatusByte3
,
110 ExpectingLoopSetSamplingRateACK
,
111 ExpectingLoopSetSamplingRateValueACK
,
121 ExpectingGetDeviceId2ACK
,
122 ExpectingGetDeviceId2Value
,
123 ExpectingSetSamplingRateACK
,
124 ExpectingSetSamplingRateValueACK
,
126 ExpectingFinalResolutionACK
,
127 ExpectingFinalResolutionValueACK
,
128 ExpectingGetDeviceIdDetectACK
,
129 ExpectingGetDeviceIdDetectValue
,
130 CustomHookStateMinimum
= 100,
131 CustomHookStateMaximum
= 999,
132 I8042ReservedMinimum
= 1000
133 } MOUSE_RESET_SUBSTATE
, *PMOUSE_RESET_SUBSTATE
;
135 typedef struct _INTERNAL_I8042_START_INFORMATION
{
137 PKINTERRUPT InterruptObject
;
139 } INTERNAL_I8042_START_INFORMATION
, *PINTERNAL_I8042_START_INFORMATION
;
142 (*PI8042_ISR_WRITE_PORT
)(
143 /*IN*/ PVOID Context
,
147 (*PI8042_QUEUE_PACKET
)(
148 /*IN*/ PVOID Context
);
150 typedef NTSTATUS DDKAPI
151 (*PI8042_SYNCH_READ_PORT
) (
152 /*IN*/ PVOID Context
,
153 /*OUT*/ PUCHAR Value
,
154 /*IN*/ BOOLEAN WaitForACK
);
156 typedef NTSTATUS DDKAPI
157 (*PI8042_SYNCH_WRITE_PORT
)(
158 /*IN*/ PVOID Context
,
160 /*IN*/ BOOLEAN WaitForACK
);
163 typedef NTSTATUS DDKAPI
164 (*PI8042_KEYBOARD_INITIALIZATION_ROUTINE
)(
165 /*IN*/ PVOID InitializationContext
,
166 /*IN*/ PVOID SynchFuncContext
,
167 /*IN*/ PI8042_SYNCH_READ_PORT ReadPort
,
168 /*IN*/ PI8042_SYNCH_WRITE_PORT WritePort
,
169 /*OUT*/ PBOOLEAN TurnTranslationOn
);
171 typedef BOOLEAN DDKAPI
172 (*PI8042_KEYBOARD_ISR
)(
174 PKEYBOARD_INPUT_DATA CurrentInput
,
175 POUTPUT_PACKET CurrentOutput
,
178 PBOOLEAN ContinueProcessing
,
179 PKEYBOARD_SCAN_STATE ScanState
);
181 typedef struct _INTERNAL_I8042_HOOK_KEYBOARD
{
182 /*OUT*/ PVOID Context
;
183 /*OUT*/ PI8042_KEYBOARD_INITIALIZATION_ROUTINE InitializationRoutine
;
184 /*OUT*/ PI8042_KEYBOARD_ISR IsrRoutine
;
185 /*IN*/ PI8042_ISR_WRITE_PORT IsrWritePort
;
186 /*IN*/ PI8042_QUEUE_PACKET QueueKeyboardPacket
;
187 /*IN*/ PVOID CallContext
;
188 } INTERNAL_I8042_HOOK_KEYBOARD
, *PINTERNAL_I8042_HOOK_KEYBOARD
;
190 typedef BOOLEAN DDKAPI
193 PMOUSE_INPUT_DATA CurrentInput
,
194 POUTPUT_PACKET CurrentOutput
,
197 PBOOLEAN ContinueProcessing
,
198 PMOUSE_STATE MouseState
,
199 PMOUSE_RESET_SUBSTATE ResetSubState
);
201 typedef struct _INTERNAL_I8042_HOOK_MOUSE
{
202 /*OUT*/ PVOID Context
;
203 /*OUT*/ PI8042_MOUSE_ISR IsrRoutine
;
204 /*IN*/ PI8042_ISR_WRITE_PORT IsrWritePort
;
205 /*IN*/ PI8042_QUEUE_PACKET QueueMousePacket
;
206 /*IN*/ PVOID CallContext
;
207 } INTERNAL_I8042_HOOK_MOUSE
, *PINTERNAL_I8042_HOOK_MOUSE
;
213 #endif /* __NTDD8042_H */