Analog stick functionality

Started by CitizenKyle, January 25, 2016, 12:02:02 PM

Previous topic - Next topic
I've got the D-pad and the buttons working on the XBOX 360 controller with this:

game:set_command_joypad_binding("up", "button 0")
game:set_command_joypad_binding("down", "button 1")
game:set_command_joypad_binding("left", "button 2")
game:set_command_joypad_binding("right", "button 3")
game:set_command_joypad_binding("attack", "button 10") -- A
game:set_command_joypad_binding("action", "button 11") -- B
game:set_command_joypad_binding("item_1", "button 12") -- X
game:set_command_joypad_binding("item_2", "button 13") -- Y


But how do I get the left analog stick to control movement like the D-pad?

When you create a new game, the engine sets direction commands like this for the joypad:
game:set_command_joypad_binding("up", "axis 1 -")
game:set_command_joypad_binding("down", "axis 1 +")
game:set_command_joypad_binding("left", "axis 0 -")
game:set_command_joypad_binding("right", "axis 0 +")

Does not it work?

That sort of got it working...

Compiling with MSVC from a fork of v1.4, the hero sometimes keeps moving even when the analog stick has returned back to the center. Jiggling it sometimes gets him to stop. I played around with InputEvent::get_event() for a while but I can't completely get rid of the issue. I'll try more to find the cause tomorrow.

Also, when using the quest editor directly to run the quest, the analog stick works perfectly, but if I exit and run the quest again, the quest editor crashes :(   -I'll have to try it with a new quest since it could be something in my quest that's causing the issue.

It is very strange if the joystick works better when running the quest from the quest editor. As far as I knew it is the contrary... There are known issues with keybard and joypad events when the quest is run by the quest editor.

OK, I've got a version of InputEvent::get_event() running here. I'll get a pull request to you soon :)

Thanks, but your pull request reverts unrelated changes. What is the relevant part of the fix?