• 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 Mice for Android & HTML (cursor locking and multiple USB/BT mice support at once!)

grant

Member
CX Code Contributor
3rd Party Module Dev
3rd Party Tool Dev
Joined
Nov 19, 2019
Messages
80
This module gives you the ability to support multiple different mice at once on Android, customize/hide the cursor on Android, and capture the cursor on Android and HTML! It is similar to my Advanced Keyboard module for Android. To be clear the only function for HTML is the cursor capture, and the user has to interact with the game before it can capture the cursor on HTML. It will take some work to setup on your projects, and it's not the cleanest API, but I wanted to share it.

Functions​

tick:Void()
Call this function before anything else at the beginning of every OnUpdate().​
cursor_capture:Void()
On Android use this to capture the mouse cursor.​
cursor_uncapture:Void()
On Android use this to release the mouse cursor.​
cursor_capture_is_supported:Bool()
Checks if the Android system or Web Browser supports capturing the cursor. (Note: Android 8+ supports capturing the cursor.)​
cursor_is_captured:Bool()
Checks if the cursor is captured currently.​
mouse_get_offset_x:Float(mouseIndex:Int)
Gets the x movement of the mouse since the last frame. mouseIndex is the index of the mouse on Android. Use -1 for the most recently used mouse.​
mouse_get_offset_y:Float(mouseIndex:Int)
Gets the y movement of the mouse since the last frame. mouseIndex is the index of the mouse on Android. Use -1 for the most recently used mouse.​
mouse_get_offset_z:Float(mouseIndex:Int)
Gets the mouse wheel movement of the mouse since the last frame. mouseIndex is the index of the mouse on Android. Use -1 for the most recently used mouse.​
mouse_is_connected:Bool(mouseIndex:Int)
On Android it returns if the mouse with that index is currently connected.​
mouse_name:String(mouseIndex:Int)
On Android it returns the name of the mouse with that index.​
change_cursor_is_supported:Bool()
On Android it checks if changing the cursor is supported (Which is Android 7+).​
set_cursor:Void(cursor:Int)
On Android it sets the cursor to one of the cursor constants listed below. To include a custom cursor you need to copy the files into YOUR-PROJECTS-BUILD-FOLDER/android/app/src/main/DRAWABLE-FOLDERS. 4 sample custom cursors are included at all the different DPI sizes. ShowMouse() and HideMouse() already work on HTML.​
mouse_count:Int()
On Android this returns the count of mice. When a mouse is disconnected while the game is run mouse_is_connected will return false until it is reconnected or a new one is connected.​
mouse_button_down:Bool(mouseIndex:Int, button:Int)
On Android this returns if the mouse button (MOUSE_LEFT/MOUSE_RIGHT/MOUSE_MIDDLE) is down for the given mouse index. Use -1 for the most recently used mouse. MouseDown mouse down already works just fine on HTML.​
set_cursor_capture_trigger:Void(keyTriggers:Int[],mouseTriggers:Int[])
On HTML this will set what keyboard keys and mouse buttons will be used to trigger toggling the cursor capture. The keycodes are Javascript keycodes (not Cerberus-X.) Set them to empty arrays to disable it.​

Constants​

CURSOR_NONE:Int = 0
CURSOR_DEFAULT:Int = 1
CURSOR_CUSTOM:Int = 2
CURSOR_CUSTOM_2:Int = 3
CURSOR_CUSTOM_3:Int = 4
CURSOR_CUSTOM_4:Int = 5

Demo: The included demo.cxs draws info about all the mice on screen and demonstrates all the functions on Android and HTML.

Install: extract the zip file inside the modules_ext folder inside your Cerberus X installation folder. Rename the resulting folder to advancedmice. You will need to add a file to Cerberus X and edit a couple files in Cerberus X too. Read the included install.txt.

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

If someone wants to do a port to Windows/Mac/Linux, that would be awesome! Also touchscreen functions on Windows and Linux.
 

Attachments

  • AdvancedMice-module-V1.0-for-Cerberus-X-for-Android.zip
    46.3 KB · Views: 87
Last edited:
Back
Top Bottom