BlitzMice

BlitzMax Forums/BlitzMax Module Tweaks/BlitzMice

Ferminho(Posted 2005) [#1]
I hope someone finds this useful:

http://personales.ya.com/ferminho/BlitzMice.0.3.zip

BlitzMice is a small mod that lets you read input from more than one mouse at the same time.

It's currently 0.3, working only under Windows. Hopefully I'll manage to make it fully cross-platform. (As I don't have a Mac neither I have Linux installed -but planning on doing so someday again-, any help in this point would be greatly appreciated)

For the Win version I heavily modified an opensource driver+api that is the real one doing all the dirty job.
It's called CPNMouse - http://cpnmouse.sourceforge.net

As far as I know, should work under Win2000 and WinXP (any NT will do, I guess).

My current experience is: working under 2kPro, not working under W98 and half-way on XP Pro (only driver for the ps2 mouse worked for me, USB one rejected). Still got to try with some COM mouse I have, too.

For info on issues, how to install etc please refer to BlitzMice.bmx

This mod isn't complete, of course; however I've focused it to use it as an 'add-on', I mean, as 'another' control method for a game, but never meant to be a required one.

IMPORTANT : Main mouse gets frozen while the app is running. Not only in Bmax's app but in Windows. So, Blitzmax's Mouse functions are disabled while BlitzMice is inited. Only one of both can be used at a time. Killing BlitzMice anytime makes mouse return to its 'normal' state.


xlsior(Posted 2005) [#2]
Heh, I did this eons ago in AMOS on the Amiga, analyze the bit stream coming in on the joystick port to analyze mouse movements, to generate 2 seperate pointers. (Mouse and joystick sent different signals so the built-in joystick commands wouldn't work with the mouse)

Can be pretty nice for a 2-player game, although nowadays it's seems to be more common to do multi-player over LAN than on the same computer.

(A few years later I also got the serial mice signals working under PowerBASIC for DOS, to get mouse input without the need for a mousedriver to be loaded under DOS... That was well before USB mice entered the scene though.)


Ferminho(Posted 2005) [#3]
I thought of doing a joystick driver that mapped the mouse movement as an analog joystick X-Y axis movement, too :) but I think that'd be quite a challenge for me

Although maybe it'd be the easiest way to make it cross-platform... maybe I'll have a look on it.


Space_guy(Posted 2005) [#4]
Sounds great! i wishedfor that one some months ago. better try it out. i might get back in a programming new golden age of programming my darned game :)


xlsior(Posted 2005) [#5]
I thought of doing a joystick driver that mapped the mouse movement as an analog joystick X-Y axis movement, too :) but I think that'd be quite a challenge for me


On the Amiga the joystick port and the mouseport looked the same -- Normally your mouse was in port 1 and your joystick in port 2, but you could also fit two mice or two joysticks instead...

The catch was that most programming languages did support two joysticks out of the box, but not two mice.

On the PC you can't really hijack the joystick port for mouse usage as easily since you won't be able to physically plug a mouse into it... Although you can always steer a 'mousepointer' using a real joystick.


Vorderman(Posted 2005) [#6]
Yeah, 2 player Lemmings on the Amiga with 2 mice - multiplayer gaming perfection!


Robert Cummings(Posted 2005) [#7]
This is FANTASTIC!

Any chance of getting it working under win98 and Mac os X ?

What happens when a user alt-tabs?


TartanTangerine (was Indiepath)(Posted 2005) [#8]
This can also be achieved by using the raw input feeds and it used in great effect in games like Big Kahuna Reef. The downside is that it's XP and 2000 only and will never work on win98 due to internal structures. With Raw Input you do not need any additional drivers and it will work with as many mice as you can plug in your machine. In fact it will work with any input device(s) you want.

Here is some sample code if anyone is interested : http://www.indiepath.com/tim/2micesample.rar


Ferminho(Posted 2005) [#9]
On the PC you can't really hijack the joystick port for mouse usage as easily since you won't be able to physically plug a mouse into it... Although you can always steer a 'mousepointer' using a real joystick.

I didn't explain myself quite right; I was referring to read an USB Device (mouse) with a self-made joystick driver (making the OS think it's a joystick). But of course it'd be far from easy to do that (at least for me with not much driver knowledge -yet-).

This is FANTASTIC!
Any chance of getting it working under win98 and Mac os X ?
What happens when a user alt-tabs?

Glad you like the idea :) About win98 I'm afraid it's very unlikely it'll work unless I do something like I've said before (using a fake joystick) or someone comes with a better idea.
About Mac, I'll do what I can. I myself don't have a Mac. If noone can help with this port I'll manage somehow...

And well, it may sound stupid but I haven't tried alt-tabbing! I did the little test in windowed mode and Windows' mouse was clearly locked. *MAYBE* it'd be necessary to detect when the user wants to alt+tab to kill BlitzMice, then restore it again (f.e : ESC brings up the menu, killing BMice and using bmax mouse. In this state player may alt+tab with no problems. Returning to the app and closing the menu inits BlitzMice again)

This can also be achieved by using the raw input feeds and it used in great effect in games like Big Kahuna Reef. The downside is that it's XP and 2000 only and will never work on win98 due to internal structure

I thought Raw Input was XP only? that's what I found when looking for some info and that's why I turned it down... I better check it out again :) Thanks IndiePath!

This is indeed a better approach, as no driver has to be installed. I'll look into it this afternoon at home ;)

Thanks for your comments


Ferminho(Posted 2005) [#10]
I just tried it in a Win2k Pro and got a "raw_input_init failed". Will try at home later too.

But I searched again and found in MSDN Raw Input is only XP supported

[Edited] I tried here at home too and got the same error. I'm afraid raw input is XP only :/ however, if I could get system information to determine if it's running 2k or XP, I could make BMice choose wether to use CPNMouse or raw input...


TartanTangerine (was Indiepath)(Posted 2005) [#11]
No one is going to install the CPN driver to use your code.


Ferminho(Posted 2005) [#12]
Thanks for the tip. But it's still better than nothing. (And probably better than having to install XP)


Robert Cummings(Posted 2005) [#13]
How does that kung fu game with multiple mice do it? it works on all machines as far as I know.


Ferminho(Posted 2005) [#14]
In fact that's where I first found that raw input is XP only :(

[url]http://www.rdkf.net/index.php?module=content&id=2#2-7[/url]
"Multi Mice will only work with Windows XP"

It's funny because it was a freelance dev who made a multi mice mod for Mame, and got mailed by the guys of Ragdoll KungFu
[url]http://link.mywwwserver.com/~jstookey/arcade/rawmouse/[/url]

He mentions too that...
"Microsoft removed support for using multiple mice independently from DirectX in Windows XP."

does this mean is there a way to read multiple mice with DirectX in previous Win versions? do anyone know something about this?


xlsior(Posted 2005) [#15]
Of course there's also a difference between supporting multiple mice, and supporting multiple *seperate* mice. I've used systems with both a PS/2 and serial mice at the same time, or of course simultaneous mouse + touchpad on a laptop... But you are still onyl controlling a single arrow, even though it can be moved using any of the controllers.


Hotcakes(Posted 2005) [#16]
Ferminho, I think DirectInput 7 had support for multiple mice... I think somebody did a userlib for it a looong time ago.


Ferminho(Posted 2005) [#17]
Thanks Vanilla! I'll look into it