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:

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

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’ button 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 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 <hidapi.h>

Search results suggest this is due to libhidapi-dev not being installed, which is odd because that step seems to have worked. I searched more and one other person had a build error, and on a whim I installed the packages they needed: sudo apt install pkg-config libusb-dev

This seems to have worked.

$ sudo make install
/usr/bin/install -c -d /usr/local/bin
/usr/bin/install -c footswitch /usr/local/bin
/usr/bin/install -c scythe /usr/local/bin
/usr/bin/install -c scythe2 /usr/local/bin
/usr/bin/install -c -d /etc/udev/rules.d
/usr/bin/install -c -m 644 19-footswitch.rules /etc/udev/rules.d

Now footswitch is installed, so it’s time to configure the foot pedal. I want it to do printscreen. I first check the defaults:

$ sudo footswitch -r
[switch 1]: a
[switch 2]: b
[switch 3]: c

Despite only having a single device, I guess it’s considered #2, since I’m seeing ‘b’ written when I press it.

To determine which keycode I want to program it with, I ran sudo evtest, chose my normal keyboard, and pressed printscreen.

Event: time 1696817084.289900, -------------- SYN_REPORT ------------
Event: time 1696817086.433854, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70046
Event: time 1696817086.433854, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 1
Event: time 1696817086.433854, -------------- SYN_REPORT ------------
Event: time 1696817086.529856, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70046
Event: time 1696817086.529856, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 0

So I want KEY_SYSRQ “Sys Rq” is shared with the printscreen key on my keyboard.

sudo footswitch -2 -k SYSRQ failed with “Cannot encode key ‘SYSRQ’” I tried sudo footswitch -2 -k printscreen and this worked.