JInput ERROR : Failed to poll device: Failed to get device key states (9)

Hello!

My computer has “twin usb joysticks”, thats two gamepads on one usb2 connector.
I keep receiving the following error from JInput.

Failed to poll device: Failed to get device key states (9)

Im on a demo run with “ReadAllEvents” source.
My Gamepad 1 stops being operative with JInput usually when polling all components.

everything works about 3 sec or to 30 sec then the gamepad 1 fails permanently and i need to restart my JInput program.

//----

Thanks,

I have no school history for Java or computers.
Im planning to use JOGL + JNLPAPPLETLAUNCHER + JINPUT with my Java game projects to amuse my friends.

The JOGL is the only library i ever added with Java,
the JOGL comes as a Netbeans plugin so it has always have been very easy to add to Netbeans.

Now when i have an attempt to add JINPUT to JOGL Applet, i need help.
Could someone please inform me how to add both JINPUT and JOGL to JNLPAPPLETLAUNCHER Applet.

I have two problems ->

(1) I seem not to have permission to use JINPUT from my JNLPLauncher ??
(2) I dont know how to set java.library.path when there is JOGL included on Netbeans 6.5.1 project, i only
receive jinput not on java.library.path. I think that JOGL takes the library.path, how to set one path for both.

I have Linux Ubuntu 9.04 OS + Netbeans 6.5.1 + JOGL Plugin + JInput.

//----

Thanks,

Hi,

[quote]I dont know how to set java.library.path when there is JOGL included on Netbeans 6.5.1 project
[/quote]
lets say you want to run your jinput/jogl project from within your IDE (not webstart).
-Just open the run configuration (the combo box on the toolbar on top of NetBeans) and choose ‘Customize’.
-select the ‘Run’ item in the tree.
-Now you can enter additional vm arguments in the ‘VM Arguments’ textfield :wink:
e.g -java.library.path=“lib/jinput”

(you can add more run configurations to the same project just hit new and give them a name…)

[quote]Now when i have an attempt to add JINPUT to JOGL Applet, i need help.
[/quote]
I don’t know if there is a public server or jnlp extension available which hosts jinput for you (maybe someone else can help here). In worst case you will have to host jinput on your own server.

lets say you are using a jogl project template from the OpenGL Pack and already successfully enabled webstart support in project properties.
-you should find a file called ‘master-application.jnlp’ in your project folder -> open it
-add

<jar href="jinput.jar"/>

somewhere between and
-add:

  <resources os="Windows" arch="x86_64 x86">
    <nativelib href="jinput-windows-native.jar"/>
  </resources>
  <resources os="Linux" arch="i386 ia64 x84_64">
    <nativelib href="jinput-linux-native.jar"/>
  </resources>
  <resources os="Mac OS">
    <nativelib href="jinput-osx-native.jar"/>
  </resources>

somewhere after the tag which is already there by default.

after a rebuild your project should be ready for webstart/applet deployment, at least on java 6u10 or later.

hope that helps.

The first question.

This sounds very much a linux/hardware issue to me, I don’t have access to many devices, so I go on what the API suggests. You could try getting the JInput source and doing some extra debugging for us. Does the device work in X? I’m guessing you have turned off the auto enable features for the device in your x config?

What does the text test show?, does it show the right device(s) with the right features?

Endolf

Hei!

Right device names are for sure, i dont know for buttons, their a bit strange,
i dont have button1 button2 button3 and so on, i have BASE, PINKIE, THUMB, TOP, TRIGGER,
and for directions my stick has “x , y , z , rz”.

I have graphics display on, on my Ubuntu 9.04 desktop, with OpenGL support.

Im not very experienced Linux dude, i dont know about “auto enable features”.

//----

Thanks,

Hi

Can you copy the output from text test for the relevant devices?, you mention that it’s 2 gamepads, do both show up right?

Endolf

Here you go!

run:
Controller Env = net.java.games.input.DefaultControllerEnvironment@42e816
Loading: net.java.games.input.LinuxEnvironmentPlugin
Failed to open device (/dev/input/event9): Failed to open device /dev/input/event9 (13)

Failed to open device (/dev/input/event8): Failed to open device /dev/input/event8 (13)

Failed to open device (/dev/input/event7): Failed to open device /dev/input/event7 (13)

Failed to open device (/dev/input/event4): Failed to open device /dev/input/event4 (13)

Failed to open device (/dev/input/event2): Failed to open device /dev/input/event2 (13)

Failed to open device (/dev/input/event1): Failed to open device /dev/input/event1 (13)

Failed to open device (/dev/input/event0): Failed to open device /dev/input/event0 (13)

Failed to open device (/dev/input/js1): Failed to get button map (22)

Failed to open device (/dev/input/js0): Failed to get button map (22)

Linux plugin claims to have found 5 controllers
A4Tech PS/2+USB Mouse
Type: Mouse
Component Count: 13
Component 0: Left
    Identifier: Left
    ComponentType: Absolute Digital
Component 1: Right
    Identifier: Right
    ComponentType: Absolute Digital
