• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Advanced Keyboards for Android (multiple USB/BT keyboards support at once!)

grant

Member
CX Code Contributor
3rd Party Module Dev
3rd Party Tool Dev
Joined
Nov 19, 2019
Messages
80
The keyboard support in Cerberus X seems to only support virtual keyboards on Android (it's been a while since I tested it). This module lets you get input from physical keyboards, and you can get input from multiple keyboards separately! You can check if each keyboard was disconnected and even get their names. The module comes with androidkeycodes.cxs that contains some Android keycodes for use with the functions. The key constants built into Cerberus X didn't work with it when I tested it.

I already had the keyboard engine written up, so I just hooked it into Cerberus X. You will need to make a small edit to Cerberus X to install the module though. I don't know how to get around that. Some other improvements could also probably be made.

tick:Void()
This needs to get called at the start of every OnUpdate to pull new info.​
isKeyboardConnected:Bool(device:Int)
Checks if a keyboard is connected.​
keyboardGetDeviceId:Int(device:Int)
This returns the Android input device deviceId and is not used with the other functions of this module.​
getKeyboardCount:Int()
Returns the total number of keyboards. Keyboards that got disconnected after the game started will show up as disconnected, but be replaced when a different keyboard is connected.​
keyboardGetDescription:String(device:Int)
Returns the display name of a keyboard. device is the index from 0 up to getKeyboardCount().​
isKeyPressed:Bool(device:Int, KeyCode:Int)
Returns if the key was just pressed. Set device to -1 to check all keyboards.​
isKeyReleased:Bool(device:Int, KeyCode:Int)
Returns if the key was just released. Set device to -1 to check all keyboards.​
isKeyDown:Bool(device:Int, KeyCode:Int)
Returns if the key is down. Set device to -1 to check all keyboards.​

Demo: The included demo.cxs draws info about all the keyboards on screen.

Install: extract the zip file inside the modules_ext folder inside your Cerberus X installation folder. Rename the resulting folder to advancedkeyboards. Unfortunately you will need to make a small edit to /targets/android-original/modules/native/androidgame.java for it to work and then all your projects will need to import this module when targeting Android. (see included install.txt)

License: zlib/libpng (see included license.txt)

Note: If your game is restarting when a keyboard is connected, change the value of android:configChanges inside AndroidManifest.xml to this (the navigation|keyboard part is what fixes that).
Code:
        android:configChanges="orientation|keyboardHidden|screenSize|navigation|keyboard|screenLayout|smallestScreenSize"

Check out my Advanced Mice module!

If someone wants to do a port to Windows/Mac/Linux, that would be awesome!
 

Attachments

  • AdvancedKeyboards-module-V1.0-for-Cerberus-X-for-Android.zip
    6 KB · Views: 80
Last edited:
Back
Top Bottom