[Home](/)
2023-10-08. Omar Mustardo.
I had a good experience using a foot pedal while scanning books. It's great to be able to trigger an action while using your hands. I was only borrowing that foot pedal and it was part of a book scanning kit so I needed a different one.
The following sites were useful:
* [http://blog.ssokolow.com/archives/2017/04/10/getting-your-cheap-chinese-usb-foot-pedal-doing-useful-things-on-linux/](http://blog.ssokolow.com/archives/2017/04/10/getting-your-cheap-chinese-usb-foot-pedal-doing-useful-things-on-linux/)
* [https://thejeshgn.com/2022/05/03/usb-foot-pedal-or-switch-as-a-keyboard-in-linux/](https://thejeshgn.com/2022/05/03/usb-foot-pedal-or-switch-as-a-keyboard-in-linux/)
I browsed Amazon but all of the foot pedals seemed overly expensive and not guaranteed to work. I ended up ordering a cheap pedal off of AliExpress: [https://www.aliexpress.us/item/3256803520148582.html](https://www.aliexpress.us/item/3256803520148582.html)
I kept my expectations low. When it arrived I plugged it in and ran `sudo dmesg` to see if it connected.
```
[ 1733.742318] usb 1-2: new full-speed USB device number 12 using xhci_hcd
[ 1733.892366] usb 1-2: New USB device found, idVendor=3553, idProduct=b001, bcdDevice= 0.00
[ 1733.892381] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1733.892389] usb 1-2: Product: FootSwitch
[ 1733.892394] usb 1-2: Manufacturer: PCsensor
[ 1733.898003] input: PCsensor FootSwitch Keyboard as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:3553:B001.0008/input/input33
[ 1733.954698] input: PCsensor FootSwitch Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:3553:B001.0008/input/input34
[ 1733.955195] hid-generic 0003:3553:B001.0008: input,hidraw5: USB HID v1.11 Keyboard [PCsensor FootSwitch] on usb-0000:00:14.0-2/input0
[ 1733.956315] input: PCsensor FootSwitch as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/0003:3553:B001.0009/input/input35
[ 1733.956538] hid-generic 0003:3553:B001.0009: input,hidraw6: USB HID v1.10 Device [PCsensor FootSwitch] on usb-0000:00:14.0-2/input1
[ 1761.593220] usb 1-2: USB disconnect, device number 12
```
It seems to be plug and play. It presses the 'b' key by default. This matches the ssokolow blog linked above, which is a good sign.
I used `watch xinput list` to see which device it was as I unplugged and replugged it. It's: "PCsensor FootSwitch Mouse" and in this case has id=18
A bit more testing with `sudo evtest` (Event Test)
```
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
...
/dev/input/event10: PCsensor FootSwitch Keyboard
/dev/input/event24: PCsensor FootSwitch Mouse
/dev/input/event25: PCsensor FootSwitch
Select the device event number [0-25]: 10
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x3553 product 0xb001 version 0x111
Input device name: "PCsensor FootSwitch Keyboard"
Supported events:
...
```
I'm not sure why it is considered three different devices. The Keyboard one seems to work though. The "Supported events" list is very long since it covers most event/key codes.
Test output from pressing and releasing:
```
Event: time 1696815989.679224, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70005
Event: time 1696815989.679224, type 1 (EV_KEY), code 48 (KEY_B), value 1
Event: time 1696815989.679224, -------------- SYN_REPORT ------------
bEvent: time 1696815989.881227, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70005
Event: time 1696815989.881227, type 1 (EV_KEY), code 48 (KEY_B), value 0
Event: time 1696815989.881227, -------------- SYN_REPORT ------------
```
The top of ssokolow's blog suggests using: [https://github.com/rgerganov/footswitch](https://github.com/rgerganov/footswitch)
I gave it a try with:
```
sudo apt-get install libhidapi-dev
git clone https://github.com/rgerganov/footswitch.git
cd footswitch
make
sudo make install
```
It failed at `make` with:
```
footswitch.c:28:10: fatal error: hidapi.h: No such file or directory
28 | #include