Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to be committed: #76

Open
wants to merge 19 commits into
base: six-buttons
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ubuntu-build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Dependencies
run: |
sudo apt update
sudo apt install libhidapi-dev
- name: Build
run: make

osx-build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Dependencies
run: |
brew update
brew install hidapi
- name: Build
run: make
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.swp

# binaries
scythe
footswitch
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

14 changes: 9 additions & 5 deletions 19-footswitch.rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ATTR{product}=="FootSwitch*"\
MODE:="0666"\
GROUP="hid"\
RUN+="keymap $name 0x70066 screenlock"\
SYMLINK+="footswitch"
# PCsensor
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7403", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7404", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="413d", ATTRS{idProduct}=="2107", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e026", TAG+="uaccess"
# Scythe
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0426", ATTRS{idProduct}=="3011", TAG+="uaccess"
# Scythe2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="055a", ATTRS{idProduct}=="0998", TAG+="uaccess"
13 changes: 13 additions & 0 deletions HomebrewFormula/footswitch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Footswitch < Formula
desc "Command-line utility for PCsensor foot switch"
homepage "https://github.com/rgerganov/footswitch"
license "MIT"
head "https://github.com/rgerganov/footswitch.git"

depends_on "hidapi"

def install
system "mkdir", "#{prefix}/bin"
system "make", "install", "PREFIX=#{prefix}"
end
end
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,30 @@ else
endif
endif

all: footswitch scythe
all: footswitch scythe scythe2

footswitch: footswitch.c common.c debug.c
scythe: scythe.c common.c debug.c
scythe2: scythe2.c common.c debug.c

install: all
$(INSTALL) footswitch $(PREFIX)/bin
$(INSTALL) scythe $(PREFIX)/bin
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
$(INSTALL) footswitch $(DESTDIR)$(PREFIX)/bin
$(INSTALL) scythe $(DESTDIR)$(PREFIX)/bin
ifeq ($(UNAME), Linux)
$(INSTALLDATA) 19-footswitch.rules /etc/udev/rules.d
$(INSTALL) -d $(DESTDIR)$(UDEVPREFIX)/rules.d
$(INSTALLDATA) 19-footswitch.rules $(DESTDIR)$(UDEVPREFIX)/rules.d
endif

uninstall:
rm -f $(PREFIX)/bin/footswitch
rm -f $(PREFIX)/bin/scythe

rm -f $(DESTDIR)$(PREFIX)/bin/footswitch
rm -f $(DESTDIR)$(PREFIX)/bin/scythe
ifeq ($(UNAME), Linux)
rm -f /etc/udev/rules.d/19-footswitch.rules
rm -f $(DESTDIR)$(UDEVPREFIX)/rules.d/19-footswitch.rules
endif

clean:
rm -f scythe footswitch *.o

clean:
rm -f scythe scythe2 footswitch *.o
rm -f scythe footswitch *.o
53 changes: 53 additions & 0 deletions Makefile.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
PREFIX = /usr/local
UDEVPREFIX = /etc/udev

INSTALL = /usr/bin/install -c
INSTALLDATA = /usr/bin/install -c -m 644
CFLAGS = -Wall
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
LDLIBS = $(shell pkg-config --libs hidapi)
else
ifeq ($(UNAME), Linux)
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
LDLIBS = $(shell pkg-config --libs hidapi-libusb)
else
LDLIBS = -lhidapi
endif
endif

all: footswitch scythe scythe2

footswitch: footswitch.c common.c debug.c
scythe: scythe.c common.c debug.c
scythe2: scythe2.c common.c debug.c

install: all
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
$(INSTALL) footswitch $(DESTDIR)$(PREFIX)/bin
$(INSTALL) scythe $(DESTDIR)$(PREFIX)/bin
ifeq ($(UNAME), Linux)
$(INSTALL) -d $(DESTDIR)$(UDEVPREFIX)/rules.d
$(INSTALLDATA) 19-footswitch.rules $(DESTDIR)$(UDEVPREFIX)/rules.d
endif

