[1046] | 1 | /*
|
---|
| 2 | * ntdd8042.h
|
---|
| 3 | *
|
---|
| 4 | * i8042 IOCTL interface.
|
---|
| 5 | *
|
---|
| 6 | * This file is part of the w32api package.
|
---|
| 7 | *
|
---|
| 8 | * Contributors:
|
---|
| 9 | * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
---|
| 10 | *
|
---|
| 11 | * THIS SOFTWARE IS NOT COPYRIGHTED
|
---|
| 12 | *
|
---|
| 13 | * This source code is offered for use in the public domain. You may
|
---|
| 14 | * use, modify or distribute it freely.
|
---|
| 15 | *
|
---|
| 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.
|
---|
| 20 | *
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | #ifndef __NTDD8042_H
|
---|
| 24 | #define __NTDD8042_H
|
---|
| 25 |
|
---|
| 26 | #if __GNUC__ >=3
|
---|
| 27 | #pragma GCC system_header
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | #include "ntddk.h"
|
---|
| 35 | #include "ntddkbd.h"
|
---|
| 36 | #include "ntddmou.h"
|
---|
| 37 |
|
---|
| 38 | #define IOCTL_INTERNAL_I8042_CONTROLLER_WRITE_BUFFER \
|
---|
| 39 | CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF2, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 40 |
|
---|
| 41 | #define IOCTL_INTERNAL_I8042_HOOK_KEYBOARD \
|
---|
| 42 | CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF0, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 43 |
|
---|
| 44 | #define IOCTL_INTERNAL_I8042_KEYBOARD_START_INFORMATION \
|
---|
| 45 | CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF3, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 46 |
|
---|
| 47 | #define IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER \
|
---|
| 48 | CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0FF1, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 49 |
|
---|
| 50 | #define IOCTL_INTERNAL_I8042_HOOK_MOUSE \
|
---|
| 51 | CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF0, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 52 |
|
---|
| 53 | #define IOCTL_INTERNAL_I8042_MOUSE_START_INFORMATION \
|
---|
| 54 | CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF3, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 55 |
|
---|
| 56 | #define IOCTL_INTERNAL_I8042_MOUSE_WRITE_BUFFER \
|
---|
| 57 | CTL_CODE(FILE_DEVICE_MOUSE, 0x0FF1, METHOD_NEITHER, FILE_ANY_ACCESS)
|
---|
| 58 |
|
---|
| 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)
|
---|
| 65 |
|
---|
| 66 | typedef enum _TRANSMIT_STATE {
|
---|
| 67 | Idle = 0,
|
---|
| 68 | SendingBytes
|
---|
| 69 | } TRANSMIT_STATE;
|
---|
| 70 |
|
---|
| 71 | typedef struct _OUTPUT_PACKET {
|
---|
| 72 | PUCHAR Bytes;
|
---|
| 73 | ULONG CurrentByte;
|
---|
| 74 | ULONG ByteCount;
|
---|
| 75 | TRANSMIT_STATE State;
|
---|
| 76 | } OUTPUT_PACKET, *POUTPUT_PACKET;
|
---|
| 77 |
|
---|
| 78 | typedef enum _KEYBOARD_SCAN_STATE {
|
---|
| 79 | Normal,
|
---|
| 80 | GotE0,
|
---|
| 81 | GotE1
|
---|
| 82 | } KEYBOARD_SCAN_STATE, *PKEYBOARD_SCAN_STATE;
|
---|
| 83 |
|
---|
| 84 | typedef enum _MOUSE_STATE {
|
---|
| 85 | MouseIdle,
|
---|
| 86 | XMovement,
|
---|
| 87 | YMovement,
|
---|
| 88 | ZMovement,
|
---|
| 89 | MouseExpectingACK,
|
---|
| 90 | MouseResetting
|
---|
| 91 | } MOUSE_STATE, *PMOUSE_STATE;
|
---|
| 92 |
|
---|
| 93 | typedef enum _MOUSE_RESET_SUBSTATE {
|
---|
| 94 | ExpectingReset,
|
---|
| 95 | ExpectingResetId,
|
---|
| 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,
|
---|
| 109 | StartPnPIdDetection,
|
---|
| 110 | ExpectingLoopSetSamplingRateACK,
|
---|
| 111 | ExpectingLoopSetSamplingRateValueACK,
|
---|
| 112 | ExpectingPnpIdByte1,
|
---|
| 113 | ExpectingPnpIdByte2,
|
---|
| 114 | ExpectingPnpIdByte3,
|
---|
| 115 | ExpectingPnpIdByte4,
|
---|
| 116 | ExpectingPnpIdByte5,
|
---|
| 117 | ExpectingPnpIdByte6,
|
---|
| 118 | ExpectingPnpIdByte7,
|
---|
| 119 | EnableWheel,
|
---|
| 120 | Enable5Buttons,
|
---|
| 121 | ExpectingGetDeviceId2ACK,
|
---|
| 122 | ExpectingGetDeviceId2Value,
|
---|
| 123 | ExpectingSetSamplingRateACK,
|
---|
| 124 | ExpectingSetSamplingRateValueACK,
|
---|
| 125 | ExpectingEnableACK,
|
---|
| 126 | ExpectingFinalResolutionACK,
|
---|
| 127 | ExpectingFinalResolutionValueACK,
|
---|
| 128 | ExpectingGetDeviceIdDetectACK,
|
---|
| 129 | ExpectingGetDeviceIdDetectValue,
|
---|
| 130 | CustomHookStateMinimum = 100,
|
---|
| 131 | CustomHookStateMaximum = 999,
|
---|
| 132 | I8042ReservedMinimum = 1000
|
---|
| 133 | } MOUSE_RESET_SUBSTATE, *PMOUSE_RESET_SUBSTATE;
|
---|
| 134 |
|
---|
| 135 | typedef struct _INTERNAL_I8042_START_INFORMATION {
|
---|
| 136 | ULONG Size;
|
---|
| 137 | PKINTERRUPT InterruptObject;
|
---|
| 138 | ULONG Reserved[8];
|
---|
| 139 | } INTERNAL_I8042_START_INFORMATION, *PINTERNAL_I8042_START_INFORMATION;
|
---|
| 140 |
|
---|
| 141 | typedef VOID DDKAPI
|
---|
| 142 | (*PI8042_ISR_WRITE_PORT)(
|
---|
| 143 | /*IN*/ PVOID Context,
|
---|
| 144 | /*IN*/ UCHAR Value);
|
---|
| 145 |
|
---|
| 146 | typedef VOID DDKAPI
|
---|
| 147 | (*PI8042_QUEUE_PACKET)(
|
---|
| 148 | /*IN*/ PVOID Context);
|
---|
| 149 |
|
---|
| 150 | typedef NTSTATUS DDKAPI
|
---|
| 151 | (*PI8042_SYNCH_READ_PORT) (
|
---|
| 152 | /*IN*/ PVOID Context,
|
---|
| 153 | /*OUT*/ PUCHAR Value,
|
---|
| 154 | /*IN*/ BOOLEAN WaitForACK);
|
---|
| 155 |
|
---|
| 156 | typedef NTSTATUS DDKAPI
|
---|
| 157 | (*PI8042_SYNCH_WRITE_PORT)(
|
---|
| 158 | /*IN*/ PVOID Context,
|
---|
| 159 | /*IN*/ UCHAR Value,
|
---|
| 160 | /*IN*/ BOOLEAN WaitForACK);
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 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);
|
---|
| 170 |
|
---|
| 171 | typedef BOOLEAN DDKAPI
|
---|
| 172 | (*PI8042_KEYBOARD_ISR)(
|
---|
| 173 | PVOID IsrContext,
|
---|
| 174 | PKEYBOARD_INPUT_DATA CurrentInput,
|
---|
| 175 | POUTPUT_PACKET CurrentOutput,
|
---|
| 176 | UCHAR StatusByte,
|
---|
| 177 | PUCHAR Byte,
|
---|
| 178 | PBOOLEAN ContinueProcessing,
|
---|
| 179 | PKEYBOARD_SCAN_STATE ScanState);
|
---|
| 180 |
|
---|
| 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;
|
---|
| 189 |
|
---|
| 190 | typedef BOOLEAN DDKAPI
|
---|
| 191 | (*PI8042_MOUSE_ISR)(
|
---|
| 192 | PVOID IsrContext,
|
---|
| 193 | PMOUSE_INPUT_DATA CurrentInput,
|
---|
| 194 | POUTPUT_PACKET CurrentOutput,
|
---|
| 195 | UCHAR StatusByte,
|
---|
| 196 | PUCHAR Byte,
|
---|
| 197 | PBOOLEAN ContinueProcessing,
|
---|
| 198 | PMOUSE_STATE MouseState,
|
---|
| 199 | PMOUSE_RESET_SUBSTATE ResetSubState);
|
---|
| 200 |
|
---|
| 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;
|
---|
| 208 |
|
---|
| 209 | #ifdef __cplusplus
|
---|
| 210 | }
|
---|
| 211 | #endif
|
---|
| 212 |
|
---|
| 213 | #endif /* __NTDD8042_H */
|
---|