Help! Using gamepad controls with Keyboard Events.

Liam Earles

Member
Hey guys! I am currently trying to code gamepad controls to "emulate" the keyboard events. This is an example of a code of what I'm trying to do:

Code:
gamepad_button_check_pressed(0, gp_face1)
keyboard_check(ord('X'))
What I'm trying to do is that I am trying to make a separate object to be as the "controller" for the player object who already has keyboard events to basically jump, move and do other things, but I'm having a hard time doing it right. Let me know if you have a solution!
 
you may not like my answer ...

go back through and change the player object from checking if a keyboard button is pressed to checking if a variable is true or false
example
Code:
if global.Key_Up = true
{
// Go UP
}
then in your controller object have it check for user input.

Code:
global.Key_Up = false;

if gamepad_button_check_pressed(0,gp_face1) == true ||
    keyboard_check(ord("X")) == true
{
global.Key_Up = true;
};
" || " means " or "

the first line will reset the variable global.Key_Up to not being pressed and when the user presses the buttons it will be changed to true
 

Alexx

Member
Or simulate a keypress when a gamepad button is pressed:
Code:
keyboard_key_press(key);
You could code / script to do this, so you wouldn't need change your existing code.

ie:
Code:
if gamepad_button_check_pressed(0,gp_face1)
{
          keyboard_check_press(ord("X"))
}
 
Top