A lightweight Python implementation to map a VEC foot pedal to mouse or keyboard actions under Linux. Adapted from https://github.com/DeflateAwning/vec-footpedal-hid-linux using ChatGPT
- Maps foot pedal buttons to any mouse or keyboard events.
- Automatically finds the foot pedal and reconnects if unplugged.
- Supports Wayland and X11.
- Full hardware-level drag-and-drop support via
uinput. - No need for sudo if udev rules and permissions are correctly configured.
Create a udev rule to allow access to /dev/uinput:
sudo nano /etc/udev/rules.d/99-uinput.rulesPaste in:
KERNEL=="uinput", MODE="0660", GROUP="input"Save and exit, then reload udev rules:
sudo udevadm control --reload-rules
sudo udevadm triggerAdd your user to the input group:
sudo usermod -aG input $USER⚡ Log out and log back in to apply group changes.
python3 -m pip install -r requirements.txtThe requirements.txt should contain:
evdev
python-uinput
Manually:
sudo modprobe uinputOptional: to auto-load at boot:
echo "uinput" | sudo tee /etc/modules-load.d/uinput.confpython3 vec.pyOr enable debug mode to see pedal events:
python3 vec.py --debugCreate a user service:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/footpedal.servicePaste:
[Unit]
Description=Foot Pedal Mapper
After=graphical-session.target
[Service]
ExecStart=/usr/bin/python3 /full/path/to/vec.py
Restart=always
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/$(id -u)
[Install]
WantedBy=default.targetEnable and start the service:
systemctl --user daemon-reload
systemctl --user enable footpedal.service
systemctl --user start footpedal.service- Use
evtestto identify button codes:256= left pedal257= middle pedal258= right pedal
- Listen for key press/release events.
- Map each event to mouseDown/mouseUp via virtual device.
- Send real hardware-level events to the system for maximum compatibility.
this script started as a fork of https://github.com/DeflateAwning/vec-footpedal-hid-linux but no longer refers to it much as far as the code goes. Like the parent repo, I did this with ChatGPT pyton AI. I think the model improved.
The following resources didn't fully solve this use case, so this project was created:
- https://saulalbert.net/blog/transcription-with-a-foot-pedal-under-linux/
- https://github.com/kostmo/footpedal
- https://github.com/peternewman/VECFootpedal
- https://catswhisker.xyz/log/2018/8/27/use_vecinfinity_usb_foot_pedal_as_a_keyboard_under_linux/
-
Make sure the
uinputmodule is loaded:lsmod | grep uinputIf it's not listed, load it manually:
sudo modprobe uinput
-
To auto-load
uinputon every boot, create:echo "uinput" | sudo tee /etc/modules-load.d/uinput.conf
-
Ensure you have created the udev rule:
sudo nano /etc/udev/rules.d/99-uinput.rules
With contents:
KERNEL=="uinput", MODE="0660", GROUP="input"
Then reload rules:
sudo udevadm control --reload-rules sudo udevadm trigger
-
Verify your user is in the
inputgroup:groups
If not, add yourself:
sudo usermod -aG input $USERThen log out and log back in.
- Confirm that the script is using uinput and not fallback methods like
pyautoguiorxdotool. - Ensure your systemd service (if used) has access to the user session's input environment.
- If problems persist, try running the script manually with
sudoas a test to isolate permission issues.
Run the script with --debug enabled to see detailed event logs:
python3 vec.py --debugThis will print pedal press and release events for troubleshooting.