Erroneous Events fired by creating new DefaultControllerEnvironment

Behavior: Everytime I use the ControllerEnvironment class (and trigger the static-construction of the DefaultControllerEnvironment), I know these two things happen

1.) Because of my win32 system, the “DirectAndRawInputControllerEnvironment” is picked
2.) The DirectInputControllerEnvironment is set up
3.) The RawInputControllerEnvironment is set up

SOMEWHERE in those 3 steps, all buttons of all my controllers send off a “hello world” event (that is, they appear in the event queue) .
Sometimes they have value=0, sometimes value = 1. Sometimes they send a value=0 and then a nanosecond later again with value = 1.

They’re giving me problems, because I can’t tell them apart from actual events.

I’m thinking these erroneous events (because they are created everytime the environment is set back up, and are not triggered by button presses) are some sort of debugging, and I would like to know how to disable it

Thanks, I really love using this library!

Hi

It’s not something we’ve done on purpose. I suspect that it’s driver related. Some controllers are not very callibratable and fire off events all the time, one of my joysticks is never silent, but that’s the hardware, not JInput. If the events only happen on startup it’s not the same thing though. All I can suggest is that you try ignoring any events that happen in the first ‘x’ milliseconds, but it’s an odd one that I’ve not heard of before.
What OS are you using, and what device causes the problems?

Cheers

Endolf

Link to adapter: http://www.play-asia.com/paOS-13-71-6m-49-en-70-qc3.html
With a MadCatz dance pad
(I’m suspecting its the adapter, not the pad though lol) I’m on windows VISTA, but I get the same problem on my XP)

Here’s the offending code.


			Field defaultEnvironment;
			try { //Replace controllerenvironment with new one, unfortunately we can't dispose old one correctly till shutdown
				defaultEnvironment = ControllerEnvironment.class.getDeclaredField("defaultEnvironment");
				defaultEnvironment.setAccessible(true);
				defaultEnvironment.set(null,new DefaultControllerEnvironment()); //DefaultControllerEnvironment made public.
			} catch (Exception e){
				e.printStackTrace();
			}

This is the only way I’ve found to actually refresh the list of controllers.

Maybe one of the Win32 components created in the DirectInputControllernvironment is triggering the state info things whenever its created?

Here’s the debug:


Refreshed:71045.44189948
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
[HID Keyboard Device, HID Keyboard Device, HID-compliant mouse, Logitech Gaming Keyboard, Logitech Gaming Keyboard, G15 Keyboard, Dual USB Force Feedback Joypad (MP-8866), Dual USB Force Feedback Joypad (MP-8866), 4 axis 16 button joystick, 4 axis 16 button joystick]
rz: -0.007827878 @ 71045.93283804
z: -0.007827878 @ 71045.93334332
y: -0.007827878 @ 71045.93373372
x: -0.007827878 @ 71045.93407944
rz: -0.007827878 @ 71045.93718604
z: -0.007827878 @ 71045.93919352
y: -0.007827878 @ 71045.94007088
x: -0.007827878 @ 71045.94045692
slider: -1.0 @ 71045.9409122
slider: -1.0 @ 71045.94123924
rz: 1.0 @ 71045.94304308
z: 1.0 @ 71045.9433288
y: 1.0 @ 71045.94360948
x: 1.0 @ 71045.94386904
slider: -1.0 @ 71045.94459044
slider: -1.0 @ 71045.94500684

So, I execute the aforementioned code to refresh the controllers, and then this output comes. The Controller sending these is the “4 axis 16 button joystick” listed here (the superdualjoybox) The time is in seconds (nanos / 1e9)


My solution: Those “-0.007827878” in value() seem to be specific to the first few erroneous events: Whenever I press actual buttons, I get nice clean 0.0 and 1.0 results. So, solution: if you get -0.007827878, ignore the next event unless its also -0.007827878.

Nevermind. The one that works best is just ignoring input for a second or so. I grey-out the refresh button during this time to the user “gets it”.