Android Question Detect key press from BLE mouse

I have a BLE mouse connected to b4x app. How to detect the mouse click? I don't want to detect press on any particular view. This code doesn't work in B4X:

B4X:
#if B4A
Private Sub mRoot_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
#else
Private Sub mRoot_Touch (Action As Int, X As Float, Y As Float)
#end if

    If ACTION = mRoot.TOUCH_ACTION_DOWN Then
        Log($"Touch action down"$)
    Else If ACTION = mRoot.TOUCH_ACTION_UP Then
        Log($"Touch action down"$)
   
    End If

    #if B4A
    Return True
    #end if
End Sub
 
Adding this in Main Activity module of b4xpage detects BLE mouse ! However unable to distinguish between right and left mouse click:

B4X:
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
    If Action = 1 Then
        Log("Mouse clicked at X: " & X & ", Y: " & Y)
        ' Perform actions on click
    End If
End Sub
 
Upvote 0
Top