Component 2: Middle
    Identifier: Middle
    ComponentType: Absolute Digital
Component 3: Side
    Identifier: Side
    ComponentType: Absolute Digital
Component 4: Extra
    Identifier: Extra
    ComponentType: Absolute Digital
Component 5: Forward
    Identifier: Forward
    ComponentType: Absolute Digital
Component 6: Back
    Identifier: Back
    ComponentType: Absolute Digital
Component 7: Unknown
    Identifier: Unknown
    ComponentType: Absolute Digital
Component 8: x
    Identifier: x
    ComponentType: Relative Analog
Component 9: y
    Identifier: y
    ComponentType: Relative Analog
Component 10: slider
    Identifier: slider
    ComponentType: Relative Analog
Component 11: z
    Identifier: z
    ComponentType: Relative Analog
Component 12: slider
    Identifier: slider
    ComponentType: Relative Analog
---------------------------------
ImExPS/2 Generic Explorer Mouse
Type: Mouse
Component Count: 9
Component 0: Left
    Identifier: Left
    ComponentType: Absolute Digital
Component 1: Right
    Identifier: Right
    ComponentType: Absolute Digital
Component 2: Middle
    Identifier: Middle
    ComponentType: Absolute Digital
Component 3: Side
    Identifier: Side
    ComponentType: Absolute Digital
Component 4: Extra
    Identifier: Extra
    ComponentType: Absolute Digital
Component 5: x
    Identifier: x
    ComponentType: Relative Analog
Component 6: y
    Identifier: y
    ComponentType: Relative Analog
Component 7: slider
    Identifier: slider
    ComponentType: Relative Analog
Component 8: z
    Identifier: z
    ComponentType: Relative Analog
---------------------------------
Twin USB Joystick
Type: Stick
Component Count: 17
Component 0: Trigger
    Identifier: Trigger
    ComponentType: Absolute Digital
Component 1: Thumb
    Identifier: Thumb
    ComponentType: Absolute Digital
Component 2: Thumb 2
    Identifier: Thumb 2
    ComponentType: Absolute Digital
Component 3: Top
    Identifier: Top
    ComponentType: Absolute Digital
Component 4: Top 2
    Identifier: Top 2
    ComponentType: Absolute Digital
Component 5: Pinkie
    Identifier: Pinkie
    ComponentType: Absolute Digital
Component 6: Base
    Identifier: Base
    ComponentType: Absolute Digital
Component 7: Base 2
    Identifier: Base 2
    ComponentType: Absolute Digital
Component 8: Base 3
    Identifier: Base 3
    ComponentType: Absolute Digital
Component 9: Base 4
    Identifier: Base 4
    ComponentType: Absolute Digital
Component 10: Base 5
    Identifier: Base 5
    ComponentType: Absolute Digital
Component 11: Base 6
    Identifier: Base 6
    ComponentType: Absolute Digital
Component 12: x
    Identifier: x
    ComponentType: Absolute Analog
Component 13: y
    Identifier: y
    ComponentType: Absolute Analog
Component 14: z
    Identifier: z
    ComponentType: Absolute Analog
Component 15: rz
    Identifier: rz
    ComponentType: Absolute Analog
Component 16: pov
    Identifier: pov
    ComponentType: Absolute Digital
---------------------------------
Twin USB Joystick
Type: Stick
Component Count: 17
Component 0: Trigger
    Identifier: Trigger
    ComponentType: Absolute Digital
Component 1: Thumb
    Identifier: Thumb
    ComponentType: Absolute Digital
Component 2: Thumb 2
    Identifier: Thumb 2
    ComponentType: Absolute Digital
Component 3: Top
    Identifier: Top
    ComponentType: Absolute Digital
Component 4: Top 2
    Identifier: Top 2
    ComponentType: Absolute Digital
Component 5: Pinkie
    Identifier: Pinkie
    ComponentType: Absolute Digital
Component 6: Base
    Identifier: Base
    ComponentType: Absolute Digital
Component 7: Base 2
    Identifier: Base 2
    ComponentType: Absolute Digital
Component 8: Base 3
    Identifier: Base 3
    ComponentType: Absolute Digital
Component 9: Base 4
    Identifier: Base 4
    ComponentType: Absolute Digital
Component 10: Base 5
    Identifier: Base 5
    ComponentType: Absolute Digital
Component 11: Base 6
    Identifier: Base 6
    ComponentType: Absolute Digital
Component 12: x
    Identifier: x
    ComponentType: Absolute Analog
Component 13: y
    Identifier: y
    ComponentType: Absolute Analog
Component 14: z
    Identifier: z
    ComponentType: Absolute Analog
Component 15: rz
    Identifier: rz
    ComponentType: Absolute Analog
Component 16: pov
    Identifier: pov
    ComponentType: Absolute Digital
---------------------------------
Macintosh mouse button emulation
Type: Mouse
Component Count: 5
Component 0: Left
    Identifier: Left
    ComponentType: Absolute Digital
Component 1: Right
    Identifier: Right
    ComponentType: Absolute Digital
Component 2: Middle
    Identifier: Middle
    ComponentType: Absolute Digital
