jInput returns 0.0 as position under Windows 7

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.

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
[/quote]
Output on Win764bit:

[quote]1392124909590 true HID-compliant mouse: Unknown: 0: 0.0/0.0
[/quote]
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.

java -Djava.library.path=. -cp jinput.jar:jinput-test.jar net.java.games.input.test.ControllerReadTest

Thanks in advance.

Greetings

Hi

Is it reproducible only with this mouse?

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

Hi,

I found the problem…

The class needs to extend from JFrame…

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

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

Don’t ask me…

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

... 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…