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: 25
Last edited:
Top Bottom