Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Erroneous Events fired by creating new DefaultControllerEnvironment  (Read 1483 times)
0 Members and 1 Guest are viewing this topic.
Offline taifunbrowser

Senior Newbie





« Posted 2008-07-17 07:01:34 »

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!

http://beam.to/jtouhou - the JTouhou project! Mixed 3d and 2d, a multiplatform port for the classic dojin-soft series by Shanghai alice!
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #1 - Posted 2008-07-17 08:23:10 »

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

Offline taifunbrowser

Senior Newbie





« Reply #2 - Posted 2008-07-17 15:39:37 »

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.
1  
2  
3  
4  
5  
6  
7  
8  
         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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
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".

http://beam.to/jtouhou - the JTouhou project! Mixed 3d and 2d, a multiplatform port for the classic dojin-soft series by Shanghai alice!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (32 views)
2014-07-18 06:55:21

Zero Volt (28 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (25 views)
2014-07-16 23:30:00

Cero (40 views)
2014-07-16 00:42:17

Riven (42 views)
2014-07-14 18:02:53

OpenGLShaders (29 views)
2014-07-14 16:23:47

Riven (29 views)
2014-07-14 11:51:35

quew8 (26 views)
2014-07-13 13:57:52

SHC (63 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!