Joystick issues & feature request [+Patch]

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
cybertiger
Above Average
Above Average
Posts: 16
Joined: Mon Mar 24, 2008 5:50 pm

Joystick issues & feature request [+Patch]

Post by cybertiger »

Hi,

It's been awhile since I've played oolite, but I've managed to aquire a joystick (Microsoft sidewinder precision pro / gameport).

I'm having an issue that the game ignores the joystick if it is deflected < 5%. (STICK_DEADZONE in ./src/Core/OOJoystickManager.h:105-109)
0
Ignoring the fact that this is hard coded and can't be configured, the main issue is that as soon as the joystick is deflected 5% the roll/pitch/yaw jumps to 5%, meaning that it is impossible to have your roll/yaw/pitch at between 0-5% without using precision mode.

I'm using version 0.76.1.

Ideally the code should do something like this:

Code: Select all

double min_deflect = 0.05; // minimum deflection before movement.
double scale_power = 2.0; // optional extra to redistribute the precision of the joystick.
double axis_value = raw_value / 32768.0;
double axis_sign = axis_value ? value < 0 ? -1 : 1;

axis_value = abs(axis_value);
// Test if joystick is deflected beyond min_deflect.
if (axis_value > min_deflect) {
    // subtract min_deflect from axis_value.
    axis_value -= min_deflect;
    // scale axis_value so it is between 0 and 1.
    axis_value = axis_value / (1.0 - min_deflect);
}

// scale value to redistribute precision
axis_value = pow(axis_value, scale_power);
// restore sign.
axis_value *= axis_sign;
min_deflect really needs to be configurable at least via config files, as it's hardware dependent (depends on your joystick).

If you do add the suggested scale_power as well, it'd be great if that was also configurable, 1.0 would result in unmodified behaviour, and higher values result in the joystick being more accurate near the center and less towards the extremities.

If I can get the damn code to compile I'll send you a patch (I'm having issues with spidermonkey js being compiled with the wrong options on Ubuntu - no trace functionality).

Thanks,

-CT

P.S. By hexediting the binary so that STICK_DEADZONE became 0.0 I found the joystick performed great, however this had the unfortunate side effect of making Trumbles invulnerable ;)
Last edited by cybertiger on Wed Jan 09, 2013 9:30 pm, edited 1 time in total.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Joystick issues & feature request

Post by Cody »

I think something is already in the pipeline that may help - though I know zilch about such technical stuff!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
cybertiger
Above Average
Above Average
Posts: 16
Joined: Mon Mar 24, 2008 5:50 pm

Re: Joystick issues & feature request

Post by cybertiger »

Finally got oolite to compile.

Patch against 0.76.1 here http://cyberiantiger.org/oolite/oolite-joystick.patch

It's a bit rough in places, Objective C isn't my primary, secondary or tertiary programming language :)

Edit: I need to fix tab damage, forgot to change my editor settings to match your tab usage.

-Antony
Post Reply