Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Pages: [1] 2

Author Topic: OIS::Slider  (Read 3321 times)

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
OIS::Slider
« on: February 20, 2008, 09:40:42 AM »

I have a controller with a slider that's being detected as an axis.

How is OIS::JoyStick::mSliders being populated, if nothing sets it in _enumerate()?

Code: [Select]
void Win32JoyStick::_enumerate()
{
//We can check force feedback here too
DIDEVCAPS  DIJoyCaps;
DIJoyCaps.dwSize = sizeof(DIDEVCAPS);
mJoyStick->GetCapabilities(&DIJoyCaps);

mPOVs = (short)DIJoyCaps.dwPOVs;

mState.mButtons.resize(DIJoyCaps.dwButtons);
mState.mAxes.resize(DIJoyCaps.dwAxes);

//Reset the axis mapping enumeration value
_AxisNumber = 0;

//Enumerate Force Feedback (if any)
mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);

//Enumerate and set axis constraints (and check FF Axes)
mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
}
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #1 on: February 26, 2008, 06:31:33 AM »

Still awaiting an answer... I'm not sure how the sliders can be getting set because I didn't see the win32 code that does it.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: OIS::Slider
« Reply #2 on: February 28, 2008, 05:53:50 PM »

In order to solve this, you need to be more specific.

When you say it is detected as an axis, do you mean you see an extra axis? Do you get call backs with axis values? ie axisMoved? Or do you simply see an extra axis and no data coming from it? Whether or not the slider was detected as an axis, it should still fire the slidermoved callback not the axisMoved callback.

The Sliders are a static array, so enumeration would not cause any problems of reading them. Though, I did notice (I don't have any sliders) that the mSliders variable that kept track of the number of sliders was never set to any value. Probably because the enumeration doesn't seem to have any values for slider count. However, I think slider count maybe combined with axis count. So, I have a small tweak that may fix this specific count enumeration. I'll commit to CVS v1_2 since I don't think it will impact anything and may improve - at least it won't try to adjust any settings when an enumerated axis is a slider axis. Can you test again in a few.

Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: OIS::Slider
« Reply #3 on: February 28, 2008, 06:15:51 PM »

Change is committed.

I must also say, for some reason DirectInput is really enumerating my joystick oddly. But, it might be because I use a modified XBox controller & unofficial drivers. For some reason, it enumerates 6 Axes, when all I have is two, and 20 buttons, when all there is is 12. And, it marks one of the axes (now) as a slider.. But, there is no slider on this device. I think my problem is simply the XBCD driver probably allocates all these devices but only puts values in them when you alter the layout via the control panel.
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #4 on: February 29, 2008, 06:37:28 AM »

Awesome, I'll give 1.2 a shot. When I said my slider was enumerated as an axis. I meant the axis is functional and returns values as if it was an axis.

Code: [Select]
cvs up -r v1_2
« Last Edit: February 29, 2008, 06:52:47 AM by tgraupmann »
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #5 on: March 01, 2008, 08:47:20 AM »

Ok interesting.

My slider is being enumerated and is returning values.

However, I had expected a slider to be a single axis. At least the slider on my joysticks are a single axis. Yet, slider has absX and absY. I had assumed each would be enumerated as absX is slider 0 and absY is slider 1.

But anyway, this would be an easy fix. I'll just wrap the input to change this how I expected.

Also why doesn't SLIDER have a MIN_SLIDER and MAX_SLIDER const property. It looks like values are coming in at the 65535 range.
« Last Edit: March 01, 2008, 08:52:51 AM by tgraupmann »
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #6 on: March 01, 2008, 09:06:02 AM »

How can you detect whether a joystick has an X or Y slider? I only have an X slider, so the Y is extra...
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #7 on: March 02, 2008, 07:50:16 PM »

Can DirectInput distinguish between an X or Y slider?
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #8 on: March 06, 2008, 12:17:42 PM »

What's the difference between an X slider and Y slider? Isn't a slider a single axis? What does a dual-axis slider look like?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: OIS::Slider
« Reply #9 on: March 07, 2008, 07:36:01 AM »

I don't know much about sliders except that it is a DirectInput component only. Other OS's (at least) linux treat it as an axis. I'm not sure what the range should be of a slider.

So, with the CVS change, your slider now comes in as a sliderMoved event? But before the change it came in as an AxisMoved? I need to know specifically so I know if the fix did anything useful. It is possible to also set the min/max range, but I need to know the answer to the first question - does this code change the behavior?
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #10 on: March 07, 2008, 06:03:33 PM »

I'm not accessing the state using an event. I'm just using the Joystick state to get access to the slider.

Code: [Select]
long S13OISJoystick::GetSlider(short _sliderId)
{
if (m_Joystick)
{
const OIS::JoyStickState& joyStickState = m_Joystick->getJoyStickState();
const OIS::Slider& slider = joyStickState.mSliders[_sliderId / 2]; // bit shift maybe faster than / 2

if (_sliderId % 2)
{
// cap value X / MAX_AXIS * 1000
return ((slider.abX * 500.0f) / OIS::JoyStick::MAX_AXIS);
}
else
{
// cap value Y / MAX_AXIS * 1000
return ((slider.abY * 500.0f) / OIS::JoyStick::MAX_AXIS);
}
}

return 0;
}

Also check out how I'm normalizing the output using OIS::JoyStick::MAX_AXIS, but it'd like to be using OIS::Slider::MAX_AXIS.
« Last Edit: March 07, 2008, 06:05:30 PM by tgraupmann »
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: OIS::Slider
« Reply #11 on: March 07, 2008, 08:10:35 PM »

Ok, I made a small change to force enumerated slider axes to min/mac range. Can you update cvs and check again?
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #12 on: March 08, 2008, 07:25:09 AM »

Ok I got the update. I'm testing shortly. I figured I'd upgrade Ogre at the same time.
Logged

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Re: OIS::Slider
« Reply #13 on: March 08, 2008, 05:40:34 PM »

I verified the slider range is now in the range of 32767.

I still need a way to detect x vs y slider axii...?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Re: OIS::Slider
« Reply #14 on: March 09, 2008, 06:51:48 AM »

You'll be wanting to setup some kind of action binding/user configuration menu. This way, you can let the user move a control to setup a bind action - which in that case you would detect either X or Y axis was moved. Perhaps the Y value is useless anyway, you'll probably be safe with just using the X axis.
Logged
Pages: [1] 2