USB HID Library

Developed or developing a new product in PureBasic? Tell the world about it.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: USB HID Library

Post by chris319 »

User_Russian wrote:Rename it is not necessary. It is not used in the project. This electrical circuit thermometer device.
The original name Схема_USB_Termo.gif. You can rename it to Circuit_USB_Termo.gif.
Oh good. I haven't upgraded my computer to Cyrillic yet.
Susan20
User
User
Posts: 19
Joined: Fri Feb 29, 2008 1:10 pm
Location: Berlin

Re: USB HID Library

Post by Susan20 »

I have a USB-HID footpedal connected to my computer. When I run the DeviceTest-Code, I get the message that device is connected. (by the way: I use the hid_module.pbi and not the lib).
So far so good. But my question is: How can I observe that for example the left pedal is pressed? Is there a function in the hid_module.pbi respectively in the lib, that causes an event, when the left or right pedal is pressed?
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: USB HID Library

Post by User_Russian »

It is necessary to receive a stream of data from the device and to analyze it.
Susan20
User
User
Posts: 19
Joined: Fri Feb 29, 2008 1:10 pm
Location: Berlin

Re: USB HID Library

Post by Susan20 »

Is there a function in your lib, that can detect such a stream of data?
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: USB HID Library

Post by User_Russian »

In "HID module" this function ReadDevice() and GetFeature().
Susan20
User
User
Posts: 19
Joined: Fri Feb 29, 2008 1:10 pm
Location: Berlin

Re: USB HID Library

Post by Susan20 »

Thanks, User_Russian, for your information. I will try it ...
Susan20
User
User
Posts: 19
Joined: Fri Feb 29, 2008 1:10 pm
Location: Berlin

Re: USB HID Library

Post by Susan20 »

@User_Russian, could you have a quick look at my code? As you said, I try to produce a data stream from the device by the function GetFeature. My hope was, that I can detect this data stream as an event in the repeat-loop. But it didn't work.

Code: Select all

;the IDs of the infinity foot pedal
#USB_PID=$FF
#USB_VID=$5F3

XIncludeFile "HID_Module.pbi"

HID::HID_Init()

hDev = HID::OpenDevice(#USB_PID, #USB_VID) 


OpenWindow(0,0,0,320,100,"HID in action",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
TextGadget(1,10,10,300,16,"press a pedal")

Global *buffer = AllocateMemory(256)      
HID::GetFeature(hDev, *buffer, 256)
   
Repeat
   Event=WaitWindowEvent()
   Debug event
Until Event=#PB_Event_CloseWindow

HID::HID_End()
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: USB HID Library

Post by User_Russian »

"HID_Module" does not generate window events.
In the loop must be called ReadDevice() or GetFeature() in dependence on, through which channel the data is transmitted.
Susan20
User
User
Posts: 19
Joined: Fri Feb 29, 2008 1:10 pm
Location: Berlin

Re: USB HID Library

Post by Susan20 »

Thanks! I put the ReadDevice function in a thread, which is called by a timer-event. Although I only get one value, which is independent from the pedal action (press, release), I can control the play/stopp-process.
Deraman
User
User
Posts: 28
Joined: Thu Mar 10, 2016 8:00 am

Re: USB HID Library

Post by Deraman »

Dear, I am getting POLINK..... error when compiling examples that contain Thread command and procedure, if I remove both the example compile without any error, this is same for HID Lib and module both.
Kindly help me to solve this problem.
Thanks
Deraman
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: USB HID Library

Post by User_Russian »

Deraman
User
User
Posts: 28
Joined: Thu Mar 10, 2016 8:00 am

Re: USB HID Library

Post by Deraman »

User_Russian wrote:You are using HID_Module? http://www.purebasic.fr/english/viewtop ... 50#p450450
Yes Dear!
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: USB HID Library

Post by User_Russian »

About what error reports POLINK?
Deraman
User
User
Posts: 28
Joined: Thu Mar 10, 2016 8:00 am

Re: USB HID Library

Post by Deraman »

POLINK: fatal error: Access is denied
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: USB HID Library

Post by Bisonte »

Sometimes your AV is the cause. Try to deactivate your AV and try to compile again.
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Post Reply