longer1996 / adapt-ffb-joy

Automatically exported from code.google.com/p/adapt-ffb-joy
0 stars 0 forks source link

Button 9, shift, doesn't on a M$ FFB Pro #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the adapter with a M$ Force Feedback Pro joystick in XP and probably any 
other OS
2. Open "Control Panel" -> "Printers and Other Hardware" -> "Game Controllers", 
click "Properties" on the "LUFA Joystick wFFB" and go to the "Test" tab. 
3.  Try using the 9'th button (the shift arrow) and it will trigger by itself 
as button 9, and not shift the other buttons to the remaining stubbed out 
button entries 10-16. 

What is the expected output? What do you see instead?
I expected to button 9 to not trigger a press by itself, but for button 1-8 
pressed in conjunction to read as button 9-16 respectively.

What version of the product are you using? On what operating system?
I'm using the M$ Force Feedback Pro with the adapt-ffb-joy latest svn firmware 
(downloaded 11/08/2014) and installed on a self-made adapter with a teensy 2.0. 

I managed to fix it in the code, but am not sure if it's more than just a hack 
or should be fixed other places.

I changed this line in Joystick.c:
outReportData->Button = ((sw_report[4] & 0x7F) << 2) + ((sw_report[3] & 0xC0) 
>> 6);

to these lines:
        if ((sw_report[4] & 0b01000000) == 0b01000000)
        {
            // button 9 (shift) is held down
            sw_report[4] &= 0b10111111;     // Lift up button 9; it's not to be used alone.
            outReportData->Button = ((sw_report[4] & 0x7F) << 10) + ((sw_report[3] & 0xC0) << 2);
        }
        else
            outReportData->Button = ((sw_report[4] & 0x7F) << 2) + ((sw_report[3] & 0xC0) >> 6);

And it does exactly what I wanted.  I'm a bit surprised and proud of myself 
since I haven't ever edited code to a hardware device before and was successful 
so quickly.  I know I should have applied it in patch format, but as I'm on 
windows right now I don't have diff easily available.  I'm attaching the fully 
modified Joystick.c file.

Thanks if you decide to include this in future releases,

  Lucas

Original issue reported on code.google.com by jaffa225...@gmail.com on 7 Mar 2015 at 11:13

Attachments: