|
1 | 1 | //#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 |
3 | 3 | //#define FPSLIMIT 4000 //comment out for uncapped FPS
|
4 | 4 |
|
5 | 5 | //set these for different viewport resolution, for example
|
@@ -75,11 +75,17 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
75 | 75 | //if (!raw_buf) { stop = TRUE; return false; }
|
76 | 76 |
|
77 | 77 | GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_buf, &cb_size, sizeofRAWINPUTHEADER);
|
78 |
| -#ifndef MODEZERO |
| 78 | + |
79 | 79 | if (raw_buf->header.dwType == RIM_TYPEMOUSE &&
|
80 | 80 | (raw_buf->data.mouse.usButtonFlags == RI_MOUSE_LEFT_BUTTON_DOWN ||
|
81 | 81 | 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 |
83 | 89 | if (state == 0) {
|
84 | 90 | system("CLS"); //clear console
|
85 | 91 | state = 1;
|
@@ -119,8 +125,9 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
119 | 125 | std::cout << " successful clicks: " << clickAmount << "\n";
|
120 | 126 | std::cout << " early clicks: " << errors << "\n";
|
121 | 127 | }
|
122 |
| - } |
123 | 128 | #endif
|
| 129 | + } |
| 130 | + |
124 | 131 | #ifndef MODEZERO
|
125 | 132 | if (raw_buf->header.dwType == RIM_TYPEKEYBOARD) {
|
126 | 133 | #endif
|
@@ -252,18 +259,56 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
252 | 259 | Keyboard.hwndTarget = hWnd;
|
253 | 260 | if (!RegisterRawInputDevices(&Keyboard, 1, sizeof(RAWINPUTDEVICE))) return -1;
|
254 | 261 |
|
255 |
| -#ifndef MODEZERO |
| 262 | +//#ifndef MODEZERO |
256 | 263 | RAWINPUTDEVICE Mouse;
|
257 | 264 | Mouse.usUsagePage = 0x01;
|
258 | 265 | Mouse.usUsage = 0x02; //mouse
|
259 | 266 | Mouse.dwFlags = RIDEV_NOLEGACY;
|
260 | 267 | Mouse.hwndTarget = hWnd;
|
261 | 268 | if (!RegisterRawInputDevices(&Mouse, 1, sizeof(RAWINPUTDEVICE))) return -1;
|
262 |
| -#endif |
| 269 | +//#endif |
263 | 270 |
|
264 | 271 | ShowCursor(FALSE);
|
265 | 272 | SetCursor(NULL);
|
266 | 273 | 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 |
267 | 312 |
|
268 | 313 | #ifdef USETHREADS
|
269 | 314 | std::thread renderThread; //declare a thread without launching it
|
|
0 commit comments