Jump to content

Input system Issues


photo

Recommended Posts

We are working with two joystick configurations. One being an XBox360 wired controller and the others being XBox360 wireless controllers for windows - however this in principle could be any two joysticks.

The problem is that the drivers behave differently so they have to be configured slightly differently but events for the joystick that is not attached to the system appear to be being processed.

 

Config looks something like this. (note that the XBox360 controller has a different device string on windows Vista to what it does on Windows 7)

 

<?xml version="1.0" encoding="utf-8"?>
<controls definition="ai3d/config/controls/free.controls_def">
<action name="look_down"/>
<action name="look_left"/>
<action name="look_right"/>
<action name="look_up"/>
<action name="move_backward"/>
<action name="move_down">
	<input device="Microsoft X-Box 360 pad" state="2" min="-1024" max="1024"/>
</action>
<action name="move_forward"/>
<action name="move_left"/>
<action name="move_right"/>
<action name="move_up">
	<input device="Microsoft X-Box 360 pad" state="5" min="-1024" max="1024"/>
</action>
<action name="move_x">
	<input device="XBOX 360 For Windows (Controller)" state="0" min="-1024" max="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="0" min="-1024" max="1024"/>
	<input device="Microsoft X-Box 360 pad" state="1" min="-1024" max="1024"/>
</action>
<action name="move_y">
	<input device="XBOX 360 For Windows (Controller)" state="4" min="-1024" max="1024" neutral="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="4" min="-1024" max="1024" neutral="1024"/>
</action>
<action name="move_z">
	<input device="XBOX 360 For Windows (Controller)" state="1" min="-1024" max="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="1" min="-1024" max="1024"/>
	<input device="Microsoft X-Box 360 pad" state="0" min="-1024" max="1024"/>
</action>
<action name="run"/>
<action name="turn_pitch">
	<input device="XBOX 360 For Windows (Controller)" state="3" min="-900" max="900"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="3" min="-900" max="900"/>
	<input device="Microsoft X-Box 360 pad" state="3" min="-900" max="900"/>
</action>
<action name="turn_yaw">
	<input device="XBOX 360 For Windows (Controller)" state="2" min="-1200" max="1200"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="2" min="-1200" max="1200"/>
	<input device="Microsoft X-Box 360 pad" state="4" min="-1200" max="1200"/>
</action>
</controls>

 

and the def file looks like this.

<?xml version="1.0" encoding="utf-8"?>
<controls_def>
<action_def name="look_down" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_left" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_right" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_up" min="0" max="100" neutral="0" type="state"/>
<action_def name="move_backward" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_down" min="0" max="1024" neutral="0" type="state"/>
<action_def name="move_forward" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_left" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_right" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_up" min="0" max="1024" neutral="0" type="state"/>
<action_def name="move_x" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="move_y" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="move_z" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="run" min="0" max="1" neutral="0" type="state"/>
<action_def name="turn_pitch" min="-900" max="900" neutral="0" type="state"/>
<action_def name="turn_yaw" min="-1200" max="1200" neutral="0" type="state"/>
</controls_def>

 

so for example when I have the Microsoft X-Box 360 pad plugged in I shouldn't be receiving events for the move_y function. Since they apply to a different joystick I have gotten as far as querying each input to see if it has a device attached to filter out events but a lot of events that should have been attached to a device weren't. This is further complicated by the fact that for what ever reason the unattached move_y function is putting out the min value (-1024) rather than the neutral value (whatever I set it at). Any clues as to what can be done about this.

 

Also we tend to loose unattached devices when the file autosaves which in the case where we are keeping the same configuration but different devices between multiple machines is a massive PITA.

  • Like 1
Link to comment

We are working with two joystick configurations. One being an XBox360 wired controller and the others being XBox360 wireless controllers for windows - however this in principle could be any two joysticks.

The problem is that the drivers behave differently so they have to be configured slightly differently but events for the joystick that is not attached to the system appear to be being processed.

 

