ReactOS 0.4.15-dev-7918-g2a2556c
registry.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS i8042 (ps/2 keyboard-mouse controller) driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/input/i8042prt/i8042prt.c
5 * PURPOSE: Reading the registry
6 * PROGRAMMERS: Copyright Victor Kirhenshtein (sauros@iname.com)
7 Copyright Jason Filby (jasonfilby@yahoo.com)
8 Copyright Martijn Vernooij (o112w8r02@sneakemail.com)
9 Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
10 */
11
12/* INCLUDES ******************************************************************/
13
14#include "i8042prt.h"
15
16#include <debug.h>
17
18/* FUNCTIONS *****************************************************************/
19
24{
27
28 ULONG DefaultKeyboardDataQueueSize = 0x64;
29 PCWSTR DefaultKeyboardDeviceBaseName = L"KeyboardPort";
30 ULONG DefaultMouseDataQueueSize = 0x64;
31 ULONG DefaultMouseResolution = 3;
32 ULONG DefaultMouseSynchIn100ns = 20000000;
33 ULONG DefaultNumberOfButtons = 2;
34 PCWSTR DefaultPointerDeviceBaseName = L"PointerPort";
35 ULONG DefaultPollStatusIterations = 1;
36 ULONG DefaultOverrideKeyboardType = 4;
37 ULONG DefaultOverrideKeyboardSubtype = 0;
38 ULONG DefaultPollingIterations = 12000;
39 ULONG DefaultPollingIterationsMaximum = 12000;
40 ULONG DefaultResendIterations = 0x3;
41 ULONG DefaultSampleRate = 60;
42 ULONG DefaultCrashOnCtrlScroll;
43
44 /* Default value for CrashOnCtrlScroll depends if we're
45 * running a debug build or a normal build.
46 */
47#if DBG
48 DefaultCrashOnCtrlScroll = 1;
49#else
50 DefaultCrashOnCtrlScroll = 0;
51#endif
52
54
56 Parameters[0].Name = L"Parameters";
57
59 Parameters[1].Name = L"KeyboardDataQueueSize";
60 Parameters[1].EntryContext = &Settings->KeyboardDataQueueSize;
61 Parameters[1].DefaultType = REG_DWORD;
62 Parameters[1].DefaultData = &DefaultKeyboardDataQueueSize;
63 Parameters[1].DefaultLength = sizeof(ULONG);
64
66 Parameters[2].Name = L"KeyboardDeviceBaseName";
67 Parameters[2].EntryContext = &Settings->KeyboardDeviceBaseName;
68 Parameters[2].DefaultType = REG_SZ;
69 Parameters[2].DefaultData = (PVOID)DefaultKeyboardDeviceBaseName;
70 Parameters[2].DefaultLength = 0;
71
73 Parameters[3].Name = L"MouseDataQueueSize";
74 Parameters[3].EntryContext = &Settings->MouseDataQueueSize;
75 Parameters[3].DefaultType = REG_DWORD;
76 Parameters[3].DefaultData = &DefaultMouseDataQueueSize;
77 Parameters[3].DefaultLength = sizeof(ULONG);
78
80 Parameters[4].Name = L"MouseResolution";
81 Parameters[4].EntryContext = &Settings->MouseResolution;
82 Parameters[4].DefaultType = REG_DWORD;
83 Parameters[4].DefaultData = &DefaultMouseResolution;
84 Parameters[4].DefaultLength = sizeof(ULONG);
85
87 Parameters[5].Name = L"MouseSynchIn100ns";
88 Parameters[5].EntryContext = &Settings->MouseSynchIn100ns;
89 Parameters[5].DefaultType = REG_DWORD;
90 Parameters[5].DefaultData = &DefaultMouseSynchIn100ns;
91 Parameters[5].DefaultLength = sizeof(ULONG);
92
94 Parameters[6].Name = L"NumberOfButtons";
95 Parameters[6].EntryContext = &Settings->NumberOfButtons;
96 Parameters[6].DefaultType = REG_DWORD;
97 Parameters[6].DefaultData = &DefaultNumberOfButtons;
98 Parameters[6].DefaultLength = sizeof(ULONG);
99
101 Parameters[7].Name = L"PointerDeviceBaseName";
102 Parameters[7].EntryContext = &Settings->PointerDeviceBaseName;
103 Parameters[7].DefaultType = REG_SZ;
104 Parameters[7].DefaultData = (PVOID)DefaultPointerDeviceBaseName;
105 Parameters[7].DefaultLength = 0;
106
108 Parameters[8].Name = L"PollStatusIterations";
109 Parameters[8].EntryContext = &Settings->PollStatusIterations;
110 Parameters[8].DefaultType = REG_DWORD;
111 Parameters[8].DefaultData = &DefaultPollStatusIterations;
112 Parameters[8].DefaultLength = sizeof(ULONG);
113
115 Parameters[9].Name = L"OverrideKeyboardType";
116 Parameters[9].EntryContext = &Settings->OverrideKeyboardType;
117 Parameters[9].DefaultType = REG_DWORD;
118 Parameters[9].DefaultData = &DefaultOverrideKeyboardType;
119 Parameters[9].DefaultLength = sizeof(ULONG);
120
122 Parameters[10].Name = L"OverrideKeyboardSubtype";
123 Parameters[10].EntryContext = &Settings->OverrideKeyboardSubtype;
124 Parameters[10].DefaultType = REG_DWORD;
125 Parameters[10].DefaultData = &DefaultOverrideKeyboardSubtype;
126 Parameters[10].DefaultLength = sizeof(ULONG);
127
129 Parameters[11].Name = L"PollingIterations";
130 Parameters[11].EntryContext = &Settings->PollingIterations;
131 Parameters[11].DefaultType = REG_DWORD;
132 Parameters[11].DefaultData = &DefaultPollingIterations;
133 Parameters[11].DefaultLength = sizeof(ULONG);
134
136 Parameters[12].Name = L"PollingIterationsMaximum";
137 Parameters[12].EntryContext = &Settings->PollingIterationsMaximum;
138 Parameters[12].DefaultType = REG_DWORD;
139 Parameters[12].DefaultData = &DefaultPollingIterationsMaximum;
140 Parameters[12].DefaultLength = sizeof(ULONG);
141
143 Parameters[13].Name = L"ResendIterations";
144 Parameters[13].EntryContext = &Settings->ResendIterations;
145 Parameters[13].DefaultType = REG_DWORD;
146 Parameters[13].DefaultData = &DefaultResendIterations;
147 Parameters[13].DefaultLength = sizeof(ULONG);
148
150 Parameters[14].Name = L"SampleRate";
151 Parameters[14].EntryContext = &Settings->SampleRate;
152 Parameters[14].DefaultType = REG_DWORD;
153 Parameters[14].DefaultData = &DefaultSampleRate;
154 Parameters[14].DefaultLength = sizeof(ULONG);
155
157 Parameters[15].Name = L"CrashOnCtrlScroll";
158 Parameters[15].EntryContext = &Settings->CrashOnCtrlScroll;
159 Parameters[15].DefaultType = REG_DWORD;
160 Parameters[15].DefaultData = &DefaultCrashOnCtrlScroll;
161 Parameters[15].DefaultLength = sizeof(ULONG);
162
165 RegistryPath->Buffer,
167 NULL,
168 NULL);
169
170 if (NT_SUCCESS(Status))
171 {
172 /* Check values */
173 if (Settings->KeyboardDataQueueSize < 1)
174 Settings->KeyboardDataQueueSize = DefaultKeyboardDataQueueSize;
175 if (Settings->MouseDataQueueSize < 1)
176 Settings->MouseDataQueueSize = DefaultMouseDataQueueSize;
177 if (Settings->NumberOfButtons < 1)
178 Settings->NumberOfButtons = DefaultNumberOfButtons;
179 if (Settings->PollingIterations < 0x400)
180 Settings->PollingIterations = DefaultPollingIterations;
181 if (Settings->PollingIterationsMaximum < 0x400)
182 Settings->PollingIterationsMaximum = DefaultPollingIterationsMaximum;
183 if (Settings->ResendIterations < 1)
184 Settings->ResendIterations = DefaultResendIterations;
185 }
187 {
188 /* Registry path doesn't exist. Set defaults */
189 Settings->KeyboardDataQueueSize = DefaultKeyboardDataQueueSize;
190 Settings->MouseDataQueueSize = DefaultMouseDataQueueSize;
191 Settings->MouseResolution = DefaultMouseResolution;
192 Settings->MouseSynchIn100ns = DefaultMouseSynchIn100ns;
193 Settings->NumberOfButtons = DefaultNumberOfButtons;
194 Settings->PollStatusIterations = DefaultPollStatusIterations;
195 Settings->OverrideKeyboardType = DefaultOverrideKeyboardType;
196 Settings->OverrideKeyboardSubtype = DefaultOverrideKeyboardSubtype;
197 Settings->PollingIterations = DefaultPollingIterations;
198 Settings->PollingIterationsMaximum = DefaultPollingIterationsMaximum;
199 Settings->ResendIterations = DefaultResendIterations;
200 Settings->SampleRate = DefaultSampleRate;
201 Settings->CrashOnCtrlScroll = DefaultCrashOnCtrlScroll;
202 if (!RtlCreateUnicodeString(&Settings->KeyboardDeviceBaseName, DefaultKeyboardDeviceBaseName)
203 || !RtlCreateUnicodeString(&Settings->PointerDeviceBaseName, DefaultPointerDeviceBaseName))
204 {
205 WARN_(I8042PRT, "RtlCreateUnicodeString() failed\n");
207 }
208 else
209 {
211 }
212 }
213
214 if (NT_SUCCESS(Status))
215 {
216 INFO_(I8042PRT, "KeyboardDataQueueSize : 0x%lx\n", Settings->KeyboardDataQueueSize);
217 INFO_(I8042PRT, "KeyboardDeviceBaseName : %wZ\n", &Settings->KeyboardDeviceBaseName);
218 INFO_(I8042PRT, "MouseDataQueueSize : 0x%lx\n", Settings->MouseDataQueueSize);
219 INFO_(I8042PRT, "MouseResolution : 0x%lx\n", Settings->MouseResolution);
220 INFO_(I8042PRT, "MouseSynchIn100ns : %lu\n", Settings->MouseSynchIn100ns);
221 INFO_(I8042PRT, "NumberOfButtons : 0x%lx\n", Settings->NumberOfButtons);
222 INFO_(I8042PRT, "PointerDeviceBaseName : %wZ\n", &Settings->PointerDeviceBaseName);
223 INFO_(I8042PRT, "PollStatusIterations : 0x%lx\n", Settings->PollStatusIterations);
224 INFO_(I8042PRT, "OverrideKeyboardType : 0x%lx\n", Settings->OverrideKeyboardType);
225 INFO_(I8042PRT, "OverrideKeyboardSubtype : 0x%lx\n", Settings->OverrideKeyboardSubtype);
226 INFO_(I8042PRT, "PollingIterations : 0x%lx\n", Settings->PollingIterations);
227 INFO_(I8042PRT, "PollingIterationsMaximum : %lu\n", Settings->PollingIterationsMaximum);
228 INFO_(I8042PRT, "ResendIterations : 0x%lx\n", Settings->ResendIterations);
229 INFO_(I8042PRT, "SampleRate : %lu\n", Settings->SampleRate);
230 }
231
232 return Status;
233}
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS ReadRegistryEntries(IN PUNICODE_STRING RegistryPath, OUT PI8042_SETTINGS Settings)
Definition: registry.c:21
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define REG_SZ
Definition: layer.c:22
#define RTL_QUERY_REGISTRY_SUBKEY
Definition: nt_native.h:125
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define RTL_REGISTRY_OPTIONAL
Definition: nt_native.h:169
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
#define INFO_(ch,...)
Definition: debug.h:159
#define WARN_(ch,...)
Definition: debug.h:157
#define STATUS_SUCCESS
Definition: shellext.h:65
const uint16_t * PCWSTR
Definition: typedefs.h:57
void * PVOID
Definition: typedefs.h:50
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869