Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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  
  jInput returns 0.0 as position under Windows 7  (Read 1289 times)
0 Members and 1 Guest are viewing this topic.
Offline rplc

Junior Newbie


Exp: 4 years



« Posted 2014-02-11 13:34:56 »

Hi guys,

I've got a problem running jInput on Windows 7. I've downloaded jInput from http://ci.newdawnsoftware.com/job/JInput/2119/artifact/dist/.

If I run the scala code below on Linux 64 bit everything works fine and I get the positions of the mice. (If I run it as sudo.)
If I run the code on Windows 7 64 bit I just get 0.0 as positions of the mice.


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  
private class JInputTest() {

  private val pause = 20
  private var mice: List[Mouse] = Nil
  private val ca = ControllerEnvironment.getDefaultEnvironment.getControllers
  println(Version.getVersion)

  for (c <- ca) {
    println(c.getName + " " + c.getType + " " + c.getPortType)
    if (c.getType == Type.MOUSE)
      mice = c.asInstanceOf[Mouse] :: mice
  }
  println(mice.size)

  loopie()

  private def loopie() {
    val in = System.currentTimeMillis()
    for (m <- mice) {
      val erg = m.poll()

      println(in + " " +  erg + " " + m.getName + ": " +   m.getPortType + ": " + m.getPortNumber + ": " +  m.getX.getPollData + "/" + m.getY.getPollData)
    }

    val delay = (System.currentTimeMillis() - in).toInt

    Thread.sleep(pause - delay)

    loopie()
  }
}


Output on Linux64bit (Ubuntu 13.10):
Quote
1392125100588 true PixArt USB Optical Mouse: USB: Port 2: 1.0/-8.0

Output on Win764bit:
Quote
1392124909590 true HID-compliant mouse: Unknown: 0: 0.0/0.0

Does anyone have a clue, why I won't get a realistic output on Win7?

Another strange thing: The demo application below runs smooth on both OS and returns realistic outputs.
1  
java -Djava.library.path=. -cp jinput.jar:jinput-test.jar net.java.games.input.test.ControllerReadTest


Thanks in advance.

Greetings
Offline gouessej
« Reply #1 - Posted 2014-02-11 16:32:56 »

Hi

Is it reproducible only with this mouse?

Offline rplc

Junior Newbie


Exp: 4 years



« Reply #2 - Posted 2014-02-11 22:12:53 »

Hi,

I've tested 3 different mice on Win7. The same error with all 3. (And I've tested it not only one. Wink )

The same 3 mice are running without any problems on Linux.

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

Junior Newbie


Exp: 4 years



« Reply #3 - Posted 2014-02-12 08:23:57 »

Hi,

I found the problem...

The class needs to extend from JFrame...

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  
34  
35  
private class JInputTest() extends JFrame {

  private val pause = 20
  private var mice: List[Controller] = Nil
  private val ca = ControllerEnvironment.getDefaultEnvironment.getControllers
  println(Version.getVersion)

  for (c <- ca)
    if (c.getType == Type.MOUSE)
      mice = c :: mice

  pack()
  setSize(400, 400)
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
  setVisible(true)

  loopie()

  private def loopie() {
    val in = System.currentTimeMillis()
    for (m <- mice) {
      val erg = m.poll()

      val x = m.getComponent(Identifier.Axis.X)
      val y = m.getComponent(Identifier.Axis.Y)
      println(in + " " +  erg + " " + m.getName + ": " +   m.getPortType + ": " + m.getPortNumber + ": " +  x.getPollData + "/" + y.getPollData)
    }

    val delay = (System.currentTimeMillis() - in).toInt

    Thread.sleep(pause - delay)

    loopie()
  }
}


Greetings
Offline jonjava
« Reply #4 - Posted 2014-02-12 08:29:46 »

Wait, what? Why would it need to extend JFrame?

Offline rplc

Junior Newbie


Exp: 4 years



« Reply #5 - Posted 2014-02-12 09:02:40 »

Don't ask me...

I just added the JFrame part, i.e.:

1  
2  
3  
4  
5  
6  
... extends JFrame
...
pack()
setSize(400, 400)
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
setVisible(true)


and now it works.

Would be great, if there is another solution but I have no clue...

If I remove this, it won't work...
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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!