[solved]XInput: Logitech f710 wireless. Analog Values

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

[solved]XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

Hi,

I have a logitech f710 wireless. I'm using XInput to control navigation in Ogre.
http://www.amazon.com/Logitech-940-0001 ... 768&sr=8-1

Now, the problem that I'm having is that when I read GetState().Gamepad.sThumbLX , it always start at a non-zero value when is center. While this can be easily fix, I still have other problems

1) It doesn't start at zero...
I fixed this by saving the value when it is center, at the beginning of the application.

2) when it returns to center, it doesn't always have the initial value. For example, let's say that the 128 was the initial center, then it may report 386.
One possible solution would be to have a dead zone between 400 to -400
However, this seems to be a big dead zone and there is something weird.

I haven't tested yet with the XBOX 360 controller. I will test tomorrow...

Any input?
Thanks
Last edited by iblues1976 on Wed Feb 22, 2012 5:35 pm, edited 1 time in total.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

I just tested an xbox 360 controller I have (wired) It is an old controller. It is worst than the logitech in terms of dead zone.
I have only tested the left thumb as of now... For logitech the dead zone, I'm setting it a t Absolute Value of 800. Actually, even 700 should be enough. I could create my own calibration for the joystick I guess.

For the xbox, it would have to be at least 2.5 the value of logitech... 2000
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by johnhpus »

1) It doesn't start at zero...
I fixed this by saving the value when it is center, at the beginning of the application.

2) when it returns to center, it doesn't always have the initial value. For example, let's say that the 128 was the initial center, then it may report 386.
One possible solution would be to have a dead zone between 400 to -400
However, this seems to be a big dead zone and there is something weird.
You're going about that all wrong. The XInput example code shows you example how to handle the "dead zone". It's not a big deal at all.

If x < DEAD_ZONE_THRESHOLD then x = 0;
If y < DEAD_ZONE_THRESHOLD then y = 0;

It's that easy.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

johnhpus wrote:
1) It doesn't start at zero...
I fixed this by saving the value when it is center, at the beginning of the application.

2) when it returns to center, it doesn't always have the initial value. For example, let's say that the 128 was the initial center, then it may report 386.
One possible solution would be to have a dead zone between 400 to -400
However, this seems to be a big dead zone and there is something weird.
You're going about that all wrong. The XInput example code shows you example how to handle the "dead zone". It's not a big deal at all.

If x < DEAD_ZONE_THRESHOLD then x = 0;
If y < DEAD_ZONE_THRESHOLD then y = 0;

It's that easy.
Thank you for the input.

You are correct. There are threashold for the deadzone. as I mention in the other thread, you can find the constant in the XInput.h header file.

Code: Select all

#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD    30
XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE
In my particular case, I found that it is better to do

Code: Select all

if (std::abs(leftX) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)
{
 //some code
}
It is important to notice that the deadzone for the logitech is a lot smaller that for the xbox 360 controller.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by Kojack »

The problem with simply clamping the deadzone to zero is that you get a sudden jump in values when leaving the dead zone.
If the dead zone is -400 to 400, then you get 0 in the dead zone, but the first position outside of the dead zone is 400 instead of 1.

Take a look at these pics (yay for Inkscape).

Image

In each the x axis is the actual joystick position (-1 to +1 if you normalise to floats) and y axis is the value sent to your game logic.
The left pic has no deadzone.
The middle pick has a clamp on values near the centre. There's a sudden jump in velocity at the edge of the dead zone.
The right pic has the same dead zone, but rescales the joystick values so there's a smooth progress from deadzone to max range.

Although the throw on a thumbstick is so small that it's probably hard to tell the difference, but on larger joysticks it's more obvious.

For even better control you might want a non linear graph. So the further the stick is from the centre the more of an effect a small stick movement has. This lets you have more precise control at low velocity. Flight sims tend to let you control this in the configuration (X-Plane has response sliders that control how non linear each axis is).

It all depends on the game. For example, I found the 360 controls for Alan Wake's flashlight aiming to be badly done. It allowed fast aiming when the stick was at maximum throw, but it was linear so when you leave the deadzone the flashlight started moving fast. It was annoying to carefully aim the narrow part of the beam at distant or moving objects. Having a non linear response would give much better fine precision control, while still having the same max turn rate at full throw.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

@Kojack
Excellent point
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by johnhpus »

Good stuff Kojack, and great use of the visual aid. That's fine forum support.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by Kojack »

There's some cool info on this stuff in a recent AltDevBlogADay article: http://altdevblogaday.com/2011/06/16/an ... processing

There's also some cool info on joysticks at http://www.xbitlabs.com/articles/multim ... dup_7.html
It's more of a review and it's about flightsim joysticks, but it has some testing software which graphs joystick response, so you can see polling rate, linearity and stuff.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

@Kojack The article you provided : http://altdevblogaday.com/2011/06/16/an ... rocessing/ ... processing is very helpful. Thanks!
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by iblues1976 »

Hello..

The great article from AltDevBlogToday is not longer available (at least for some months now).

Just in case, I added my cached version to here http://franciscoraulortega.com/pwinput/

It is also available in the internet archive, which is https://web.archive.org/web/20120418171 ... rocessing/
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: [solved]XInput: Logitech f710 wireless. Analog Values

Post by Kojack »

Such a shame it went down, great resource.
But luckily we have archive.org. :)
Post Reply