Author Topic: Analog stick functionality  (Read 1415 times)

CitizenKyle

  • Newbie
  • *
  • Posts: 6
    • View Profile
Analog stick functionality
« on: January 25, 2016, 12:02:02 pm »
I've got the D-pad and the buttons working on the XBOX 360 controller with this:

Code: [Select]
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?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1173
    • View Profile
Re: Analog stick functionality
« Reply #1 on: January 25, 2016, 12:41:35 pm »
When you create a new game, the engine sets direction commands like this for the joypad:
Code: [Select]
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?

CitizenKyle

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Analog stick functionality
« Reply #2 on: January 26, 2016, 10:15:10 am »
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.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1173
    • View Profile
Re: Analog stick functionality
« Reply #3 on: January 26, 2016, 10:18:01 am »
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.

CitizenKyle

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Analog stick functionality
« Reply #4 on: January 26, 2016, 10:49:46 am »
OK, I've got a version of InputEvent::get_event() running here. I'll get a pull request to you soon :)

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1173
    • View Profile
Re: Analog stick functionality
« Reply #5 on: January 26, 2016, 11:52:44 am »
Thanks, but your pull request reverts unrelated changes. What is the relevant part of the fix?