Well, we can read multiple mice in Windows - see the attached code
However I'm not sure about reading the absolute position of the cursor - it tracks movement pretty good using dx/dy, but you can't quickly move a mouse and have the position jump immediately to where the mouse cursor should be. There is a value the subprogram reads that I thought might be the absolute position but doesn't seem to be. Any ideas? Also how to read the scroll wheel?
I'm also not sure how to detect keypresses in the current program. Normal methods of reading the keyboard like _BUTTON, _KEYHIT and _KEYDOWN from the main loop in the subprogram (which has the focus) don't seem to work. Maybe the keyboard needs to be read using Raw Input? And as long as we're using the Raw Input API to read the keyboard, can we read seperate input from multiple keyboards, like we do with mice? I found a bunch of information on using the Raw Input API to read keyboard input:
but this stuff is way over my head, and I would need some help translating this into QB64PE.
With everyone's help I was able to get the mouse mostly working, so the keyboard should be possible too.
If anyone is interested in giving this a look, that would be great.
- plug in 2+ USB mice
- make sure .h files are in program directory
- compile subprogram 'readmicesub43.bas" (or run it, it will run and immediately close)
- run the main program "readmicemain43.bas"
- try moving around the different mice on your PC, you should see letters move around the screen
- try clicking left and middle mouse buttons to hear sounds
- to quit, right click any mouse
However I'm not sure about reading the absolute position of the cursor - it tracks movement pretty good using dx/dy, but you can't quickly move a mouse and have the position jump immediately to where the mouse cursor should be. There is a value the subprogram reads that I thought might be the absolute position but doesn't seem to be. Any ideas? Also how to read the scroll wheel?
I'm also not sure how to detect keypresses in the current program. Normal methods of reading the keyboard like _BUTTON, _KEYHIT and _KEYDOWN from the main loop in the subprogram (which has the focus) don't seem to work. Maybe the keyboard needs to be read using Raw Input? And as long as we're using the Raw Input API to read the keyboard, can we read seperate input from multiple keyboards, like we do with mice? I found a bunch of information on using the Raw Input API to read keyboard input:
- MSDN's information on Raw Input
- Using Raw Input from C# to handle multiple keyboards by Emma Burrows, Steve Messer
- Raw Keyboard (HID) Input (discussion) - PowerBASIC Peer Support Community
- Keyboard Input Overview - Win32 apps | Microsoft Learn
- Hardware IDs on HIDs
- Looking at RAWINPUT for more detail | Details | Hackaday.io
but this stuff is way over my head, and I would need some help translating this into QB64PE.
With everyone's help I was able to get the mouse mostly working, so the keyboard should be possible too.
If anyone is interested in giving this a look, that would be great.