D-Pad diagonal input

Monkey Forums/Monkey Programming/D-Pad diagonal input

lom(Posted 2014) [#1]
Monkey has JOY_RIGHT,JOY_LEFT,JOY_UP,JOY_DOWN and it works fine. But obviously it's impossible to press, for example UP and RIGHT on D-Pad at the same time. How can I detect diagonal inputs from D-Pad? I'm stuck right now.


ImmutableOctet(SKNG)(Posted 2014) [#2]
This is not impossible. It's completely based on the hardware. My Xbox 360 controller can do this with or without Monkey. Monkey can detect both the 'JOY_UP' and 'JOY_LEFT' buttons (At the same time) on my controller without any issues. This same effect applies to the other configurations. The original Xbox 360 controller's D-pad is pretty terrible, but it can technically do diagonal input. Again, this is based on the controller, but if you tried this effect with a keyboard, you won't have any issues. Keyboards have support for simultaneous button presses, but some keyboards (Like mine) only support two or three at a time. The same generally goes for mice as well. Other than potential hardware issues, you should be fine detecting multiple buttons at once. The software definitely supports it.

Here's an example of how to use diagonal input-detection with Mojo (Top Left):


This will also work with the 'Hit' versions of the input-commands. The only thing to worry about there is that not everything can press both at the exact same time (Within a single frame; 16 milliseconds at 60 frames per-second) consistently. My controller can do this reasonably, but it also has a weird D-pad. Sticking to the 'Down' versions is a good idea for diagonal input.


lom(Posted 2014) [#3]
This is not impossible. It's completely based on the hardware. My Xbox 360 controller can do this with or without Monkey. Monkey can detect both the 'JOY_UP' and 'JOY_LEFT' buttons (At the same time) on my controller without any issues. This same effect applies to the other configurations. The original Xbox 360 controller's D-pad is pretty terrible, but it can technically do diagonal input. Again, this is based on the controller, but if you tried this effect with a keyboard, you won't have any issues. Keyboards have support for simultaneous button presses, but some keyboards (Like mine) only support two or three at a time. The same generally goes for mice as well. Other than potential hardware issues, you should be fine detecting multiple buttons at once. The software definitely supports it.

Here's an example of how to use diagonal input-detection with Mojo (Top Left):


Yes, keyboard input works fine, but pressing two directions at the same time on a gamepad doesn't work at all. I tried with two different gamepads with no result. However pressing only one direction works at those gamepads.
Blitz3D has a function JoyHat () which returns D-Pad value as an angle in the range 0 to 360 and it works perfect with my gamepads. I wish Monkey has the same function to improve D-Pad input.


ImmutableOctet(SKNG)(Posted 2014) [#4]
I completely forgot about this thread. lom, I forgot to post this for you:


It turns out, the D-pad detection is better with the new GLFW3 target. The GLFW2 target doesn't actually work very well with this.


lom(Posted 2014) [#5]
ImmutableOctet(SKNG)

Thanks, it seems like GLFW3 target works much better with my gamepads (that's weird:))