<<<<<<< HEAD
uninstall:
=======
uninstall:
>>>>>>> 87f1a4f ( Changes to be committed:)
rm -f $(DESTDIR)$(PREFIX)/bin/footswitch
rm -f $(DESTDIR)$(PREFIX)/bin/scythe
ifeq ($(UNAME), Linux)
rm -f $(DESTDIR)$(UDEVPREFIX)/rules.d/19-footswitch.rules
endif


clean:
<<<<<<< HEAD
rm -f scythe scythe2 footswitch *.o

=======
rm -f scythe footswitch *.o
>>>>>>> 87f1a4f ( Changes to be committed:)
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
[![Build Status](https://travis-ci.org/rgerganov/footswitch.svg?branch=master)](https://travis-ci.org/rgerganov/footswitch)
[![Build Status](https://github.com/rgerganov/footswitch/workflows/CI/badge.svg)](https://github.com/rgerganov/footswitch/actions)

Footswitch
----------

Command line utlities for programming [PCsensor][1] 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`:
Command line utlities for programming [PCsensor][1] and [Scythe](https://www.scythe-eu.com/en/products/pc-accessory/usb-foot-switch-ii.html) foot switches.

* `0c45:7403`
* `0c45:7404`
* `413d:2107`
The following list of devices are supported:

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.
| vendorId | productId | Program |
| ---------|----------| ------------ |
| 0c45 | 7403 | `footswitch` |
| 0c45 | 7404 | `footswitch` |
| 413d | 2107 | `footswitch` |
| 1a86 | e026 | `footswitch` |
| 1a86 | e02d | `footswitch` |
| 0426 | 3011 | `scythe` |
| 055a | 0998 | `scythe2` |

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][2].

Expand All @@ -24,13 +32,13 @@ The programs are using the [hidapi][3] library and should work on Linux and OSX.
make
sudo make install

The `install` target installs udev rules on Linux which allow running the programs without root.
You may need to use `sudo` otherwise.

To build on OSX:

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

Usage
-----
Expand Down
2 changes: 2 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ static const keymap_entry keymap[] =
{"XF86AudioRaiseVolume", 0x80},
{"XF86AudioLowerVolume", 0x81},
{"<82>", 0x82},
{"Hangul", 0x82},
{"<83>", 0x83},
{"Hangul_Hanja",0x83},
{"A", 0x84},
{"B", 0x85},
{"C", 0x86},
Expand Down
17 changes: 10 additions & 7 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ THE SOFTWARE.
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#include <stdbool.h>

enum modifier {
CTRL = 1,
SHIFT = 2,
ALT = 4,
WIN = 8,
R_CTRL = 16,
R_SHIFT = 32,
R_ALT = 64,
R_WIN = 128,
};

enum mouse_button {
Expand All @@ -36,14 +41,12 @@ enum mouse_button {
MOUSE_DOUBLE = 8,
};

typedef unsigned char Bool;
bool parse_modifier(const char *arg, enum modifier *mod);
bool parse_mouse_button(const char *arg, enum mouse_button *btn);

Bool parse_modifier(const char *arg, enum modifier *mod);
Bool parse_mouse_button(const char *arg, enum mouse_button *btn);

Bool encode_string(const char *str, unsigned char *arr);

Bool encode_key(const char *key, unsigned char *b);
bool encode_string(const char *str, unsigned char *arr);
bool encode_char(const char ch, unsigned char *b);
bool encode_key(const char *key, unsigned char *b);

const char* decode_byte(unsigned char b);

Expand Down
6 changes: 4 additions & 2 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ THE SOFTWARE.
#include "debug.h"

void debug_arr(unsigned char data[], int length) {
int i;
for (i = 0 ; i < length ; i++) {
for (int i = 0 ; i < length ; i++) {
if (i > 0 && i % 16 == 0) {
printf("\n");
}
printf("%02x ", data[i]);
}
printf("\n");
Expand Down
Binary file added footswitch
Binary file not shown.
Loading