Skip to content

Commit 21de95c

Browse files
author
asd
committed
added mouse functionality to black / white mode
1 parent c57a775 commit 21de95c

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

DirectX 9.cpp

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//#define USETHREADS //spawn a second renderer thread and use busy message reading for input
2-
//#define MODEZERO //comment out for human benchmark mode, uncomment for black and white
2+
#define MODEZERO //comment out for human benchmark mode, uncomment for black and white
33
//#define FPSLIMIT 4000 //comment out for uncapped FPS
44

55
//set these for different viewport resolution, for example
@@ -75,11 +75,17 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
7575
//if (!raw_buf) { stop = TRUE; return false; }
7676

7777
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_buf, &cb_size, sizeofRAWINPUTHEADER);
78-
#ifndef MODEZERO
78+
7979
if (raw_buf->header.dwType == RIM_TYPEMOUSE &&
8080
(raw_buf->data.mouse.usButtonFlags == RI_MOUSE_LEFT_BUTTON_DOWN ||
8181
raw_buf->data.mouse.usButtonFlags == RI_MOUSE_RIGHT_BUTTON_DOWN)) { //only triggers once per button press
82-
82+
#ifdef MODEZERO
83+
if (currentColor == white)
84+
currentColor = black;
85+
else
86+
currentColor = white;
87+
#endif
88+
#ifndef MODEZERO
8389
if (state == 0) {
8490
system("CLS"); //clear console
8591
state = 1;
@@ -119,8 +125,9 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
119125
std::cout << " successful clicks: " << clickAmount << "\n";
120126
std::cout << " early clicks: " << errors << "\n";
121127
}
122-
}
123128
#endif
129+
}
130+
124131
#ifndef MODEZERO
125132
if (raw_buf->header.dwType == RIM_TYPEKEYBOARD) {
126133
#endif
@@ -252,18 +259,56 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
252259
Keyboard.hwndTarget = hWnd;
253260
if (!RegisterRawInputDevices(&Keyboard, 1, sizeof(RAWINPUTDEVICE))) return -1;
254261

255-
#ifndef MODEZERO
262+
//#ifndef MODEZERO
256263
RAWINPUTDEVICE Mouse;
257264
Mouse.usUsagePage = 0x01;
258265
Mouse.usUsage = 0x02; //mouse
259266
Mouse.dwFlags = RIDEV_NOLEGACY;
260267
Mouse.hwndTarget = hWnd;
261268
if (!RegisterRawInputDevices(&Mouse, 1, sizeof(RAWINPUTDEVICE))) return -1;
262-
#endif
269+
//#endif
263270

264271
ShowCursor(FALSE);
265272
SetCursor(NULL);
266273
d3ddev->ShowCursor(FALSE);
274+
275+
276+
//using System;
277+
//using System.Diagnostics;
278+
//using System.Threading;
279+
//#include <sched.h> // sched_setaffinity
280+
//using System.Windows.Forms;
281+
282+
HANDLE process = GetCurrentProcess();
283+
284+
DWORD_PTR processAffinityMask;
285+
DWORD_PTR systemAffinityMask;
286+
287+
if (!GetProcessAffinityMask(process, &processAffinityMask, &systemAffinityMask))
288+
return -1;
289+
290+
int core = 4; /* set this to the core you want your process to run on */
291+
DWORD_PTR mask = 0x1;
292+
for (int bit = 0, currentCore = 1; bit < 64; bit++)
293+
{
294+
if (mask & processAffinityMask)
295+
{
296+
if (currentCore != core)
297+
{
298+
processAffinityMask &= ~mask;
299+
}
300+
currentCore++;
301+
}
302+
mask = mask << 1;
303+
}
304+
305+
//BOOL success = SetProcessAffinityMask(process, processAffinityMask);
306+
SetPriorityClass(process, REALTIME_PRIORITY_CLASS);
307+
//SetPriorityClass(process, HIGH_PRIORITY_CLASS);
308+
309+
//Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2); // Use only the second core
310+
//Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; // Set highest process priority
311+
//Thread.CurrentThread.Priority = ThreadPriority.Highest; // Set highest thread priority
267312

268313
#ifdef USETHREADS
269314
std::thread renderThread; //declare a thread without launching it

0 commit comments

Comments
 (0)