#768546 kobodeluxe: [PATCH] Please add this joystick-hat support

#768546#5
Date:
2014-11-08 10:12:18 UTC
From:
To:
Dear Maintainer,
	Kobo Deluxe is a twitch-reaction game, thus we should
take advantage of a joystick hat if one is present. This patch
should do the trick, applied to KoboDeluxe_0.5.1.orig.tar.gz

***** BEGIN RAW DIFF *****
--- a/kobo.cpp
+++ b/kobo.cpp
@@ -1717,6 +1717,38 @@
 				gsm.release(BTN_FIRE);
 			}
 			break;
+		  case SDL_JOYHATMOTION:
+			if(ev.jhat.value == SDL_HAT_LEFT)
+			{
+				gamecontrol.press(BTN_LEFT);
+				gsm.press(BTN_LEFT);
+			}
+			else if(ev.jhat.value == SDL_HAT_RIGHT)
+			{
+				gamecontrol.press(BTN_RIGHT);
+				gsm.press(BTN_RIGHT);
+			}
+			else if(ev.jhat.value == SDL_HAT_UP)
+			{
+				gamecontrol.press(BTN_UP);
+				gsm.press(BTN_UP);
+			}
+			else if(ev.jhat.value == SDL_HAT_DOWN)
+			{
+				gamecontrol.press(BTN_DOWN);
+				gsm.press(BTN_DOWN);
+			}
+			else
+			{
+				gamecontrol.release(BTN_LEFT);
+				gamecontrol.release(BTN_RIGHT);
+				gamecontrol.release(BTN_UP);
+				gamecontrol.release(BTN_DOWN);
+				gsm.release(BTN_LEFT);
+				gsm.release(BTN_RIGHT);
+				gsm.release(BTN_UP);
+				gsm.release(BTN_DOWN);
+			}
 		  case SDL_JOYAXISMOTION:
 			// FIXME: We will want to allow these to be
 			// redefined, but for now, this works ;-)
***** END RAW DIFF

#768546#8
Date:
2014-11-08 10:59:19 UTC
From:
To:
-=| Eric Duhamel, 08.11.2014 02:12:18 -0800 |=-

Thanks!

Did you test the resulting binary? I have no joystick myself and am
hesitating passing upstream a completely untested patch.

#768546#17
Date:
2014-11-08 20:49:06 UTC
From:
To:
Thank you for that discretion in accepting an untested patch.

I've played with a similarly patched version of kobodeluxe before. I will attempt to build and test this patch now....

After building, I tested playing the game using a Logitech F310 controller, and the D-Pad "Hat" worked like a charm.

#768546#22
Date:
2014-11-09 17:36:27 UTC
From:
To:
Hi David,

Eric Duhamel have sent a patch adding support for joistick hat to
kobodeluxe.

(I didn't know what a joistick hat is and
https://en.wikipedia.org/wiki/Joystick#Hat_switch helped)

The patch looks fine to my uneducated eyes and Eric says it works with
a Logitech F310 controller, so perhaps it is suitable for inclusion in
kobodeluxe proper?


Thanks for considering it,
    Damyan