XBox 360 gamepad with xpad driver and analog triggers

Questions about Wine on Linux
Locked
gmureddu
Level 1
Level 1
Posts: 8
Joined: Wed Feb 23, 2011 2:27 am

XBox 360 gamepad with xpad driver and analog triggers

Post by gmureddu »

Hi all, I know, I know, I did my homework and searched around the forums, sorry, not so much around bugzilla, and found at least these three threads that although related to what I want to say/ask/express, are not 100% the same:

http://forum.winehq.org/viewtopic.php?f=8&t=22121
http://forum.winehq.org/viewtopic.php?f=2&t=22113
http://forum.winehq.org/viewtopic.php?f=8&t=21185

So I managed to get my wirless XBox 360 gamepad play nice with Linux through the use of the much appreciated Valve's xpad patched up version of the kernel driver (which among other things solves the pair lights issue). Also, I have managed to get accurate Xinput information for the gamepad thruough the use of xbox360cemu and the use of its .ini config file. All is great and dandy... But there are issues remaining concerning this gamepad and driver. Since I use an original Microsoft Xbox 360 Wireless Controller, the driver does nothing if I set the options for it to set the triggers as buttons. These controllers have a set of two analog triggers (as probably everyone knows by now), which are detected by the Linux xpad driver as axes, and these triggers work wonderfully on native games and SDL 2 games under Steam and all; but no so under Wine. In wine these buttons are mapped "verbatim" as axes and as such games that support the XBox360 gamepads do make use of the gamepad as they should, only that the moment you put intput into it, the "trigger's axis" will keep sending input (much like the accelerometers in PS3 DS3 controllers).

Why do I not simply use xboxdrv instead? Because I'd rather use the kernel driver, which does actually work very well, and I have it set up in such a way that I do not have to change perms on the device nodes, as they are given an generic group and write perms on them so to have rumble and all, which no matter how hard I tried, I cannot accomplish with xboxdrv, even when changing perms after the device nodes are created, so I reckon no ff is being sent to the device at all (even when the fftest program does recognize the controller as an XBox360 Wireless one). All in all, since the [patched] xpad driver does work indeed "better" in terms of features now, I'd like to use it to play those Windows games that do run under Wine (Skyrim, and others) but since I cannot use the module option --triggers-as-buttons because it is an original Microsoft pad (this option apparently works with generic unknown devices and non Microsoft devices, from what I can make out of the xpad.c file), I wanted to know if there is any way to accomplish this with the xpad driver in Wine 1.7.22 through any of the Dinput keys or similar.

I'm not sure this is exactly a bug, since apparently Joystick input is a bit of a hit and mss issue in Wine in general, of all the years I've been using Linux and wine in particular, this is the first time I attempt to actually use a gamepad with it, as I normally used my gamepads with native games only.
gmureddu
Level 1
Level 1
Posts: 8
Joined: Wed Feb 23, 2011 2:27 am

Re: XBox 360 gamepad with xpad driver and analog triggers

Post by gmureddu »

Ok... So I did find some little information regarding DirectInput and mapping of the actual device buttons... It's a start... I'm not sure this alone will be enough to solve this problem, but at least is a step in the right direction to tackle this... Now, for initial setup I have to figure out a few things that wine registry keys wiki state about this:
WineWiki wrote:

Code: Select all

<joystick name> = <axes mapping>
      |  |   [This maps axes of joystick "joystick name". The "axes mapping" is
      |  |    comma-separated list of "axis type"s - one for each joystick axis (hat-pov uses 2 axes).
      |  |    "axis type" is one of: X, Y, Z, Rx, Ry, Rz, Slider1, Slider2, POV1, POV2, POV3, POV4.
      |  |    To find the joystick name run
      |  |    'WINEDEBUG=+dinput wine game.exe 2>&1 | grep joydev_enum_device'
      |  |    Example output: trace:dinput:joydev_enum_deviceW Enumerating the linux Joystick device: /dev/input/js0 (Logitech Logitech Dual Action)
      |  |    Example registry entry: "Logitech Logitech Dual Action"="X,Y,Rz,Slider1,POV1". (two "Logitech"s not a typo)]
