Support Forums > General Board

mice - usb devices

(1/6) > >>

raymw:
It is possible to have more than one (at least two) mouse devices connected to a windows10 (maybe so for xp, 7, 8 too) PC at the same time. Any one of which will control the cursor. Is it possible to distinguish between the two in freebasic? My intention is to modify a mouse into a different sort of input device, but I need to discern if it is the modified devices button presses and x/y movements that are taking place. Is there any usb handling within freebasic?

Thanks, any help appreciated.

Pierre Bellisle:
Yes you can,
Look at GetRawInputData() and GetRawInputDeviceInfo()...


--- Code: ---'Extract from Josť's stuff...
GetRawInputData function uiCommand = RID_HEADER

UNION RAWINPUT_UNION DWORD
   mouse     AS RAWMOUSE      ' RAWMOUSE
   keyboard  AS RAWKEYBOARD   ' RAWKEYBOARD
   hid       AS RAWHID        ' RAWHID
END UNION

UNION RAWINPUT_DATA_UNION DWORD
   data   AS RAWINPUT_UNION
   RAWINPUT_UNION
END UNION

TYPE RAWINPUT DWORD
   header AS RAWINPUTHEADER
   RAWINPUT_DATA_UNION
END TYPE

GetRawInputDeviceInfo function
 hDevice A handle to the raw input device.
 uiCommand (RIDI_DEVICENAME RIDI_DEVICEINFO RIDI_PREPARSEDDATA)
--- End code ---

Josť Roca:
The declares and types for FreeBasic are available in winuser.bi, eg.


--- Code: ---union tagRAWINPUT_data
mouse as RAWMOUSE
keyboard as RAWKEYBOARD
hid as RAWHID
end union

type tagRAWINPUT
header as RAWINPUTHEADER
data as tagRAWINPUT_data
end type

type RAWINPUT as tagRAWINPUT
type PRAWINPUT as tagRAWINPUT ptr
type LPRAWINPUT as tagRAWINPUT ptr

--- End code ---

Pierre Bellisle:
Thank Josť, I was lazy, the one I used where from another universe...

[Added] Not to forget GetRawInputDeviceList()

Some keyboard code from the other universe, may be expanded for mouse...

raymw:
Thanks for your suggestions, Jose and Pierre.  Unfortunately, I'm not familiar with 'Jose's stuff', and have not got very far in my attempts so far. (at the moment I'm trying to use Paul's winfbe and graphical editor, and I've had to search for winuser.bi (which requires other binary files which I'll have to locate)). I'm guessing that Jose has more** or less put wrappers around the windows api's to enable easier use with Freebasic. Is there any chance, pretty please, that you could write for me, a complete program to, say, read a right button click from a specific mouse. Maybe a big ask, but if you've had a good day..., who knows. Hopefully, then I could discover how to read the other buttons, wheel, coordinates, etc.

At this stage, I'm not even sure how to distinguish between two identical mice . I suppose could plug one in first, or press a sequence of buttons.
I'm thinking it would be better to deal with a lower level of communication, e.g. i/o to the specific usb port, at least for the mouse I'm mechanically messing with. I've had a quick look at this, https://blogs.msdn.microsoft.com/usbcoreblog/2015/07/29/what-is-new-with-serial-in-windows-10/ which is most likely what I need to get to grips with, but not sure if it will be backwards compatible with w7, say. And it will most likely be difficult for me to get an understanding of it, I am not familiar with using windows api's, and what I've found on the web, and looks easy, https://freebasic.net/forum/viewtopic.php?f=7&t=13451 has been criticized in later posts. Are there any complete and better explained examples?

Best wishes,

Ray

** probably much more than that.

Navigation

[0] Message Index

[#] Next page

Go to full version