Question

I'm looking for a way to determine if the computer my game is running on has a mouse or a trackpad connected so I can set the default controls accordingly. I'm trying to distinguish a typical keyboard + mouse setup you'd find on a desktop versus a laptop which may or may not have an external mouse but will have a built in trackpad.

In pseudo code this is what I'm trying to achieve:

if (hasMouse())
{
    setUpMouseControls();
}
else if (hasTrackPad())
{
    setUpTrackPadControls();
}

Is there an API that makes this doable? My targets for support are Windows 7+. I'm writing the game in C++.

Was it helpful?

Solution

Some trackpads have special functions that can be used together with a special driver (like scroll bars at the border of the trackpad). In this case it might be possible to detect the presence of a certain device driver (e.g. Acme Trackpad driver).

Howerver this would only work for some track pad models!

You could always detect an USB trackpad by the VID/PID.

However both methods would only work for trackpad models known by your program.

Other trackpads (especially PS/2 ones - maybe built in into laptops) do not identify themselfes as trackpads - they "tell" the computer that they are an ordinary mouse.

There is no chance to detect such a trackpad!

OTHER TIPS

Follow this link: http://msdn.microsoft.com/en-us/library/ms645600%28VS.85%29.aspx

You can use RegisterRawInputDevices function to recieve WM_INPUT messages. Using this message you can determine type of input device and then set your default controls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top