[PATCH 11/20] Adjust joystick code for the SDL2 scancodes

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


---
 src/jaguar/joystick.c | 77 +++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 39 deletions(-)

diff --git a/src/jaguar/joystick.c b/src/jaguar/joystick.c
index 935a9891..ee9abbda 100644
--- a/src/jaguar/joystick.c
+++ b/src/jaguar/joystick.c
@@ -58,7 +58,7 @@ uint8 joypad_1_buttons[21];
 
 bool keyBuffer[21];
 
-//extern bool finished;
+extern bool bQuitProgram;
 ////extern bool showGUI;
 bool GUIKeyHeld = false;
 extern int start_logging;
@@ -85,24 +85,24 @@ void JoystickInit(void)
 
 void JoystickExec(void)
 {
-//	uint8 * keystate = SDL_GetKeyState(NULL);
+	uint8 * keystate = SDL_GetKeyboardState(NULL);
 
-//	memset(joypad_0_buttons, 0, 21);
-//	memset(joypad_1_buttons, 0, 21);
+	memset(joypad_0_buttons, 0, sizeof(joypad_0_buttons));
+	memset(joypad_1_buttons, 0, sizeof(joypad_1_buttons));
 	gpu_start_log = 0;							// Only log while key down!
 	effect_start = 0;
 	effect_start2 = effect_start3 = effect_start4 = effect_start5 = effect_start6 = 0;
 	blit_start_log = 0;
 	iLeft = iRight = false;
 
-#if 0
-	if ((keystate[SDLK_LALT] || keystate[SDLK_RALT]) & keystate[SDLK_RETURN])
+#if 1
+	if ((keystate[SDL_SCANCODE_LALT] || keystate[SDL_SCANCODE_RALT]) & keystate[SDL_SCANCODE_RETURN])
 		ToggleFullscreen();
 
 	// Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
-//	vjs.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDLK_UP);
+//	vjs.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDL_SCANCODE__UP);
 
-#if 0
+#if 1
 	if (keystate[vjs.p1KeyBindings[0]])
 		joypad_0_buttons[BUTTON_U] = 0x01;
 	if (keystate[vjs.p1KeyBindings[1]])
@@ -199,16 +199,15 @@ void JoystickExec(void)
 #warning "!!! FIX !!! (debounceRunKey)"
 //	extern bool debounceRunKey;
 	bool debounceRunKey;
-    if (keystate[SDLK_ESCAPE])
-    {
+	if (keystate[SDL_SCANCODE_ESCAPE])
+	{
 		if (!debounceRunKey)
-#warning "!!! FIX !!! (finished = true)"
-;//	    	finished = true;
-    }
-    else
+			bQuitProgram = true;
+	}
+	else
 		debounceRunKey = false;
 
-	if (keystate[SDLK_TAB])
+	if (keystate[SDL_SCANCODE_TAB])
 	{
 		if (!GUIKeyHeld)
 #warning "!!! FIX !!! (showGUI = !showGUI, ...)"
@@ -217,37 +216,37 @@ void JoystickExec(void)
 	else
 		GUIKeyHeld = false;
 
-	if (keystate[SDLK_q])
+	if (keystate[SDL_SCANCODE_Q])
 		start_logging = 1;
-	if (keystate[SDLK_w])
+	if (keystate[SDL_SCANCODE_W])
 		GPUResetStats();
-//	if (keystate[SDLK_u])		jaguar_long_write(0xf1c384,jaguar_long_read(0xf1c384)+1);
-	if (keystate[SDLK_d])
+//	if (keystate[SDL_SCANCODE_U])		jaguar_long_write(0xf1c384,jaguar_long_read(0xf1c384)+1);
+	if (keystate[SDL_SCANCODE_E])
 		DumpMainMemory();
-	if (keystate[SDLK_l])
+	if (keystate[SDL_SCANCODE_G])
 		gpu_start_log = 1;
-	if (keystate[SDLK_o])
+	if (keystate[SDL_SCANCODE_O])
 		op_start_log = 1;
-	if (keystate[SDLK_b])
+	if (keystate[SDL_SCANCODE_B])
 		blit_start_log = 1;
 
-	if (keystate[SDLK_1])
+	if (keystate[SDL_SCANCODE_1])
 		effect_start = 1;
-	if (keystate[SDLK_2])
+	if (keystate[SDL_SCANCODE_2])
 		effect_start2 = 1;
-	if (keystate[SDLK_3])
+	if (keystate[SDL_SCANCODE_3])
 		effect_start3 = 1;
-	if (keystate[SDLK_4])
+	if (keystate[SDL_SCANCODE_4])
 		effect_start4 = 1;
-	if (keystate[SDLK_5])
+	if (keystate[SDL_SCANCODE_5])
 		effect_start5 = 1;
-	if (keystate[SDLK_6])
+	if (keystate[SDL_SCANCODE_6])
 		effect_start6 = 1;
 
-	if (keystate[SDLK_i])
+	if (keystate[SDL_SCANCODE_I])
 		interactiveMode = true;
 
-	if (keystate[SDLK_8] && interactiveMode)
+	if (keystate[SDL_SCANCODE_8] && interactiveMode)
 	{
 		if (!keyHeld1)
 			objectPtr--, keyHeld1 = true;
@@ -255,7 +254,7 @@ void JoystickExec(void)
 	else
 		keyHeld1 = false;
 
-	if (keystate[SDLK_0] && interactiveMode)
+	if (keystate[SDL_SCANCODE_0] && interactiveMode)
 	{
 		if (!keyHeld2)
 			objectPtr++, keyHeld2 = true;
@@ -263,7 +262,7 @@ void JoystickExec(void)
 	else
 		keyHeld2 = false;
 
-	if (keystate[SDLK_9] && interactiveMode)
+	if (keystate[SDL_SCANCODE_9] && interactiveMode)
 	{
 		if (!keyHeld3)
 			iToggle = !iToggle, keyHeld3 = true;
@@ -271,20 +270,20 @@ void JoystickExec(void)
 	else
 		keyHeld3 = false;
 
-	if (keystate[SDLK_e])
+	if (keystate[SDL_SCANCODE_E])
 		startMemLog = true;
-	if (keystate[SDLK_r])
+	if (keystate[SDL_SCANCODE_R])
 		WriteLog("\n--------> MARK!\n\n");
-	if (keystate[SDLK_t])
+	if (keystate[SDL_SCANCODE_T])
 		doDSPDis = true;
-	if (keystate[SDLK_y])
-		doGPUDis = true;
+//	if (keystate[SDL_SCANCODE_Y])
+//		doGPUDis = true;
 
 	// BLITTER single step
-	if (keystate[SDLK_F5])
+	if (keystate[SDL_SCANCODE_F5])
 		blitterSingleStep = true;
 
-	if (keystate[SDLK_F6])
+	if (keystate[SDL_SCANCODE_F6])
 	{
 		if (!bssHeld)
 		{
-- 
2.48.1


--MP_/VkVZp1l8MIESxWVe2vPSxV2
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0012-Fix-RGB-calculation-for-the-setting-that-we-use-in-H.patch



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/