I do something similar to you. I enumerate all devices and their controls (I've got libraries for pure Win32, DirectInput and RawInput).
I differ between digital values (interpreted as button presses) and analog values (joystick axes for example). Analog axes are also mapped to digital (with threshold).
All these virtual buttons and axes can then be assigned to different actions; customizable by the player. The player can then map any buttons at will (mix joystick, keyboard, mouse).
Fun fact: Mapping the analog axis to digital lets me play jump ´n´ runs with the mouse, and it's actually playable