Input system

So I was rewriting my jME 2 GUI System for jME 3, and I noticed a rather stupid thing v/the MouseButtonEvent (and possibly the KeyInputEvent??).

isDown() is the exact same thing as isPressed() ?

isReleased() is the exact opposite of the two above.



Feel free to correct me if I'm wrong.


  • Mikkel



    EDIT: I'm refering to the RawInputListener.

isPressed() tells you if the key was pressed, isReleased() tells you if it was released and isRepeating() (in the latest SVN) tells you if it's a repeat event (e.g holding down the key).



In other words, the moment a key is pressed you will get an event with isPressed() = true, then while it is held down, you will get an event with isRepeating() = true, then the moment it is released you will get isReleased() = true.

Momoko_Fan said:

isPressed() tells you if the key was pressed, isReleased() tells you if it was released and isRepeating() (in the latest SVN) tells you if it's a repeat event (e.g holding down the key).

In other words, the moment a key is pressed you will get an event with isPressed() = true, then while it is held down, you will get an event with isRepeating() = true, then the moment it is released you will get isReleased() = true.


Aww I did my own isRepeating() system :p
So you removed the isDown()?
And I believe I get it though.. Events are triggered once the flags are activated, which is why there's an isPressed() and isReleased() (even though !isPressed() = isReleased())

- Mikkel

EDIT: I only see isRepeating() for the KeyInputEvent (from which you removed the isDown() flag, yaah),
Shouldn't the MouseButtonEvent have the same feature?
For instance: Shooter games.

The repeat events are strictly for typing, it uses the OS defined settings. Like for example when you press a letter on the keyboard, it appears on the screen and then after a few seconds it just starts repeating. This is how typing works and that's what the isRepeating() flag is for.

For mouse buttons, they are not used for typing, if you want to know if a mouse is pressed or not just wait till you get an event with isPressed() = true, set some flag like mouseButtonPressed, when you get event with isReleased() = true you set that flag to false. Now in your game's update method you just check mouseButtonPressed and do the shooting.

Actually, what I said is wrong :stuck_out_tongue: you're only permitted to use the RawMouseListener for GUI systems, so the scenario with the shooter wont happen. Non-GUI things should use the BindingListener interface. With that its a lot simpler, you just register a binding for the mouse button, and in the listener you will get a callback every update that the mouse button is pressed.

Momoko_Fan said:

The repeat events are strictly for typing, it uses the OS defined settings. Like for example when you press a letter on the keyboard, it appears on the screen and then after a few seconds it just starts repeating. This is how typing works and that's what the isRepeating() flag is for.
For mouse buttons, they are not used for typing, if you want to know if a mouse is pressed or not just wait till you get an event with isPressed() = true, set some flag like mouseButtonPressed, when you get event with isReleased() = true you set that flag to false. Now in your game's update method you just check mouseButtonPressed and do the shooting.
Actually, what I said is wrong :P you're only permitted to use the RawMouseListener for GUI systems, so the scenario with the shooter wont happen. Non-GUI things should use the BindingListener interface. With that its a lot simpler, you just register a binding for the mouse button, and in the listener you will get a callback every update that the mouse button is pressed.


Ah.. I see. :)
I noticed the small delay as well, and was like yah :p Saved me some time.
Well thanks.

This is what I spend my day doing using the great jME3 engine! ;)







It puzzels me that jME isn't more famous..
Mikkel said:

Ah.. I see. :)
I noticed the small delay as well, and was like yah :p Saved me some time.
Well thanks.

This is what I spend my day doing using the great jME3 engine! ;)


It puzzels me that jME isn't more famous..

Cool! Although I gotta ask, why aren't you using the well-supported NiftyGUI engine included with jME3?
jME is actually quite famous, its just that most people think its dead (after josh left jme2), and jME3 hasn't had an official release yet.
Momoko_Fan said:

Mikkel said:

Ah.. I see. :)
I noticed the small delay as well, and was like yah :p Saved me some time.
Well thanks.

This is what I spend my day doing using the great jME3 engine! ;)


It puzzels me that jME isn't more famous..

Cool! Although I gotta ask, why aren't you using the well-supported NiftyGUI engine included with jME3?
jME is actually quite famous, its just that most people think its dead (after josh left jme2), and jME3 hasn't had an official release yet.


That would be boring now wouldn't it? :p
Ah.. I see. Lets hope for a "resurrection" w/the official release then :)

- Mikkel