mirror of
https://github.com/ecraven/g13.git
synced 2025-06-20 01:03:43 -04:00
Merge cbe53d1f32
into 815e0001cb
This commit is contained in:
commit
66f10dcebc
@ -1 +0,0 @@
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0666"
|
47
CMakeLists.txt
Normal file
47
CMakeLists.txt
Normal file
@ -0,0 +1,47 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(g13d LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_executable(g13d)
|
||||
add_executable(pbm2lpbm)
|
||||
|
||||
#------------pbm2lpbm Configure-----------------
|
||||
# pbm2lpbm sources
|
||||
target_sources( pbm2lpbm PUBLIC
|
||||
src/pbm2lpbm.c
|
||||
)
|
||||
set_source_files_properties(src/pbm2lpbm.c PROPERTIES LANGUAGE CXX)
|
||||
|
||||
#------------g13d Configure-----------------
|
||||
|
||||
#Configure dynamic libraries for g13d
|
||||
target_link_libraries(g13d PUBLIC usb-1.0 )
|
||||
target_link_libraries(g13d PUBLIC pthread)
|
||||
|
||||
#Configure static libraries for g13d
|
||||
target_link_libraries( g13d PUBLIC boost_system.a)
|
||||
target_link_libraries( g13d PUBLIC boost_program_options.a)
|
||||
target_link_libraries( g13d PUBLIC boost_log.a)
|
||||
target_link_libraries( g13d PUBLIC boost_log_setup.a)
|
||||
target_link_libraries( g13d PUBLIC boost_thread.a)
|
||||
|
||||
#g13d source files
|
||||
target_sources( g13d PUBLIC
|
||||
src/g13.cc
|
||||
src/g13_keys.cc
|
||||
src/g13_log.cc
|
||||
src/g13_stick.cc
|
||||
src/g13_fonts.cc
|
||||
src/g13_lcd.cc
|
||||
src/g13_main.cc
|
||||
src/helper.cpp
|
||||
)
|
||||
|
||||
install(TARGETS g13d DESTINATION /usr/local/bin/)
|
||||
install(TARGETS pbm2lpbm DESTINATION /usr/local/bin/)
|
||||
install(FILES sys/default.bind DESTINATION /etc/g13d)
|
||||
install(FILES sys/91-g13d.rules DESTINATION /etc/udev/rules.d/)
|
||||
install(FILES sys/g13d.service DESTINATION /etc/systemd/system/)
|
62
Makefile
62
Makefile
@ -1,49 +1,51 @@
|
||||
all: g13d pbm2lpbm
|
||||
|
||||
FLAGS=$(CXXFLAGS) -DBOOST_LOG_DYN_LINK -std=c++0x
|
||||
LIBS=-lusb-1.0 -lboost_log -lboost_log_setup-mt -lboost_thread -lboost_system-mt -lpthread
|
||||
FLAGS=$(CXXFLAGS) -std=c++0x
|
||||
SLIBS=-lboost_system -lboost_program_options -lboost_log -lboost_log_setup -lboost_thread
|
||||
DLIBS=-lusb-1.0 -lpthread
|
||||
BUILDDIR=build
|
||||
|
||||
g13.o: g13.h helper.hpp g13.cc
|
||||
g++ $(FLAGS) -c g13.cc
|
||||
g13.o: src/g13.h src/helper.hpp src/g13.cc
|
||||
g++ $(FLAGS) -c src/g13.cc
|
||||
|
||||
g13_main.o: g13.h helper.hpp g13_main.cc
|
||||
g++ $(FLAGS) -c g13_main.cc
|
||||
g13_main.o: src/g13.h src/helper.hpp src/g13_main.cc
|
||||
g++ $(FLAGS) -c src/g13_main.cc
|
||||
|
||||
|
||||
g13_log.o: g13.h helper.hpp g13_log.cc
|
||||
g++ $(FLAGS) -c g13_log.cc
|
||||
g13_log.o: src/g13.h src/helper.hpp src/g13_log.cc
|
||||
g++ $(FLAGS) -c src/g13_log.cc
|
||||
|
||||
g13_fonts.o: g13.h helper.hpp g13_fonts.cc
|
||||
g++ $(FLAGS) -c g13_fonts.cc
|
||||
g13_fonts.o: src/g13.h src/helper.hpp src/g13_fonts.cc
|
||||
g++ $(FLAGS) -c src/g13_fonts.cc
|
||||
|
||||
g13_lcd.o: g13.h helper.hpp g13_lcd.cc
|
||||
g++ $(FLAGS) -c g13_lcd.cc
|
||||
g13_lcd.o: src/g13.h src/helper.hpp src/g13_lcd.cc
|
||||
g++ $(FLAGS) -c src/g13_lcd.cc
|
||||
|
||||
g13_stick.o: g13.h helper.hpp g13_stick.cc
|
||||
g++ $(FLAGS) -c g13_stick.cc
|
||||
g13_stick.o: src/g13.h src/helper.hpp src/g13_stick.cc
|
||||
g++ $(FLAGS) -c src/g13_stick.cc
|
||||
|
||||
g13_keys.o: g13.h helper.hpp g13_keys.cc
|
||||
g++ $(FLAGS) -c g13_keys.cc
|
||||
|
||||
helper.o: helper.hpp helper.cpp
|
||||
g++ $(FLAGS) -c helper.cpp
|
||||
g13_keys.o: src/g13.h src/helper.hpp src/g13_keys.cc
|
||||
g++ $(FLAGS) -c src/g13_keys.cc
|
||||
|
||||
helper.o: src/helper.hpp src/helper.cpp
|
||||
g++ $(FLAGS) -c src/helper.cpp
|
||||
|
||||
g13d: g13_main.o g13.o g13_log.o g13_fonts.o g13_lcd.o g13_stick.o g13_keys.o helper.o
|
||||
g++ -o g13d -std=c++0x \
|
||||
g13_main.o g13.o g13_log.o g13_fonts.o g13_lcd.o g13_stick.o g13_keys.o helper.o \
|
||||
-lusb-1.0 -lboost_program_options \
|
||||
-lboost_log \
|
||||
-lboost_system -lpthread
|
||||
-lpthread \
|
||||
-Wl,-Bstatic \
|
||||
-lboost_system \
|
||||
-lboost_program_options \
|
||||
-lboost_log\
|
||||
-lboost_log_setup\
|
||||
-lboost_thread\
|
||||
-Wl,-Bdynamic \
|
||||
-lusb-1.0 \
|
||||
-Wl,--as-needed
|
||||
|
||||
pbm2lpbm: pbm2lpbm.c
|
||||
g++ -o pbm2lpbm pbm2lpbm.c
|
||||
pbm2lpbm: src/pbm2lpbm.c
|
||||
g++ -o pbm2lpbm src/pbm2lpbm.c
|
||||
|
||||
package:
|
||||
rm -Rf g13-userspace
|
||||
mkdir g13-userspace
|
||||
cp g13.cc g13.h logo.h Makefile pbm2lpbm.c g13-userspace
|
||||
tar cjf g13-userspace.tbz2 g13-userspace
|
||||
rm -Rf g13-userspace
|
||||
clean:
|
||||
rm -f g13 pbm2lpbm
|
@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
g13_stdin=/run/g13d/g13-0
|
||||
|
||||
center_x=30
|
||||
center_y=20
|
||||
diameter=18
|
||||
@ -37,6 +39,6 @@ min_x=$(echo "scale=3;$center_x + $min_orig_y * s($min/60*(2*4*a(1)))" | bc -l)
|
||||
min_y=$(echo "scale=3;$center_y - $min_orig_y * c($min/60*(2*4*a(1)))" | bc -l)
|
||||
preparams="-size 160x43 xc:white -stroke black -fill white -draw \"circle 30,20 30,2\" -draw \"line 30,20 $sec_x,$sec_y\" -draw \"line 30,20 $min_x,$min_y\" -draw \"line 30,20 $hr_x,$hr_y\" "
|
||||
postparams="-pointsize 16 -fill black -font Courier -draw \"text 60,15 '$Date'\" -draw \"text 68,35 '$Time'\" pbm:- "
|
||||
eval convert $preparams $ticks $postparams | ./pbm2lpbm > /tmp/g13-0
|
||||
eval convert $preparams $ticks $postparams | ./pbm2lpbm > $g13_stdin
|
||||
sleep 1
|
||||
done
|
Before Width: | Height: | Size: 335 KiB After Width: | Height: | Size: 335 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
@ -157,6 +157,10 @@ int g13_create_uinput(G13_Device *g13) {
|
||||
ioctl(ufile, UI_SET_RELBIT, REL_Y);*/
|
||||
for (int i = 0; i < 256; i++)
|
||||
ioctl(ufile, UI_SET_KEYBIT, i);
|
||||
//Mouse buttons
|
||||
for (int i = 0x110; i < 0x118; i++)
|
||||
ioctl(ufile, UI_SET_KEYBIT, i);
|
||||
|
||||
ioctl(ufile, UI_SET_KEYBIT, BTN_THUMB);
|
||||
|
||||
int retcode = write(ufile, &uinp, sizeof(uinp));
|
@ -47,9 +47,24 @@ namespace G13 {
|
||||
(F1)(F2)(F3)(F4)(F5)(F6)(F7)(F8)(F9)(F10)(F11)(F12) \
|
||||
(NUMLOCK)(SCROLLLOCK) \
|
||||
(KP7)(KP8)(KP9)(KPMINUS)(KP4)(KP5)(KP6)(KPPLUS) \
|
||||
(KP1)(KP2)(KP3)(KP0)(KPDOT) \
|
||||
(KP1)(KP2)(KP3)(KP0)(KPDOT)(KPSLASH) \
|
||||
(LEFT)(RIGHT)(UP)(DOWN) \
|
||||
(PAGEUP)(PAGEDOWN)(HOME)(END)(INSERT)(DELETE) \
|
||||
(F13)(F14)(F15)(F16)(F17)(F18)(F19)(F20)(F21)(F22)(F23)(F24) \
|
||||
(NEXTSONG)(PLAYPAUSE)(PREVIOUSSONG) \
|
||||
|
||||
|
||||
/*! m_INPUT_BTN_SEQ is a Boost Preprocessor sequence containing the
|
||||
* names of button events we can send through binding actions.
|
||||
* These correspond to BTN_xxx value definitions in <linux/input.h>,
|
||||
* i.e. LEFT is BTN_LEFT, RIGHT is BTN_RIGHT, etc.
|
||||
*
|
||||
* The binding names have prefix M to avoid naming conflicts.
|
||||
* e.g. LEFT keyboard button and LEFT mouse button
|
||||
* i.e. LEFT mouse button is named MLEFT, MIDDLE mouse button is MMIDDLE
|
||||
*/
|
||||
#define M_INPUT_BTN_SEQ \
|
||||
(LEFT)(RIGHT)(MIDDLE)(SIDE)(EXTRA) \
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
@ -159,6 +174,18 @@ void G13_Manager::init_keynames() {
|
||||
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(ADD_KB_KEY_MAPPING, _, KB_INPUT_KEY_SEQ)
|
||||
|
||||
// setup maps to let us convert between strings and linux button names
|
||||
#define ADD_M_BTN_MAPPING( r, data, elem ) \
|
||||
{ \
|
||||
std::string name = string("M") + string(BOOST_PP_STRINGIZE(elem)); \
|
||||
int keyval = BOOST_PP_CAT( BTN_, elem ); \
|
||||
input_key_to_name[keyval] = name; \
|
||||
input_name_to_key[name] = keyval; \
|
||||
} \
|
||||
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(ADD_M_BTN_MAPPING, _, M_INPUT_BTN_SEQ)
|
||||
}
|
||||
|
||||
LINUX_KEY_VALUE G13_Manager::find_g13_key_value( const std::string &keyname ) const {
|
15
sys/91-g13d.rules
Normal file
15
sys/91-g13d.rules
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
GOTO="SYSTEMD_LABEL"
|
||||
# Workaround on systems where ID_VENDOR_ID, ID_PRODUCT_ID attributes are not defined when removing device.
|
||||
ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="46d/c21c/*",\
|
||||
ACTION=="add", MODE="0666", RUN+="/bin/systemctl --no-block start g13.service"
|
||||
|
||||
ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="46d/c21c/*",\
|
||||
ACTION=="remove", RUN+="/bin/systemctl --no-block stop g13.service"
|
||||
|
||||
GOTO="G13_END"
|
||||
LABEL="SYSTEMD_LABEL"
|
||||
|
||||
ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="46d/c21c/*",\
|
||||
SYMLINK+="g13kb", TAG+="systemd", MODE="0666", ENV{SYSTEMD_WANTS}="g13.service"
|
||||
LABEL="G13_END"
|
56
sys/default.bind
Normal file
56
sys/default.bind
Normal file
@ -0,0 +1,56 @@
|
||||
# Keypad:
|
||||
# ______________
|
||||
# | 160x43 LCD |
|
||||
# | |
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
# <BD> <L1> <L2> <L3> <L4> <LIGHT_STATE>
|
||||
# <M1> <M2> <M3> <MR>
|
||||
# <G1> <G2> <G3> <G4> <G5> <G6> <G7>
|
||||
# <G8> <G9> <G10> <G11> <G12> <G13> <G14>
|
||||
# <G15> <G16> <G17> <G18> <G19>
|
||||
# <G10> <G21> <G22>
|
||||
|
||||
# Joystick:
|
||||
# <STICK_UP>
|
||||
# <STICK_LEFT> <TOP> <STICK_RIGHT>
|
||||
# <STICK_DOWN>
|
||||
# <LEFT>
|
||||
# <DOWN>
|
||||
#
|
||||
#
|
||||
profile none
|
||||
profile default
|
||||
rgb 177 13 201
|
||||
|
||||
bind G1 KEY_1
|
||||
bind G2 KEY_2
|
||||
bind G3 KEY_Q
|
||||
bind G4 KEY_W
|
||||
bind G5 KEY_E
|
||||
bind G6 KEY_R
|
||||
bind G7 KEY_T
|
||||
bind G8 KEY_3
|
||||
bind G9 KEY_4
|
||||
bind G10 KEY_A
|
||||
bind G11 KEY_S
|
||||
bind G12 KEY_D
|
||||
bind G13 KEY_F
|
||||
bind G14 KEY_G
|
||||
bind G15 KEY_LEFTSHIFT
|
||||
bind G16 KEY_Z
|
||||
bind G17 KEY_X
|
||||
bind G18 KEY_C
|
||||
bind G19 KEY_V
|
||||
bind G20 KEY_LEFTCTRL
|
||||
bind G21 KEY_LEFTALT
|
||||
bind G22 KEY_SPACE
|
||||
|
||||
bind STICK_UP KEY_W
|
||||
bind STICK_LEFT KEY_A
|
||||
bind STICK_DOWN KEY_S
|
||||
bind STICK_RIGHT KEY_D
|
||||
bind LEFT KEY_5
|
||||
bind DOWN KEY_6
|
||||
bind TOP KEY_7
|
||||
|
||||
profile default
|
20
sys/g13d.service
Normal file
20
sys/g13d.service
Normal file
@ -0,0 +1,20 @@
|
||||
[Unit]
|
||||
Description=Logitech G13 daemon
|
||||
BindsTo=dev-g13kb.device
|
||||
After=dev-g13kb.device
|
||||
StopWhenUnneeded=true
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=g13d
|
||||
Group=uinput
|
||||
PIDFile=/run/g13d/pid
|
||||
RuntimeDirectory=g13d
|
||||
ExecStart=-/usr/local/bin/g13d\
|
||||
--config /etc/g13d/default.bind \
|
||||
--pipe_in /run/g13d/g13-0 \
|
||||
--pipe_out /run/g13d/g13-0_out
|
||||
ExecStop=/bin/kill $MAINPID
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
Loading…
Reference in New Issue
Block a user