Get joystick position translated to scene?

Im not really sure how to phrase this one, but, I need to figure out how to accurately get where a joystick on a controller is and make something move in the scene only as much as its moved? if that makes sense. Example: when you move the joystick left, instead of something moving left at a speed based on how far left it is pushed, i need it to move a distance and be able to return when you start to “unpush left”.
it would basically be just offsetting a sprite but there isn’t an option for that, only to offset the image of a tiled sprite.

this is all for a program im making to test controllers. yes, i know gdevelop probably isnt the best, yes i know things already exist for it, this is just how im doing it because i need it to be able to do other things that other peoples programes dont.

i can upload whatever is needed if it grants assistance

So, you want an onscreen joystick displaying what you’re doing with the physical joystick, right?
I believe the gamepad extension provides expressions you can use to display the joystick value.
I’ve never tried the extension, but if the value goes from 0 to 1 in each direction and your virtual joystick has 100 pixels radius… simply multiply the returned value by 100 to adjust the position of the on-screen stick.

Ive tried that, or at least something similar. the problem i had was that

1 it didn’t work diagonally because the extension doesn’t give the actual axis values, it translates them into how far the stick is pushed in a given direction. the problem is that, it wouldn’t detect more than one direction at once, so it cant go diagonally if you start going up and then left. it would just think up and then when you start going left it shoots left instead of doing what the actual joystick does

2 the only other way to get stick values is by getting how far the stick is pushed in any direction, they call it stick force in the extension. obvious problem with this is the lack of directions. you cant go a lot left and a little up, the extension would think that the joystick was a lot left and a lot up.

Another problem i had was that the joystick object would move infinetly in a given direction instead of the default position plus or minus a bit.

This is clearly a problem with your events, and makes me question the validity of your other points. But I don’t have any joystick to experiment with, so count me out. :person_shrugging:

For both #1 and #2. You shouldn’t be using the axis values for sticks, as most gamepads don’t actually use real axis anymore anyway (it’s more interpolation via potentiometers…which is a heck of a thing), it’s moreso rotation (which angle the stick is pushed in from center) and force (0 to 1, minimum to maximum) as the output.

You can translate the two parameters (Joystick rotation + Joystick force) to whatever you’d like. Whether that be full-screen movement (0 force being the center of the screen, full force (1) being to any side of the screen), or some form of fixed minimums/maximums.

The angle is what determines your direction moved, as you can move an object based off angles as well. It’s just going to involve figuring out the math depending on what you’re really wanting the start/stop locations to be.

Here is a super quick example:

I’m using two objects. The white circle outer, and the L button stick center.

Here is the only event required with both expressions.

If you’re wanting to do a whole screen, you’re going to need to do some heavier math as you’ll need to figure out what translates to the corners (since gamepad sticks have round movement and not rectangular, they’re going to only move in a full circle at maximum by default. You’re going to have to figure out the math to translate to 16:9 if that’s what you’re going for.)