Where do I get these names from? What does each of the above X, Y, Z, Rx, Rz, etc axes actually represent for this device in particular, where do I get that information from? jstest tool finds about 6 axes, how are these mapped in wine? (I know, I know, trial and error is the fun way to do it...)

When I get this right for this device in particular, I'll post what the key actually looks like and see if it does work (to an extent) the same way it has been without using this method for remapping axes.

Are there any other keys that as of Wine 1.7.22 I sould be aware regarding DirectInput and joystics otehr than this and DefaultDeadZone?

TIA!
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: XBox 360 gamepad with xpad driver and analog triggers

Post by oiaohm »

gmureddu this is a case of cat meants dog and pray they are friendly. When they are not the critical big stick with net to break them up is missing

<joystick name> = <axes mapping> in wine registry is to help with the horrible case that wine auto detect does something badly wrong like mapping 1} X axis as Y or 2} a button as a axis or 3} axis as a button. Please note 2 and 3 errors result in that item not working at all with wine(ok not exactly not working but doing something really wrong that they are not usable).

Wine contains no joystick over mapping code to make a joystick appear to be something other than it is so application is handed nicely raw joystick information and told deal with it. Lack of overmapping code is not a new problem.

I think this will kinda catch you there is in fact no xpad driver driver inside wine. There is 1 huge joystick interface that talks to them all inside Wine and its kinda short on features. Two major feature missing is buttons to axis and axis to buttons this is found in Linux SDL and lot of other Linux native solutions just not wine. If wine implemented mapping you would be able to use any joystick as a xbox ps2 .... joystick without third party.


Yes why joysticks are so hard inside wine compared to everything else Linux is complete lack of any wine side adjustments other than making sure buttons and axis are lined up with the device.
gmureddu
Level 1
Level 1
Posts: 8
Joined: Wed Feb 23, 2011 2:27 am

Re: XBox 360 gamepad with xpad driver and analog triggers

Post by gmureddu »

Thank you for the explanation. And given the situation, I think that Wine actually does a pretty damned good job at detecting the thing on my system, based on current state of support, or lack there off, for dedicated joystick and gamepad handling built into wine itself, i.e not relying on SDL2 or having a more robust implementation of DirectInput (Xinput) as such... Remarkable.

Since my issue in particular (triggers which are analog, and in turn set by the driver as axes, and in turn given a "bad" center, because they have no other position than >=0, their center is way off...) I've tried to calibrate the thing with jscal (but its actual use is a bit of a hit and miss, it seems) in order to have the center and minimum position of the trigger axes set to the same and in that way have them only handle one position. Its options syntax is beyond freaking confusiong, and I don't seem to only set the values for those two axes (2 and 5 in my case) through the command line, and no matter how much I read the manpage, it doesn't have ONE darned example on how to do that, if at all possible!

I've heard about another tool that might be of help for that situation, jstest-gtk... Now I face the problem that there are no Fedora compatible jstest-gtk packages nor there seems to be a way to build it without patching, as apparently the available source is not compatible with gcc 4.8 and it complaints about variables and method declarations outside of a given scope (I only know so much about programming, so I'm stuck). Still I'm looking at ways to calibrate the gamepad in such a way that at least Wine would detect the offending axes as having only one availeble possition instead of a bad case of off center dizziness.
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: XBox 360 gamepad with xpad driver and analog triggers

Post by oiaohm »

https://www.kernel.org/doc/Documentatio ... ystick.txt

gmureddu I will give you Linux Kernel Developer man pages are the masters of super vague when you strike a super vague man page do have a look in the kernel documentation sometimes its helpful. Yes jscal and jstest are both applications to assist features in the Linux kernel.

Code: Select all

jscal -p /dev/input/js0
Is kinda a good idea before you mess with too much.

Note jstest has old and new this is interface testing.

I am a KDE user so I am use to access KDE Settings to set up joystick. Yes it has multi axis support.
jstest-gtk is a graphical more friendly version of jstest and jscal. Its not the only one either. qjoypad provides wrapping from axis to button as well as some calibration settings.

Sorry KDE/QT is my base environment thinking anything out side that is hard.

Wine does not contain wrapping but there are a lot of applications that do provide it.
Locked