Joystick axis centering problem

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
LRFLEW
Level 1
Level 1
Posts: 5
Joined: Mon Jul 16, 2012 10:59 pm

Joystick axis centering problem

Post by LRFLEW »

I have started installing some PC games into wine on my mac, and I have started to get my usb XBox 360 controller to work with some of these games. I have the drivers installed properly on my mac (the controller works perfectly with mac-native games), and can get it detected and functioning on my wine games. I am, however, having a problem with how the games detect the center of my controller.

Here are some specs on the controller and the driver. The controller has 6 axis. The two joysticks are called X, Y, Rx, and Ry and use 16 bit signed integers to represent their positions (-32768 to 32767) with 0 being the center (or natural) position. The two triggers are called Z and Rz, and they use 8 bit unsigned integers (0 to 255) with 0 being the natural position it goes to.

The problem is different games don't seem to be able to get the centers correct.

The most common case I've seen so far is treating all of the axis as using the mid-point. Project64 does this, and trying to configure the controller caused it to default to Rz-. This problem could be worked around if I temporarily turned up the dead zone really high and kept the triggers slightly pulled, but not all games I've tried has this flexibility.

The stranger case I've seen is the game treating all of the axis as having the center be in the corner. I've noticed this problem mostly with Midnight Club II. Not touching the controller causes the game to see an input that's up and to the left. It seems to think that the bottom-right position (the positive ends of the axis). There are no configurations in-game that I could find that would fix this issue.

I have no clue how to fix this type of error. Does anybody know of some type of configuration in wine that could allow me to recenter the axis? Is there some tool that could even change the values that go into the game to get it to react properly? I can configure wine separately for each game because I have them installed under separate installations of wine, fyi. I'm not too worried about Project64 because I was able to get it configured properly, but I still need help getting the controller to play nicely with Midnight Club II. If you know of any way to configure the game itself, that would be helpful too.

Thanks.
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: Joystick axis centering problem

Post by lahmbi5678 »

Did you use wine's joystick configuration applet? The simplest way to get there would be a command like "wine control joy.cpl". If it still wouldn't work, you'd have to file a bug.
LRFLEW
Level 1
Level 1
Posts: 5
Joined: Mon Jul 16, 2012 10:59 pm

Re: Joystick axis centering problem

Post by LRFLEW »

lahmbi5678 wrote:Did you use wine's joystick configuration applet? The simplest way to get there would be a command like "wine control joy.cpl". If it still wouldn't work, you'd have to file a bug.
How exactly am I supposed to "use" the configuration applet? All I can see is a list of the connected controllers (which is my one controller), a tab to "test" the controller (by showing where the axis are and what buttons are pressed), and a tab to test the rumble feature (which doesn't work for me, but it's probably the drivers). I don't see what I'm supposed to do in there.
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: Joystick axis centering problem

Post by lahmbi5678 »

Hm, I thought it would be possible to calibrate the joystick, my fault.

Maybe http://forum.winehq.org/viewtopic.php?t=1148 helps.
LRFLEW
Level 1
Level 1
Posts: 5
Joined: Mon Jul 16, 2012 10:59 pm

Re: Joystick axis centering problem

Post by LRFLEW »

lahmbi5678 wrote:Maybe http://forum.winehq.org/viewtopic.php?t=1148 helps.
No, that doesn't really apply to my problem.

I went ahead and tried some more Google searching, and realized I was using the wrong key words all along. After some more searching, I found the problem is with MC2 itself. I found a few forums on the issue. I don't know if the problem with Project64 is wine or not, but the Midnight Club 2 issue is not wine.
bookerg
Newbie
Newbie
Posts: 4
Joined: Sun Apr 28, 2013 4:14 pm

Re: Joystick axis centering problem

Post by bookerg »

Hi,

I had a similar problem with the Xbox controller, and found two solutions to it:-


1) (the better solution)
Recompile the xpad Linux driver, and manually set the RZ minimum axis in xpad.c to -255 (and not 0 as it usually is)

This way, the default trigger value of 0 will be in the center of the range rather than at the minimum (the triggers will obviously only ever report positive values, but this shouldn't matter)

Here is the offending line (from http://lxr.free-electrons.com/source/dr ... ick/xpad.c):-


827 case ABS_RZ: /* the triggers (if mapped to axes) */
828 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);



2) Manually adjust the Wine joystick enumeration routine ("find_joydevs()" in dlls/dinput/joystick_linuxinput.c) so that if a minimum axis value of "0" is found, Wine should simply use a negative version of the maximum instead (i.e. an axis of 0 to 255 becomes -255 to 255)

https://github.com/mirrors/wine/blob/ma ... put.c#L290:-

290 joydev.axes[j].minimum

(^add a check in here so that joydev.axes[j].minimum = -joydev.axes[j].maximum if min=0)

You'd also need to do this for dlls/dinput/joystick_linux.c (for /dev/input/jsx joysticks) and dlls/winejoystick.drv/joystick.c (for games that use Winmm rather than DirectInput)




However, the problem with (2) is that some joysticks actually use an entirely positive range for their axes with the mid-way point as the center value, so this would screw those up

(e.g. my SNES-style USB pad goes from 0 to 255 for the X & Y axes, and uses 128 as the center)

The problem with the Xpad driver is that the "rest" (center) value is the same as the minimum, which seems to cause the confusion





If you need further help with this (or if I've misunderstood your problem!!) please let me know (this is my first post as I'm new to compiling Wine etc!)
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: Joystick axis centering problem

Post by lahmbi5678 »

Hi,

imo the issue needs to be fixed in wine (assuming that the linux kernel does it 'right'(tm)), maybe via a config option in the wine joystick applet. Please file a bug report and describe the issue there, as a kind of documentation, the wine devs aren't closely following this forum, but the do read bug reports.
Locked