Browse Source

Protect Win32 GDISP driver from some strange config file configurations

inmarket 2 years ago
parent
commit
0d1741a52e
1 changed files with 19 additions and 19 deletions
  1. 19 19
      drivers/multiple/Win32/gdisp_lld_Win32.c

+ 19 - 19
drivers/multiple/Win32/gdisp_lld_Win32.c

@@ -80,7 +80,7 @@
80 80
 	#define GDISP_FLG_WRAPPED			(GDISP_FLG_DRIVER<<4)
81 81
 #endif
82 82
 
83
-#if GINPUT_NEED_TOGGLE
83
+#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
84 84
 	/* Include toggle support code */
85 85
 	#include "../../../src/ginput/ginput_driver_toggle.h"
86 86
 
@@ -88,7 +88,7 @@
88 88
 	static GDisplay *toggleWindow;
89 89
 #endif
90 90
 
91
-#if GINPUT_NEED_MOUSE
91
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
92 92
 	// Include mouse support code
93 93
 	#define GMOUSE_DRIVER_VMT		GMOUSEVMT_Win32
94 94
 	#include "../../../src/ginput/ginput_driver_mouse.h"
@@ -130,7 +130,7 @@
130 130
 	}};
131 131
 #endif
132 132
 
133
-#if GINPUT_NEED_KEYBOARD
133
+#if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
134 134
 	#define GKEYBOARD_DRIVER_VMT		GKEYBOARDVMT_Win32
135 135
 	#include "../../../src/ginput/ginput_driver_keyboard.h"
136 136
 
@@ -422,7 +422,7 @@ static HWND				hWndParent = 0;
422 422
 /* Driver local routines    .                                                */
423 423
 /*===========================================================================*/
424 424
 
425
-#if GINPUT_NEED_TOGGLE
425
+#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
426 426
 	#define WIN32_BUTTON_AREA		16
427 427
 #else
428 428
 	#define WIN32_BUTTON_AREA		0
