Thanks for the suggestion. I looked up some devices, but all of them cater to musicians -- obviously -- and therefore don't have many different types of input. Korg nanokontrol and nanokontrol studio seem to be the best ones in this regard. I wish there was a device made for hackers with small and large knobs and buttons, horizontal and vertical sliders, touch panels, etc.
For Mac users, BetterTouchTool [0] allows assigning system-wide actions to MIDI inputs. I haven't used its MIDI capabilities, but I happily use its other features.
[0] BetterTouchTool. https://folivora.ai