Config looks something like this. (note that the XBox360 controller has a different device string on windows Vista to what it does on Windows 7)

 

<?xml version="1.0" encoding="utf-8"?>
<controls definition="ai3d/config/controls/free.controls_def">
<action name="look_down"/>
<action name="look_left"/>
<action name="look_right"/>
<action name="look_up"/>
<action name="move_backward"/>
<action name="move_down">
	<input device="Microsoft X-Box 360 pad" state="2" min="-1024" max="1024"/>
</action>
<action name="move_forward"/>
<action name="move_left"/>
<action name="move_right"/>
<action name="move_up">
	<input device="Microsoft X-Box 360 pad" state="5" min="-1024" max="1024"/>
</action>
<action name="move_x">
	<input device="XBOX 360 For Windows (Controller)" state="0" min="-1024" max="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="0" min="-1024" max="1024"/>
	<input device="Microsoft X-Box 360 pad" state="1" min="-1024" max="1024"/>
</action>
<action name="move_y">
	<input device="XBOX 360 For Windows (Controller)" state="4" min="-1024" max="1024" neutral="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="4" min="-1024" max="1024" neutral="1024"/>
</action>
<action name="move_z">
	<input device="XBOX 360 For Windows (Controller)" state="1" min="-1024" max="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="1" min="-1024" max="1024"/>
	<input device="Microsoft X-Box 360 pad" state="0" min="-1024" max="1024"/>
</action>
<action name="run"/>
<action name="turn_pitch">
	<input device="XBOX 360 For Windows (Controller)" state="3" min="-900" max="900"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="3" min="-900" max="900"/>
	<input device="Microsoft X-Box 360 pad" state="3" min="-900" max="900"/>
</action>
<action name="turn_yaw">
	<input device="XBOX 360 For Windows (Controller)" state="2" min="-1200" max="1200"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="2" min="-1200" max="1200"/>
	<input device="Microsoft X-Box 360 pad" state="4" min="-1200" max="1200"/>
</action>
</controls>

 

and the def file looks like this.

<?xml version="1.0" encoding="utf-8"?>
<controls_def>
<action_def name="look_down" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_left" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_right" min="0" max="100" neutral="0" type="state"/>
<action_def name="look_up" min="0" max="100" neutral="0" type="state"/>
<action_def name="move_backward" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_down" min="0" max="1024" neutral="0" type="state"/>
<action_def name="move_forward" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_left" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_right" min="0" max="1" neutral="0" type="state"/>
<action_def name="move_up" min="0" max="1024" neutral="0" type="state"/>
<action_def name="move_x" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="move_y" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="move_z" min="-1024" max="1024" neutral="0" type="state"/>
<action_def name="run" min="0" max="1" neutral="0" type="state"/>
<action_def name="turn_pitch" min="-900" max="900" neutral="0" type="state"/>
<action_def name="turn_yaw" min="-1200" max="1200" neutral="0" type="state"/>
</controls_def>

 

so for example when I have the Microsoft X-Box 360 pad plugged in I shouldn't be receiving events for the move_y function. Since they apply to a different joystick I have gotten as far as querying each input to see if it has a device attached to filter out events but a lot of events that should have been attached to a device weren't. This is further complicated by the fact that for what ever reason the unattached move_y function is putting out the min value (-1024) rather than the neutral value (whatever I set it at). Any clues as to what can be done about this.

 

Also we tend to loose unattached devices when the file autosaves which in the case where we are keeping the same configuration but different devices between multiple machines is a massive PITA.

 

we are also getting issues with joystick events being processed even when no Joysticks are present on the system

Link to comment

I have had some success in filtering out non attached inputs by changing the get_max_input_state function in the Action class of the input script to filter out

unattached inputs. I have yet to see if this has any negative side effects.

 

			// Get input with maximum state value.
			Input get_max_input_state() {

				if(inputs.size() < 1) return NULL;
				// find maximum input value
				Input max_input = NULL;
				float max_state = -1.0;

				foreach(Input input; inputs) {

					if(input == NULL || input.getInputDevice() == NULL) continue;
					float state = abs(input.getState() - input.getNeutralStateValue());
					if(max_state < 0 || max_state < state) {
						max_state = state;
						max_input = input;
					}
				}

				return max_input;
			}

Link to comment

 

Config looks something like this. (note that the XBox360 controller has a different device string on windows Vista to what it does on Windows 7)

 

<...>
<action name="move_y">
	<input device="XBOX 360 For Windows (Controller)" state="4" min="-1024" max="1024" neutral="1024"/>
	<input device="Controller (Xbox 360 Wireless Receiver for Windows)" state="4" min="-1024" max="1024" neutral="1024"/>
</action>
<...>

 

and the def file looks like this.

<...>
<action_def name="move_y" min="-1024" max="1024" neutral="0" type="state"/>
<...>

 

so for example when I have the Microsoft X-Box 360 pad plugged in I shouldn't be receiving events for the move_y function. Since they apply to a different joystick I have gotten as far as querying each input to see if it has a device attached to filter out events but a lot of events that should have been attached to a device weren't.

 

we are also getting issues with joystick events being processed even when no Joysticks are present on the system

 

What do you mean by "receiving events"? Does it mean that you call Unigine::Input::Action::getState() method and receive non-neutral value?

All actions are updated every Unigine::Input::update() no matter if there is input device for it's inputs or not. However, those inputs which have no plugged devices keep their initial (neutral) value.

 

This is further complicated by the fact that for what ever reason the unattached move_y function is putting out the min value (-1024) rather than the neutral value (whatever I set it at). Any clues as to what can be done about this.

 

This was caused by another problem - you used non-zero neutral value for unattached input. There was a bug in our code and this case was handled incorrectly.

Try attached files, they should fix this problem.

 

Also we tend to loose unattached devices when the file autosaves which in the case where we are keeping the same configuration but different devices between multiple machines is a massive PITA.

 

This is fixed too.

 

I have had some success in filtering out non attached inputs by changing the get_max_input_state function in the Action class of the input script to filter out

unattached inputs. I have yet to see if this has any negative side effects.

 

			// Get input with maximum state value.
			Input get_max_input_state() {

				if(inputs.size() < 1) return NULL;
				// find maximum input value
				Input max_input = NULL;
				float max_state = -1.0;

				foreach(Input input; inputs) {

					if(input == NULL || input.getInputDevice() == NULL) continue;
					float state = abs(input.getState() - input.getNeutralStateValue());
					if(max_state < 0 || max_state < state) {
						max_state = state;
						max_input = input;
					}
				}

				return max_input;
			}

 

This fix should not do any harm. But it seems to me that the main problem was incorrectly handled neutral values.

 

If this will not help, please, provide more detailed description for bug reproduction: what steps you perform, what you get and what you expected.

action.h

input.h

input_dialog.h

Link to comment

What do you mean by "receiving events"? Does it mean that you call Unigine::Input::Action::getState() method and receive non-neutral value?

All actions are updated every Unigine::Input::update() no matter if there is input device for it's inputs or not. However, those inputs which have no plugged devices keep their initial (neutral) value.

 

I wasn't invoking any of this directly. I was accessing everything indirectly using the game framework script. We used the city level to figure out how to use it properly. In fact checking things we are using the GamePlayerComponentControl class pretty much unmodified.

 

This was caused by another problem - you used non-zero neutral value for unattached input. There was a bug in our code and this case was handled incorrectly.

Try attached files, they should fix this problem.

 

we were using zero neutral values... I decided to try non zero values to see what effect they had if any since the attached devices were sending a value of 0.5 when in the neutral state.

 

This is fixed too.

 

Thankyou very much :)

 

This fix should not do any harm. But it seems to me that the main problem was incorrectly handled neutral values.

 

If this will not help, please, provide more detailed description for bug reproduction: what steps you perform, what you get and what you expected.

 

I certainly will do.

Link to comment
×
×
  • Create New...