aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Healy <lmiphay@gmail.com>2015-11-03 20:15:04 +0000
committerPaul Healy <lmiphay@gmail.com>2015-11-03 20:15:04 +0000
commit9502e81dba59856dd2556e1e34b173e1d6122523 (patch)
tree020a30a1cca3304ca8076665e885f5c6abb6f0e2 /app-misc/g13
parentadd ebuild for latest known working version (diff)
downloadlmiphay-9502e81dba59856dd2556e1e34b173e1d6122523.tar.gz
lmiphay-9502e81dba59856dd2556e1e34b173e1d6122523.tar.bz2
lmiphay-9502e81dba59856dd2556e1e34b173e1d6122523.zip
add experimental modifier patch
Diffstat (limited to 'app-misc/g13')
-rw-r--r--app-misc/g13/Manifest4
-rw-r--r--app-misc/g13/files/add-modifiers.patch314
-rw-r--r--app-misc/g13/g13-9999.ebuild1
3 files changed, 318 insertions, 1 deletions
diff --git a/app-misc/g13/Manifest b/app-misc/g13/Manifest
index 5f76705..46a5330 100644
--- a/app-misc/g13/Manifest
+++ b/app-misc/g13/Manifest
@@ -1,6 +1,8 @@
AUX 99-uinput-g13.rules 48 SHA256 499589608961e50edc99a9d4652a5153091436b487cd4e365fe1e4cc9b25b2e3 SHA512 880c08499031a0ee3ce0868112c689358a800a09489a33eea7c34d433221cc483ac1e6ca7fbbc95531b9f93259da84d6404070f59c9a3752d60971b3cd9e4c16 WHIRLPOOL 0319b513c89b4ddd09a855ebd6e3c0171275c2c66ba19ba56c31f5919628e1949b03132ffd62827e9a8077c0d66aa4d58d5a69bad250b633d068a2d22862c447
+AUX add-modifiers.patch 10316 SHA256 e2c4e6e556f1fcc908ef28d57ee3d9f1c4dc2a035b16c6621039fc9a2b664e16 SHA512 12d932bb53c10a2df93a943517ba07cfae98bbf0aeb1a4959d9e08e178894ebeb4a7fb4508a6ed76c5779a07aeda8a1ee6fcbb881f3d72b2a8cfa746b23d435e WHIRLPOOL 2072730fe365b67c68a7d76be982b41d49d92bc71805cab0b03a2b02f4dbb2c5a227c02ca9663e527e91a4b7d08cb6bd4422424c1a00bdbd579e101281a27510
AUX g13.conf.d 216 SHA256 faeb300966ad00855e6265d657663e77455c3241434b1787b25290ba585e51be SHA512 5e4a0aeb7d63628109666e05359ba96453979e21e83267ce2529b492c19dd2e0abe4d7ee4044e973efd3f0914d675c49ed7c2dbbb86228e5fddec8d59a6441c7 WHIRLPOOL 29c320fce553f809af5e97007adab57b46a4be35e9fca9630c46b7b15df5441c6880a37415077df1a607df8d0d743e6ff722ef3aa8edeabdb7b4865000d6e07b
AUX g13.init.d 850 SHA256 3815ce5111a19d8fd6760d085158d8c67fe926e488aa9501a4cc063639746a45 SHA512 8a0ae05e043a0e8bb285f070661d17a3374839d14ffe4ca11160678cf0aac8ff1dece9f572b76724c3e944a5df7453b357aeafc94b2819ab19f2f3d44e42b6b1 WHIRLPOOL 9e3c8553d8b463a06e61470a0455a133f31f2f2f62e30726c82e53ae06bafddf4e142093a49241942f5dd544fdce3ce11e8da9a7ed1b11e6738450de9e2cb7b7
AUX g13writelcd 112 SHA256 762ec322923d1d3df8c517f2063116a0e01df7ce22b3981925a7b06b00df45a3 SHA512 6900dab85d78e7e9de4743eb54f0c946f93a873c035ff76ecb547f3bbd1f3cb9b6ddcfd63d56326dfe1358c316ce78f431bf78a96ca0aede77f96576778c5412 WHIRLPOOL 7f201a37f781e00f470e6faf387c4efe26c91062550c411c12d52286cf86fed9c4ef7942d485ca91c1e43094c11e9cbe40ebbb19130fadd722892ddea949947c
AUX keys.txt 1054 SHA256 aaf0a3b118fd79fe6b56433b0881c59d8bd101e4c4d0c2c6128a3364b90bfbdb SHA512 a96d1eaef75f1b93637d25fb5b94b34a14eb9083a596e37b3c147a4ad4d762bf679c1dba44545620e23a56fb7c7dc1bff7122cd2a36813a7a1aa8c51fa6d0e58 WHIRLPOOL cace8bbbb84f89e1145dfcb66ef9cd9185e4e79ae3179a3b95457667f8bc1993808c5f00956504ede497d4e2b2a057c579254b3ce3e23b5ee4ecb6c3848b888c
-EBUILD g13-9999.ebuild 1938 SHA256 4d823a74efcf326f419d8d32dbef338c2051014d8ac347dae5ecd61a494f9d54 SHA512 046dcf6fd174c8590f04bae201f9f1d456d13018ef163c8b7cd84c181607b48632d6af4d4f2f22210ba2acb11ad077a6b891bcc143b68e6f783576ee76846f23 WHIRLPOOL 2a64457b0ed5307cd462f0d68a411d28d3c5ae0c3e283c3ba787c5948c0bc5ced72ba0e06c2c6ce4df81d4ca76fb02f5c8aed2ff04d242155750323250cccaca
+EBUILD g13-20150528.ebuild 1993 SHA256 885f53daa06d109da026d8331ef81d760ee586b40206d2ffc47fd65455d406d4 SHA512 d8573860f45950df1b7782df93b844ab9495ced2ec5eb20dde52e97223a682378e12752e0d536de730feb0b36b24994d5a488b9041061c0c13f504031c77804d WHIRLPOOL a852579686aea7455b1502db76fa3c234fc4a33d8d321b5853a0b0d2c4f2dd3a4fa8f3d24013592804dfb74a2765b4e063470b97c10b2394fc9f68772c0394ed
+EBUILD g13-9999.ebuild 1980 SHA256 6a44be0d8d8c5924fd48c78f6652f7baa85d10ab2b3a657812b60e593fcd716a SHA512 ab7edcd8e8d139e7a4c891361fa37e9d70a278abb74ed6f972fc967708b97d9f4ff7761b13a93469116eda1d33a38fa9d5c19bda50470e285a9da0724b689241 WHIRLPOOL 24f35534fa26e5c20d1011dad74536921b0db3b5c42046ce071ca46fc493a28636db2c427b25cb807266adec79273ae1a3309cf744f8a57a1ba0d950346b1926
diff --git a/app-misc/g13/files/add-modifiers.patch b/app-misc/g13/files/add-modifiers.patch
new file mode 100644
index 0000000..12888c8
--- /dev/null
+++ b/app-misc/g13/files/add-modifiers.patch
@@ -0,0 +1,314 @@
+diff --git a/91-g13.rules b/91-g13.rules
+index 7926d4e..b4cbb0f 100644
+--- a/91-g13.rules
++++ b/91-g13.rules
+@@ -1 +1,2 @@
+-SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0666"
+\ No newline at end of file
++SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0666"
++
+diff --git a/Makefile b/Makefile
+index ee53160..df3aeff 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,10 @@
+ all: g13d pbm2lpbm
+
+-g13d: g13.h g13.cc
+- g++ -o g13d -std=c++0x g13.cc -lusb-1.0
++g13d: g13.h g13.cc g13map.o
++ g++ -o g13d -std=c++0x g13.cc g13map.o -lusb-1.0
++
++g13map.o: g13map.cc g13map.h
++ g++ -c -o g13map.o -std=c++0x g13map.cc
+
+ pbm2lpbm: pbm2lpbm.c
+ g++ -o pbm2lpbm pbm2lpbm.c
+@@ -13,4 +16,4 @@ package:
+ tar cjf g13-userspace.tbz2 g13-userspace
+ rm -Rf g13-userspace
+ clean:
+- rm -f g13 pbm2lpbm
+\ No newline at end of file
++ rm -f g13d g13map.o pbm2lpbm
+diff --git a/README.org b/README.org
+index f4f5adb..a05fd06 100644
+--- a/README.org
++++ b/README.org
+@@ -12,13 +12,13 @@ If you want to run the daemon as user, put the file 91-g13.rules into /etc/udev/
+ Connect your device, then run ./g13, it should automatically find your device.
+
+ If you see output like
+-
++```
+ Known keys on G13:
+ BD DOWN G1 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G2 G20 G21 G22 G3 G4 G5 G6 G7 G8 G9 L1 L2 L3 L4 LEFT LIGHT LIGHT_STATE M1 M2 M3 MR TOP STICK_LEFT STICK_RIGHT STICK_UP STICK_DOWN
+ Known keys to map to:
+ KEY_0 KEY_1 KEY_2 KEY_3 KEY_4 KEY_5 KEY_6 KEY_7 KEY_8 KEY_9 KEY_A KEY_APOSTROPHE KEY_B KEY_BACKSLASH KEY_BACKSPACE KEY_C KEY_CAPSLOCK KEY_COMMA KEY_D KEY_DOT KEY_DOWN KEY_E KEY_ENTER KEY_EQUAL KEY_ESC KEY_F KEY_F1 KEY_F10 KEY_F2 KEY_F3 KEY_F4 KEY_F5 KEY_F6 KEY_F7 KEY_F8 KEY_F9 KEY_G KEY_GRAVE KEY_H KEY_I KEY_J KEY_K KEY_KP0 KEY_KP1 KEY_KP2 KEY_KP3 KEY_KP4 KEY_KP5 KEY_KP6 KEY_KP7 KEY_KP8 KEY_KP9 KEY_KPASTERISK KEY_KPDOT KEY_KPMINUS KEY_KPPLUS KEY_L KEY_LEFT KEY_LEFTALT KEY_LEFTBRACE KEY_LEFTCTRL KEY_LEFTSHIFT KEY_M KEY_MINUS KEY_N KEY_NUMLOCK KEY_O KEY_P KEY_Q KEY_R KEY_RIGHT KEY_RIGHTBRACE KEY_RIGHTSHIFT KEY_S KEY_SCROLLLOCK KEY_SEMICOLON KEY_SLASH KEY_SPACE KEY_T KEY_TAB KEY_U KEY_UP KEY_V KEY_W KEY_X KEY_Y KEY_Z
+ Found 1 G13s
+-
++```
+ that is good. This also shows you which name the keys on the G13 have, and what keys you can bind them to.
+
+ ** Commands
+@@ -38,6 +38,17 @@ would set M1, M3 and MR, and unset M2).
+
+ This binds a key. The possible values of <keyname> are shown upon startup (e.g. G1), same for <binding> (e.g. KEY_LEFTSHIFT).
+
++A single G13 key press can be mapped to multiple key events using this syntax:
++```
++bind G1 KEY_LEFTCTRL KEY_F
++bind G2 KEY_LEFTSHIFT KEY_G
++bind G3 KEY_LEFTALT KEY_H
++bind G4 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_I
++bind G5 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_LEFTALT KEY_J
++bind G6 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_LEFTALT KEY_K # this is a comment
++```
++This is useful in the case of modifiers.
++
+ *** Stick mode
+
+ The stick can be used as an absolute input device or can send key events. Right now there is no command for this, you need to edit the source (file g13.cc, around line 622, this->stick_mode = STICK_KEYS, change to this->stick_mode = STICK_ABSOLUTE).
+@@ -50,4 +61,4 @@ Use pbm2lpbm to convert a pbm image to the correct format, then just cat that in
+ The pbm file must be 160x43 pixels.
+
+ * License
+-This code is placed in the public domain. Do with it whatever you want.
+\ No newline at end of file
++This code is placed in the public domain. Do with it whatever you want.
+diff --git a/g13.cc b/g13.cc
+index d428bce..9a0e057 100644
+--- a/g13.cc
++++ b/g13.cc
+@@ -142,8 +142,14 @@ void g13_parse_key(int key, unsigned char *byte, g13_keypad *g13) {
+ unsigned char actual_byte = byte[key / 8];
+ unsigned char mask = 1 << (key % 8);
+ if(bool value = g13->update(key, actual_byte & mask)) {
+-// cout << g13->mapping(key) << ": " << g13->is_set(key) << endl;
+- send_event(g13->uinput_file, EV_KEY, g13->mapping(key), g13->is_set(key));
++
++ const std::list<int>& keys = g13->keymap->mapping(key);
++
++ for (std::list<int>::const_iterator it = keys.begin(); it!= keys.end(); it++) {
++ // std::cout << *it << ": " << g13->is_set(key) << std::endl;
++ send_event(g13->uinput_file, EV_KEY, *it, g13->is_set(key));
++ }
++
+ }
+ }
+ void g13_parse_keys(unsigned char *buf, g13_keypad *g13) {
+@@ -395,6 +401,7 @@ void cleanup(int n = 0) {
+ g13_destroy_uinput(g13s[i]);
+ g13_destroy_fifo(g13s[i]);
+ g13_deregister(g13s[i]);
++ delete g13s[i]->keymap;
+ delete g13s[i];
+ }
+ libusb_exit(ctx);
+@@ -654,23 +661,11 @@ g13_keypad::g13_keypad(libusb_device_handle *handle, int id) {
+ uinput_file = -1;
+ for(int i = 0; i < sizeof(keys); i++)
+ keys[i] = false;
+- for(int i = 0; i < G13_NUM_KEYS; i++)
+- map[i] = KEY_A;
+- /* map = { KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H,
+- KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P,
+- KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, 0, 0,
+- KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4,
+- KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_F1, KEY_F2 };*/
+- // starcraft 2
+- // map = { KEY_5, KEY_3, KEY_1, KEY_0, KEY_2, KEY_4, KEY_6,
+- // KEY_V, KEY_F, KEY_E, KEY_C, KEY_B, KEY_G, KEY_I,
+- // KEY_LEFTSHIFT, KEY_M, KEY_T, KEY_L, KEY_H,
+- // KEY_A, KEY_S, KEY_LEFTCTRL, 0, 0,
+- // KEY_F1, KEY_N, KEY_R, KEY_P, KEY_K, KEY_D, KEY_X, KEY_Y,
+- // KEY_Z, KEY_TAB, KEY_W, KEY_BACKSPACE, 0, 0, 0, 0};
+- }
+
+- void g13_keypad::command(char const *str) {
++ keymap = new g13map(G13_NUM_KEYS);
++}
++
++void g13_keypad::command(char const *str) {
+ int red, green, blue, mod;
+ char keyname[256];
+ char binding[256];
+@@ -684,7 +679,9 @@ g13_keypad::g13_keypad(libusb_device_handle *handle, int id) {
+ int bind = input_name_to_key[binding];
+ if(name_to_key.find(keyname) != name_to_key.end()) {
+ int key = name_to_key[keyname];
+- map[key] = bind;
++
++ keymap->bind(key, str, input_name_to_key);
++
+ } else if(key_name == "STICK_LEFT") {
+ this->stick_keys[STICK_LEFT] = bind;
+ } else if(key_name == "STICK_RIGHT") {
+diff --git a/g13.h b/g13.h
+index 4eb7b5a..9e4e1ad 100644
+--- a/g13.h
++++ b/g13.h
+@@ -1,5 +1,6 @@
+ #include <string>
+ #include <map>
++#include "g13map.h"
+
+ #define null 0
+
+@@ -23,15 +24,9 @@ struct g13_keypad {
+ stick_mode_t stick_mode;
+ int stick_keys[4];
+ g13_keypad(libusb_device_handle *handle, int id);
+- int map[G13_NUM_KEYS];
+
+- void set_mapping(int mapping[G13_NUM_KEYS]) {
+- for(int i = 0; i < G13_NUM_KEYS; i++)
+- map[i] = mapping[i];
+- }
+- int mapping(int key) {
+- return map[key];
+- }
++ g13map* keymap;
++
+ bool keys[G13_NUM_KEYS];
+ bool is_set(int key) {
+ return keys[key];
+diff --git a/g13map.cc b/g13map.cc
+new file mode 100644
+index 0000000..9b43526
+--- /dev/null
++++ b/g13map.cc
+@@ -0,0 +1,63 @@
++#include <iostream>
++#include <boost/algorithm/string.hpp>
++#include <cassert>
++#include <linux/uinput.h>
++#include "g13map.h"
++
++g13map::g13map(const int g13_num_keys) :
++ m_bind(g13_num_keys),
++ m_keya(1)
++{
++ std::cout << "g13map ctor"<< std::endl;
++ m_keya.push_back(KEY_A); // from <linux/uinput.h>
++}
++
++g13map::~g13map()
++{
++ std::cout << "g13map dtor"<< std::endl;
++}
++
++bool
++g13map::bind(const int g13key, const char* cmd,
++ const std::map<std::string, int>& lut)
++{
++ assert(g13key>=0);
++ assert(g13key<m_bind.size());
++
++ m_bind[g13key].clear();
++
++ std::vector<std::string> tok;
++
++ boost::split(tok, cmd, boost::is_any_of(" "));
++
++ for (int i=2; i<tok.size(); i++) {
++ std::cout << "g13map::bind " << i << " <" << tok[i] << ">" << std::endl;
++
++ if (tok[i].size() < 1 || tok[i][0] == '#')
++ break;
++ else if (lut.count(tok[i])==1)
++ m_bind[g13key].push_back(lut.at(tok[i]));
++ else {
++ std::cerr << "Keyboard key not found for: " << tok[i] << std::endl;
++ return false;
++ }
++ }
++
++ return true;
++}
++
++const std::list<int>&
++g13map::mapping(const int g13key) const
++{
++ if ((g13key>=0) && (g13key<m_bind.size()))
++
++ if (m_bind[g13key].size()<1)
++ return m_keya;
++ else
++ return m_bind[g13key];
++
++ else {
++ std::cerr << "Bad G13 key: " << g13key << std::endl;
++ return m_keya;
++ }
++}
+diff --git a/g13map.h b/g13map.h
+new file mode 100644
+index 0000000..03c5aec
+--- /dev/null
++++ b/g13map.h
+@@ -0,0 +1,47 @@
++#ifndef _g13map_
++#define _g13map_ 1
++#include <map>
++#include <string>
++#include <vector>
++#include <list>
++
++/** This class maps between a single key pressed on the G13 and one or
++ * key presses which will be generated for passing via the uinput
++ * interface.
++ */
++class g13map {
++public:
++
++ // ctor: create a map capable of holding g13_num_keys number of mappings
++ g13map(const int g13_num_keys);
++
++ // dtor
++ virtual ~g13map();
++
++ // add a mapping between g13key and the to-be decoded normal keyboard
++ // mappings in cmd (cmd holds the full bind command line, e.g.
++ // 'bind G12 KEY_U') - use the look up table lut to map between the strings
++ // found in cmd and key numbers
++ virtual bool bind(const int g13key, const char* cmd,
++ const std::map<std::string, int>& lut);
++
++ // return the current mapping for the G13 key g13key as a list of one or
++ // more keys
++ virtual const std::list<int>& mapping(const int g13key) const;
++
++private:
++
++ // the mapping between the G13 key and a list of one or more key codes
++ // for each g13key
++ std::vector<std::list<int> > m_bind;
++
++ // a list to return when the mapping has not been set for a key
++ // (contains KEY_A)
++ std::list<int> m_keya;
++
++ // disabled
++ g13map();
++
++};
++
++#endif // _g13map_
+diff --git a/modifiertest.bind b/modifiertest.bind
+new file mode 100644
+index 0000000..0a2006c
+--- /dev/null
++++ b/modifiertest.bind
+@@ -0,0 +1,11 @@
++bind G1 KEY_LEFTCTRL KEY_F
++bind G2 KEY_LEFTSHIFT KEY_G
++bind G3 KEY_LEFTALT KEY_H
++bind G4 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_I
++bind G5 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_LEFTALT KEY_J
++bind G6 KEY_LEFTCTRL KEY_LEFTSHIFT KEY_LEFTALT KEY_K # this is a comment
++bind G7 KEY_L
++bind G7 KEY_M #another comment
++bind G8
++bind G9 FOO
++bind G10 BAR #comment
diff --git a/app-misc/g13/g13-9999.ebuild b/app-misc/g13/g13-9999.ebuild
index 84d298d..529d688 100644
--- a/app-misc/g13/g13-9999.ebuild
+++ b/app-misc/g13/g13-9999.ebuild
@@ -36,6 +36,7 @@ pkg_setup() {
}
src_prepare () {
+ epatch "${FILESDIR}/add-modifiers.patch"
sed -i -e 's:/tmp/:/run/:' "g13.h"
sed -i -e 's:g++:$(CXX) $(CXXFLAGS) $(LDFLAGS):' "Makefile"
sed -i '/MODE/G' "91-g13.rules"