[SOLVED] How do I 'simulate' keyboard presses with gamepad?

0 favourites
  • 5 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I have about 1000+ different events with keypresses with the keyboard keycode variables:

    "ButtonUp,ButtonDown,ButtonFire, etc etc." and have assigned each variable to a keycode.

    I want people to be able to pick up their Gamepad and use both if they desire, without me having to duplicate every event that has keyboard keycode presses. OR blocks would be nice but unfortunately it goes for every condition.

    Is there a simple way to simulate a Keyboard press to activate a Keyboard event with a gamepad?

    Thanks! c:

  • It's usually a good idea to separate the player input events from the actual game logic. You could have a certain keystroke event that call an "InputLeft" user-defined function and have another gamepad button press event that calls the same.

    If that's not an option, I guess you could look into triggering keyboard javascript event with the Browser.ExecJS function.

    http://stackoverflow.com/questions/5964 ... key-events

  • Thanks for the reply!

    I will redo everything if I have to.

    I was sort of hoping to press "ButtonUp,ButtonDown,ButtonFire," with the gamepad but realized that they wouldn't have the same keycodes anyway.

    So basically I will call a function every time I press a button and then have conditions in the current keypress events: "If function called".

    What about "Button is down"? Wouldn't it call functions every tick?

    Thanks in advance.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It would, indeed. However, if that's not the wanted behavior, you can add the special condition "Trigger once while true" that will effectively turn any non-trigger event in a triggered one.

  • Thanks a lot for your help!

    I took time to adjust everything. Works like a charm now!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)