Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (488)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Failed to poll device: Device is released??  (Read 3855 times)
0 Members and 1 Guest are viewing this topic.
Offline HermanssoN

Senior Newbie





« Posted 2009-10-05 17:40:01 »

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:
1  
Failed to poll device: Device is released

I'm trying to get the mouse movement using this loop:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
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
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #1 - Posted 2009-10-05 18:06:48 »

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

Offline HermanssoN

Senior Newbie





« Reply #2 - Posted 2009-10-05 18:10:12 »

Ok I made some more tests:

the pooling now looks like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
 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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HermanssoN

Senior Newbie





« Reply #3 - Posted 2009-10-05 18:13:19 »

Oh we posted at the same time Smiley
I fixed the double  m_deltaMouse.y = x. Very clumsy of me Sad
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
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);
         }
               
      }

Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #4 - Posted 2009-10-05 18:21:59 »

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

Offline HermanssoN

Senior Newbie





« Reply #5 - Posted 2009-10-05 18:28:07 »

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

Senior Newbie





« Reply #6 - Posted 2009-10-05 18:57:27 »

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:
1  
2  
3  
4  
5  
public static void main( String[]args)
{
      System.setProperty("jinput.plugins", "net.java.games.util.plugins.test.PluginTest");  
      PluginTest.main(args);
}


I got this message:
1  
2  
3  
4  
5  
6  
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)
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #7 - Posted 2009-10-06 05:58:07 »

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

Offline HermanssoN

Senior Newbie





« Reply #8 - Posted 2009-10-06 14:31:41 »

I found the error.

I used following before creatingmy controlls
1  
System.setProperty("jinput.plugins", "net.java.games.input.DirectInputEnvironmentPlugin");

If I remove that no erros occure.
Offline HermanssoN

Senior Newbie





« Reply #9 - Posted 2009-10-06 14:43:54 »

Also worth mentioning is that if I use this loop when polling the mouse evry thing works perfectly:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
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,:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
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;  
           
         }
         
      }



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #10 - Posted 2009-10-06 16:16:54 »

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

HTH

Endolf

Offline HermanssoN

Senior Newbie





« Reply #11 - Posted 2009-10-06 18:52:59 »

Same story  Huh
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. :/
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #12 - Posted 2009-10-07 06:04:57 »

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

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.

TehJavaDev (17 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (69 views)
2014-08-11 02:49:23

BurntPizza (46 views)
2014-08-09 21:09:32

BurntPizza (37 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!