Hi [B]Erel[/B] and B4A/Java gurus,
Regarding my B4A Generic GamePad Support, I realized that I'm only able to retrieve my controller's device info after the OnGenericMotionEvent has fired.
Since the gamepad controller is already plugged-in and recognized by the Android OS before starting my app, how can I retrieve this info without the need of the event being fired?
Regarding my B4A Generic GamePad Support, I realized that I'm only able to retrieve my controller's device info after the OnGenericMotionEvent has fired.
Since the gamepad controller is already plugged-in and recognized by the Android OS before starting my app, how can I retrieve this info without the need of the event being fired?
B4X:
Sub Activity_OnGenericMotionEvent(event As Object)
Controller.Input = event 'Controller.Input is a JavaObject
If Controller.Device_Name = "" Then Controller.Device_Name = getDevice(False)
If Controller.Device_Info = "" Then Controller.Device_Info = getDevice(True)
End Sub
B4X:
Sub getDevice(Full_Info As Boolean) As String
Dim full_description = Controller.Input.RuNMethod("getDevice", Null) As String
If full_description <> "null" Then
If Full_Info = True Then
Return full_description
Else
For i = 0 To (full_description.Length - 1)
If full_description.SubString2(i, i + 2) = ": " Then
Dim device_name As String
For j = i + 2 To (full_description.Length - 1)
If full_description.SubString2(j, j + 11) = "Descriptor:" Then
Exit
Else
device_name = device_name & full_description.CharAt(j)
End If
Next
End If
If device_name <> "" Then Exit
Next
Return device_name
End If
Else
Return "No controller detected."
End If
End Sub