1
\$\begingroup\$

I am looking to write a non-network multiplayer game for Windows 10 with QB64 that accepts input from 2 or more USB mice plugged into the system. Like a simple Pong game where additional players plug mice into a USB hub to use as game controllers.

I have been googling this and found some older threads

however these are pretty old threads from before Windows 10, also they seem to be more oriented towards C++ or .NET.

Can anyone provide some example how it might be done with QB64 under Windows 10?

Thanks

\$\endgroup\$
2
  • \$\begingroup\$ What kind of issues have you encountered converting the C++ or .NET solutions to QB64? \$\endgroup\$
    – Tyyppi_77
    Dec 2 '20 at 18:29
  • \$\begingroup\$ Mainly nothing I found gave an example of how to read multiple mice. From all the threads, it seems the best bet is to use Microsoft's RawInput API, but their docs are very low level with no examples of how to use the various functions / macros / notifications / structures. I guess I'm not advanced a programmer enough to make sense of it (maybe that's why I am working in BASIC! Lol). I did find a c# example for multiple keyboards (codeproject.com/Articles/17123/…) but I'd have to learn C#, install VS etc, to follow it. Too much work! \$\endgroup\$
    – madscijr
    Dec 7 '20 at 19:20
0
\$\begingroup\$

From the docs on Controller_Devices:

  • In order to read the device controls, the number of input devices MUST first be found using _DEVICES.
  • After the device count is determined we can find out the type of device, the device name and the type of controls available using the _DEVICE$(device_number) function. The function returns a STRING containing information about each numbered device.

When I tried the example code for displaying attached devices, on my system it failed to report the presence of an additional mouse.

The project maintainer suggested using MOUSEPIPEOPEN, but I was not able to separate clicks from two mice on the same PC.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks, I'll give this a try... \$\endgroup\$
    – madscijr
    Dec 7 '20 at 19:18
  • \$\begingroup\$ I plugged in 2 USB mice & tried the example code to enumerate the _DEVICES, but it only sees 1 mouse: DIM devices% : DIM iLoop% : CLS : devices% = _DEVICES : PRINT "# input devices found ="; STR$(devices%) : FOR iLoop% = 1 TO devices% : PRINT _DEVICE$(iLoop%) : PRINT "Buttons:"; _LASTBUTTON(iLoop%) : NEXT iLoop% : PRINT "PRESS <ESC>" : DO : LOOP UNTIL _KEYDOWN(27) Outputs: # input devices found = 2; [KEYBOARD][BUTTON]; Buttons: 512; [MOUSE][BUTTON][AXIS][WHEEL]; Buttons: 3 Any ideas? \$\endgroup\$
    – madscijr
    Dec 8 '20 at 1:56
  • \$\begingroup\$ Let me check a couple more things & get back to you. \$\endgroup\$
    – Pikalek
    Dec 8 '20 at 2:36
  • \$\begingroup\$ The project maintainer suggested using MOUSEPIPEOPEN, but I still wasn't able to separate clicks from 2 mice on the same PC. I did find a very post on the about USB HID I/O on qb64, which might be a different way to approach the problem. I would check w/ the QB64 forum / Discord next; the community seems active & friendly. Sorry I wasn't able to find more than that. If you find an answer, please come back & share it. \$\endgroup\$
    – Pikalek
    Dec 8 '20 at 5:00
  • \$\begingroup\$ No worries I will ask there. Thank you for your efforts! \$\endgroup\$
    – madscijr
    Dec 8 '20 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.