Checking for devices...
I'm using Dev-C++ 188.8.131.52 on Windows XP Home Edition, and I am wondering if there is a way to see if the mouse and the keyboard are plugged into the computer. Like:
or something along those lines. Thanks.
if( !MousePluggedIn )
std::cout << "No mouse!";
else if( !KeyboardPluggedIn )
std::cout << "No keyboard!";
I can't find anything to determine if a keyboard is available, but I can answer your mouse question.
Using Win32API, you can determine if the mouse is available by:
The value of fMouse will be TRUE (nonzero) if a mouse is installed and 0 if mouse is not installed.
fMouse = GetSystemMetrics(SM_MOUSEPRESENT);
(However in Windows 98 this functions always returns TRUE whether a mouse is attached or not)
To determine the number of mouse buttons:
cButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
According to MSDN, GetSystemMetrics( SM_MOUSEPRESENT ) returns non-zero if there is a mouse installed and zero if there isn't. I tested this: mouse in was true and mouse out was true. This seems to be because the mouse is installed whether or not it is plugged into the computer. Thanks anyways :)