The way that you read from other input devices is device-specific. You'd have to use the APIs on the platform that you're using; the APIs are different on each platform.
If you're really curious, you can google search for "C++ mouse input" or "C++ joystick input" (and even "C++ keyboard input" for low-level keyboard handling) to find the details that you're looking for. Add "Windows", "Linux", or "Mac" to the search to find results for your specific platform.
Note that you can find some excellent low-level device control, suitable for game development, on the Stack Exchange Game Development site.
Windows APIs
On Windows, the low-level device inputs require that you use the Windows event-handling system and handling the specific events that your app needs. Microsoft documents the low-level APIs on the Windows Dev Center.
The specific APIs are:
Mac OS X
Handling low-level input events on the Mac is different than on Windows, and the documentation on the Mac Developer Library is often presented in Objective C, rather than C++. It's useful to note that on Mac OS X, XCode will allow you to write hybrid C++/Objective C code called Objective C++, so you can easily leverage your C++ experience.
The individual APIs are:
Linux/*nix
Linux (and other Unix-like systems) can support X11, KDE, or Gnome GUIs, so those each have their own APIs. I won't enumerate them here, but you can easily locate the appropriate APIs for your purpose, if you want to develop for Linux, FreeBSD, OpenBSD, or any of the other Unix variants.
Abstraction Libraries / Frameworks
There are a number of libraries (C) and frameworks (C++) that provide cross-platform interfaces for low-level input and output. Some are very well done and widely supported, and often have game engines built on them.
Some very common and well supported libraries are:
There are also portable frameworks, typically used for developing more traditional applications, and these also provide abstractions for handling user input:
If you dig around just a bit, you can find many, many more portable libraries and frameworks. Not only will they generally make it easier to develop complex logic, you'll also have a significant advantage getting your code to build and run on another platform, entirely.