View Issue Details

IDProjectCategoryView StatusLast Update
0002651FSSCPuser interfacepublic2014-07-25 02:45
ReporterZekeSulastin Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionwon't fix 
Platformx86_64OSLinuxOS VersionArch 2012-05-13
Product Version3.6.14 RC5 
Fixed in Version3.7.2 
Summary0002651: Limited to 32 joystick buttons by io/joy.h and controlsconfig/controlsconfigcommon.cpp
DescriptionFS2_Open is limited to 32 joystick buttons (and 6 axes). Although not much of an issue when a joystick profiler/keyboard emulator is available (i.e. in Windows), this can make advanced setups in the absence of such software (i.e. in Linux) problematic.

By my (probably incomplete) investigation, this is caused by two factors:
1) io/joy.h: #define JOY_NUM_BUTTONS 32
2) controlsconfig/controlsconfigcommon.cpp: char *Joy_button_text_language[] = { "Button 1", "Button 2," ... "Button 32", "Hat Up" ...}

Changing only 1) causes 3.6.14 RC6 to crash if the button is outside what's defined by 2) (Addl Info *1). r8781 mislabels the button (Button 37= , Button 38, 39, etc. = 1, 2, etc) but saves and uses the button correctly otherwise.

However, if you also add sufficient additional entries to 2) (i.e. add "Button 37", "Button 38", etc before the Hat entries), both 3.6.14 RC6 and r8781 work normally, showing the proper button on the mapping screen, using the proper button in flight, and not crashing. I have not tested whether the hat switch works normally with this addition - on my stick the POV hat, if not defined as more buttons, is axes 8 and 9, above the limit of 6 in 1) - but it looks like it should work (and treating the hat as buttons is trivial anyways). Attached is a simple patch that does exactly that and builds against both RC6 and r8781, bringing the total usable number of buttons to 98 (so that the 6xXX list of buttons in 2) still lines up :p)

A better solution would be to take SDL's reported number of buttons and axes then populate 1) and 2) based on that, but since I have no idea how to do that I'll just fix the symptom rather than the problem!
Steps To Reproduce1) Somehow get joystick device with > 32 buttons
2) Start FS2 and attempt to bind button 33+ to a function
3) Observe crashes/mislabeling
Additional Information*1:
ERROR: EINVAL: String error. Please Report.
Trying to put into 40 byte buffer:
(null)
File: controlconfig/controlsconfig.cpp
Line: 1504

