2727
2828#include " keycapture.h"
2929#include " keyboardproc.h"
30+ #include " mouseproc.h"
3031#include " mouseinput.h"
3132#include " configfile.h"
3233
@@ -42,10 +43,10 @@ extern "C"
4243void InitiallizeEntryContainerListItem (RemapEntryContainerListItem* pKeyItem, RemapEntry* pEntry);
4344
4445// sweet globals
45- HHOOK g_hookKeyboard = NULL , g_hookMouse = NULL ;
46+ HHOOK g_hookKeyboard = nullptr , g_hookMouse = nullptr ;
4647RemapEntryContainerListItem* g_KeyTranslationTable[WIN_KEY_COUNT];
47- RemapEntry* g_KeyTranslationHead = NULL ;
48- void * g_KeyTranslationEnd = NULL ; // pointer indicating the end of the input file data
48+ RemapEntry* g_KeyTranslationHead = nullptr ;
49+ void * g_KeyTranslationEnd = nullptr ; // pointer indicating the end of the input file data
4950
5051/*
5152Performs the load file operation and initiates the keyboard capture process
@@ -77,7 +78,7 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
7778
7879 // The translation table contains linked lists of all the output sets for a given key due to the flag keys (shift/alt/ctrl)
7980 // Example: input 'a' will be in the same list as 'shift+a' 'alt+a' 'ctrl+a' (or any combos like 'alt+shift+a')
80- while (NULL != pEntry)
81+ while (nullptr != pEntry)
8182 {
8283 if (0 == pEntry->outputCount )
8384 {
@@ -91,25 +92,25 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
9192 free (pInputConfigDescription);
9293#endif
9394 // if the entry doesn't exist yet for the given input vkey create a new one with a null next pointer
94- if (NULL == g_KeyTranslationTable[pEntry->inputConfig .virtualKey ])
95+ if (nullptr == g_KeyTranslationTable[pEntry->inputConfig .virtualKey ])
9596 {
9697 g_KeyTranslationTable[pEntry->inputConfig .virtualKey ] = (RemapEntryContainerListItem*)malloc (sizeof (RemapEntryContainerListItem));
9798 InitiallizeEntryContainerListItem (g_KeyTranslationTable[pEntry->inputConfig .virtualKey ], pEntry);
98- g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pNext = NULL ;
99+ g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pNext = nullptr ;
99100 }
100101
101102 // if the entry does exist create a new entry and append it to the existing linked list
102103 else
103104 {
104105 RemapEntryContainerListItem* pKeyItem = g_KeyTranslationTable[pEntry->inputConfig .virtualKey ];
105- while (NULL != pKeyItem->pNext )
106+ while (nullptr != pKeyItem->pNext )
106107 {
107108 pKeyItem = pKeyItem->pNext ;
108109 }
109110 pKeyItem->pNext = (RemapEntryContainerListItem*)malloc (sizeof (RemapEntryContainerListItem));
110111 pKeyItem = pKeyItem->pNext ;
111112 InitiallizeEntryContainerListItem (pKeyItem, pEntry);
112- pKeyItem->pNext = NULL ;
113+ pKeyItem->pNext = nullptr ;
113114 }
114115 // jump to the next entry
115116 pEntry = (RemapEntry*)(&pEntry->outputCount + (sizeof (unsigned int ) + (pEntry->outputCount * sizeof (OutputConfig))));
@@ -130,7 +131,7 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
130131 {
131132 // Note: This fails in VisualStudio if managed debugging is NOT enabled in the project(!)
132133 g_hookKeyboard = SetWindowsHookEx ( WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, NULL );
133- g_hookMouse = SetWindowsHookEx (WH_MOUSE_LL, LowLevelKeyboardProc , hInstance, NULL );
134+ g_hookMouse = SetWindowsHookEx (WH_MOUSE_LL, LowLevelMouseProc , hInstance, NULL );
134135 if (g_hookKeyboard && g_hookMouse)
135136 {
136137 return HOOK_CREATION_SUCCESS;
@@ -155,14 +156,14 @@ void ShutdownInputThreads(bool forceShutdown)
155156 // signal shutdown for all entries with a thread handle
156157 for (int nIdx = 0 ; nIdx < WIN_KEY_COUNT; nIdx++)
157158 {
158- if (NULL != g_KeyTranslationTable[nIdx])
159+ if (nullptr != g_KeyTranslationTable[nIdx])
159160 {
160161 RemapEntryContainerListItem* pListItem = g_KeyTranslationTable[nIdx];
161- RemapEntryContainerListItem* pNextItem = NULL ;
162- while (NULL != pListItem)
162+ RemapEntryContainerListItem* pNextItem = nullptr ;
163+ while (nullptr != pListItem)
163164 {
164165 pNextItem = pListItem->pNext ;
165- if (NULL != pListItem->pEntryContainer ->pEntryState ->threadHandle )
166+ if (nullptr != pListItem->pEntryContainer ->pEntryState ->threadHandle )
166167 {
167168 pListItem->pEntryContainer ->pEntryState ->bShutdown = true ;
168169 }
@@ -177,14 +178,14 @@ void ShutdownInputThreads(bool forceShutdown)
177178 // monitor and terminate threads for all entries with a thread handle
178179 for (int nIdx = 0 ; nIdx < WIN_KEY_COUNT; nIdx++)
179180 {
180- if (NULL != g_KeyTranslationTable[nIdx])
181+ if (nullptr != g_KeyTranslationTable[nIdx])
181182 {
182183 RemapEntryContainerListItem* pListItem = g_KeyTranslationTable[nIdx];
183- RemapEntryContainerListItem* pNextItem = NULL ;
184- while (NULL != pListItem)
184+ RemapEntryContainerListItem* pNextItem = nullptr ;
185+ while (nullptr != pListItem)
185186 {
186187 pNextItem = pListItem->pNext ;
187- if (NULL != pListItem->pEntryContainer ->pEntryState ->threadHandle )
188+ if (nullptr != pListItem->pEntryContainer ->pEntryState ->threadHandle )
188189 {
189190 DWORD dwExitCode = WAIT_TIMEOUT;
190191 for (int shutdownIteration = 0 ; shutdownIteration < THREAD_SHUTDOWN_MAX_ATTEMPTS && dwExitCode != WAIT_OBJECT_0; shutdownIteration++)
@@ -217,31 +218,31 @@ __declspec(dllexport) void ShutdownCapture()
217218 {
218219 LogDebugMessage (" Unhooked keyboard" );
219220 UnhookWindowsHookEx (g_hookKeyboard);
220- g_hookKeyboard = NULL ;
221+ g_hookKeyboard = nullptr ;
221222 }
222223 if (g_hookMouse)
223224 {
224225 LogDebugMessage (" Unhooked mouse" );
225226 UnhookWindowsHookEx (g_hookMouse);
226- g_hookMouse = NULL ;
227+ g_hookMouse = nullptr ;
227228 }
228229
229230 // memory clean up
230- if (NULL != g_KeyTranslationHead)
231+ if (nullptr != g_KeyTranslationHead)
231232 {
232233 LogDebugMessage (" Cleared Memory!" );
233234 free (g_KeyTranslationHead);
234- g_KeyTranslationHead = NULL ;
235+ g_KeyTranslationHead = nullptr ;
235236 }
236237
237238 // clean up "hash" table
238239 for (int nIdx = 0 ; nIdx < WIN_KEY_COUNT; nIdx++)
239240 {
240- if (NULL != g_KeyTranslationTable[nIdx])
241+ if (nullptr != g_KeyTranslationTable[nIdx])
241242 {
242243 RemapEntryContainerListItem* pListItem = g_KeyTranslationTable[nIdx];
243- RemapEntryContainerListItem* pNextItem = NULL ;
244- while (NULL != pListItem)
244+ RemapEntryContainerListItem* pNextItem = nullptr ;
245+ while (nullptr != pListItem)
245246 {
246247 pNextItem = pListItem->pNext ;
247248 free (pListItem->pEntryContainer ->pEntryState );
@@ -250,11 +251,11 @@ __declspec(dllexport) void ShutdownCapture()
250251 free (pListItem);
251252 pListItem = pNextItem;
252253 }
253- g_KeyTranslationTable[nIdx] = NULL ;
254+ g_KeyTranslationTable[nIdx] = nullptr ;
254255 }
255256 }
256257
257- g_KeyTranslationEnd = NULL ;
258+ g_KeyTranslationEnd = nullptr ;
258259
259260 LogDebugMessage (" Capture Shutdown" );
260261}
0 commit comments