InputHandler.BUTTON_NONE

Hello,



I'd like to take your attention to a little bug. jME's InputHandler class has an error. When i was trying to register a Keyboard Idle event with my custom inputhandler class, i've got an exception for InputHandler.BUTTON_NONE. The exception spreaded down to LWJGL's Keyboard system. Looked something like this:


ava.lang.IndexOutOfBoundsException
   at java.nio.Buffer.checkIndex(Unknown Source)
   at java.nio.DirectByteBuffer.get(Unknown Source)
   at org.lwjgl.input.Keyboard.isKeyDown(Keyboard.java:399)
   at com.jme.input.lwjgl.LWJGLKeyInput.isKeyDown(LWJGLKeyInput.java:73)
   at com.jme.input.KeyBindingManager.isValidCommand(KeyBindingManager.java:183)
   at com.jme.input.ActionTrigger$CommandTrigger.performAction(ActionTrigger.java:285)
   at com.jme.input.InputHandler.processTriggers(InputHandler.java:420)
   at com.jme.input.InputHandler.update(InputHandler.java:405)
   at main.State.update(State.java:197)
   at com.jmex.game.state.GameStateNode.update(GameStateNode.java:71)
   at com.jmex.game.StandardGame.update(StandardGame.java:323)
   at com.jmex.game.StandardGame.run(StandardGame.java:198)
   at java.lang.Thread.run(Unknown Source)



I took my chances and tracked down this filthy little bug. I went to KeybindingManager, InputHandler, ActionTrigger and so on, with no luck. Then I went to take a look at lwjgl's documentation. The "no-key" value for their Keyboard system is 0, InputHandler's no-key is -1. I switched BUTTON_NONE to 0 and that corrected the problem. Some dev might take a look at it too. 

Well it didnt solve the problem entirely…

I'm not getting my keyaction. I cant seem to find any other ways to implement the no-key button. Is that possible?

I'm not sure "idle" is a valid use case for the input system as written?

It's not a bug. You used the constant for a different method call it was meant for. It should never arrive at lwjgl calls. Which method did you use and which parameter did you pass the constant?

Okay, this is the problem:

When i press 'w' my charcter starts walking with a walking JointAnimation. The problem comes when i release the button. He should stop walking, but instead he keeps walking in one place. What i need is to disable the JointAnimation when i release 'w' or when there is no action. I'm looking for a way to achieve this.

LWJGL Keyboard seemed to have a KEY_NONE key, but that's not working either.

What you need is a release a event for your 'w' key. Have a look into TestInputHandler on how to get that. KEY_NONE or BUTTON_NONE will not help you here.

Many thanks, got it. And it was right under my nose again! Sorry to rob your time folks…