Hello!
I don't like play with paddles and joysticks in shooter games (it is so hard to target heads with those gizmos) but I like to play them with other players. So I thought it would be funny to play with other players on one computer.
So here is a patch for OIS to support multiple mice. It seems to work (checked under Linux and Windows). You can download it from here:
multiple_mouse_OIS.diffI'm not good in legal stuff so if I did something wrong with the license notice just write me and I'll rewrite it (I did add "Altered OIS source information ... " in files that were changed).
So what I did and how it works:
Linux:Since XInput2 is part of X11 now i just used it. (resources:
http://who-t.blogspot.com/ http://alec.mooo.com/mpx.html )
To set the XInput2 to work you must pass parameters to
InputMenager::createInputSystem( ParamList & params ):
"x11_XInput2" => "true"If it will not be set old InputManager will be used
"x11_XInput2_fallback" => "false"If it will be set then if some error will issue during initialization of XInput2 an exception will be thrown.
By default no exception will be thrown but the old InputMenager will be used.
To see multiple mice pointers see:
http://alec.mooo.com/mpx.htmlIn shortcut:
sudo urpmi xinput #it's simple program to manage devices
xinput create-master "Secondary Pointer Name" #create secondary pointer
#plug other mouse (any time just before next statement)
xinput list #to see ids (id=number)
xinput reattach <id of mouse> <id of master> #as id I mean number
#happily play with multiple mice pointers
#cleanup:
xinput remove-master <id of secondary pointer>
xinput reattach <other mice> <master id>
If you dont create additional pointers you will not be able to use multiple mice.
Win32:I used RawInput and hooks (
http://www.jstookey.com/arcade/rawmouse/ http://msdn.microsoft.com/en-us/library/ms645536 )
I cross-compiled it with mingw so I dont know if it works under M$VC. It was tested on Windows 7 and it seems to work fine.
Parameters for
InputMenager::createInputSystem( ParamList & ):
"RawInput" => "true"If not set the old InputManager will be used
"allowFallback" => "false"If it will be set then if some error will issue during initialization of RawInput an exception will be thrown.
By default no exception will be thrown but the old InputMenager will be used.
"w32_mouse" => "DISCL_BACKGROUND"
"w32_mouse" => "DISCL_EXCLUSIVE"
"w32_mouse" => "DISCL_FOREGROUND"
"w32_mouse" => "DISCL_NONEXCLUSIVE"
I tried to ensure similar behaviour it used to had in old InputManager
"w32_mouse" => "RIDEV_CAPTUREMOUSE"
"w32_mouse" => "RIDEV_EXINPUTSINK"
"w32_mouse" => "RIDEV_INPUTSINK"
"w32_mouse" => "RIDEV_NOLEGACY"
Meaning of these flags can be found here:
http://msdn.microsoft.com/en-us/library/ms645565%28v=VS.85%29.aspx"RawInput_THREAD" => "thread in which hook functions will work"Set if you want pass param to SetWindowsHookEx, if not set it works fine.
"RawInput_WINDOW" => windowHandleIf not set works fine, if you realy want to set this look here:
http://msdn.microsoft.com/en-us/library/ms645565Just like old "WINDOW" param - if you set that no need to worry.
"user32.dll" => "path to user32.dll if it should be dynamically loadedI couldn't dynamically load that library so it's meaningless.
Other:I don't have any other OSes, sorry.
I didn't exactly knew what the return value in the listeners mean. As I read the code guess that if listener returns
true it wants to get next messages and if
false than it wants to stop. And so I implemented the new Mice.
I also changed the ConsoleApp demo to work with multiple mice.
To show how it work I set the new managers to work I turn them on by default in this patch, to change the behaviour to described,
you need to change in these files:
LinuxX11XInput2.cpp
//if( i != paramList.end() && i->second != "false" ) //ania: I used XInput2 by default for debug
if( i == paramList.end() || i->second != "true" ) //we use old Manager by default
return new LinuxInputManager();
Win32RawInput.cpp
if( i != paramList.end() && i->second != "false" ) //ania: for debug I use RawInput
//if( i == paramList.end() || i->second != "true" ) // by default we use old manager
return new Win32InputManager();
Both RawInput and XInput2 can support multiple keyboards too, but for other devices than mice I just copied old code.
Hope someone can use it.
Best regards and sorry for my English.