@@ -435,14 +435,14 @@ typedef struct winPriv {
435 435
 	HDC				dcBuffer;
436 436
 	HBITMAP			dcBitmap;
437 437
 	HBITMAP 		dcOldBitmap;
438
-	#if GINPUT_NEED_MOUSE
438
+	#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
439 439
 		coord_t		mousex, mousey;
440 440
 		uint16_t	mousebuttons;
441 441
 		GMouse		*mouse;
442 442
 		bool_t		mouseenabled;
443 443
 		void (*capfn)(HWND hWnd, GDisplay *g, uint16_t buttons, coord_t x, coord_t y);
444 444
 	#endif
445
-	#if GINPUT_NEED_TOGGLE
445
+	#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
446 446
 		uint8_t		toggles;
447 447
 	#endif
448 448
 	#if GDISP_HARDWARE_STREAM_WRITE || GDISP_HARDWARE_STREAM_READ
@@ -455,7 +455,7 @@ void gfxEmulatorSetParentWindow(HWND hwnd) {
455 455
 	hWndParent = hwnd;
456 456
 }
457 457
 
458
-#if GINPUT_NEED_MOUSE
458
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
459 459
 	void gfxEmulatorMouseInject(GDisplay *g, uint16_t buttons, coord_t x, coord_t y) {
460 460
 		winPriv *		priv;
461 461
 		
@@ -480,10 +480,10 @@ static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
480 480
 	PAINTSTRUCT		ps;
481 481
 	GDisplay *		g;
482 482
 	winPriv *		priv;
483
-	#if GINPUT_NEED_MOUSE
483
+	#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
484 484
 		uint16_t	btns;
485 485
 	#endif
486
-	#if GINPUT_NEED_TOGGLE
486
+	#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
487 487
 		HBRUSH		hbrOn, hbrOff;
488 488
 		HPEN		pen;
489 489
 		RECT		rect;
@@ -512,7 +512,7 @@ static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
512 512
 		g->flags |= GDISP_FLG_READY;
513 513
 		break;
514 514
 
515
-	#if GINPUT_NEED_MOUSE || GINPUT_NEED_TOGGLE
515
+	#if GFX_USE_GINPUT && (GINPUT_NEED_MOUSE || GINPUT_NEED_TOGGLE)
516 516
 		case WM_LBUTTONDOWN:
517 517
 			// Get our GDisplay structure
518 518
 			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
@@ -579,7 +579,7 @@ static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
579 579
 			break;
580 580
 	#endif
581 581
 
582
-	#if GINPUT_NEED_MOUSE
582
+	#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
583 583
 		case WM_MBUTTONDOWN:
584 584
 			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
585 585
 			priv = (winPriv *)g->priv;
@@ -636,7 +636,7 @@ static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
636 636
 			break;
637 637
 	#endif
638 638
 
639
-	#if GINPUT_NEED_KEYBOARD
639
+	#if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
640 640
 		case WM_SYSKEYDOWN:
641 641
 		case WM_SYSKEYUP:
642 642
 		case WM_KEYDOWN:
@@ -694,7 +694,7 @@ static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
694 694
 			priv->dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
695 695
 
696 696
 		// Paint the toggle area
697
-		#if GINPUT_NEED_TOGGLE
697
+		#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
698 698
 			if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
699 699
 				pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
700 700
 				hbrOn = CreateSolidBrush(RGB(0, 0, 255));
@@ -791,7 +791,7 @@ static DWORD WINAPI WindowThread(void *param) {
791 791
 				// Set the window rectangle
792 792
 				rect.top = 0; rect.bottom = g->g.Height;
793 793
 				rect.left = 0; rect.right = g->g.Width;
794
-				#if GINPUT_NEED_TOGGLE
794
+				#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
795 795
 					if ((g->flags & GDISP_FLG_HASTOGGLE))
796 796
 						rect.bottom += WIN32_BUTTON_AREA;
797 797
 				#endif
@@ -851,7 +851,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
851 851
 	g->g.Height = GDISP_SCREEN_HEIGHT;
852 852
 
853 853
 	// Turn on toggles for the first GINPUT_TOGGLE_CONFIG_ENTRIES windows
854
-	#if GINPUT_NEED_TOGGLE
854
+	#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
855 855
 		if (g->controllerdisplay < GINPUT_TOGGLE_CONFIG_ENTRIES) {
856 856
 			g->flags |= GDISP_FLG_HASTOGGLE;
857 857
 			toggleWindow = g;
@@ -877,7 +877,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
877 877
 		Sleep(1);
878 878
 
879 879
 	// Create the associated mouse
880
-	#if GINPUT_NEED_MOUSE
880
+	#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
881 881
 		priv->mouseenabled = hWndParent ? FALSE : TRUE;
882 882
 		priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT const *)GMOUSE_DRIVER_VMT, g);
883 883
 	#endif
@@ -1544,7 +1544,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
1544 1544
 	}
1545 1545
 #endif
1546 1546
 
1547
-#if GINPUT_NEED_MOUSE
1547
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
1548 1548
 	static bool_t Win32MouseInit(GMouse *m, unsigned driverinstance) {
1549 1549
 		(void)	m;
1550 1550
 		(void)	driverinstance;
@@ -1593,7 +1593,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
1593 1593
 	}
1594 1594
 #endif /* GINPUT_NEED_MOUSE */
1595 1595
 
1596
-#if GINPUT_NEED_KEYBOARD
1596
+#if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
1597 1597
 	static bool_t Win32KeyboardInit(GKeyboard *k, unsigned driverinstance) {
1598 1598
 		(void)	driverinstance;
1599 1599
 
@@ -1621,7 +1621,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
1621 1621
 	}
1622 1622
 #endif
1623 1623
 
1624
-#if GINPUT_NEED_TOGGLE
1624
+#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
1625 1625
 	#if GINPUT_TOGGLE_CONFIG_ENTRIES > 1
1626 1626
 		#error "GDISP Win32: GINPUT_TOGGLE_CONFIG_ENTRIES must be 1 until Toggles can use GDriver"
1627 1627
 	#endif