DosBox fully bindable Joystick Patch

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

DosBox fully bindable Joystick Patch

Postby cfoesch » 2011-2-14 @ 16:54

I've tried to use my XBox360 controller with DOSBox every once and a while every so often, but it never works, because DOSBox won't let you bind any axes after the first four, and won't actually register bindings to the hat/d-pad either unless the hat/d-pad is supported by the emulated device. Not to mention that the XBox360 driver stupidly places the trigger/rudder axis as the 3rd axis, and thus totally breaking the "first two axes are joy1, second two axes are joy2" assumption made by DOSBox... and every other rational human being.

But think about it, if I'm remapping the d-pad to keys, then the emulated device doesn't _need_ to support the hat, right? So why would DOSBox block me from doing so? (Answer? DOSBox was arbitrarily capping the axes and hats to only what was being emulated.)

This patch removes a few MAGIC_NUMBERS in favor of defines, and also raises the scans on the axes and the hats for event handling so that you can actually bind all axes (up to 8 ), and hats (up to 2) to something...

Of course, the emulated environment will still only ever see the 4-axis or whatever you setup, this is simply a limitation of how joysticks were handled in DOS. However, at least now you can bind those otherwise useless axes to keys, and bind hat switch positions to your favorite emulated keys.

I shall now spend the next 8 hours playing my Descent with my entire gamepad, rather than the hideous horrible mess I was forced to use before, because Microsoft decided to be total idiots in laying out the axes on their controller...
Attachments
dosbox-joystick-patch.diff
Patch to raise limits on event scans for axes and hats so that they can be bound even if they're not being emulated.
(3.39 KiB) Downloaded 1304 times
User avatar
cfoesch
Newbie
 
Posts: 23
Joined: 2011-2-14 @ 16:00
Location: Albuquerque

Re: DosBox fully bindable Joystick Patch

Postby wd » 2011-2-14 @ 19:52

DOSBox was arbitrarily capping the axes and hats to only what was being emulated.

Wrong, DOSBox intentionally capped mappable features to keep the mapper file
sane in case of replacing joysticks or switching to keyboard-only mapping of joystick
targets and back to real joysticks.

I don't have any joystick any more so hope somebody is interested in checking out
ways of testing this or a more useful implementation rather than "arbitrarily removing
the arbitrary capping".
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: DosBox fully bindable Joystick Patch

Postby ADDiCT » 2011-2-14 @ 23:46

Hey wd, I don't understand the slightly hostile tone in this matter. There are a few threads about joystick troubles connected to the "axis limit" IIRC, and I remember not being able to use the right thumbstick on my Xbox 360 controller (XBCD driver) at all. I don't have the knowledge (and motivation/time, to be frank) to setup a compile environment. If someone could compile a Windows build with that patch applied I could do some quick Windows 7 testing and reporting though if that's any help.
User avatar
ADDiCT
Oldbie
 
Posts: 1170
Joined: 2007-2-02 @ 15:07
Location: Retroland

Re: DosBox fully bindable Joystick Patch

Postby cfoesch » 2011-2-14 @ 23:48

Wrong, DOSBox intentionally capped mappable features to keep the mapper file sane in case of replacing joysticks or switching to keyboard-only mapping of joystick targets and back to real joysticks.


I'm trying to think of a situation where the mapper file would stop being sane if DOSBox recognized 8 axes instead of just limiting itself to 4 axes... and why it would stop being sane if DOSBox recognized a hat for binding even when not emulating a hat...

I'm failing to see how the addition of about 16 more possible bindable inputs (4 axes * 2 directions + 2 hats * 4 directions) would have any impact on the sanity of the file, when the keyboard itself has about 101...

DOSBox without this patch is literally throwing away inputs. Sure if you never have more than 4 axes on your joystick, you would never notice, but Microsoft pumped out a controller with 5 axes, and arranged them somewhat retardedly: Axes 0,1 = Left control stick, Axis 2 = the triggers together as one axis, Axes 3,4 = Right control stick. Put this together with DOSBox arbitrarily capping at 4 axes, and you only get one-axis of the right control stick, with no possible way to map Axes 3,4 onto emulated Axes 2,3.

I don't have any joystick any more so hope somebody is interested in checking out ways of testing this or a more useful implementation rather than "arbitrarily removing the arbitrary capping".


There is no way to implement this except removing the arbitrary cap on input (or rather raising the arbitrary cap on input... if someone had a controller with more than 8-axes, it would now still throw away the 9th axis and above).

As for testing, I'm all for testing anything you can possibly dream up that you think I might be forgetting about... but as is, it's all the same code that has been working for years... just reading more axes and the hat even if there isn't a hat being emulated.
User avatar
cfoesch
Newbie
 
Posts: 23
Joined: 2011-2-14 @ 16:00
Location: Albuquerque

Re: DosBox fully bindable Joystick Patch

