Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
kind of works? reading multiple mice: any c programmers want to look at this?
#2
(09-06-2022, 08:08 PM)madscijr Wrote: Thanks to the help from the kind folks here with compiling C with QB64's built in compiler, I made some progress compiling this Raw Input API multi-mouse code, and got 2 of the examples "HelloRawInput.c" and "ShowMultipleMiceValues.c" to compile and run.

If you run HelloRawInput (see attached "HelloRawInput_minimal.zip", run the batch file to compile with QB64), it counts the system devices. When you plug in a 2nd USB mouse, the count increases.

If you run ShowMultipleMiceValues (see attached "ShowMultipleMiceValues.zip", run the batch file to compile with QB64), with 2 USB mice plugged in, and move one, it displays the device ID and some values. Then if you move the second mouse, the device ID changes. Running it from Windows, where 2 USB mice plugged in both control the same mouse pointer, there is only one set of x/y coordinates. So this example doesn't show separate x/y coordinates for each mouse. 

However JStookey provides a raw mouse API to read separate coordinates from multiple mice (see attached "raw_mouse_test_(attempt_1).zip", and "raw_mouse_test_(attempt_2).zip" where I tried to clean up code putting compound IF statements inside braces, etc.), but either way compiling gives errors (see "errors1.txt").

I am not C-savvy enough to really understand the erorrs but I did see some comments on the page about needing to convert libraries and massage header files to make it work for MinGW. They talk about using a program called, "reimp" (part of MinGW tools) on the MS Platform SDK "user32.lib" file. I don't think I have "reimp" and don't know what this MS Platform SDK is, so I haven't gotten far enough along to try and do the things they are talking about to make it work, and was hoping someone more familiar with that stuff might be able to help figure it out or guide me through some/any of it? 

The hope is that this version (or one slightly modified) could read separate coordinates for each mouse, and QB64 could talk to it and get back separate input for each mouse plugged in. Think of the multiplayer Pong and puzzle games you could make! LoL

Then there is an example program that lists all the raw input devices on the computer (see attached "ListRawInputDevices_vc++.zip") which similarly doesn't compile. That one is in C++, which I have even less of a clue about making work, but GCC should be able to handle C++ so maybe it can work?

Anyway, at least 2 of these examples compile right out of the box, and if anyone has got any interest & spare time to help get the raw mouse API example to work, we could have a way to read 2 or more mice as separate input devices from QB64 (how to get QB64 to talk to a C program is a separate problem, I figure we can tackle another day!)

Meanwhile I will try to mess around with converting libraries / header files as time allows, to see if I can figure it out, but I am sure someone who actually knows what they're doing with the C stuff would have a better chance at succeeding...

Also, I think this RawInput method can be used for reading multiple keyboards as separate devices, which would open up some other interesting possibilities.

That's all I have for now!

Looking at the errors, raw_mouse.c has no WinMain function, so it needs to be compiled to an object (".o") file, then linked to a Windows GUI program which uses it.  In this case, that Windows GUI program is raw_mouse_test.c.

I've modified the batch file to get everything compiled.  The compiler issues a few warnings, but finishes compilation.  raw_mouse_test.exe seems to work, although I only have one mouse to test it on.  ZIP file attached to post.


[Image: 2022-09-06-153904.png]



In regards to ListRawInputDevices_vc++.zip, that is a Visual C++ project, which I am not equipped to handle.  I was able to compile it with MinGW after one small change, but it immediately exits without displaying anything.  No luck for me.


Attached Files
.zip   raw_mouse_test_(attempt_2)_compiles.zip (Size: 17.46 KB / Downloads: 58)
Reply


Messages In This Thread
RE: kind of works? reading multiple mice: any c programmers want to look at this? - by JRace - 09-06-2022, 09:07 PM



Users browsing this thread: 38 Guest(s)