Simulate Keyboard pressing

Get help using Construct 2

Post » Sat Sep 29, 2012 10:17 am

Hi everyone!

I was wondering if there was a way to simulate a keypress action.

For exemple :

Gamepad button A down --> Simulate X key down
Gamepad button A pressed --> Simulate X key pressed
Gamepad button A released --> Simulate X key released

But it seems there's no keyboard action available.
That would be so more easy for me to add a gamepad support this way. :)
Perhaps you know a method to do this.

Thank you.
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Sat Sep 29, 2012 12:55 pm

@KaMiZoTo
At the moment I can only think of one way to do it, but it's extremely tedious and rather dodgy. But if you still want to try it, here's what I am thinking.

Make global variable for all your control keys 'X', 'Y', etc. Make it a number variable or a text value, it's up to you (text would be easier but more tedious to type).

Set up your events so it's like if gamepad button A pressed set 'X' (the global variable) to "pressed", and then copy it and invert it and make it set 'X' to "released". This means that when Gamepad button A is not pressed it sets 'X' to "released".
This can be applied for the other actions too.

Then, make an event:

If 'X' = "released" --> (Your actions, don't shoot for example)
If 'X' = "pressed" --> (Your actions, Shoot for example)

That's a very clunky work around, but it should do it's job (I'm away from my PC so I can't really check).lonehangman2012-09-29 12:57:23
B
19
S
9
G
6
Posts: 77
Reputation: 5,241

Post » Sat Sep 29, 2012 1:55 pm

Thank you lonehangman for your answer!

Yeah I though about that solution too. But as you said, it's quite tedious.
But if it's the only way to do it, I will have to. :*(
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Sat Sep 29, 2012 3:12 pm

Take a look at XPADDER
B
44
S
21
G
13
Posts: 723
Reputation: 14,770

Post » Sat Sep 29, 2012 3:36 pm

XPADDER seems to be a Windows software. And I supposed it has to be installed by the player in order to use the pad functions. I prefer to not use external tools to be sure everything works on any system (on Mac for example).
Am I wrong ?

But thank you for the link. :)
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Sat Sep 29, 2012 8:29 pm

I'm kinda wondering why you want to simulate keypresses when you could just copy your keyboard events and switch out the conditions with the gamepad equivalents. Or if your control scheme isn't overly complicated just have the gamepad and keyboard input events together in "OR" blocks.

I also imagine being able to simulate keypresses would be a big security issue with browsers, and would not expect it to be possible.
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Sat Sep 29, 2012 11:22 pm

Thank you inkBot!
I haven't though about the "OR" blocks! Now that I almost know how the sub event can be used with this "OR" function, it should definitly work. :)

Sorry if my question seems stange. I'm still learning how to do so basic things. ^^
B
68
S
21
G
12
Posts: 314
Reputation: 12,011


Return to How do I....?

Who is online

Users browsing this forum: ankas, tetuan, Yahoo [Bot] and 7 guests