Thursday, April 2, 2009

Software - Multiple Mice Support for VC++ 6.0



So, I've been working to add multiple mouse support to my Wii games - it is easiest to first support multiple mice, then trivial to point the mouse functions to Wiimote functions. That way i can debug and develop without waving a Wiimote at my PC. Wiimotes are fun to play with , but not fun to write code with ;-)


MSoft has a new SDK for Multi-Mouse support here - http://blogs.msdn.com/multipoint/default.aspx , but guess what - it doesn't support C++! I know, managed code is "the way of the future", but I have alot of old C++ applications, and I'm slow to transition to C#. Besides, if I can do it in C++, I can more easily do it in C#, right? So, I found this ManyMouse class: http://icculus.org/manymouse/ and finally got it to work with VC++ 6.0, which was no small feat!





Here is my test app - it lets me manually handle and draw separate cursors and handle separate mouse-clicks. I've begun porting it into my "quick-draw" application, and I'll release it soon.

To use the manymouse class, simply follow the directions Ryan Gordon includes with the files. C++ 6.0 compiler had some errors to overcome:


error LNK2005: "void __cdecl operator delete(void *)"(??3@YAXPAX@Z)... is caused by the compiler itself, and can be avoided by forcing the build despite the linker error. Go to Proj Settings->Build menu ->Settings ->Link->Customize and select "force file output".

fatal error LNK1103: debugging information corrupt;... is another compiler bug (so much for using VC++ 6.0, right?) and can be fixed simply by building the release version instead of the debug version.

there were also pre-compiler header errors when compiling the .c and .h files - in Project Settings you can specify NOT to use P-C headers for each of these files.

The demo app works pretty good - it tracks separate mouse movements and button clicks on the screen. Basically, I override the WM_LMOUSEBUTTON and WM_MOUSEMOVE events, and use them to manually track which mouse moved or clicked, and record the position of the cursor manually. in the OnPaint() override function, I then manually track and paint each cursor independant. If you are interested, I'll send you the sourcecode... I'm also planning to post it on CodeProject.com. Multiple mice is a great option for games and data collection.

I've just posted an article on how I did this using VC++ 6.0 on CodeProject: http://www.codeproject.com/KB/docview/ManyMouse.aspx

The demo application is about 220kb and can be downloaded HERE: http://nwpodcast.comuf.com/ManyMouseDlg.exe

No comments:

Post a Comment