As you can imagine, this depends entirely on the kind of control device you want to implement.
At the beginner end of the spectrum, there are devices like the Makey Makey, which is basically a kit for setting up custom controllers out of everyday items like tinfoil or bananas.
The device has a circuit board you can wire up to electrodes on the controller you've built, and the circuit board itself connects to a PC via USB. It reports itself as a standard keyboard, so listening & responding to inputs from your custom controller is the same as reacting to key presses in your language/framework/engine of choice. No special software or libraries required.
It may seem simplistic, but you can make some pretty exciting controllers this way. Our first prototypes for the modular starship construction in Starlink were built using a Makey Makey and LEGO bricks. :)
The next level of complexity you might try is a programmable input emulator like GlovePIE on Windows (now dead, but an open-source alternative FreePIE exists), or OSCulator on Mac.
These programs know how to read input from a vast array of controllers — including things like Wii remote motion sensors — and can translate them to a standard format called "Open Sound Control". You can listen for these messages in your game using a suitable OSC library to react to these inputs, without managing all the complexity of device drivers or network protocols yourself.
You can then combine inputs from a whole batch of different devices, or even tear them apart and embed their guts in a custom form of your choosing. :)
The next level up would be using a miniature computer like an Arduino or Raspberry PI to build your controller. These hobbyist devices are commonly used for making one-off gadgets like controllers, so you should be able to find guides or pre-made kit parts for the features you need.
Because these are fully programmable computers, you have the freedom to make them work and communicate however you want - over USB, Bluetooth, Wifi, or other connections of your own design - but you'll usually have to implement your own networking code or device driver / human interface device reporting to make the connection on each end.
Other answers may be able to give more detailed insights into the types of communication or libraries that can help you here.
Beyond that, you can look at less hobbyist-friendly microcontrollers, paring down the feature set from the full computers onboard the Arduino/PI to just the bare minimum you need. (The final shipping Starship mounts & parts in Starlink use a much simpler chip, for example)