Postby cfoesch » 2011-2-14 @ 23:53

@ADDiCT attached, I have the Windows binary I built from the raw SVN tarball with patch applied.

Wide testing base == good.
Attachments
DOSBox-Joystick-patch.zip
DOSBox.exe with Joystick patch applied.
(1.15 MiB) Downloaded 1132 times
User avatar
cfoesch
Newbie
 
Posts: 23
Joined: 2011-2-14 @ 16:00
Location: Albuquerque

Re: DosBox fully bindable Joystick Patch

Postby wd » 2011-2-14 @ 23:58

I don't understand the slightly hostile tone in this matter

Why would I care whether you understand or not?
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: DosBox fully bindable Joystick Patch

Postby ADDiCT » 2011-2-15 @ 10:11

Because you are a caring and friendly person?
User avatar
ADDiCT
Oldbie
 
Posts: 1170
Joined: 2007-2-02 @ 15:07
Location: Retroland

Re: DosBox fully bindable Joystick Patch

Postby aireca » 2012-11-14 @ 09:27

@cfoesch A BIG THANK YOU, i was very dissapointed that my controller did not fully worked (Hat & right thumb does not worked before), Now i can play like it should be, Thank you very much again, i hope this is included into the next release, if not then please continue to compile your awesome build. THANKS.
User avatar
aireca
Newbie
 
Posts: 2
Joined: 2012-11-14 @ 09:19

Re: DosBox fully bindable Joystick Patch

Postby mgtroyas » 2012-12-01 @ 20:01

Taewoong's SVN build has added this patch. I'll try my logitech F710 in X360 mode to test it's effect.

http://ykhwong.x-y.net/
User avatar
mgtroyas
Newbie
 
Posts: 20
Joined: 2011-1-21 @ 15:00
Location: Spain

Re: DosBox fully bindable Joystick Patch

Postby aireca » 2013-1-25 @ 12:53

mgtroyas wrote:Taewoong's SVN build has added this patch. I'll try my logitech F710 in X360 mode to test it's effect.

http://ykhwong.x-y.net/


Yeah, i asked him to add this patch, i'm very glad he did it, i don't have experienced any trouble during this 2 months of use. :blush:
User avatar
aireca
Newbie
 
Posts: 2
Joined: 2012-11-14 @ 09:19

Re: DosBox fully bindable Joystick Patch

Postby Xenphor » 2013-7-12 @ 19:14

If there's no cap on buttons then why cap axes and hats? I could use a dualshock 3 with both left and right stick because the rest of the controller was mapped to buttons, no analog triggers or hat. I could map up to 17 buttons with no issues (with button wrap off), even though dosbox was only emulating a max number of 6 buttons with the ch profile. For some reason this same approach isn't applied to axes. If dosbox is only emulating 4 axes you can only use 4, and the bigger problem is that you can't even tell it which 4 to use. It will just choose the 4 itself which is what messes up the 360 controller. At the very least you should be able to drop the analog triggers in favor of another axis on the right stick if you still want to cap 4 axes.
Xenphor
Newbie
 
Posts: 94
Joined: 2009-7-08 @ 00:33

Re: DosBox fully bindable Joystick Patch

Postby iworkedatsubway » 2014-1-03 @ 17:19

I'm pretty new at using DosBox and haven't even begun to even consider attempting to foray into its source to try and make changes, so I just wanted to extend my gratitude for providing this change and the accompanying build. I can now play MechWarrior 2 using both Xbox 360 joysticks (whereas before I couldn't bind anything to the X axis of the right joystick). I'm kind of ecstatic now and am gonna spend the rest of the day in pure nostalgic bliss.

@cfoesch, thank you!!!
iworkedatsubway
Newbie
 
Posts: 1
Joined: 2014-1-03 @ 17:15

Re: DosBox fully bindable Joystick Patch

Postby LouG » 2014-4-05 @ 00:08

Will this excellent enhancement work in Linux dosbox?

Thanks...
LouG
Newbie
 
Posts: 1
Joined: 2014-4-05 @ 00:05

Re: DosBox fully bindable Joystick Patch

Postby amix » 2014-4-22 @ 01:59

I would like to know, how I can interact with this patch (config options). I am using SVN-Daum, but I find no instructions, on what to do. I have a Logitech Rumblepad F710, which I got to get working with X-Wing and TIE-Fighter, but gives me headaches with Strike Commander. I can use the Joypad in the menu, but I get no functionality ingame. Whatever I chose, no luck. I also tried using it in DirectInput mode and XInput mode. Does it count, which input mode I use? I guess, since this patch was made for the XBox controller, originally, it should be XInput (the Joypad I am using can be switched to either)?

So, after having this patch applied (i.e SVN-Daum installed), what is the next step do do? Thanks a lot!

Andreas
amix
Newbie
 
Posts: 8
Joined: 2014-4-22 @ 01:50


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 2 guests