*2:
Saitek X52 Pro w/ stickshift (https://github.com/petechap/stickshift) to add arbitrary shift and button/axis remap functionality
TagsNo tags attached.

Activities

ZekeSulastin

2012-05-14 10:32

reporter   ~0013558

Last edited: 2012-05-14 10:34

I am bad and should feel bad.

When making the simple patch, I edited and tested the files in RC6 first before copying and testing them in svn trunk. Unfortunately, there was a line (std::...) in the RC that was changed in trunk, and because I was bad I let that become part of the patch. It didn't impact apparent functionality (but does probably explain why RC6 crashed and r8781 mislabeled), aiding its unnoticability.

Attached is a fixed patch and my apologies for being bad.

(Also, thank you ni1s from #scp, for helping start this whole report :)

ZekeSulastin

2012-05-14 10:32

reporter  

CommanderDJ

2012-05-15 07:29

developer   ~0013559

Old patch removed to avoid confusion.

z64555

2012-06-03 04:24

developer   ~0013631

Maybe?
 string Joy_button_text_language[button_number] = "Button " + button_number;

I don't like how the hat is grouped together with the buttons, though.

Mastadon

2012-06-07 16:19

reporter   ~0013635

How many buttons does your joystick have?!

In all seriousness though, why would you or anyone else need 32 joystick button bindings?

ZekeSulastin

2012-06-07 18:07

reporter   ~0013636

Last edited: 2012-06-07 18:08

I briefly explained it in the start of the description; overlong version to follow:

Because joystick profiling software and specialized drivers for button-laden sticks like the Saitek x52 Pro HOTAS generally don't exist for Linux: there's only the generic HID driver available, and while it does see everything on the stick that everything includes 11 axes (joystick, twist, throttle, one of the hats, the slider, the three knobs, and the little mouse-stick thingy) and 39 buttons (buttons, toggles, the other two hats, the scrollwheels, and the mode selector). Indeed, the Windows driver doesn't actually see all of these as separate mappable buttons.

To be honest, if all you want is a basic config that still isn't too much of an issue - a lot of the extra stuff is stuff that wouldn't be used much in FS (like the mousewheels). However, if you want to do fancy profiler stuff (i.e. a shift-function button that changes what all the others do while held, mapping axes to commands, etc), things become more difficult. For instance, I have the mouse-stick on the throttle mapped to weapon selection unshifted and power distribution shifted, one stick hat as shield distro unshifted and basic comms shifted, the other as two different types of targeting, etc. As there's no profiler for Linux to do shifts or map buttons to keyboard keys, things become a bit more ... complicated.

The solution I found was a little program written by an X-Plane fan called stickshift (https://github.com/petechap/stickshift). This program implements the remap, shift, and mode elements of the Windows profiler by letting you map axes to buttons and define arbitrary shift states; you can look at his example .xml config to see how fine-grained you can get the control. To accomplish this, his program takes input from the real joystick, interprets it, then outputs final commands to a virtual joystick device. After remapping and adding shift-states from my config, FreeSpace2 sees 7 axes (of which only 4 are needed - the little knobs aren't that useful :p) and 61 buttons.

Thankfully, FS2 already works with maor butanz - all that "patch" does is add labels for a lot more. The whole process isn't that pretty, but in the end supporting HOTAS and such are always "hacky" - in both Windows and Linux you're essentially adding a virtual input device; they just happen to work differently.

MageKing17

2014-07-18 00:54

developer  

2651.patch (5,300 bytes)   

MageKing17

2014-07-18 00:55

developer   ~0016089

I've uploaded a patch that applies this to current trunk. Is there any reason to leave this issue open, instead of either committing the patch or closing it in expectation of antipodes solving the problem?

niffiwan

2014-07-20 21:50

developer   ~0016106

Commit now should be fine, I'll do that tonight or tomorrow night.

niffiwan

2014-07-21 09:25

developer   ~0016112

Hmmm - just noticed that the patch changes the hat "button" indexes but doesn't update the defaults hat mapping. Patch attached that does that. When this is committed there should also be a post on the forum explaining the change, because any existing pilots that use the hat will need to rebind their controls.

niffiwan

2014-07-21 09:25

developer  

mantis2651-mk2.patch (6,793 bytes)   

niffiwan

2014-07-23 10:33

developer   ~0016118

Fix committed to trunk@10933.

Goober5000

2014-07-24 00:50

administrator   ~0016120

Reopening because that hat remapping issue needs a bit more than a forum post.

Goober5000

2014-07-25 02:45

administrator   ~0016130

Closing as WONTFIX since this will be overcome by events once the new SDL code is completed.

Related Changesets

fs2open: trunk r10933

2014-07-23 06:58

niffiwan


Ported: N/A

Details Diff
Fix mantis 2651: from ZekeSulastin

Add support for up to 98 joystick buttons
Affected Issues
0002651
mod - /trunk/fs2_open/code/controlconfig/controlsconfigcommon.cpp Diff File
mod - /trunk/fs2_open/code/io/joy.h Diff File

fs2open: trunk r10937

2014-07-24 23:07

Goober5000


Ported: N/A

Details Diff
for Mantis 0002651: revert r10933, per forum discussion:
http://www.hard-light.net/forums/index.php?topic=88047.0
Affected Issues
0002651
mod - /trunk/fs2_open/code/controlconfig/controlsconfigcommon.cpp Diff File
mod - /trunk/fs2_open/code/io/joy.h Diff File

Issue History

Date Modified Username Field Change
2012-05-14 10:11 ZekeSulastin New Issue
2012-05-14 10:11 ZekeSulastin File Added: increase_joy_buttons.patch
2012-05-14 10:32 ZekeSulastin Note Added: 0013558
2012-05-14 10:32 ZekeSulastin File Added: increase_joy_buttons_fixed.patch
2012-05-14 10:33 ZekeSulastin Note Edited: 0013558
2012-05-14 10:34 ZekeSulastin Note Edited: 0013558
2012-05-15 07:29 CommanderDJ File Deleted: increase_joy_buttons.patch
2012-05-15 07:29 CommanderDJ Note Added: 0013559
2012-06-03 04:24 z64555 Note Added: 0013631
2012-06-07 16:19 Mastadon Note Added: 0013635
2012-06-07 18:07 ZekeSulastin Note Added: 0013636
2012-06-07 18:08 ZekeSulastin Note Edited: 0013636
2012-12-11 14:01 Echelon9 Status new => code review
2014-07-18 00:54 MageKing17 File Added: 2651.patch
2014-07-18 00:55 MageKing17 Note Added: 0016089
2014-07-20 21:50 niffiwan Note Added: 0016106
2014-07-21 09:25 niffiwan Note Added: 0016112
2014-07-21 09:25 niffiwan File Added: mantis2651-mk2.patch
2014-07-23 10:33 niffiwan Changeset attached => fs2open trunk r10933
2014-07-23 10:33 niffiwan Note Added: 0016118
2014-07-23 10:33 niffiwan Status code review => resolved
2014-07-23 10:33 niffiwan Resolution open => fixed
2014-07-24 00:50 Goober5000 Note Added: 0016120
2014-07-24 00:50 Goober5000 Assigned To => niffiwan
2014-07-24 00:50 Goober5000 Status resolved => code review
2014-07-24 00:50 Goober5000 Resolution fixed => reopened
2014-07-25 02:42 Goober5000 Changeset attached => fs2open trunk r10937
2014-07-25 02:45 Goober5000 Note Added: 0016130
2014-07-25 02:45 Goober5000 Status code review => closed
2014-07-25 02:45 Goober5000 Resolution reopened => won't fix
2014-07-25 02:45 Goober5000 Fixed in Version => 3.7.2