Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joysticks on N3DS #14

Open
H4x0r-000 opened this issue Aug 4, 2024 · 2 comments
Open

Joysticks on N3DS #14

H4x0r-000 opened this issue Aug 4, 2024 · 2 comments

Comments

@H4x0r-000
Copy link

Hi,

I am playing around a bit with your engine and want to make a little game for the N3DS.

However I have some trouble reading the joysticks axis.

Using Input.IsGamepadConnected(1) returns false which for me does not make much sense to me but Input.IsGamepadButtonDown(Gamepad.Left) for example works perfectly fine.

Now I dont know if I am using Input.GetGamepadAxisValue wrong, becuase testing it on windows just crashes the editor. I previously used Input.IsGamepadConnected(1) to check if there even is axis input but since the N3DS does not trigger this I kind of dont know if I am using it wrong or if I have to detect the platfrom differently.

@mholtkamp
Copy link
Owner

mholtkamp commented Aug 5, 2024

The Axis IDs are different from the other Gamepad buttons, so that might be the issue you are running into.
Try this code and see if you can retrieve the axis values for the left stick:

        local leftAxisX = Input.GetGamepadAxisValue(Gamepad.AxisLX)
        local leftAxisY = Input.GetGamepadAxisValue(Gamepad.AxisLY)

The axes are

Gamepad.AxisL -- Left Trigger
Gamepad.AxisR -- Right Trigger
Gamepad.AxisLX -- Left Stick X
Gamepad.AxisLY -- Left Stick Y
Gamepad.AxisRX -- Right Stick X
Gamepad.AxisRY -- Right Stick Y

In hindsight, I'm not sure if I like the names I gave them...

It's true that Input.IsGamepadConnected(1) isn't returning an accurate value on 3DS, but it should be safe to assume that the Gamepad 1 is always available on 3DS. I'll make a note to fix that though.

Edit: Just fixed Input.IsGamepadConnected() for 3DS. Thanks for pointing that out!

@H4x0r-000
Copy link
Author

H4x0r-000 commented Aug 5, 2024

Awesome work! Input.IsGamepadConnected() is working.

Also I got the axis readout working too, looks like I just was a little stupid, this is what I did before:
local x = Input.GetGamepadAxisValue(Gamepad.AxisL, 0)
local y = Input.GetGamepadAxisValue(Gamepad.AxisL, 1)

for some reason I thought that the index is indexing the coordinate like 0 for x, 1 for y and so on...

One thing is a bit weird though, the R-Joystick on the New3DS is only outputing 9 possible values. For example (1,0) or (0,0) or (-1,0) and so on. There are no inbetweens, I dont know if it is normal I was just expecting it to work exactly as the L-Joystick. Anyways....

Thanks for your quick response and even fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants