[Resolved] Keyboard handling


#1

Hello all.

I am making a custom controller which emulates a keyboard using additional software (AACKeys). I can see that the controller is working fine, since I can see the keys I send from the controller in various applications like notepad or in web sites(https://typewritesomething.com/). Unfortunately, I can’t make the keys to work in the HTML5 game from GDevelop. It’s doesn’t read the keystrokes unless I use the real keyboard on my PC. I have tested this on win7 and win10 using Firefox and Edge.

The AACKeys software reads ASCII characters from the serial port which translates into keystrokes. It’s a pretty basic application and it working without any issues on win7 and win10 setups.

Anyone has a clue how the keyboard is handled in GDevelop or what I should try?


#2

I don’t know the reason of using another software but GDevelop has an Extension for Gamepads here is the example
https://editor.gdevelop-app.com/?project=example://multiplayer-platformer-with-gamepads


#3

Hi.
It’s not a game pad that connects on a USB port as an HID class device , so I can’t use this extension.


#4

The keyboard and the gamepad are two different things.
The keyboard is native in the game, it’s bundled with electron (electron is a chrome browser for portable app used in GD as base for run your games.)
And the gamepad used an API in this electron. This API is dedicated to the gamepad only.

With your have you tryed to type here ?
Can you write with your keyboard in Discord ? (discord use electron)
Can you type on character here and show me the result.
Maybe your keyboard return a special character and this one cannot be read by the engine.
I said maybe.


#5

Hi Bouh.

I tried both links (not the Discord app though) and I could type/see the characters using the custom controller. No special characters while testing on the second link. I also tried playing around on w3school with some examples that involved a keyboard and it was also working fine.

This is how I handle the Keyboard:


#6

So GDevelop and electron work fine no need to test in Discord.

Ensure your expression in the condition is correct, use it for display the value as string in a text object.


#7

Well, I did try that at some point. I could see the characters as I was typing on the keyboard, but when using the custom controller I didn’t receive anything.

I am using the Developer tools to debug the game at the moment and I can see that if I enable ‘Event Listener Breakpoints’ I do get the breakpoint to trigger on ‘runtimegame-pixi-renderer,js’ when I use the custom controller. I can also see that the key is correctly identified (it’s d):


#8

OK, I finally got it!

I had to switch from “Key pressed” to “Key released” event in the code to make it work with the custom controller. Not sure why it works though, any ideas?

Thank you all for your help.


#9

Excuse me Steliosm for spamming your post but what is “Developer tools”.
I see it works in twin with GDevelop but i don’t know what it is and how to get it.
Is it a Javascript tool?

Thanks to reply et again, excuse me for my spam


#10

Hello Amigo.

It’s located in the Browser’s menu. For example, for Firefox, it’s called “Web Developer”.
Is this what you are asking?


#11

Yes, it’s that exactly. With Microsoft Edge, it is called in french (“Outils de développement” ) or “Developer tools” too in english version of Edge.

Thanks Steliosm :smiley: