Author Topic: USB game controller not working correctly.  (Read 246 times)

0 Members and 1 Guest are viewing this topic.

rogerdg

  • Newbie
  • *
  • Posts: 3
    • View Profile
USB game controller not working correctly.
« on: July 23, 2021, 01:38:31 AM »
I have a Windows 10 laptop running Solarus Version 1.6.5 that I just downloaded today. I used to play with the program using a keyboard on a Windows 8 machine, but after upgrading, decided to try out my old game controller.

When I run calibration for the controller in Win 10, everything looks OK, but when I start Solarus, the character only goes diagonally up-left or down,right when I press and hold a direction button until it hits a wall, then moves in a single direction until it hits another wall, and stops moving when it hits a corner.

The character stops as expected when the movement button is released, and resumes when the button is pressed again.

Pressing KEY(S) cause the character to go DIRECTION
               Up                                                Nowhere
               Up-Right                                       Down-Right                               
               Right                                             Down-Right
               Down-Right                                  Down-Right
               Down                                            Nowhere
               Down-Left                                    Up-Left
               Left                                              Up-Left
               Up-Left                                         Up-Left

I am not sure where in the code to look for the cause of this issue.  If someone could point me in the right direction, I could try to figure out how to correct the character moves for my gamepad.

Roger

               
Great games require creative programmers...

Rogerdg

Max

  • Sr. Member
  • ****
  • Posts: 269
    • View Profile
Re: USB game controller not working correctly.
« Reply #1 on: August 04, 2021, 06:45:18 PM »
Hi!
So you could add code like this somewhere in your game where it will run, like the game manager if you're using one, or something like that
Code: [Select]
function game:on_joypad_button_pressed(button)
  print("Pressed button:", button)
end

function game:on_joypad_button_released(button)
  print("Released button:", button)
end

function game:on_joypad_axis_moved(axis, state)
  print("Axis moved:", axis, state)
end

--etc...

See https://www.solarus-games.org/doc/latest/lua_api_game.html#lua_api_game_on_joypad_button_pressed and below events for the details of all joypad inputs.
This will let you see what the engine is seeing- you can compare this to what you're actually pushing, to see if the problem is that the engine is getting the wrong inputs, or if the game is processing them incorrectly.


Also, this is maybe obvious, but your controller could also maybe be broken. You did say it's an old game controller, maybe the most obvious thing is to try a different one and see if the problem is just with the controller.

Also, feel free to post on the Solarus discord, the forums aren't nearly as active : )