QinHeng Electronics Foot Pedal

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

USB Foot Pedal for a PC by QinHeng Electronics - device OS independent (Linux, Windows, etc).

This is a series of foot pedal switches that appear unbranded and are sold on ebay. There is a single pedal version and a three pedial version. The foot switch connects to the computer by a USB interface. The foot pedal is programmed into its own firmware with a character or string that will be sent to the computer via input I/O when depressed, much like a keyboard does when a key is depressed. Consider that it functions like a keyboard which has only a single key.

Programming software included with the device is Windows only even though the devices is marketed as OS independent. An independent developer created a utility using the C programming language and can be executed on Linux.

Programming

Windows

Linux and Mac

The programs are using the hidapi library and should work on Linux and OSX. To build on Linux:

sudo apt-get install libhidapi-dev
git clone https://github.com/rgerganov/footswitch.git
cd footswitch
make
sudo make install

To build on OSX:

brew install hidapi
git clone https://github.com/rgerganov/footswitch.git
cd footswitch
make
sudo make install


Obtained the source and compiled.

But first you will need libhidapi-dev or you will get an error "error while loading shared libraries: libhidapi-libusb.so.0: cannot open shared object file: No such file or directory"

sudo apt-get install libhidapi-dev


$ ls -l ./by-id|grep e026
lrwxrwxrwx 1 root root 9 Feb  9 15:12 usb-1a86_e026-event-mouse -> ../event9
lrwxrwxrwx 1 root root 6 Feb  9 15:12 usb-1a86_e026-mouse -> ../js0
$ udevadm monitor --udev

monitor will print the received events for:

UDEV - the event which udev sends out after rule processing

udevadm monitor [options]
      Listens to the kernel uevents and events sent out by a udev rule and prints the devpath of the event to the console. It can be used to analyze the event timing, by comparing the timestamps of the kernel uevent and the udev
      event.

      -k, --kernel
          Print the kernel uevents.

      -u, --udev
          Print the udev event after the rule processing.

      -p, --property
          Also print the properties of the event.

      -s, --subsystem-match=string[/string]
          Filter kernel uevents and udev events by subsystem[/devtype]. Only events with a matching subsystem value will pass.

      -t, --tag-match=string
          Filter udev events by tag. Only udev events with a given tag attached will pass.

$ footswitch Usage: footswitch [-123] [-r] [-s <string>] [-S <raw_string>] [-ak <key>] [-m <modifier>] [-b <button>] [-xyw <XYW>]

  -r          - read all pedals
  -1          - program the first pedal
  -2          - program the second pedal (default)
  -3          - program the third pedal
  -s string   - append the specified string
  -S rstring  - append the specified raw string (hex numbers delimited with spaces)
  -a key      - append the specified key
  -k key      - write the specified key
  -m modifier - ctrl|shift|alt|win
  -b button   - mouse_left|mouse_middle|mouse_right
  -x X        - move the mouse cursor horizontally by X pixels
  -y Y        - move the mouse cursor vertically by Y pixels
  -w W        - move the mouse wheel by W
You cannot mix -sSa options with -kmbxyw options for one and the same pedal
$ sudo footswitch -r
[switch 1]: a
[switch 2]: b
[switch 3]: c
$ sudo footswitch -1 w
$ sudo footswitch -2 w
$ sudo footswitch -3 w
$ sudo footswitch -r
[switch 1]: unconfigured
[switch 2]: unconfigured
[switch 3]: unconfigured
$ sudo footswitch -1
$ sudo footswitch -k w
$ wwwwwwwwwwww


Command line utlities for programming PCsensor and Scythe foot switches. There is support for both single pedal devices and three pedal devices. Use the footswitch binary for the following combinations of vendorId:productId:

   0c45:7403
   0c45:7404
   413d:2107

Scythe switches with vendorId:productId=0426:3011 can be programmed with the scythe binary. You can find the vendorId and productId of your device using the lsusb command on Linux.

The same kind of foot switches are used for building the popular VIM Clutch.


0x4F	Keyboard RightArrow
0x50	Keyboard LeftArrow
0x51	Keyboard DownArrow
0x52	Keyboard UpArrow
sudo footswitch -k w


Codes taken from: http://www.freebsddiary.org/APC/usb_hid_usages.php

sudo ./footswitch -S '28'

In this example the 28 produces a carriage return because 28 is 0x28 Keyboard Return (ENTER)

sudo ./footswitch -S '52'

In this example the 52 produces up arrow press because 2 is 0x52 Keyboard UpArrow

But this is only momentary. It is not like holding the UpArrow key depressed, so in a video game you will not keep moving forward but only just take a single step.

sudo /chooser/footswitch -k up

The key name 'up' refers to the up arrow key 0x52 which in this example will act as a keyboard key so that it is _not_ momentary when the foot pedal remains depressed.

THREE PEDAL SWITCH / MULTI PEDAL SWITCH

For a multi pedal switch you are not going to be able to program each pedal one at a time on individual command lines. All three must be programmed on a single command line. Each time the command is executed any unspecified pedals are simply set to null, therefore, even if you intend on only changing a single pedal it is still necessary to reinforce the same command on the other two. Here is an example command line:

sudo footswitch -3 -k up -1 -k down -2 -k enter