Component 3: x
    Identifier: x
    ComponentType: Relative Analog
Component 4: y
    Identifier: y
    ComponentType: Relative Analog
---------------------------------
BUILD SUCCESSFUL (total time: 0 seconds)

Everything is allways found :slight_smile:

I now have modified the “readallevents”,.
This next code still gives the error, but unlike on “readallevents”
i can still have succes with a use of both sticks. ( they both are found as a sticks,
even if they are gamepads )

 public void gamepads ( )
  {
        Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();

        for (int i = 0; i < controllers.length; i++)
            {
                    controllers[i].poll();
                    net.java.games.input.EventQueue queue = controllers[i].getEventQueue();

                    Event event = new Event();

                    while (queue.getNextEvent(event))
                    {
                        Component comp = event.getComponent();
                      
                        if ( ( controllers[i].getType()==Controller.Type.STICK ) && ( comp.getName()=="x") ) leri = event.getValue();
                        if ( ( controllers[i].getType()==Controller.Type.STICK ) && ( comp.getName()=="y") ) updo = -event.getValue();

                        System.out.println( comp.getName());
                        System.out.println( event.getValue());
                    }
    		}
  }

//----

Thanks,

Hello!

I still every 8th - 20th run on my applet, receive this Failed to get device key states (9).
My code is completely updated and completely different than previously.

Still, sometimes my second gamepad is not enabled, why is this ??
Is there a known bugs with JINPUT ??

my code ->


       Controller [] controller = new Controller [10];
-------------
        try
        {
            Controllers.create();
            for ( int aa=0; aa<10; ++aa )
                controller [aa] = Controllers.getController (aa);
        } catch(Exception e)
        {
            System.err.println("GamePad create fail.");
        }
-------------
    public void _GamePads ()
    {        
        if(controller[0]!=null)
        {
            leri  = -controller[0].getXAxisValue();
            leri2 = -controller[0].getRZAxisValue();
        }
        for ( int aa=1;aa<10; ++aa)
            if(controller[aa]!=null)
            {
                leri3 = -controller[aa].getXAxisValue();
                leri4 = -controller[aa].getRZAxisValue();
            }
    }
}
-------------
Controllers.destroy();


Is there any programming errors on my simple code ??

Hmpf, Do i have an hardware failure ?? or is this error common with JInput ??

//----

Thanks,

when using applets with natives, do make sure you use the

<param name="separate_jvm" value="true">

tag inside the applet tag, it avoids many problems that can happen with natives + same vm.

Hello!

Here is my current applet tag, is there anything i should add or remove ??

 <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar, lzma.jar, kuvat.jar" codebase="." width="98%" height="98%">
  
    <!-- The following tags are mandatory -->
    
    <!-- Name of Applet, will be used as name of directory it is saved in, and will uniquely identify it in cache -->
    <param name="al_title" value="Empty Screen">
    
    <!-- Main Applet Class -->
    <param name="al_main" value="test004.Main">
    
    <!-- logo to paint while loading, will be centered -->
    <param name="al_logo" value="appletlogo2.png">
    
    <!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done -->
    <param name="al_progressbar" value="appletprogress3.gif">
    
    <!-- List of Jars to add to classpath -->
    <param name="al_jars" value="IlmojeinPilotit_00001.jar lwjgl_applet.jar.pack.lzma, lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma, res.jar.lzma">
   
    <!-- signed windows natives jar in a jar --> 
    <param name="al_windows" value="windows_natives.jar.lzma">
    
    <!-- signed linux natives jar in a jar --> 
    <param name="al_linux" value="linux_natives.jar.lzma">
    
    <!-- signed mac osx natives jar in a jar --> 
    <param name="al_mac" value="macosx_natives.jar.lzma">

    <!-- signed solaris natives jar in a jar --> 
    <param name="al_solaris" value="solaris_natives.jar.lzma">
    
    <!-- Tags under here are optional -->
    
    <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float -->
    <!-- <param name="al_version" value="0.1"> -->
    
    <!-- background color to paint with, defaults to white -->
    <!-- <param name="al_bgcolor" value="000000"> -->
    
    <!-- foreground color to paint with, defaults to black -->
    <!-- <param name="al_fgcolor" value="ffffff"> -->
    
    <!-- error color to paint with, defaults to red -->
    <!-- <param name="al_errorcolor" value="ff0000"> -->
    
    <!-- whether to run in debug mode -->
    <!-- <param name="al_debug" value="true"> -->	
    
    <!-- whether to prepend host to cache path - defaults to true -->
    <param name="al_prepend_host" value="false">    
    <param name="separate_jvm" value="true">
  </applet>

//----

Thanks,

The applet tag looks fine.

However best to leave al_prepend_host parameter as true or commented out, unless you have a special need for it, only then change it to false.

btw does adding separate_jvm parameter fix the jinput issue?

Aaah, so it’s not every run that it fails?, in that case, I would suspect that either a process has the event device file open (program didn’t finish nicely), or the device driver is funny or something, but JInput shouldn’t be behaving differently on different runs.

Endolf