In addition to the USB keyboard, I added a three channels digital input (on/off) just by using an old USB mouse

In any mouse there are three button switches (SW1-2-3 in the picture) that triggerhappy can handle.

Triggerhappy discovering function:
root@OpenWrt:~#
thd --dump /dev/input/event*EV_KEY BTN_LEFT 1 /dev/input/event0
# BTN_LEFT 1 command
EV_KEY BTN_LEFT 0 /dev/input/event0
# BTN_LEFT 0 command
EV_KEY BTN_MIDDLE 1 /dev/input/event0
# BTN_MIDDLE 1 command
EV_KEY BTN_MIDDLE 0 /dev/input/event0
# BTN_MIDDLE 0 command
EV_KEY BTN_RIGHT 1 /dev/input/event0
# BTN_RIGHT 1 command
EV_KEY BTN_RIGHT 0 /dev/input/event0
# BTN_RIGHT 0 command
# values for key events are 1 (pressed), 0 (released)
than to associate a command to each button when is
pressed, add the following lines to your triggerhappy configuration file (/etc/triggerhappy/triggers.d/example.conf):
BTN_LEFT 1 /path/command &
BTN_MIDDLE 1 /path/command &
BTN_RIGHT 1 /path/command &
or to associate a command when the button is
released:
BTN_LEFT 0 /path/command &
...This is a generic schematic of a USB mouse:

Each button switch needs to be grounded to give "1" level for tryggerhappy, you can connect in parallel to the switch a transistor/mosfet, a relay or an optocoupler to perform this function.
P.S.: Triggerhappy does not handle the rotary encoder of the mouse, but Openwrt does, if you want to see what openwrt sees when the rotary encoder of the mouse is turned use this command:
cat /dev/input/event0 |hexdumpYou'll get something like this:
Clockwise rotation:
root@OpenWrt:~# cat /dev/input/event0 |hexdump
0000000 54a4 185d 0007 1259 0002 0008 0000 0001
0000010 54a4 185d 0007 1267 0000 0000 0000 0000
0000020 54a4 185e 0000 3c9c 0002 0008 0000 0001
0000030 54a4 185e 0000 3caa 0000 0000 0000 0000
0000040 54a4 185e 0006 95d2 0002 0008 0000 0001
0000050 54a4 185e 0006 95e0 0000 0000 0000 0000
0000060 54a4 185e 0007 eda1 0002 0008 0000 0001
0000070 54a4 185e 0007 edae 0000 0000 0000 0000
0000080 54a4 185e 0008 a911 0002 0008 0000 0001
0000090 54a4 185e 0008 a91e 0000 0000 0000 0000
00000a0 54a4 185e 000a 00f2 0002 0008 0000 0001
00000b0 54a4 185e 000a 0100 0000 0000 0000 0000
00000c0 54a4 185e 000b b674 0002 0008 0000 0001
00000d0 54a4 185e 000b b680 0000 0000 0000 0000
Counter clockwise rotation:
root@OpenWrt:~# cat /dev/input/event0 |hexdump
0000000 54a4 1865 000b d96a 0002 0008 ffff ffff
0000010 54a4 1865 000b d977 0000 0000 0000 0000
0000020 54a4 1865 000e 4a6c 0002 0008 ffff ffff
0000030 54a4 1865 000e 4a78 0000 0000 0000 0000
0000040 54a4 1866 0000 9e86 0002 0008 ffff ffff
0000050 54a4 1866 0000 9e95 0000 0000 0000 0000
0000060 54a4 1866 0001 f647 0002 0008 ffff ffff
0000070 54a4 1866 0001 f654 0000 0000 0000 0000
0000080 54a4 1866 0003 cb1d 0002 0008 ffff ffff
0000090 54a4 1866 0003 cb2b 0000 0000 0000 0000
00000a0 54a4 1866 0005 a001 0002 0008 ffff ffff
00000b0 54a4 1866 0005 a00f 0000 0000 0000 0000
00000c0 54a4 1866 0007 f1c9 0002 0008 ffff ffff
00000d0 54a4 1866 0007 f1d5 0000 0000 0000 0000
00000e0 54a4 1866 000a dfe4 0002 0008 ffff ffff
00000f0 54a4 1866 000a dff2 0000 0000 0000 0000