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

Get help using Construct 2

Post » Thu Jul 30, 2015 6:47 pm

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:
Last edited by Beldrama on Sat Aug 01, 2015 8:29 pm, edited 1 time in total.
B
9
S
1
Posts: 16
Reputation: 563

Post » Thu Jul 30, 2015 8:31 pm

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
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Fri Jul 31, 2015 2:23 pm

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.
B
9
S
1
Posts: 16
Reputation: 563

Post » Fri Jul 31, 2015 2:59 pm

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.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Sat Aug 01, 2015 8:28 pm

Thanks a lot for your help!

I took time to adjust everything. Works like a charm now!
B
9
S
1
Posts: 16
Reputation: 563


Return to How do I....?

Who is online

Users browsing this forum: David181, Norafaithrainbow and 32 guests