B4J Question Help with HID keyboard

Christian García S.

Active Member
Licensed User
Hello,

I need to integrate this keyboard USB with an application, the idea is that for each button that the client presses on the keyboard do call a job to send that information to the server.

I have reviewed the HID keyboard information in the forum, but I could not find anything, I do not know if you with more knowledge can guide me and do this with B4J.

Thanks in advance
 

Attachments

  • HIDKeyboard.jpeg
    HIDKeyboard.jpeg
    83.6 KB · Views: 404

Daestrum

Expert
Licensed User
Longtime User
What is the manufacturer / model number of the keypad ?
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
if it appear as keyboard in os i guess
if u input something in notepad
u type a char in single or multibyte, just a value.
 
Upvote 0

Christian García S.

Active Member
Licensed User
What is the manufacturer / model number of the keypad ?
The keypad has no make or model,
if it appear as keyboard in os i guess
if u input something in notepad
Of course that was the first thing I did, but Windows does not recognize the device, I clicked on the buttons and do not write anything in the notepad.

The device comes with software, but if it is not connected to the server it does not allow to install it, I see two files inside the folder:

AtUsbHid.dll
Mscomm32.ocx
midas.dll

u type a char in single or multibyte, just a value.
How can I do that ?


Thanks.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
do you see if windows map this usb port to a serial port?
u have a terminal app that can connect to a serial port?

this Mscomm32.ocx can be used in old Visual Basic or Delphi to make a serial connection, send and receive data.

this At in the name of AtUsbHid.dll might mention Vendor Name, Atmel Corp... googled for VID_03EB

in past i had only one keyboard from here http://xkeys.com/xkeys.php , i used it for a flight simulator.
 
Upvote 0

Christian García S.

Active Member
Licensed User
I checked this thread (https://www.b4x.com/android/forum/threads/how-to-send-data-to-usb-hid.81909/#post-635156) to list all the devices, and it worked correctly, the device is listed.

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
    
    #AdditionalJar: purejavahidapi
    #AdditionalJar: jna-4.0.0   
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private ListView1 As ListView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    
    
    'initial HidDeviceInfo
    Dim hdi As JavaObject
    hdi.InitializeStatic("purejavahidapi.HidDeviceInfo")
 
 
    'initial PureJavaHidApi
    Dim jo As JavaObject
    jo.InitializeStatic("purejavahidapi.PureJavaHidApi")
 
    'list all usb hid
    Dim lst As List
    lst = jo.RunMethodJO("enumerateDevices", Null)
 
    For i=0 To lst.Size-1
        
        Log("*************************************")
        
        Log("lst:" & lst.Get(i))
        ListView1.Items.Add("lst:"  & lst.Get(i))
        
        
        'open usb hid
        Dim obj As JavaObject
        obj.InitializeStatic("purejavahidapi.HidDeviceInfo")
        
        obj = lst.Get(i)
        
        Dim getPath As String
        getPath = obj.RunMethod("getPath",Null)
        
        Log("getVendorId: " & obj.RunMethod("getVendorId",Null))
        Log("getProductId: " & obj.RunMethod("getProductId",Null))
        Log("getManufacturerString: " & obj.RunMethod("getManufacturerString",Null))
        Log("getProductString: " & obj.RunMethod("getProductString",Null))
        Log("getPath: " & getPath)
        
        
    Next
 
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

My device is:

B4X:
lst:purejavahidapi.windows.HidDeviceInfo@67d5b75d
getVendorId: 14648
getProductId: 4146
getManufacturerString: MOSART Semi.
getProductString: 2.4G RF Keyboard & Mouse
getPath: \\?\hid#vid_3938&pid_1032&mi_01&col02#9&1e778fb3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}

In this link https://github.com/nyholku/purejavahidapi, can you check this "... and then open and attach an input report listener to it:":


B4X:
HidDevice dev=PureJavaHidApi.openDevice(devInfo);
dev.setInputReportListener(new InputReportListener() {
   @Override
   public void onInputReport(HidDevice source, byte Id, byte[] data, int len) {
       System.out.printf("onInputReport: id %d len %d data ", Id, len);
       for (int i = 0; i < len; i++)
           System.out.printf("%02X ", data[i]);
       System.out.println();
       }
   });

Maybe if this code is converted to B4J, we can make the computer listen to the keyboard.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
My device is:
getProductString: 2.4G RF Keyboard & Mouse
getPath: \\?\hid#vid_3938&pid_1032&mi_01&col02#9&1e778fb3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
are u sure u not found your wireless keyboard or mouse? because its a different vendor id from your post above.
 
Upvote 0

Christian García S.

Active Member
Licensed User
I think so, I checked each one of the variables one by one in the device manager and I have some other data

{745a17a0-74d3-11d0-b6fe-00a0c90f57da}
00FF3202
{745a17a0-74d3-11d0-b6fe-00a0c90f57da} \ 0078
USB \ VID_3938 & PID_1032 \ 7 & 17e4f553 & 0 & 3
00000004
C21AA55B
{5be47591-1d04-11e9-8bd5-9a5fd3454e45}
Port_ # 0004.Hub_ # 0004
\ Device \ USBPDO-8
USB \ VID_1A40 & PID_0101 \ 6 & 1624f049 & 0 & 4
HID \ VID_03EB & PID_5500 \ 8 & 26696303 & 0 & 0000

Other devices are Intel, Microsoft and this said MOSART Semi
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
first i would look if windows it recognized in the system control / device manager correct.
 
Upvote 0

Christian García S.

Active Member
Licensed User
I had to execute a program that looks for the missing drivers, after executing that program and installing the missing drivers it is now recognized.

Thanks for your help
 
Upvote 0
Top