Failed to poll device: Device is released??

Hello, I’m trying to implement Mouse input. I’ve brought up the topic in another thread when asking questions about the keyboard. The reason I made a whole new thread is caus Iv’e got the error:

Failed to poll device: Device is released

I’m trying to get the mouse movement using this loop:


m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
                                //boolean hash map
				m_mouseDown.put(c.getIdentifier(), true);
				//deadZone is always 0.0...
                                m_deltaMouse.x = m_mouse.getX().getPollData();
				m_deltaMouse.x = m_mouse.getY().getPollData();
								
			}
			else
			{
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
				m_deltaMouse.x = 0.0f;
				m_deltaMouse.x = 0.0f;
			}
					
		}

in my main loop I print the values to the output console in Eclipse and get:

Failed to poll device: Device is released
Failed to poll device: Device is released
delta mouse x : 0.0
delta mouse y : 0.0
Failed to poll device: Device is released
Failed to poll device: Device is released
delta mouse x : 0.0
delta mouse y : 0.0
Failed to poll device: Device is released
Failed to poll device: Device is released
delta mouse x : 0.0
and so on...

It seems like JInput looses and regains contact wit my mouse??

I’m using windows xp, and the mouse is a Razer Krait

You’re mixing event queues and the old way, get the value of the axis from the event and update your map from that. You’re also update m_deltaMouse.x twice instead of x and then y.

Do you have other applications running at the same time?, JInput doesn’t like it if other apps steal the devices.

Endolf

Ok I made some more tests:

the pooling now looks like this:


m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
				m_mouseDown.put(c.getIdentifier(), true);
				
								
			}
			else
			{
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
							}
					
		}
		m_deltaMouse.x = m_mouse.getX().getPollData();
		m_deltaMouse.y = m_mouse.getY().getPollData();

No bigg change:

the test app now looks like this:


 JFrame f = new JFrame("This is a test");
	    int sizeX = 400;
	    int sizeY = 400;
	    f.setSize(sizeX, sizeY);
	   
	    Container content = f.getContentPane();
	    
	    content.setBackground(Color.white);
	    f.addWindowListener(new ExitListener());
	    f.setVisible(true);
	    
	    
	    while( true )
	    {
	    	SharkInput.getInstance().capture();
	    	if( SharkInput.getInstance().getKeyboard().isKeyDown(Identifier.Key.Q))
	    	{
	    		System.exit(0);
	    		break;
	    	}
	    	float dx = SharkInput.getInstance().getMouse().getDelta().x;
	    	float dy = SharkInput.getInstance().getMouse().getDelta().y;
	    	if(dx  != 0.0f || dy  != 0.0f)
	    	{
	    		sizeX += dx;
	    		sizeY += dy;
	    		
	    		f.setSize(sizeX,sizeY);
	    	}
	    		    	
	    }
		
	}

The window should resize after my mouse movement and it does. But I still get the : Failed to poll device: Device is released.
Is it normal to get that? cause it seems to work.
And I guess using eclipse ouput don’t give me the correct readning, most likley to many update per second. The out put will be filled instantly.

Oh we posted at the same time :slight_smile:
I fixed the double m_deltaMouse.y = x. Very clumsy of me :frowning:
but the eror message still is spammed?

well eclipse is running of course, Windows media player and Google Chrome.

polling like this makes no differance:


m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
				m_mouseDown.put(c.getIdentifier(), true);
				m_deltaMouse.x = m_mouse.getX().getPollData();
				m_deltaMouse.y = m_mouse.getY().getPollData();
								
			}
			else
			{
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
			}
					
		}

Hi

I’ve only ever seen that message when something has gone wrong, I have no idea off the top of my head why it’s doing that. I was thinking of other apps that might want the mouse through directx, but that doesn’t seem to be the case. Hmm.

Can you run the controller text test and post what falls out of it?

Thanks

Endolf

I’m faitly new to Java and JINput, how do I run it.
I got the jinput-test folder.

I didn’t realize that it was a class in the JInput API, I tought it was an executable.

anyways, I don’t understand how to use it, I tryed this:


public static void main( String[]args)
{
		System.setProperty("jinput.plugins", "net.java.games.util.plugins.test.PluginTest");	
		PluginTest.main(args);
}

I got this message:


java.io.FileNotFoundException: Plugin directory test_plugins not found.
	at net.java.games.util.plugins.Plugins.scanPlugins(Plugins.java:82)
	at net.java.games.util.plugins.Plugins.<init>(Plugins.java:76)
	at net.java.games.util.plugins.test.PluginTest.<init>(PluginTest.java:92)
	at net.java.games.util.plugins.test.PluginTest.main(PluginTest.java:119)
	at Application.main(Application.java:56)

Hi

The first post in the getting started thread will show you how to run the tests. You can always look at that thread to see how to use the event queue correctly too. Or you can look at the tests that are in the sources.

HTH

Endolf

I found the error.

I used following before creatingmy controlls


System.setProperty("jinput.plugins", "net.java.games.input.DirectInputEnvironmentPlugin");

If I remove that no erros occure.

Also worth mentioning is that if I use this loop when polling the mouse evry thing works perfectly:

m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
				m_mouseDown.put(c.getIdentifier(), true);
				
								
			}
			else
			{
				
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
			}
					
		}
		m_deltaMouse.x = m_mouse.getX().getPollData();
		m_deltaMouse.y = m_mouse.getY().getPollData();

If I use this version delta mouse won’t be set to 0.0f when mouse is still:


m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
				m_mouseDown.put(c.getIdentifier(), true);
				m_deltaMouse.x = m_mouse.getX().getPollData();
				m_deltaMouse.y = m_mouse.getY().getPollData();
								
			}
			else
			{
				
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
				m_deltaMouse.x = 0.0f;
				m_deltaMouse.y = 0.0f;
			}
					
		}

I allso tryed to get all data from the event as you mentioned above, when pointing out that I was mixing the old polling with the newer queue system, but the result is the same as the atempt above,:


m_mouse.poll();
				
		m_mouseQueue = m_mouse.getEventQueue();
		Event event = new Event();
		while( m_mouseQueue.getNextEvent(event))
		{
			Component c = event.getComponent();
			float data = c.getPollData();
			if(data != 0.0f )
			{
				m_mouseDown.put(c.getIdentifier(), true);
				
				if( c.getIdentifier() == Identifier.Axis.X)
					m_deltaMouse.x = c.getPollData();	
				
				if( c.getIdentifier() == Identifier.Axis.Y)
				m_deltaMouse.y = c.getPollData();	
			}
			else
			{
				m_mouseDown.put(event.getComponent().getIdentifier(), false);
				
				if( c.getIdentifier() == Identifier.Axis.X)
					m_deltaMouse.x = 0.0f;	
				
				if( c.getIdentifier() == Identifier.Axis.Y)
				m_deltaMouse.y = 0.0f;	
				
			}
			
		}

Instead of calling c.getPollData(), try event.getValue()

HTH

Endolf

Same story ???
It seems like I don’t recive any event for mouse stop.
I tried to switch to another mouse but no change there either. I got a steady -1 in x and y. :confused:

Hi

Nope, the mouse doesn’t stop. It’s a relative device not an absolute one. If you get no event from it in a poll cycle the it didn’t move. It’s a discussion that has come up before, we could fake a ‘it didn’t move’ event, but then you’d see that every poll, unless we did more fiddling. We decided that JInput should probably expose what the device says, and let users of the JInput API decide what they wish to do.

On the other hand, it’s something that I don’t like either, but I’m not sure I like faking it either.

Endolf