Link to home
Start Free TrialLog in
Avatar of PIBM
PIBM

asked on

Using multiple mouse separately

I want to use at least 2 mouse at the same time (on windows). Those are two logitech optical wheel mouse. I need to have the variation on the X & Y axis of both mouse, separately.

I've tried enumerating the devices with Direct X 8.1 to no avail (well, that's my first try) since I only get one GUID even if I have two mices connected. Moving any of them move the cursor so yes they are both working.

I've included that in the mouse input sample coming with the Direct X 8.1 SDK

std::vector<GUID> aGUID;

BOOL CALLBACK DIEnumProc(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
{
   aGUID.push_back(lpddi->guidInstance);
   return DIENUM_CONTINUE;
}

in the OnCreateDevice fct after the Direct Input object creation.

     aGUID.clear();
     g_pDI->EnumDevices(DI8DEVTYPE_MOUSE, DIEnumProc, 0, DIEDFL_ATTACHEDONLY);

     {
          std::ostringstream os;
          std::hex(os);
          os << "GUID" << std::endl;

          for (int i = 0; i<aGUID.size(); ++i) {
               os << aGUID[i].Data1 << " " << aGUID[i].Data2 << " " << aGUID[i].Data3 << std::endl;
          }

          std::string lReponse = os.str();
          MessageBox(NULL, lReponse.c_str(), "TEST", MB_OK);
     }


I've also tried DIDEVTYPE_HID but I get no device. (and DIEDFL_ALLDEVICES, INCLUDEHIDDEN ..)

I tried direct x since I though we had access to everything... if that's not the solution feel free to use something else, if it's on windows..

I really need to get that working!
Thank you a lot,
  PIBM

2X pts bonus if I get a working answer before Valentine's Day! ;)
Avatar of PIBM
PIBM

ASKER

I forgot to say it must work in win 2k & XP
Thank you again ..
OK, Just for the heck of it, can you look up the pinout of the mouse and just connect the wires of two mice into one PS2 wire?  Perhaps (using ball mice) remove or disconnect the X wheel from one and the Y wheel, from the other (or disable something inside the optical mouse, like, snip a wire)?  Maybe I'm not making sense, but I'm trying to say: would you consider a physical rather than programmatical approach?  Or does this have to be a global, anyone with two mice can do it, solution, like for a game that you're developing?

I'm certain that you have a good reason for doing this, and I am most curious what that might be.

Regards,

-Steve G
Avatar of PIBM

ASKER

I'm sorry to say so but you've not understood what I want. I don't want to disable an axis of each mouse : I want to have the data from both mice at the same time separately.

That mean I want to know what the mouse 1 is doing and what the mouse 2 is doing. That way, I can have two people playing the same game each with a mouse, or I can put two mice together and know the rotational movement (and this is the part that interest me most)

I've made something with Direct Input that enumerate all the device -- I get the GUID of each mouse and then I open a connection to each mouse separately, thus getting the modification of each one .. That works, but only on Win 98 \ Me so far.. so I need something like this for win 2k & XP !

Thank you for your idea, that might get handy for something  else ;)
I'm afraid this only can be done with a device driver. A so-called  filter driver is required to intercept MOUSE_INPUT_DATA coming from mouse drivers.

You can also try to open a GUID_DEVINTERFACE_MOUSE device and then ReadFile( PMOUSE_INPUT_DATA ), but I think this would interfere with the system if worked at all.

Try also XP's WM_INPUT.
Avatar of PIBM

ASKER

Yeah I got it working on XP(Raw Input), as on win 95/98/me (DirectX)... but I need it on win 2k / XP with the same implementation.. I tried opening the device (with readfile) but the access was refused, perhaps since they where already open for 2k..

Do you know how to do thoses filter driver ? Is that device hooks ? I've been able to obtain the DDK of october 2001 if need be for a demo..
I know how to do and I did that. The filter driver hooks between the mouse class driver and Win32 subsystem, or betwen lower device drivers and the mouse class driver.

You may find an example on either www.osr.com or www.sysinternals.com.
Avatar of PIBM

ASKER

I've not found anything on your sites.. can you be more precise, or give me a sample ?
http://www.sysinternals.com/ntw2k/source/ctrl2cap.shtml

This is a keyboard filter, with minimal changes it will work as a mouse filter.
Avatar of PIBM

ASKER

Well, I've looked at it, compiled it, and still hasn't found at all how that could be usefull.

First I must adapt it to be able to get the data from the mouse and that doesn't seem so simple. Second how do we access the information that we are intercepting? Third, if we aren't administrator, does that work ??

I'll continue to look at it but it doesn't seem to be useable..
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PIBM

ASKER

then can you give me your sample ? It's exactly what I need..

And how do we access this driver with another program (to get the data)?
>>then can you give me your sample

Sorry again, I do not write programs for free. I can't give you commercial driver code.

>>And how do we access this driver with another program (to get the data)?

This info is in DDK. You call DeviceIoControl() or ReadFile(), the driver receives IRP_MJ_DEVICE_CONTROL or IRP_MJ_READ.
Avatar of PIBM

ASKER

ok .. I though the driver was using these to get the data.. And that's only for a school project.. Guess I'd better keep the XP thing I did until I get more free time..
If it's just for a school project, just have two programs - one for XP, one for 95/98/ME. Conceal them behind one front-end if you like, but separate programs will be a lot easier in some ways.

One technique I like to do here is to isolate the variant code from the static, and then have two programs sharing most of the code - avoids the version control nightmare.
Avatar of PIBM

ASKER

well it's completed since end of april.. I've used the winxp thing I found since I had no working solution for win2k..

I could have made a front-end, in the case I had been able to get the data...

Anyway, I believe this should be closed since I got no real answer..

Avatar of PIBM

ASKER

Well since none of them had the solution (nothing more than I initially proposed) I believe I should get a refund.. Anyone object ? (Not that I need the points but nothing)

NickRepin still gave good advice about device filter even if he didn't wanted to give out his code =) I would not mind if I had to give him the points, in case his answers could be helpfull to someone else..
Avatar of DanRollins
>> I would not mind if I had to give him the points...
Your call.  If you accept his comment as an answer, it will save us a step in the cleanup.
-- Dan