Joystick Button States

Hey everyone. I am trying to create some joystick controls.
I am connecting my Joystick sensor with my python module.
I get the sensor and can access the joystick via:

c = bge.logic.getCurrentController()
buttonJump = c.sensors[‘joystickSensor’]

if buttonJump.positive:

I can see if my button is positive or not. But how can I get states like “just pressed”, “pressed” or “released”?
For Keyboardinputs this is no problem. I can get states from 0-3 which indicate the mentioned behaviors.
Does anyone have some Ideas?

I have found this:
getButtonStatus(buttonIndex)
But this function gives only True or False :frowning:

Greetings ndee
(btw. Charlie is making good progress… ^^ So you can asume this Joystick inputs are for “CharliesBigAdventure”)

I think SolarLune was planning on making something that tells you exactly what you’re looking for - whether he made it or not I don’t know. I think you should PM him, but his Inbox is full at the moment. Also, it’s awesome your adding Joystick support for CBA (haha CBA).

you could use a bool property. so if the button is pressed ( getButtonStatus(buttonIndex) returns true ) and the bool is false that it was just pressed. and you would set the bool true. and if the button is not pressed and the bool is true, than it was just released. extra. you can use getattr(object, Property_Name) and setattr(object,Property_Name).

Hey. Yeah, I did some work with Joysticks and built Pressed, Held, and Release state checking for both buttons and axes into the BGHelper module. It should be present in the latest version.

If you have one button on one sensor you can use the attribute status. It returns what you described.

thank you all for your quick and very good responses!
I will go for monsters solution. I wanted to use for each button on sensor anyway, so this is the most simple solution!!

Once again! Thank you. I love this forum!

Edit
YEAH… Gamepad/Joystick works! Awesome. Now I can control the character with keyboard and gamepad!

@kylona you can’t setattr() or getattr() properties on GameObjects post 2.49 because object properties are stored on a dict.