Mayflash64 C Buttons with Linux

Discuss emulation or program issues here.
Post Reply
Presence
Posts: 51
Joined: Fri Oct 18, 2013 9:27 am

Mayflash64 C Buttons with Linux

Post by Presence » Mon Nov 18, 2013 11:14 am

I couldn't get the C Buttons working in Linux with the Mayflash64 adaptor. I noticed they were mapped to the second and third axis with jstest, so this is the code I was able to get them working with:

Code: Select all

diff --git a/Actions.c b/Actions.c
index 8777f80..ebc33fa 100644
--- a/Actions.c
+++ b/Actions.c
@@ -205,10 +205,10 @@ PIFHandleCommand(struct PIFController *controller, unsigned channel,
 
         /* Check for C buttons. */
         memcpy(joystickint, joystick, 16);
-        if(0x3F4103C2 == joystickint[2]) recvBuffer[1] |= BUTTON_C_DOWN;
-        else if(0xBF3FFFC0 == joystickint[2]) recvBuffer[1] |= BUTTON_C_UP;
-        if(0x3F4103C2 == joystickint[3]) recvBuffer[1] |= BUTTON_C_LEFT;
-        else if(0xBF3FFFC0 == joystickint[3]) recvBuffer[1] |= BUTTON_C_RIGHT;
+        if(joystick[2] > .75F) recvBuffer[1] |= BUTTON_C_DOWN;
+        else if(joystick[2] < -.75F) recvBuffer[1] |= BUTTON_C_UP;
+        if(joystick[3] < -.75F) recvBuffer[1] |= BUTTON_C_LEFT;
+        else if(joystick[3] > .75F) recvBuffer[1] |= BUTTON_C_RIGHT;
 
         /* Check for L/R flippers. */
         recvBuffer[1] |= buttons[6] << 5;
I haven't tested this on Windows, so not sure if it will work there as well.

Presence
Posts: 51
Joined: Fri Oct 18, 2013 9:27 am

Re: Mayflash64 C Buttons with Linux

Post by Presence » Mon Feb 24, 2014 10:07 pm

Did some more testing on this and came up with a patch that works on both Windows and Linux (for me at least):

Code: Select all

@@ -205,10 +205,16 @@ PIFHandleCommand(struct PIFController *controller, unsigned channel,
 
         /* Check for C buttons. */
         memcpy(joystickint, joystick, 16);
-        if(0x3F4103C2 == joystickint[2]) recvBuffer[1] |= BUTTON_C_DOWN;
-        else if(0xBF3FFFC0 == joystickint[2]) recvBuffer[1] |= BUTTON_C_UP;
-        if(0x3F4103C2 == joystickint[3]) recvBuffer[1] |= BUTTON_C_LEFT;
-        else if(0xBF3FFFC0 == joystickint[3]) recvBuffer[1] |= BUTTON_C_RIGHT;
+
+        if(0x3F4103C2 == joystickint[2] || 0x3F5869B1 == joystickint[2])
+            recvBuffer[1] |= BUTTON_C_DOWN;
+        else if(0xBF3FFFC0 == joystickint[2] || 0xBF5325A6 == joystickint[2])
+            recvBuffer[1] |= BUTTON_C_UP;
+        if(0x3F4103C2 == joystickint[3] || 0xBF5869B1 == joystickint[3])
+            recvBuffer[1] |= BUTTON_C_LEFT;
+        else if(0xBF3FFFC0 == joystickint[3] || 0x3F5325A6 == joystickint[3])
+            recvBuffer[1] |= BUTTON_C_RIGHT;
+
 
         /* Check for L/R flippers. */
         recvBuffer[1] |= buttons[6] << 5;
It appears the X axis is inverted on Linux which could be a bug somewhere in the driver.

User avatar
Snowstorm64
Posts: 303
Joined: Sun Oct 20, 2013 8:22 pm

Re: Mayflash64 C Buttons with Linux

Post by Snowstorm64 » Tue Feb 25, 2014 10:41 am

https://github.com/dvdhrm/xwiimote/comm ... ca15e1d285

It might explain why axes are inverted as for xwiimote driver, the kernel once did report wrong values, it has been fixed and now it reports correct values, but probably gamepad drivers aren't still updated against latest version of the kernel.

EDIT: This needs confirmation, however.
OS: Debian GNU/Linux Jessie (8.0)
CPU: Intel i7 4770K @ 3.5 GHz
Build: AVX (compiled from git)

Presence
Posts: 51
Joined: Fri Oct 18, 2013 9:27 am

Re: Mayflash64 C Buttons with Linux

Post by Presence » Tue Feb 25, 2014 4:25 pm

As far as I can tell that bug only affected the wiimote driver, correct? I'm on kernel 3.12.9 and it looks like the fix for that was already commited. In any case, the patch I made works on both systems. I'll look into it more at some point and file a bug report if I can figure out why it's inverted.

User avatar
MarathonMan
Site Admin
Posts: 692
Joined: Fri Oct 04, 2013 4:49 pm

Re: Mayflash64 C Buttons with Linux

Post by MarathonMan » Thu Feb 27, 2014 4:54 pm

It looks like the best way to handle this is via a sysconf probe and conditional branching (unfortunately).

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest