1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

Merge pull request #1 from MatMoul/master

Update fork to most recent version
This commit is contained in:
Sebastian Schlicht 2018-11-28 13:49:45 +01:00 committed by GitHub
commit 6a13362f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 2621 additions and 1213 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
bin/*
lib/*
.

19
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,19 @@
# g810-led CONTRIBUTING
## Share your profile or make dump :
* [https://github.com/MatMoul/g810-led-resources](https://github.com/MatMoul/g810-led-resources)
## Contributing :
* Open an issue before work to hard
* Work on the develop branch
## Tasks (Help wanted) :
* (0%) AVERAGE: Add selection of multiple keyboards by index
* (0%) AVERAGE: Improve INSTALL.md to support more distributions (And CentOS with hidapi)
* (10%) AVERAGE: Make distributions ready package
* (0%) IMAGINATION: Use a more generic name for project, config dir and systemd units ([issue 29](https://github.com/MatMoul/g810-led/issues/29))
## Possible enhancements :
* Add deamon mode for custom effects (Add G Keys handler [issue 39](https://github.com/MatMoul/g810-led/issues/39), [CReimer](https://github.com/CReimer/g910-gkey-uinput)))
* Support country based keybord ([issue 16](https://github.com/MatMoul/g810-led/issues/16) but very hard)
* Support of new G Mouse like the G403 ([issue 40](https://github.com/MatMoul/g810-led/issues/40))

55
CONTRIBUTORS.md Normal file
View File

@ -0,0 +1,55 @@
# g810-led - CONTRIBUTORS (alpha order) :</br>
## [andreast1990](https://github.com/andreast1990) :
* Add Wireshark dump for g910
## [barul42](https://github.com/barul42) :
* Improve INSTALL.MD
## [carlba](https://github.com/carlba) :
* Improve install file
## [CReimer](https://github.com/CReimer) :
* Add Wireshark dump for g910 M and G keys
* Debug hidapi missing keys on certain computer
## [dkolosa](https://github.com/dkolosa) :
* Provide alternative productid for g910
## [francoisfreitag](https://github.com/francoisfreitag) :
* Refactor makefile (hard work)
## [hschreck](https://github.com/hschreck) :
* Fix typo
## [jdagerbo](https://github.com/jdagerbo) :
* Refactor many of the code (very hard work)
## [Landrovan](https://github.com/Landrovan) :
* Improve support of G410 (two times)
## [larsnaesbye](https://github.com/larsnaesbye) :
* Fix typo
## [lynix](https://github.com/lynix) :
* Improve makefile
## [matthunz](https://github.com/matthunz) :
* Improve INSTALL.MD for ArchLinux
## [MohamadSaada](https://github.com/MohamadSaada) :
* Add poweron effect bytes for g910
* Debug setKeys (hard work)
## [noisycat](https://github.com/noisycat) :
* Add wireshark dump effects
* Improve makefile
## [pearsonk](https://github.com/pearsonk) :
* Add g213 protocol (very hard work)
* Add support of g213
* Implement underlying device IO as a shared library
* Add multiple keyboard support (very hard work)
## [wextia](https://github.com/wextia) :
* Fixed incorrect markdown formatting in README.md

59
INSTALL.md Normal file
View File

@ -0,0 +1,59 @@
# Installation :</br>
## Build dependencies :</br>
* git
* g++
* make
## Dependencies :</br>
* hidapi or libusb
## hidapi vs libusb :</br>
hidapi is a newer implementation but needs more testing.</br>
hidapi is more responsive than libusb (~20ms vs ~150ms).</br>
hidapi seems to not work on CentOS, writing to hidraw is not allowed.</br>
hidapi is recommended but if you encounter a problem on your system, switch to libusb.</br>
## Installation using repos :</br>
ArchLinux (aur) :</br>
`yaourt -S g810-led-git` # with yaourt</br>
`pacaur -S g810-led-git` # with pacaur</br>
## Installation of dependencies :</br>
ArchLinux :</br>
`sudo pacman -S git gcc make hidapi` # for hidapi</br>
`sudo pacman -S git gcc make libusb` # for libusb</br>
Debian :</br>
`sudo apt-get install git g++ make libhidapi-dev` # for hidapi</br>
`sudo apt-get install git g++ make libusb-1.0-0-dev` # for libusb</br>
Fedora :</br>
`sudo dnf install git make gcc-c++ hidapi-devel` # for hidapi</br>
`sudo dnf install git make gcc-c++ libusbx-devel` # for libusb</br>
## Installation :</br>
`git clone https://github.com/MatMoul/g810-led.git`</br>
`cd g810-led`</br>
`make bin` # for hidapi</br>
`make bin LIB=libusb` # for libusb</br>
`sudo make install`</br>
## Installation of the library (For developers) :</br>
`make lib` # for hidapi</br>
`make lib LIB=libusb` # for libusb</br>
`sudo make install-lib` to install the libg810-led library.</br>
`sudo make install-dev` to install the libg810-led library and headers for development.</br>
## Update :</br>
Same as install, but your profile and reboot files are preserved.</br>
## Uninstall :</br>
`sudo make uninstall`</br>
## Boot profiles :</br>
On boot, the keyboard is set with the udev file /etc/udev/rules.d/g810-led.rules</br>
This file launches the profile stored in /etc/g810-led/profile</br>
To prevent your keyboard flashing 3 times when you reboot use the systemd unit (g810-led-reboot).</br>
Samples can be found in /etc/g810-led/samples.</br>

View File

@ -1,26 +1,55 @@
# g810-led # g810-led</br>
Linux LED controller for the Logitech G810 Orion Spectrum Keyboard Linux led controller for Logitech G213, G410, G413, G512, G513, G610, G810, G910 and GPRO Keyboards.</br>
Other compatible keyboard :</br> ## Compatible keyboards :</br>
G410 Atlas Spectrum</br> - **G213 Prodigy**</br>
G610 Orion</br> - **G410 Atlas Spectrum**</br>
G910 Orion Spark</br> - **G413 Carbon**</br>
G910 Orion Spectrum - **G512 Carbon**</br>
- **G513 Carbon**</br>
- **G610 Orion Brown**</br>
- **G610 Orion Red**</br>
- **G810 Orion Spectrum**</br>
- **G910 Orion Spark**</br>
- **G910 Orion Spectrum**</br>
- **GPRO**</br>
![jj](https://raw.githubusercontent.com/MatMoul/g810-led/master/pictures/logitech_g810-2.jpg) ## Contribute and evolution :</br>
* [CONTRIBUTING.md](https://github.com/MatMoul/g810-led/blob/master/CONTRIBUTING.md)
Install and use :</br> ## Install :</br>
- look at the wiki : https://github.com/MatMoul/g810-led/wiki * [INSTALL.md](https://github.com/MatMoul/g810-led/blob/master/INSTALL.md)
Samples :</br> ## Help :</br>
`g810-led -p /etc/g810/profile # Set a profile`</br> `g213-led --help`</br>
`g410-led --help`</br>
`g413-led --help`</br>
`g512-led --help`</br>
`g513-led --help`</br>
`g610-led --help`</br>
`g810-led --help`</br>
`g910-led --help`</br>
`gpro-led --help`</br>
`g810-led --help-keys`</br>
`g810-led --help-effects`</br>
`g810-led --help-samples`</br>
## Samples :</br>
`g810-led -p /etc/g810/profile # Load a profile`</br>
`g810-led -k logo ff0000 # Set color of a key`</br> `g810-led -k logo ff0000 # Set color of a key`</br>
`g810-led -a 00ff00 # Set color of all keys`</br> `g810-led -a 00ff00 # Set color of all keys`</br>
`g810-led -g fkeys ff00ff # Set color of a group of keys`</br> `g810-led -g fkeys ff00ff # Set color of a group of keys`</br>
`g810-led -s color # Set keyboard power on effect`</br> `g810-led -s color # Set keyboard power on effect`</br>
`g810-led -fx color keys 00ff00 # Set fixed color effect`</br>
`g810-led -fx breathing logo 00ff00 0a # Set breathing effect`</br>
`g810-led -fx cycle all 0a # Set color cycle effect`</br>
`g810-led -fx hwave keys 0a # Set horizontal wave effect`</br>
`g810-led -fx vwave keys 0a # Set vertical wave effect`</br>
`g810-led -fx cwave keys 0a # Set center wave effect`</br>
Samples with no commit :</br> ## Samples with no commit :</br>
`g810-led -an 000000 # Set color of all key with no action`</br> `g810-led -an 000000 # Set color of all key with no action`</br>
`g810-led -gn modifiers ff0000 # Set color of a group with no action`</br> `g810-led -gn modifiers ff0000 # Set color of a group with no action`</br>
`g810-led -kn w ff0000 # Set color of a key with no action`</br> `g810-led -kn w ff0000 # Set color of a key with no action`</br>
@ -28,3 +57,43 @@ Samples with no commit :</br>
`g810-led -kn s ff0000 # Set color of a key with no action`</br> `g810-led -kn s ff0000 # Set color of a key with no action`</br>
`g810-led -kn d ff0000 # Set color of a key with no action`</br> `g810-led -kn d ff0000 # Set color of a key with no action`</br>
`g810-led -c # Commit all changes`</br> `g810-led -c # Commit all changes`</br>
## Samples for G610 :</br>
`g610-led -a 60 # Set intensity of all keys`</br>
`g610-led -k logo ff # Set intensity of a key`</br>
`g610-led -g fkeys aa # Set intensity of a group of keys`</br>
## Samples for G213 :</br>
`g213-led -a 00ff00 # Set all keys green`</br>
`g213-led -r 1 ff0000 # Set region 1 red`</br>
## Samples with pipe (for effects) :</br>
`g810-led -pp < profilefile # Load a profile`</br>
`echo -e "k w ff0000\nk a ff0000\nk s ff0000\nk d ff0000\nc" | g810-led -pp # Set multiple keys`</br>
## Testing unsuported keyboards :</br>
Start by retrieving the VendorID and the ProductID of your keyboard using lsusb.</br>
`lsusb`</br>
Sample return :<br>
`Bus 001 Device 001: ID 046d:c331 Logitech, Inc.`</br>
In this sample VendorID is 046d and ProductID is c331. Now test your keyboard with all supported protocol :</br>
`g810-led -dv 046d -dp c331 -tuk 1 -a 000000`</br>
If your keyboard set all key to off you have found the protocol (1), if not continue.</br>
`g810-led -dv 046d -dp c331 -tuk 2 -a 000000`</br>
If your keyboard set all key to off you have found the protocol (2), if not continue.</br>
`g810-led -dv 046d -dp c331 -tuk 3 -a 000000`</br>
If your keyboard set all key to off you have found the protocol (3), if not, need new dump.</br>
## Building and linking against the libg810-led library :</br>
Include in implementing source files.</br>
```cpp
#include <g810-led/Keyboard.h>
```
To link, simply provide `-lg810-led` to the build flags.</br>
To build the g810-led application as a dynamically-linked variant, run the target:</br>
`make bin-linked`</br>
## Dumps :
Dumps of keyboards are now stored in a separate project to preserve a small download size of this project.
You can find them here : [https://github.com/MatMoul/g810-led-resources](https://github.com/MatMoul/g810-led-resources)

122
makefile
View File

@ -1,20 +1,120 @@
CC=g++ CXX?=g++
CFLAGS=-Wall -O2 -std=gnu++11 CXXFLAGS?=-Wall -O2
LIBUSB_INC?=-I/usr/include/libusb-1.0 LIB?=hidapi
LDFLAGS=-lusb-1.0 ifeq ($(LIB),libusb)
CPPFLAGS=-Dlibusb
LIBS=-lusb-1.0
else
CPPFLAGS=-Dhidapi
LIBS=-lhidapi-hidraw
endif
SYSTEMDDIR?=/usr/lib/systemd
PREFIX?=$(DESTDIR)/usr
libdir?=$(PREFIX)/lib
includedir?=$(PREFIX)/include
# Program & versioning information
PROGN=g810-led PROGN=g810-led
MAJOR=0
MINOR=2
MICRO=8
.PHONY: all debug clean CXXFLAGS+=-std=gnu++11 -DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\"
APPSRCS=src/main.cpp src/helpers/*.cpp src/helpers/*.h
LIBSRCS=src/classes/*.cpp src/classes/*.h
all: bin/$(PROGN) .PHONY: all bin debug clean setup install uninstall lib install-lib install-dev
bin/$(PROGN): src/main.cpp src/classes/*.cpp src/classes/*.h all: lib/lib$(PROGN).so bin/$(PROGN)
bin: bin/$(PROGN)
bin/$(PROGN): $(APPSRCS) $(LIBSRCS)
@mkdir -p bin @mkdir -p bin
$(CC) $(CFLAGS) $(LIBUSB_INC) -o $@ $^ $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
debug: CFLAGS += -g -Wextra -pedantic debug: CXXFLAGS += -g -Wextra -pedantic
debug: bin/$(PROGN) debug: bin/$(PROGN)
clean: lib/lib$(PROGN).so: $(LIBSRCS)
rm -rf bin @mkdir -p lib
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so
bin-linked: lib/lib$(PROGN).so
@mkdir -p bin
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(APPSRCS) -o bin/$(PROGN) $(LIBS) -L./lib -l$(PROGN)
lib: lib/lib$(PROGN).so
clean:
@rm -rf bin
@rm -rf lib
setup:
@install -m 755 -d \
$(DESTDIR)/usr/bin \
$(DESTDIR)/etc/$(PROGN)/samples \
$(DESTDIR)/etc/udev/rules.d
@cp bin/$(PROGN) $(DESTDIR)/usr/bin
@test -s $(DESTDIR)/usr/bin/g213-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g213-led
@test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
@test -s $(DESTDIR)/usr/bin/g413-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g413-led
@test -s $(DESTDIR)/usr/bin/g512-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g512-led
@test -s $(DESTDIR)/usr/bin/g513-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g513-led
@test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
@test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
@test -s $(DESTDIR)/usr/bin/gpro-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/gpro-led
@cp sample_profiles/* $(DESTDIR)/etc/$(PROGN)/samples
@cp udev/$(PROGN).rules $(DESTDIR)/etc/udev/rules.d
@test -s /usr/bin/systemd-run && \
install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system && \
cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system
install-lib: lib
@install -m 755 -d $(libdir)
@install -m 644 lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $(libdir)/
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $(libdir)/lib$(PROGN).so
install-dev: install-lib
@mkdir -p $(includedir)/$(PROGN)/
@install -m 644 src/classes/*.h $(includedir)/$(PROGN)
install: setup
@test -s /etc/$(PROGN)/profile || \
cp /etc/$(PROGN)/samples/group_keys /etc/$(PROGN)/profile
@test -s /etc/$(PROGN)/reboot || \
cp /etc/$(PROGN)/samples/all_off /etc/$(PROGN)/reboot
@udevadm control --reload-rules
@$(PROGN) -p /etc/$(PROGN)/profile
@test -s /usr/bin/systemd-run && \
systemctl daemon-reload && \
systemctl enable $(PROGN)-reboot
uninstall-lib:
@rm -f $(libdir)/lib$(PROGN).so*
uninstall-dev:
@rm -rf $(includedir)/$(PROGN)
uninstall:
@test -s /usr/bin/systemd-run && \
systemctl disable $(PROGN)-reboot && \
rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
systemctl daemon-reload && \
rm -R /etc/$(PROGN)
@rm /usr/bin/g213-led
@rm /usr/bin/g410-led
@rm /usr/bin/g413-led
@rm /usr/bin/g413-led
@rm /usr/bin/g512-led
@rm /usr/bin/g513-led
@rm /usr/bin/g610-led
@rm /usr/bin/g910-led
@rm /usr/bin/gpro-led
@rm /usr/bin/$(PROGN)
@rm /etc/udev/rules.d/$(PROGN).rules
@udevadm control --reload-rules

57
makerelease Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo "Error: No version provided"
echo "./makerelease 0.0.1"
exit 1
fi
ssh -T git@github.com
if [ ! "$?" = "1" ]; then
echo "No Github ssh key loaded exiting..."
exit 1
fi
clear
branch=$(git rev-parse --abbrev-ref HEAD)
read -p "Current branch is $branch. Continue ? (y/N)" choice
case "$choice" in
n|N|'' )
echo "Cancel !"
exit 1
;;
y|Y ) echo "Make release...";;
* )
echo "Cancel !"
exit 1
;;
esac
# Ready to update :
version=$1
sed -i "/string version = /c\\\tstring version = \"$version\";" src/helpers/help.cpp
IFS='.' read -ra VPART <<< "$version"
sed -i "/MAJOR=/cMAJOR=${VPART[0]}" makefile
sed -i "/MINOR=/cMINOR=${VPART[1]}" makefile
sed -i "/MICRO=/cMICRO=${VPART[2]}" makefile
git commit -m "Version $version" makefile src/*
git push
git checkout master
git merge develop
git push
git tag -a "v$version" -m "Version $version"
git push --tags
git checkout $branch
#wget https://github.com/MatMoul/g810-led/archive/v$version.zip
#wget https://github.com/MatMoul/g810-led/archive/v$version.tar.gz
#Publish to aur...

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

86
sample_effects/bash/k2000 Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
if [ "$1" == "--help" ]; then
echo "k2000 [speed (default:0.01] [colorOff] [colorOn] [colorFade1] [colorFade2]"
exit 0
fi
speed=0.01
colorOff=000000
colorOn=ff0000
colorFade1=aa0000
colorFade2=550000
if [ "$1" != "" ]; then
speed=$1
fi
if [ "$2" != "" ]; then
colorOff=$2
fi
if [ "$3" != "" ]; then
colorOn=$3
if [ "$4" != "" ]; then
colorFade1=$4
else
colorFade1=$colorOn
fi
if [ "$5" != "" ]; then
colorFade2=$5
else
colorFade2=$colorOn
fi
fi
setKeys () {
cmd=""
if [ $1 ] ; then
cmd=$cmd"k $1 $colorOn\n"
fi
if [ $2 ] ; then
cmd=$cmd"k $2 $colorFade1\n"
fi
if [ $3 ] ; then
cmd=$cmd"k $3 $colorFade2\n"
fi
if [ $4 ] ; then
cmd=$cmd"k $4 $colorOff\n"
fi
cmd=$cmd"c"
echo -e $cmd | g810-led -pp
sleep $speed
}
g810-led -gn fkeys $colorOff
setKeys F1
setKeys F2
setKeys F3
setKeys F4
setKeys F5 F1
setKeys F6 F2 F1
setKeys F7 F3 F2 F1
setKeys F8 F4 F3 F2
setKeys F9 F5 F4 F3
setKeys F10 F6 F5 F4
setKeys F11 F7 F6 F5
setKeys F12 F8 F7 F6
setKeys F12 F9 F8 F7
setKeys F12 F10 F9 F8
setKeys F12 F11 F10 F9
setKeys F11 F10 F10 F10
setKeys F10
setKeys F9
setKeys F8 F12
setKeys F7 F11 F12
setKeys F6 F10 F11 F12
setKeys F5 F9 F10 F11
setKeys F4 F8 F9 F10
setKeys F3 F7 F8 F9
setKeys F2 F6 F7 F8
setKeys F1 F5 F6 F7
setKeys F1 F4 F5 F6
setKeys F1 F3 F4 F5
setKeys F1 F2 F3 F4
setKeys F1 F1 F2 F3
setKeys F1 F1 F1 F2
setKeys F1 F1 F1 F1

96
sample_effects/python/k2000 Executable file
View File

@ -0,0 +1,96 @@
#!/usr/bin/python2
import sys
import subprocess
import time
if len(sys.argv) > 1:
if sys.argv[1] == '--help':
print 'k2000 [speed (default:0.01] [colorOff] [colorOn] [colorFade1] [colorFade2]'
sys.exit()
speed = 0.01
colorOff = '000000'
colorOn = 'ff0000'
colorFade1 = 'aa0000'
colorFade2 = '550000'
if len(sys.argv) > 1:
try:
speed = float(sys.argv[1])
except:
print 'Speed arg error'
if len(sys.argv) > 2:
try:
colorOff = sys.argv[2]
except:
print 'colorOff arg error'
if len(sys.argv) > 3:
try:
colorOn = sys.argv[3]
except:
print 'colorOn arg error'
if len(sys.argv) > 4:
try:
colorFade1 = sys.argv[4]
except:
print 'colorFade1 arg error'
if len(sys.argv) > 5:
try:
colorFade2 = sys.argv[5]
except:
print 'colorFade2 arg error'
def setKeys(keys):
pipeValue = ''
for index in range(len(keys)):
if index == 0:
pipeValue = pipeValue + 'k ' + keys[index] + ' ' + colorOn + '\\n'
elif index == 1:
pipeValue = pipeValue + 'k ' + keys[index] + ' ' + colorFade1 + '\\n'
elif index == 2:
pipeValue = pipeValue + 'k ' + keys[index] + ' ' + colorFade2 + '\\n'
elif index == 3:
pipeValue = pipeValue + 'k ' + keys[index] + ' ' + colorOff + '\\n'
pipeValue = pipeValue + 'c'
subprocess.call('echo -e "' + pipeValue + '" | g810-led -pp', shell=True)
time.sleep(speed)
subprocess.call('g810-led -gn fkeys ' + colorOff, shell=True)
setKeys(['F1'])
setKeys(['F2'])
setKeys(['F3'])
setKeys(['F4'])
setKeys(['F5','F1'])
setKeys(['F6','F2','F1'])
setKeys(['F7','F3','F2','F1'])
setKeys(['F8','F4','F3','F2'])
setKeys(['F9','F5','F4','F3'])
setKeys(['F10','F6','F5','F4'])
setKeys(['F11','F7','F6','F5'])
setKeys(['F12','F8','F7','F6'])
setKeys(['F12','F9','F8','F7'])
setKeys(['F12','F10','F9','F8'])
setKeys(['F12','F11','F10','F9'])
setKeys(['F11','F10','F10','F10'])
setKeys(['F10'])
setKeys(['F9'])
setKeys(['F8','F12'])
setKeys(['F7','F11','F12'])
setKeys(['F6','F10','F11','F12'])
setKeys(['F5','F9','F10','F11'])
setKeys(['F4','F8','F9','F10'])
setKeys(['F3','F7','F8','F9'])
setKeys(['F2','F6','F7','F8'])
setKeys(['F1','F5','F6','F7'])
setKeys(['F1','F4','F5','F6'])
setKeys(['F1','F3','F4','F5'])
setKeys(['F1','F2','F3','F4'])
setKeys(['F1','F1','F2','F3'])
setKeys(['F1','F1','F1','F2'])
setKeys(['F1','F1','F1','F1'])

View File

@ -0,0 +1,5 @@
a 0000ff # Set all keys blue
c # Commit changes
fx breathing logo ff0000 10 # Set breathing effect with red color and speed 10

28
sample_profiles/colors Normal file
View File

@ -0,0 +1,28 @@
# Sample profile using Groups of Keys and Single Characters.
g logo 000096 # Blue
g indicators ffffff # White
g multimedia 009600 # Green
g fkeys ff7700 # Orange
g modifiers ff7700 # Orange
g arrows 0000ff # Red
g numeric 00ff00 # Green
g functions ffffff # White
g keys ff00ff # Purple
g gkeys ffffff # White
k tilde ff0000 # Red
k W 0000ff # Blue {
k A 0000ff
k S 0000ff
k D 0000ff # }
k 1 ff0000 # Red {
k 2 ff0000
k 3 ff0000
k 4 ff0000
k 5 ff0000
k 6 ff0000
k 7 ff0000
k 8 ff0000
k 9 ff0000
k 0 ff0000 # }
c # Commit changes

View File

@ -0,0 +1,2 @@
fx breathing all ff0000 20 # Set breathing effect with red color and speed 20

View File

@ -0,0 +1,3 @@
# Green Profile
fx color all 00ff00 # Set all keys green

2
sample_profiles/fx_cwave Normal file
View File

@ -0,0 +1,2 @@
fx cwave all 20 # Set center wave effect with speed 20

2
sample_profiles/fx_cycle Normal file
View File

@ -0,0 +1,2 @@
fx cycle all 20 # Set color cycle effect with speed 20

2
sample_profiles/fx_hwave Normal file
View File

@ -0,0 +1,2 @@
fx hwave all 20 # Set horizontal wave effect with speed 20

2
sample_profiles/fx_vwave Normal file
View File

@ -0,0 +1,2 @@
fx vwave all 20 # Set vertical wave effect with speed 20

View File

@ -1,7 +1,7 @@
# Sample profile by groups keys # Sample profile by groups keys
g logo 000096 g logo 000096
g indicators 00ffff g indicators ffffff
g multimedia 009600 g multimedia 009600
g fkeys ff00ff g fkeys ff00ff
g modifiers ff0000 g modifiers ff0000
@ -9,5 +9,6 @@ g arrows ffff00
g numeric 00ffff g numeric 00ffff
g functions ffffff g functions ffffff
g keys 009696 g keys 009696
g gkeys ffffff
c # Commit changes c # Commit changes

View File

@ -56,7 +56,7 @@ k w $raw3
k e $raw3 k e $raw3
k r $raw3 k r $raw3
k t $raw3 k t $raw3
k z $raw3 k y $raw3
k u $raw3 k u $raw3
k i $raw3 k i $raw3
k o $raw3 k o $raw3
@ -94,7 +94,7 @@ k num_plus $raw4
# Raw 5 : # Raw 5 :
k shift_left $raw5 k shift_left $raw5
k intl_backslash $raw5 k intl_backslash $raw5
k y $raw5 k z $raw5
k x $raw5 k x $raw5
k c $raw5 k c $raw5
k v $raw5 k v $raw5

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +1,223 @@
#ifndef DEF_KEYBOARD #ifndef KEYBOARD_CLASS
#define DEF_KEYBOARD #define KEYBOARD_CLASS
#include <iostream> #include <iostream>
#include <libusb.h> #include <vector>
class Keyboard { #if defined(hidapi)
#include "hidapi/hidapi.h"
#elif defined(libusb)
#include "libusb-1.0/libusb.h"
#endif
public:
enum class KeyboardProtocol { generic, g910 }; class LedKeyboard {
enum class PowerOnEffect { rainbow, color };
enum class KeyAddressGroup { logo, indicators, multimedia, keys, gkeys };
enum class Key { // 127 items
logo, logo2,
caps, num, scroll, game, backlight,
mute, play, stop, prev, next,
f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
shift_left, ctrl_left, win_left, alt_left, alt_right, win_right, ctrl_right, shift_right, menu,
arrow_top, arrow_left, arrow_bottom, arrow_right,
num_1, num_2, num_3, num_4, num_5, num_6, num_7, num_8, num_9, num_0, num_dot, num_enter, num_plus, num_minus, num_asterisk, num_slash, num_lock,
esc, scroll_lock,
insert, del, home, end, page_up, page_down, print_screen, pause_break,
n1, n2, n3, n4, n5, n6, n7, n8, n9, n0,
tab, caps_lock, space, backspace, enter,
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
tilde, minus, equal,
open_bracket, close_bracket, backslash,
semicolon, quote, dollar,
intl_backslash, comma, period, slash,
g1, g2, g3, g4, g5, g6, g7, g8, g9
};
enum class KeyGroup { logo, indicators, multimedia, fkeys, modifiers, arrows, numeric, functions, keys, gkeys};
struct KeyColors { uint8_t red; uint8_t green; uint8_t blue; };
struct KeyAddress { KeyAddressGroup addressGroup; uint8_t id; };
struct KeyValue { KeyAddress key; KeyColors colors; };
bool isAttached();
bool attach();
bool detach();
bool commit();
bool getKeyAddress(Key key, KeyAddress &keyAddress);
bool parsePowerOnEffect(std::string effect, PowerOnEffect &powerOnEffect);
bool parseKey(std::string key, KeyAddress &keyAddress);
bool parseKeyGroup(std::string key, KeyGroup &keyGroup);
bool parseColor(std::string color, KeyColors &colors);
bool setPowerOnEffect(PowerOnEffect powerOnEffect);
bool setKey(KeyValue keyValue);
bool setKey(Key key, KeyColors colors);
bool setKeys(KeyValue keyValue[], size_t keyValueCount);
bool setAllKeys(KeyColors colors);
bool setGroupKeys(KeyGroup keyGroup, KeyColors colors);
private: private:
bool m_isAttached = false; enum class KeyAddressGroup : uint8_t {
bool m_isKernellDetached = false; logo = 0x00,
KeyboardProtocol kbdProtocol = KeyboardProtocol::generic; indicators,
libusb_device **devs; multimedia,
libusb_device_handle *dev_handle; gkeys,
libusb_context *ctx = NULL; keys
};
bool populateAddressGroupInternal(KeyAddressGroup addressGroup, unsigned char *data);
bool sendDataInternal(unsigned char *data, uint16_t data_size); public:
bool setKeysInternal(KeyAddressGroup addressGroup, KeyValue keyValues[], size_t keyValueCount);
std::vector<std::vector<uint16_t>> SupportedKeyboards = {
{ 0x46d, 0xc336, (u_int16_t)KeyboardModel::g213 },
{ 0x46d, 0xc330, (u_int16_t)KeyboardModel::g410 },
{ 0x46d, 0xc33a, (u_int16_t)KeyboardModel::g413 },
{ 0x46d, 0xc33c, (u_int16_t)KeyboardModel::g513 },
{ 0x46d, 0xc333, (u_int16_t)KeyboardModel::g610 },
{ 0x46d, 0xc338, (u_int16_t)KeyboardModel::g610 },
{ 0x46d, 0xc331, (u_int16_t)KeyboardModel::g810 },
{ 0x46d, 0xc337, (u_int16_t)KeyboardModel::g810 },
{ 0x46d, 0xc32b, (u_int16_t)KeyboardModel::g910 },
{ 0x46d, 0xc335, (u_int16_t)KeyboardModel::g910 },
{ 0x46d, 0xc339, (u_int16_t)KeyboardModel::gpro }
};
enum class KeyboardModel : uint8_t {
unknown = 0x00,
g213,
g410,
g413,
g513,
g610,
g810,
g910,
gpro
};
enum class StartupMode : uint8_t {
wave = 0x01,
color
};
enum class NativeEffect : uint8_t {
color = 0x01,
breathing,
cycle,
hwave,
vwave,
cwave
};
enum class NativeEffectPart : uint8_t {
all = 0xff,
keys = 0x00,
logo
};
enum class KeyGroup : uint8_t {
logo = 0x00,
indicators,
multimedia,
gkeys,
fkeys,
modifiers,
functions,
arrows,
numeric,
keys
};
enum class Key : uint16_t { // 127 items
logo = static_cast<uint8_t>(KeyAddressGroup::logo) << 8 | 0x01,
logo2,
backlight = static_cast<uint8_t>(KeyAddressGroup::indicators) << 8| 0x01,
game, caps, scroll, num,
next = static_cast<uint8_t>(KeyAddressGroup::multimedia) << 8 | 0xb5,
prev, stop,
play = static_cast<uint8_t>(KeyAddressGroup::multimedia) << 8 | 0xcd,
mute = static_cast<uint8_t>(KeyAddressGroup::multimedia) << 8 | 0xe2,
g1 = static_cast<uint8_t>(KeyAddressGroup::gkeys) << 8 | 0x01,
g2, g3, g4, g5, g6, g7, g8, g9,
a = static_cast<uint8_t>(KeyAddressGroup::keys) << 8 | 0x04,
b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
n1, n2, n3, n4, n5, n6, n7, n8, n9, n0,
enter, esc, backspace, tab, space, minus, equal, open_bracket, close_bracket,
backslash, dollar, semicolon, quote, tilde, comma, period, slash, caps_lock,
f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
print_screen, scroll_lock, pause_break, insert, home, page_up, del, end, page_down,
arrow_right, arrow_left, arrow_bottom, arrow_top, num_lock, num_slash, num_asterisk,
num_minus, num_plus, num_enter,
num_1, num_2, num_3, num_4, num_5, num_6, num_7, num_8, num_9, num_0,
num_dot, intl_backslash, menu,
ctrl_left = static_cast<uint8_t>(KeyAddressGroup::keys) << 8 | 0xe0,
shift_left, alt_left, win_left,
ctrl_right, shift_right, alt_right, win_right
};
typedef struct {
uint16_t vendorID = 0x0;
uint16_t productID = 0x0;
std::string manufacturer = "";
std::string product = "";
std::string serialNumber = "";
KeyboardModel model;
} DeviceInfo;
struct Color {
uint8_t red;
uint8_t green;
uint8_t blue;
};
struct KeyValue {
LedKeyboard::Key key;
LedKeyboard::Color color;
};
typedef std::vector<KeyValue> KeyValueArray;
~LedKeyboard();
std::vector<DeviceInfo> listKeyboards();
bool isOpen();
bool open();
bool open(uint16_t vendorID, uint16_t productID, std::string serial);
DeviceInfo getCurrentDevice();
bool close();
KeyboardModel getKeyboardModel();
bool commit();
bool setKey(KeyValue keyValue);
bool setKeys(KeyValueArray keyValues);
bool setGroupKeys(KeyGroup keyGroup, Color color);
bool setAllKeys(Color color);
bool setMRKey(uint8_t value);
bool setMNKey(uint8_t value);
bool setGKeysMode(uint8_t value);
bool setRegion(uint8_t region, Color color);
bool setStartupMode(StartupMode startupMode);
bool setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color);
private:
typedef std::vector<unsigned char> byte_buffer_t;
typedef std::vector<Key> KeyArray;
const KeyArray keyGroupLogo = { Key::logo, Key::logo2 };
const KeyArray keyGroupIndicators = { Key::caps, Key::num, Key::scroll, Key::game, Key::backlight };
const KeyArray keyGroupMultimedia = { Key::next, Key::prev, Key::stop, Key::play, Key::mute };
const KeyArray keyGroupGKeys = { Key::g1, Key::g2, Key::g3, Key::g4, Key::g5, Key::g6, Key::g7, Key::g8, Key::g9 };
const KeyArray keyGroupFKeys = {
Key::f1, Key::f2, Key::f3, Key::f4, Key::f5, Key::f6,
Key::f7, Key::f8, Key::f9, Key::f10, Key::f11, Key::f12
};
const KeyArray keyGroupModifiers = {
Key::shift_left, Key::ctrl_left, Key::win_left, Key::alt_left,
Key::alt_right, Key::win_right, Key::ctrl_right, Key::shift_right, Key::menu };
const KeyArray keyGroupFunctions = {
Key::esc, Key::print_screen, Key::scroll_lock, Key::pause_break,
Key::insert, Key::del, Key::home, Key::end, Key::page_up, Key::page_down
};
const KeyArray keyGroupArrows = { Key::arrow_top, Key::arrow_left, Key::arrow_bottom, Key::arrow_right };
const KeyArray keyGroupNumeric = {
Key::num_1, Key::num_2, Key::num_3, Key::num_4, Key::num_5,
Key::num_6, Key::num_7, Key::num_8, Key::num_9, Key::num_0,
Key::num_dot, Key::num_enter, Key::num_plus, Key::num_minus,
Key::num_asterisk, Key::num_slash, Key::num_lock
};
const KeyArray keyGroupKeys = {
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, Key::w, Key::x, Key::y, Key::z,
Key::n1, Key::n2, Key::n3, Key::n4, Key::n5, Key::n6, Key::n7, Key::n8, Key::n9, Key::n0,
Key::enter, Key::backspace, Key::tab, Key::space, Key::minus, Key::equal,
Key::open_bracket, Key::close_bracket, Key::backslash, Key::dollar, Key::semicolon, Key::quote, Key::tilde,
Key::comma, Key::period, Key::slash, Key::caps_lock, Key::intl_backslash
};
bool m_isOpen = false;
DeviceInfo currentDevice;
#if defined(hidapi)
hid_device *m_hidHandle;
#elif defined(libusb)
bool m_isKernellDetached = false;
libusb_device_handle *m_hidHandle;
libusb_context *m_ctx = NULL;
#endif
bool sendDataInternal(byte_buffer_t &data);
byte_buffer_t getKeyGroupAddress(KeyAddressGroup keyAddressGroup);
}; };

330
src/helpers/help.cpp Normal file
View File

@ -0,0 +1,330 @@
#include "help.h"
#include <iostream>
#include "utils.h"
using namespace std;
namespace help {
inline KeyboardFeatures operator|(KeyboardFeatures a, KeyboardFeatures b) {
return static_cast<KeyboardFeatures>(static_cast<uint16_t>(a) | static_cast<uint16_t>(b));
}
KeyboardFeatures getKeyboardFeatures(string cmdName) {
if(cmdName == "g213-led") return KeyboardFeatures::g213;
else if(cmdName == "g410-led") return KeyboardFeatures::g410;
else if(cmdName == "g413-led") return KeyboardFeatures::g413;
else if(cmdName == "g610-led") return KeyboardFeatures::g610;
else if(cmdName == "g810-led") return KeyboardFeatures::g810;
else if(cmdName == "g910-led") return KeyboardFeatures::g910;
else if(cmdName == "gpro-led") return KeyboardFeatures::gpro;
return KeyboardFeatures::all;
}
void usage(char *arg0) {
string cmdName = utils::getCmdName(arg0);
KeyboardFeatures features = getKeyboardFeatures(cmdName);
cout<<cmdName<<endl;
cout<<"--------"<<endl;
cout<<"Version : "<<VERSION<<endl;
cout<<endl;
cout<<"Usage: "<<cmdName<<" [OPTIONS...] [command] (command arguments)"<<endl;
cout<<"Commands:"<<endl;
if((features | KeyboardFeatures::setall) == features)
cout<<" -a {color}\t\t\t\tSet all keys color"<<endl;
if((features | KeyboardFeatures::setgroup) == features)
cout<<" -g {keygroup} {color}\t\t\tSet key group color"<<endl;
if((features | KeyboardFeatures::setkey) == features)
cout<<" -k {key} {color}\t\t\tSet key color"<<endl;
if((features | KeyboardFeatures::setregion) == features)
cout<<" -r {region} {color}\t\t\tSet the color of a region for a region-based keyboard"<<endl;
if((features | KeyboardFeatures::gkeys) == features) {
cout<<" -mr {value}\t\t\t\tSet MR key (0-1)"<<endl;
cout<<" -mn {value}\t\t\t\tSet MN key (0-7) (M1=1, M2=2, M3=4) (M1+M2=3, M1+M3=5, ...)"<<endl;
cout<<endl;
cout<<" -gkm {value}\t\t\t\tSet GKeys mode (0=Mapped to FKeys, 1=Independent)"<<endl;
}
cout<<endl;
if((features | KeyboardFeatures::commit) == features) {
if((features | KeyboardFeatures::setall) == features)
cout<<" -an {color}\t\t\t\tSet all keys color without commit"<<endl;
if((features | KeyboardFeatures::setgroup) == features)
cout<<" -gn {keygroup} {color}\t\tSet key group color without commit"<<endl;
if((features | KeyboardFeatures::setkey) == features)
cout<<" -kn {key} {color}\t\t\tSet key color without commit"<<endl;
cout<<" -c\t\t\t\t\tCommit change"<<endl;
cout<<endl;
}
cout<<" -fx ...\t\t\t\tUse --help-effects for more detail"<<endl;
cout<<endl;
cout<<" < {profile}\t\t\t\tSet a profile from a file (use --help-samples for more detail)"<<endl;
cout<<" |\t\t\t\t\tSet a profile from stdin (for scripting) (use --help-samples for more detail)"<<endl;
cout<<endl;
if((features | KeyboardFeatures::poweronfx) == features) {
cout<<" --startup-mode {startup mode}\t\tSet startup mode"<<endl;
cout<<endl;
}
cout<<" --list-keyboards \t\t\tList connected keyboards"<<endl;
cout<<" --print-device\t\t\tPrint device information for the keyboard"<<endl;
cout<<endl;
cout<<" --help\t\t\t\tThis help"<<endl;
cout<<" --help-keys\t\t\t\tHelp for keys in groups"<<endl;
cout<<" --help-effects\t\t\tHelp for native effects"<<endl;
cout<<" --help-samples\t\t\tUsage samples"<<endl;
cout<<endl;
cout<<"Options:"<<endl;
cout<<" -dv\t\t\t\t\tDevice vendor ID, such as 046d for Logitech. Can be omitted to match any vendor ID"<<endl;
cout<<" -dp\t\t\t\t\tDevice product ID, such as c337 for Logitech G810. Can be omitted to match any product ID"<<endl;
cout<<" -ds\t\t\t\t\tDevice serial number, Can be omitted to match the first device found"<<endl;
cout<<" -tuk\t\t\t\t\tTest unsuported keyboard with one of supported protocol (1-3) -dv and -dp are required"<<endl;
cout<<endl;
cout<<"Values:"<<endl;
if((features | KeyboardFeatures::rgb) == features)
cout<<" color formats :\t\t\tRRGGBB (hex value for red, green and blue)"<<endl;
if((features | KeyboardFeatures::intensity) == features)
cout<<" color formats :\t\t\tII (hex value for intensity)"<<endl;
if((features | KeyboardFeatures::setregion) == features)
cout<<" region formats :\t\t\tRN (integer value for region, 1 to 5)"<<endl;
cout<<" speed formats :\t\t\tSS (hex value for speed 01 to ff)"<<endl;
cout<<endl;
if((features | KeyboardFeatures::setkey) == features)
cout<<" key values :\t\t\t\tabc... 123... and other (use --help-keys for more detail)"<<endl;
if((features | KeyboardFeatures::setgroup) == features)
cout<<" group values :\t\t\tlogo, indicators, fkeys, ... (use --help-keys for more detail)"<<endl;
cout<<" startup mode :\t\t\twave, color"<<endl;
cout<<endl;
}
// Need to check rgb and intesity
void keys(char *arg0) {
string cmdName = utils::getCmdName(arg0);
KeyboardFeatures features = getKeyboardFeatures(cmdName);
cout<<cmdName<<" Keys"<<endl;
cout<<"-------------"<<endl;
cout<<endl;
cout<<"Group List :"<<endl;
if((features | KeyboardFeatures::logo1) == features)
cout<<" logo"<<endl;
if((features | KeyboardFeatures::setindicators) == features)
cout<<" indicators"<<endl;
if((features | KeyboardFeatures::gkeys) == features)
cout<<" gkeys"<<endl;
cout<<" fkeys"<<endl;
cout<<" modifiers"<<endl;
if((features | KeyboardFeatures::multimedia) == features)
cout<<" multimedia"<<endl;
cout<<" arrows"<<endl;
if((features | KeyboardFeatures::numpad) == features)
cout<<" numeric"<<endl;
cout<<" functions"<<endl;
cout<<" keys"<<endl;
cout<<endl;
cout<<endl;
if((features | KeyboardFeatures::logo1) == features) {
cout<<"Group Logo :"<<endl;
cout<<" logo"<<endl;
if((features | KeyboardFeatures::logo2) == features)
cout<<" logo2"<<endl;
cout<<""<<endl;
}
if((features | KeyboardFeatures::setindicators) == features) {
cout<<"Group indicators :"<<endl;
cout<<" num_indicator, numindicator, num"<<endl;
cout<<" caps_indicator, capsindicator, caps"<<endl;
cout<<" scroll_indicator, scrollindicator, scroll"<<endl;
cout<<" game_mode, gamemode, game"<<endl;
cout<<" back_light, backlight, light"<<endl;
cout<<""<<endl;
}
if((features | KeyboardFeatures::gkeys) == features) {
cout<<"Group gkeys :"<<endl;
cout<<" g1 - g9"<<endl;
cout<<""<<endl;
}
cout<<"Group fkeys :"<<endl;
cout<<" f1 - f12"<<endl;
cout<<""<<endl;
cout<<"Group modifiers :"<<endl;
cout<<" shift_left, shiftleft, shiftl"<<endl;
cout<<" ctrl_left, ctrlleft, ctrll"<<endl;
cout<<" win_left, winleft, win_left"<<endl;
cout<<" alt_left, altleft, altl"<<endl;
cout<<" alt_right, altright, altr, altgr"<<endl;
cout<<" win_right, winright, winr"<<endl;
cout<<" menu"<<endl;
cout<<" ctrl_right, ctrlright, ctrlr"<<endl;
cout<<" shift_right, shiftright, shiftr"<<endl;
cout<<""<<endl;
if((features | KeyboardFeatures::multimedia) == features) {
cout<<"Group multimedia :"<<endl;
cout<<" mute"<<endl;
cout<<" play_pause, playpause, play"<<endl;
cout<<" stop"<<endl;
cout<<" previous, prev"<<endl;
cout<<" next"<<endl;
cout<<""<<endl;
}
cout<<"Group arrows :"<<endl;
cout<<" arrow_top, arrowtop, top"<<endl;
cout<<" arrow_left, arrowleft, left"<<endl;
cout<<" arrow_bottom, arrowbottom, bottom"<<endl;
cout<<" arrow_right, arrowright, right"<<endl;
cout<<""<<endl;
if((features | KeyboardFeatures::numpad) == features) {
cout<<"Group numeric :"<<endl;
cout<<" num_lock, numlock"<<endl;
cout<<" num_slash, numslash, num/"<<endl;
cout<<" num_asterisk, numasterisk, num*"<<endl;
cout<<" num_minus, numminus, num-"<<endl;
cout<<" num_plus, numplus, num+"<<endl;
cout<<" numenter"<<endl;
cout<<" num0 - num9"<<endl;
cout<<" num_dot, numdot, num."<<endl;
cout<<""<<endl;
}
cout<<"Group functions :"<<endl;
cout<<" escape, esc"<<endl;
cout<<" print_screen, printscreen, printscr"<<endl;
cout<<" scroll_lock, scrolllock"<<endl;
cout<<" pause_break, pausebreak"<<endl;
cout<<" insert, ins"<<endl;
cout<<" home"<<endl;
cout<<" page_up, pageup"<<endl;
cout<<" delete, del"<<endl;
cout<<" end"<<endl;
cout<<" page_down, pagedown"<<endl;
cout<<""<<endl;
if((features | KeyboardFeatures::setkey) == features) {
cout<<"Group keys :"<<endl;
cout<<" 0 - 9"<<endl;
cout<<" a - z"<<endl;
cout<<" tab"<<endl;
cout<<" caps_lock, capslock"<<endl;
cout<<" space"<<endl;
cout<<" backspace, back"<<endl;
cout<<" enter"<<endl;
cout<<" tilde"<<endl;
cout<<" minus"<<endl;
cout<<" equal"<<endl;
cout<<" open_bracket"<<endl;
cout<<" close_bracket"<<endl;
cout<<" backslash"<<endl;
cout<<" semicolon"<<endl;
cout<<" dollar"<<endl;
cout<<" quote"<<endl;
cout<<" intl_backslash"<<endl;
cout<<" comma"<<endl;
cout<<" period"<<endl;
cout<<" slash"<<endl;
}
}
void effects(char *arg0) {
string cmdName = utils::getCmdName(arg0);
KeyboardFeatures features = getKeyboardFeatures(cmdName);
cout<<cmdName<<" Effects"<<endl;
cout<<"----------------"<<endl;
cout<<endl;
cout<<"At this time, FX are only tested on g810 !"<<endl;
cout<<endl;
cout<<" -fx {effect} {target}"<<endl;
cout<<endl;
cout<<" -fx color {target} {color}"<<endl;
cout<<" -fx breathing {target} {color} {speed}"<<endl;
cout<<" -fx cycle {target} {speed}"<<endl;
cout<<" -fx hwave {target} {speed}"<<endl;
cout<<" -fx vwave {target} {speed}"<<endl;
cout<<" -fx cwave {target} {speed}"<<endl;
cout<<endl;
if((features | KeyboardFeatures::logo1) == features)
cout<<"target value :\t\t\t\tall, keys, logo"<<endl;
else
cout<<"target value :\t\t\t\tall, keys (all is for compatibility with other keyboard models)"<<endl;
if((features | KeyboardFeatures::rgb) == features)
cout<<"color formats :\t\t\t\tRRGGBB (hex value for red, green and blue)"<<endl;
else if((features | KeyboardFeatures::rgb) == features)
cout<<"color formats :\t\t\t\tII (hex value for intensity)"<<endl;
cout<<"speed formats :\t\t\t\tSS (hex value for speed 01 to ff)"<<endl;
cout<<endl;
}
// Need to check rgb and intesity
void samples(char *arg0) {
string cmdName = utils::getCmdName(arg0);
KeyboardFeatures features = getKeyboardFeatures(cmdName);
cout<<cmdName<<" Samples"<<endl;
cout<<"----------------"<<endl;
cout<<endl;
cout<<"Samples :"<<endl;
cout<<cmdName<<" -p /etc/g810/profile # Load a profile"<<endl;
if((features | KeyboardFeatures::setkey) == features)
cout<<cmdName<<" -k logo ff0000 # Set color of a key"<<endl;
if((features | KeyboardFeatures::setall) == features)
cout<<cmdName<<" -a 00ff00 # Set color of all keys"<<endl;
if((features | KeyboardFeatures::setgroup) == features)
cout<<cmdName<<" -g fkeys ff00ff # Set color of a group of keys"<<endl;
if((features | KeyboardFeatures::setregion) == features)
cout<<cmdName<<" -r 1 ff0000 # Set region 1 red"<<endl;
cout<<cmdName<<" -fx color keys 00ff00 # Set fixed color effect"<<endl;
cout<<cmdName<<" -fx breathing logo 00ff00 0a # Set breathing effect"<<endl;
cout<<cmdName<<" -fx cycle all 0a # Set color cycle effect"<<endl;
cout<<cmdName<<" -fx hwave keys 0a # Set horizontal wave effect"<<endl;
cout<<cmdName<<" -fx vwave keys 0a # Set vertical wave effect"<<endl;
cout<<cmdName<<" -fx cwave keys 0a # Set center wave effect"<<endl;
if((features | KeyboardFeatures::poweronfx) == features)
cout<<cmdName<<" --startup-mode color # Set keyboard power on effect"<<endl;
cout<<endl;
if((features | KeyboardFeatures::commit) == features) {
cout<<"Samples with no commit :"<<endl;
if((features | KeyboardFeatures::setall) == features)
cout<<cmdName<<" -an 000000 # Set color of all key with no action"<<endl;
if((features | KeyboardFeatures::setgroup) == features)
cout<<cmdName<<" -gn modifiers ff0000 # Set color of a group with no action"<<endl;
if((features | KeyboardFeatures::setkey) == features) {
cout<<cmdName<<" -kn w ff0000 # Set color of a key with no action"<<endl;
cout<<cmdName<<" -kn a ff0000 # Set color of a key with no action"<<endl;
cout<<cmdName<<" -kn s ff0000 # Set color of a key with no action"<<endl;
cout<<cmdName<<" -kn d ff0000 # Set color of a key with no action"<<endl;
}
cout<<cmdName<<" -c # Commit all changes"<<endl;
cout<<endl;
}
// Need to be merged with Samples
if((features | KeyboardFeatures::intensity) == features) {
cout<<"Samples with intensity :"<<endl;
cout<<cmdName<<" -a 60 # Set intensity of all keys"<<endl;
cout<<cmdName<<" -k logo ff # Set intensity of a key"<<endl;
cout<<cmdName<<" -g fkeys aa # Set intensity of a group of keys"<<endl;
cout<<endl;
}
if((features | KeyboardFeatures::setkey) == features) {
cout<<"Samples with pipe (for effects) :"<<endl;
cout<<cmdName<<" -pp < profilefile # Load a profile"<<endl;
cout<<"echo -e \"k w ff0000\\nk a ff0000\\nk s ff0000\\nk d ff0000\\nc\" | g810-led -pp # Set multiple keys"<<endl;
cout<<endl;
}
cout<<"Testing an unsuported keyboard :"<<endl;
cout<<"lsusb"<<endl;
cout<<"#Sample result of lsusb : ID 046d:c331 Logitech, Inc. (dv=046d and dp=c331)"<<endl;
cout<<cmdName<<" -dv 046d -dp c331 -tuk 1 -a 000000"<<endl;
cout<<cmdName<<" -dv 046d -dp c331 -tuk 2 -a 000000"<<endl;
cout<<cmdName<<" -dv 046d -dp c331 -tuk 3 -a 000000"<<endl;
cout<<""<<endl;
}
}

52
src/helpers/help.h Normal file
View File

@ -0,0 +1,52 @@
#ifndef HELP_HELPER
#define HELP_HELPER
#include <iostream>
namespace help {
enum class KeyboardFeatures : uint16_t {
none = 0,
rgb = 1,
intensity = 2,
commit = 4,
logo1 = 8,
logo2 = 16,
numpad = 32,
multimedia = 64,
gkeys = 128,
setall = 256,
setgroup = 512,
setkey = 1024,
setregion = 2048,
setindicators = 4096,
poweronfx = 8192,
// fx features
all = rgb | intensity | commit | logo1 | logo2 | numpad | multimedia | gkeys |
setall | setgroup | setkey | setregion | setindicators | poweronfx,
g213 = rgb | logo1 | numpad | multimedia | setall | setregion | setindicators | poweronfx,
g410 = rgb | commit | setall | setgroup | setkey | poweronfx,
g413 = intensity | setall,
g610 = intensity | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx,
g810 = rgb | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx,
g910 = rgb | commit | logo1 | logo2 | numpad | multimedia | gkeys | setall | setgroup | setkey | setindicators | poweronfx,
gpro = rgb | commit | logo1 | multimedia | setall | setgroup | setkey | setindicators | poweronfx
};
inline KeyboardFeatures operator|(KeyboardFeatures a, KeyboardFeatures b);
KeyboardFeatures getKeyboardFeatures(std::string cmdName);
void usage(char *arg0);
void keys(char *arg0);
void effects(char *arg0);
void samples(char *arg0);
}
#ifndef VERSION
#define VERSION "unspecified"
#endif
#endif

228
src/helpers/utils.cpp Normal file
View File

@ -0,0 +1,228 @@
#include "utils.h"
#include <iostream>
#include <algorithm>
#include "../classes/Keyboard.h"
namespace utils {
std::string getCmdName(std::string cmd) {
return cmd.substr(cmd.find_last_of("/\\") + 1);
}
bool parseStartupMode(std::string val, LedKeyboard::StartupMode &startupMode) {
if (val == "wave") startupMode = LedKeyboard::StartupMode::wave;
else if (val == "color") startupMode = LedKeyboard::StartupMode::color;
else return false;
return true;
}
bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect) {
if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color;
else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle;
else if (val == "breathing") nativeEffect = LedKeyboard::NativeEffect::breathing;
else if (val == "hwave") nativeEffect = LedKeyboard::NativeEffect::hwave;
else if (val == "vwave") nativeEffect = LedKeyboard::NativeEffect::vwave;
else if (val == "cwave") nativeEffect = LedKeyboard::NativeEffect::cwave;
else return false;
return true;
}
bool parseNativeEffectPart(std::string val, LedKeyboard::NativeEffectPart &nativeEffectPart) {
if (val == "all") nativeEffectPart = LedKeyboard::NativeEffectPart::all;
else if (val == "keys") nativeEffectPart = LedKeyboard::NativeEffectPart::keys;
else if (val == "logo") nativeEffectPart = LedKeyboard::NativeEffectPart::logo;
else return false;
return true;
}
bool parseKey(std::string val, LedKeyboard::Key &key) {
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
if (val == "logo") key = LedKeyboard::Key::logo;
else if (val == "logo2") key = LedKeyboard::Key::logo2;
else if (val == "back_light" || val == "backlight" || val == "light") key = LedKeyboard::Key::backlight;
else if (val == "game_mode" || val == "gamemode" || val == "game") key = LedKeyboard::Key::game;
else if (val == "caps_indicator" || val == "capsindicator" || val == "caps") key = LedKeyboard::Key::caps;
else if (val == "scroll_indicator" || val == "scrollindicator" || val == "scroll") key = LedKeyboard::Key::scroll;
else if (val == "num_indicator" || val == "numindicator" || val == "num") key = LedKeyboard::Key::num;
else if (val == "next") key = LedKeyboard::Key::next;
else if (val == "prev" || val == "previous") key = LedKeyboard::Key::prev;
else if (val == "stop") key = LedKeyboard::Key::stop;
else if (val == "play_pause" || val == "playpause" || val == "play") key = LedKeyboard::Key::play;
else if (val == "mute") key = LedKeyboard::Key::mute;
else if (val == "a") key = LedKeyboard::Key::a;
else if (val == "b") key = LedKeyboard::Key::b;
else if (val == "c") key = LedKeyboard::Key::c;
else if (val == "d") key = LedKeyboard::Key::d;
else if (val == "e") key = LedKeyboard::Key::e;
else if (val == "f") key = LedKeyboard::Key::f;
else if (val == "g") key = LedKeyboard::Key::g;
else if (val == "h") key = LedKeyboard::Key::h;
else if (val == "i") key = LedKeyboard::Key::i;
else if (val == "j") key = LedKeyboard::Key::j;
else if (val == "k") key = LedKeyboard::Key::k;
else if (val == "l") key = LedKeyboard::Key::l;
else if (val == "m") key = LedKeyboard::Key::m;
else if (val == "n") key = LedKeyboard::Key::n;
else if (val == "o") key = LedKeyboard::Key::o;
else if (val == "p") key = LedKeyboard::Key::p;
else if (val == "q") key = LedKeyboard::Key::q;
else if (val == "r") key = LedKeyboard::Key::r;
else if (val == "s") key = LedKeyboard::Key::s;
else if (val == "t") key = LedKeyboard::Key::t;
else if (val == "u") key = LedKeyboard::Key::u;
else if (val == "v") key = LedKeyboard::Key::v;
else if (val == "w") key = LedKeyboard::Key::w;
else if (val == "x") key = LedKeyboard::Key::x;
else if (val == "z") key = LedKeyboard::Key::z;
else if (val == "y") key = LedKeyboard::Key::y;
else if (val == "1" || val == "one") key = LedKeyboard::Key::n1;
else if (val == "2" || val == "two") key = LedKeyboard::Key::n2;
else if (val == "3" || val == "three") key = LedKeyboard::Key::n3;
else if (val == "4" || val == "four") key = LedKeyboard::Key::n4;
else if (val == "5" || val == "five") key = LedKeyboard::Key::n5;
else if (val == "6" || val == "six") key = LedKeyboard::Key::n6;
else if (val == "7" || val == "seven") key = LedKeyboard::Key::n7;
else if (val == "8" || val == "eight") key = LedKeyboard::Key::n8;
else if (val == "9" || val == "nine") key = LedKeyboard::Key::n9;
else if (val == "0" || val == "zero") key = LedKeyboard::Key::n0;
else if (val == "enter") key = LedKeyboard::Key::enter;
else if (val == "esc" || val == "escape") key = LedKeyboard::Key::esc;
else if (val == "back" || val == "backspace") key = LedKeyboard::Key::backspace;
else if (val == "tab") key = LedKeyboard::Key::tab;
else if (val == "space") key = LedKeyboard::Key::space;
else if (val == "tilde" || val == "~") key = LedKeyboard::Key::tilde;
else if (val == "minus" || val == "-") key = LedKeyboard::Key::minus;
else if (val == "equal" || val == "=") key = LedKeyboard::Key::equal;
else if (val == "open_bracket" || val == "[") key = LedKeyboard::Key::open_bracket;
else if (val == "close_bracket" || val == "]") key = LedKeyboard::Key::close_bracket;
else if (val == "backslash" || val == "\\") key = LedKeyboard::Key::backslash;
else if (val == "semicolon" || val == ";") key = LedKeyboard::Key::semicolon;
else if (val == "quote" || val == "\"") key = LedKeyboard::Key::quote;
else if (val == "dollar" || val == "$") key = LedKeyboard::Key::dollar;
else if (val == "comma" || val == ",") key = LedKeyboard::Key::comma;
else if (val == "period" || val == ".") key = LedKeyboard::Key::period;
else if (val == "slash" || val == "/") key = LedKeyboard::Key::slash;
else if (val == "caps_lock" || val == "capslock") key = LedKeyboard::Key::caps_lock;
else if (val == "f1") key = LedKeyboard::Key::f1;
else if (val == "f2") key = LedKeyboard::Key::f2;
else if (val == "f3") key = LedKeyboard::Key::f3;
else if (val == "f4") key = LedKeyboard::Key::f4;
else if (val == "f5") key = LedKeyboard::Key::f5;
else if (val == "f6") key = LedKeyboard::Key::f6;
else if (val == "f7") key = LedKeyboard::Key::f7;
else if (val == "f8") key = LedKeyboard::Key::f8;
else if (val == "f9") key = LedKeyboard::Key::f9;
else if (val == "f10") key = LedKeyboard::Key::f10;
else if (val == "f11") key = LedKeyboard::Key::f11;
else if (val == "f12") key = LedKeyboard::Key::f12;
else if (val == "print_screen" || val == "printscreen" || val == "printscr" || val == "print")
key = LedKeyboard::Key::print_screen;
else if (val == "scroll_lock" || val == "scrolllock") key = LedKeyboard::Key::scroll_lock;
else if (val == "pause_break" || val == "pausebreak" || val == "pause" || val == "break")
key = LedKeyboard::Key::pause_break;
else if (val == "insert" || val == "ins") key = LedKeyboard::Key::insert;
else if (val == "home") key = LedKeyboard::Key::home;
else if (val == "page_up" || val == "pageup") key = LedKeyboard::Key::page_up;
else if (val == "delete" || val == "del") key = LedKeyboard::Key::del;
else if (val == "end") key = LedKeyboard::Key::end;
else if (val == "page_down" || val == "pagedown") key = LedKeyboard::Key::page_down;
else if (val == "arrow_right" || val == "arrowright" || val == "right") key = LedKeyboard::Key::arrow_right;
else if (val == "arrow_left" || val == "arrowleft" || val == "left") key = LedKeyboard::Key::arrow_left;
else if (val == "arrow_bottom" || val == "arrowbottom" || val == "bottom") key = LedKeyboard::Key::arrow_bottom;
else if (val == "arrow_top" || val == "arrowtop" || val == "top") key = LedKeyboard::Key::arrow_top;
else if (val == "num_lock" || val == "numlock") key = LedKeyboard::Key::num_lock;
else if (val == "num/" || val == "num_slash" || val == "numslash") key = LedKeyboard::Key::num_slash;
else if (val == "num*" || val == "num_asterisk" || val == "numasterisk") key = LedKeyboard::Key::num_asterisk;
else if (val == "num-" || val == "num_minus" || val == "numminus") key = LedKeyboard::Key::num_minus;
else if (val == "num+" || val == "num_plus" || val == "numplus") key = LedKeyboard::Key::num_plus;
else if (val == "numenter") key = LedKeyboard::Key::num_enter;
else if (val == "num1") key = LedKeyboard::Key::num_1;
else if (val == "num2") key = LedKeyboard::Key::num_2;
else if (val == "num3") key = LedKeyboard::Key::num_3;
else if (val == "num4") key = LedKeyboard::Key::num_4;
else if (val == "num5") key = LedKeyboard::Key::num_5;
else if (val == "num6") key = LedKeyboard::Key::num_6;
else if (val == "num7") key = LedKeyboard::Key::num_7;
else if (val == "num8") key = LedKeyboard::Key::num_8;
else if (val == "num9") key = LedKeyboard::Key::num_9;
else if (val == "num0") key = LedKeyboard::Key::num_0;
else if (val == "num." || val == "num_period" || val == "numperiod") key = LedKeyboard::Key::num_dot;
else if (val == "intl_backslash" || val == "<") key = LedKeyboard::Key::intl_backslash;
else if (val == "menu") key = LedKeyboard::Key::menu;
else if (val == "ctrl_left" || val == "ctrlleft" || val == "ctrll") key = LedKeyboard::Key::ctrl_left;
else if (val == "shift_left" || val == "shiftleft" || val == "shiftl") key = LedKeyboard::Key::shift_left;
else if (val == "alt_left" || val == "altleft" || val == "altl") key = LedKeyboard::Key::alt_left;
else if (val == "win_left" || val == "winleft" || val == "winl") key = LedKeyboard::Key::win_left;
else if (val == "meta_left" || val == "metaleft" || val == "metal") key = LedKeyboard::Key::win_left;
else if (val == "ctrl_right" || val == "ctrlright" || val == "ctrlr") key = LedKeyboard::Key::ctrl_right;
else if (val == "shift_right" || val == "shiftright" || val == "shiftr") key = LedKeyboard::Key::shift_right;
else if (val == "alt_right" || val == "altright" || val == "altr" || val == "altgr")
key = LedKeyboard::Key::alt_right;
else if (val == "win_right" || val == "winright" || val == "winr") key = LedKeyboard::Key::win_right;
else if (val == "meta_right" || val == "metaright" || val == "metar") key = LedKeyboard::Key::win_right;
else if (val == "g1") key = LedKeyboard::Key::g1;
else if (val == "g2") key = LedKeyboard::Key::g2;
else if (val == "g3") key = LedKeyboard::Key::g3;
else if (val == "g4") key = LedKeyboard::Key::g4;
else if (val == "g5") key = LedKeyboard::Key::g5;
else if (val == "g6") key = LedKeyboard::Key::g6;
else if (val == "g7") key = LedKeyboard::Key::g7;
else if (val == "g8") key = LedKeyboard::Key::g8;
else if (val == "g9") key = LedKeyboard::Key::g9;
else return false;
return true;
}
bool parseKeyGroup(std::string val, LedKeyboard::KeyGroup &keyGroup) {
if (val == "logo") keyGroup = LedKeyboard::KeyGroup::logo;
else if (val == "indicators") keyGroup = LedKeyboard::KeyGroup::indicators;
else if (val == "multimedia") keyGroup = LedKeyboard::KeyGroup::multimedia;
else if (val == "fkeys") keyGroup = LedKeyboard::KeyGroup::fkeys;
else if (val == "modifiers") keyGroup = LedKeyboard::KeyGroup::modifiers;
else if (val == "arrows") keyGroup = LedKeyboard::KeyGroup::arrows;
else if (val == "numeric") keyGroup = LedKeyboard::KeyGroup::numeric;
else if (val == "functions") keyGroup = LedKeyboard::KeyGroup::functions;
else if (val == "keys") keyGroup = LedKeyboard::KeyGroup::keys;
else if (val == "gkeys") keyGroup = LedKeyboard::KeyGroup::gkeys;
else return false;
return true;
}
bool parseColor(std::string val, LedKeyboard::Color &color) {
if (val.length() == 2) val = val + "0000"; // For G610
if (val.length() != 6) return false;
color.red = std::stoul("0x"+val.substr(0,2), nullptr, 16);
color.green = std::stoul("0x"+val.substr(2,2), nullptr, 16);
color.blue = std::stoul("0x"+val.substr(4,2), nullptr, 16);
return true;
}
bool parseSpeed(std::string val, uint8_t &speed) {
if (val.length() == 1) val = "0" + val;
if (val.length() != 2) return false;
speed = std::stoul("0x" + val, nullptr, 16);
return true;
}
bool parseUInt8(std::string val, uint8_t &uint8) {
if (val.length() == 1) val = "0" + val;
if (val.length() != 2) return false;
uint8 = std::stoul("0x" + val, nullptr, 16);
return true;
}
bool parseUInt16(std::string val, uint16_t &uint16) {
if (val.length() == 1) val = "0" + val;
if (val.length() == 2) val = "0" + val;
if (val.length() == 3) val = "0" + val;
if (val.length() != 4) return false;
uint16 = std::stoul("0x" + val, nullptr, 16);
return true;
}
}

23
src/helpers/utils.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef UTILS_HELPER
#define UTILS_HELPER
#include <iostream>
#include "../classes/Keyboard.h"
namespace utils {
std::string getCmdName(std::string cmd);
bool parseStartupMode(std::string val, LedKeyboard::StartupMode &startupMode);
bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect);
bool parseNativeEffectPart(std::string val, LedKeyboard::NativeEffectPart &nativeEffectPart);
bool parseKey(std::string val, LedKeyboard::Key &key);
bool parseKeyGroup(std::string val, LedKeyboard::KeyGroup &keyGroup);
bool parseColor(std::string val, LedKeyboard::Color &color);
bool parseSpeed(std::string val, uint8_t &speed);
bool parseUInt8(std::string val, uint8_t &uint8);
bool parseUInt16(std::string val, uint16_t &uint16);
}
#endif

View File

@ -1,310 +1,310 @@
#include <map> #include <iomanip>
#include <vector> #include <iostream>
#include <unistd.h>
#include <fstream> #include <fstream>
#include <map>
#include "helpers/help.h"
#include "helpers/utils.h"
#include "classes/Keyboard.h" #include "classes/Keyboard.h"
using namespace std;
void usage() { int commit(LedKeyboard &kbd) {
string appname = "g810-led"; if (! kbd.open()) return 1;
cout<<appname<<" Usages :\n"; if (kbd.commit()) return 0;
cout<<"-----------------\n";
cout<<"\n";
cout<<" -s effect :\t\tSet keyboard startup effect\n";
cout<<"\n";
cout<<" -a color :\t\tSet all keys\n";
cout<<" -g group, color :\tSet a group of keys\n";
cout<<" -k key, color :\tSet a key\n";
cout<<"\n";
cout<<" -an color :\t\tSet all keys without commit\n";
cout<<" -gn group, color :\tSet a group of keys without commit\n";
cout<<" -kn key, color :\tSet a key without commit\n";
cout<<"\n";
cout<<" -c :\t\t\tCommit changes\n";
cout<<"\n";
cout<<" -p profilefile :\tLoad a profile\n";
cout<<"\n";
cout<<" -h | --help :\t\tthis help message\n";
cout<<" -lk | --list-keys :\tList keys in groups\n";
cout<<"\n";
cout<<"color formats :\t\tRRGGBB (hex value for red, green and blue)\n";
cout<<"\n";
cout<<"effect values :\t\trainbow, color\n";
cout<<"key values :\t\tabc... 123... and other\n";
cout<<"group values :\t\tlogo, indicators, fkeys, modifiers, multimedia, arrows, numeric, functions, keys\n";
cout<<"\n";
cout<<"sample :\n";
cout<<appname<<" -k logo ff0000\n";
cout<<appname<<" -a 00ff00\n";
cout<<appname<<" -g fkeys ff00ff\n";
cout<<appname<<" -s color\n";
}
void listkeys() {
string appname = "g810-led";
cout<<appname<<" Keys in groups :\n";
cout<<"-------------------------\n";
cout<<"\n";
cout<<"Group logo :\n";
cout<<" logo\n";
cout<<" logo2\n";
cout<<"\n";
cout<<"Group indicators :\n";
cout<<" num_indicator, numindicator, num\n";
cout<<" caps_indicator, capsindicator, caps\n";
cout<<" scroll_indicator, scrollindicator, scroll\n";
cout<<" game_mode, gamemode, game\n";
cout<<" back_light, backlight, light\n";
cout<<"\n";
cout<<"Group fkeys :\n";
cout<<" f1 - f12\n";
cout<<"\n";
cout<<"Group modifiers :\n";
cout<<" shift_left, shiftleft, shiftl\n";
cout<<" ctrl_left, ctrlleft, ctrll\n";
cout<<" win_left, winleft, win_left\n";
cout<<" alt_left, altleft, altl\n";
cout<<" alt_right, altright, altr, altgr\n";
cout<<" win_right, winright, winr\n";
cout<<" menu\n";
cout<<" ctrl_right, ctrlright, ctrlr\n";
cout<<" shift_right, shiftright, shiftr\n";
cout<<"\n";
cout<<"Group multimedia :\n";
cout<<" mute\n";
cout<<" play_pause, playpause, play\n";
cout<<" stop\n";
cout<<" previous, prev\n";
cout<<" next\n";
cout<<"\n";
cout<<"Group arrows :\n";
cout<<" arrow_top, arrowtop, top\n";
cout<<" arrow_left, arrowleft, left\n";
cout<<" arrow_bottom, arrowbottom, bottom\n";
cout<<" arrow_right, arrowright, right\n";
cout<<"\n";
cout<<"Group numeric :\n";
cout<<" num_lock, numlock\n";
cout<<" num_slash, numslash, num/\n";
cout<<" num_asterisk, numasterisk, num*\n";
cout<<" num_minus, numminus, num-\n";
cout<<" num_plus, numplus, num+\n";
cout<<" numenter\n";
cout<<" num0 - num9\n";
cout<<" num_dot, numdot, num.\n";
cout<<"\n";
cout<<"Group functions :\n";
cout<<" escape, esc\n";
cout<<" print_screen, printscreen, printscr\n";
cout<<" scroll_lock, scrolllock\n";
cout<<" pause_break, pausebreak\n";
cout<<" insert, ins\n";
cout<<" home\n";
cout<<" page_up, pageup\n";
cout<<" delete, del\n";
cout<<" end\n";
cout<<" page_down, pagedown\n";
cout<<"\n";
cout<<"Group keys :\n";
cout<<" 0 - 9\n";
cout<<" a - z\n";
cout<<" tab\n";
cout<<" caps_lock, capslock\n";
cout<<" space\n";
cout<<" backspace, back\n";
cout<<" enter\n";
cout<<" tilde\n";
cout<<" minus\n";
cout<<" equal\n";
cout<<" open_bracket\n";
cout<<" close_bracket\n";
cout<<" backslash\n";
cout<<" semicolon\n";
cout<<" dollar\n";
cout<<" quote\n";
cout<<" intl_backslash\n";
cout<<" comma\n";
cout<<" period\n";
cout<<" slash\n";
cout<<"Group gkeys :\n";
cout<<" g1 - g9\n";
}
int commit() {
Keyboard lg_kbd;
lg_kbd.attach();
lg_kbd.commit();
lg_kbd.detach();
return 0;
}
int setStartupEffect(string effect) {
Keyboard lg_kbd;
Keyboard::PowerOnEffect powerOnEffect;
if (lg_kbd.parsePowerOnEffect(effect, powerOnEffect) == true) {
lg_kbd.attach();
lg_kbd.setPowerOnEffect(powerOnEffect);
lg_kbd.commit();
lg_kbd.detach();
return 0;
}
return 1; return 1;
} }
int setKey(string key, string color, bool commit) { void printDeviceInfo(LedKeyboard::DeviceInfo device) {
Keyboard lg_kbd; std::cout<<"Device: "<<device.manufacturer<<" - "<<device.product<<std::endl;
Keyboard::KeyAddress keyAddress; std::cout<<"\tVendor ID: "<<std::hex<<std::setw(4)<<std::setfill('0')<<device.vendorID<<std::endl;
if (lg_kbd.parseKey(key, keyAddress) == true) { std::cout<<"\tProduct ID: "<<std::hex<<std::setw(4)<<std::setfill('0')<<device.productID<<std::endl;
Keyboard::KeyColors colors; std::cout<<"\tSerial Number: "<<device.serialNumber<<std::endl;
if (lg_kbd.parseColor(color, colors) == true) {
Keyboard::KeyValue keyValue;
keyValue.key = keyAddress;
keyValue.colors = colors;
lg_kbd.attach();
lg_kbd.setKey(keyValue);
if (commit == true) lg_kbd.commit();
lg_kbd.detach();
return 0;
}
} }
int listKeyboards(LedKeyboard &kbd) {
std::vector<LedKeyboard::DeviceInfo> deviceList = kbd.listKeyboards();
if (deviceList.empty()) {
std::cout<<"Matching or compatible device not found !"<<std::endl;
return 1; return 1;
} }
int setAllKeys(string color, bool commit) { std::vector<LedKeyboard::DeviceInfo>::iterator iterator;
Keyboard lg_kbd; for (iterator = deviceList.begin(); iterator != deviceList.end(); iterator++) {
Keyboard::KeyColors colors; LedKeyboard::DeviceInfo device = *iterator;
if (lg_kbd.parseColor(color, colors) == true) { printDeviceInfo(device);
lg_kbd.attach(); }
lg_kbd.setAllKeys(colors);
if (commit == true) lg_kbd.commit();
lg_kbd.detach();
return 0; return 0;
} }
int setAllKeys(LedKeyboard &kbd, std::string arg2, bool commit = true) {
LedKeyboard::Color color;
if (! utils::parseColor(arg2, color)) return 1;
if (! kbd.open()) return 1;
if(! kbd.setAllKeys(color)) return 1;
if (commit) if(! kbd.commit()) return 1;
return 0;
}
int setGroupKeys(LedKeyboard &kbd, std::string arg2, std::string arg3, bool commit = true) {
LedKeyboard::KeyGroup keyGroup;
LedKeyboard::Color color;
if (! utils::parseKeyGroup(arg2, keyGroup)) return 1;
if (! utils::parseColor(arg3, color)) return 1;
if (! kbd.open()) return 1;
if (! kbd.setGroupKeys(keyGroup, color)) return 1;
if (commit) if(! kbd.commit()) return 1;
return 0;
}
int setKey(LedKeyboard &kbd, std::string arg2, std::string arg3, bool commit = true) {
LedKeyboard::Key key;
LedKeyboard::Color color;
if (! utils::parseKey(arg2, key)) return 1;
if (! utils::parseColor(arg3, color)) return 1;
LedKeyboard::KeyValue keyValue = { key, color };
if (! kbd.open()) return 1;
if (! kbd.setKey(keyValue)) return 1;
if (commit) if(! kbd.commit()) return 1;
return 0;
}
int setMRKey(LedKeyboard &kbd, std::string arg2) {
uint8_t value;
if (! utils::parseUInt8(arg2, value)) return 1;
if (! kbd.open()) return 1;
if (! kbd.setMRKey(value)) return 1;
return 0;
}
int setMNKey(LedKeyboard &kbd, std::string arg2) {
uint8_t value;
if (! utils::parseUInt8(arg2, value)) return 1;
if (! kbd.open()) return 1;
if (! kbd.setMNKey(value)) return 1;
return 0;
}
int setGKeysMode(LedKeyboard &kbd, std::string arg2) {
uint8_t value;
if (! utils::parseUInt8(arg2, value)) return 1;
if (! kbd.open()) return 1;
if (! kbd.setGKeysMode(value)) return 1;
return 0;
}
int setRegion(LedKeyboard &kbd, std::string arg2, std::string arg3) {
uint8_t region = 0;
LedKeyboard::Color color;
if (! utils::parseColor(arg3, color)) return 1;
if (! utils::parseUInt8(arg2, region)) return 1;
if (kbd.setRegion(region, color)) return 0;
return 1; return 1;
} }
int setGroupKeys(string groupKeys, string color, bool commit) { int setFX(LedKeyboard &kbd, std::string arg2, std::string arg3, std::string arg4, std::string arg5 = "") {
Keyboard lg_kbd; LedKeyboard::NativeEffect effect;
Keyboard::KeyGroup keyGroup; LedKeyboard::NativeEffectPart effectPart;
if (lg_kbd.parseKeyGroup(groupKeys, keyGroup) == true) { uint8_t speed = 0;
Keyboard::KeyColors colors; LedKeyboard::Color color;
if (lg_kbd.parseColor(color, colors) == true) { if (! utils::parseNativeEffect(arg2, effect)) return 1;
lg_kbd.attach(); if (! utils::parseNativeEffectPart(arg3, effectPart)) return 1;
lg_kbd.setGroupKeys(keyGroup, colors);
if (commit == true) lg_kbd.commit(); switch (effect) {
lg_kbd.detach(); case LedKeyboard::NativeEffect::color:
if (! utils::parseColor(arg4, color)) return 1;
break;
case LedKeyboard::NativeEffect::breathing:
if (! utils::parseColor(arg4, color)) return 1;
if (arg5 == "") return 1;
if (! utils::parseSpeed(arg5, speed)) return 1;
break;
case LedKeyboard::NativeEffect::cycle:
case LedKeyboard::NativeEffect::hwave:
case LedKeyboard::NativeEffect::vwave:
case LedKeyboard::NativeEffect::cwave:
if (! utils::parseSpeed(arg4, speed)) return 1;
break;
}
if (! kbd.open()) return 1;
if (! kbd.setNativeEffect(effect, effectPart, speed, color)) return 1;
return 0; return 0;
} }
}
int setStartupMode(LedKeyboard &kbd, std::string arg2) {
LedKeyboard::StartupMode startupMode;
if (! utils::parseStartupMode(arg2, startupMode)) return 1;
if (! kbd.open()) return 1;
if (kbd.setStartupMode(startupMode)) return 0;
return 1; return 1;
} }
int loadProfile(string profileFile) {
ifstream file;
file.open(profileFile); int parseProfile(LedKeyboard &kbd, std::istream &stream) {
std::string line;
std::map<std::string, std::string> vars;
LedKeyboard::KeyValueArray keys = {};
int retval = 0;
while (!stream.eof()) {
getline(stream, line);
if (line.size() > 0 && line.substr(0, 1) != "#") {
std::vector<std::string> args = {};
while (line.size() > 0) {
uint32_t ind = line.find(" ");
std::string argValue = line.substr(0, ind);
if (argValue.substr(0, 1) == "$") argValue = vars[argValue.substr(1)];
args.push_back(argValue);
if (line.substr(0, ind) == line) line.clear();
else line = line.substr(ind + 1);
}
if (args[0] == "var" && args.size() > 2) {
vars[args[1]] = args[2];
} else if (args[0] == "c") {
if (kbd.open()) {
if (keys.size() > 0) {
if (! kbd.setKeys(keys)) retval = 1;
keys.clear();
}
if(! kbd.commit()) retval = 1;
} else retval = 1;
} else if (args[0] == "a" && args.size() > 1) {
if (setAllKeys(kbd, args[1], false) == 1) retval = 1;
} else if (args[0] == "g" && args.size() > 2) {
if (setGroupKeys(kbd, args[1], args[2], false) == 1) retval = 1;
} else if (args[0] == "k" && args.size() > 2) {
LedKeyboard::Key key;
LedKeyboard::Color color;
if (utils::parseKey(args[1], key))
if (utils::parseColor(args[2], color))
keys.push_back({ key, color });
} else if (args[0] == "r" && args.size() > 2) {
if (setRegion(kbd, args[1], args[2]) == 1) retval = 1;
} else if (args[0] == "mr" && args.size() > 1) {
if (setMRKey(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "mn" && args.size() > 1) {
if (setMNKey(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "gkm" && args.size() > 1) {
if (setGKeysMode(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "fx" && args.size() > 4) {
if (setFX(kbd, args[1], args[2], args[3], args[4]) == 1) retval = 1;
} else if (args[0] == "fx" && args.size() > 3) {
if (setFX(kbd, args[1], args[2], args[3]) == 1) retval = 1;
}
}
}
return retval;
}
int loadProfile(LedKeyboard &kbd, char *arg2) {
std::ifstream file;
file.open(arg2);
if (file.is_open()) { if (file.is_open()) {
int retval = 0;
string line; retval = parseProfile(kbd, file);
int lineCount = 1;
int ind;
Keyboard lg_kbd;
Keyboard::KeyGroup keyGroup;
Keyboard::KeyAddress keyAddress;
Keyboard::KeyValue keyValue;
Keyboard::KeyColors colors;
map<string, string> var;
vector<Keyboard::KeyValue> keys;
lg_kbd.attach();
while (!file.eof()) {
getline(file, line);
if (line.substr(0, 3) == "var") {
line = line.substr(4);
ind = line.find(" ");
var[line.substr(0, ind)] = line.substr(ind + 1, 6);
} else if (line.substr(0, 1) == "a") {
line = line.substr(2);
if (line.substr(0, 1) == "$") {
ind = line.find(" ");
line = var[line.substr(1, ind - 1)];
} else line = line.substr(0, 6);
if (lg_kbd.parseColor(line, colors) == true) {
keys.clear();
lg_kbd.setAllKeys(colors);
} else cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
} else if (line.substr(0,1) == "g") {
line = line.substr(2);
ind = line.find(" ");
if (lg_kbd.parseKeyGroup(line.substr(0, ind), keyGroup) == true) {
line = line.substr(ind + 1);
if (line.substr(0, 1) == "$") {
ind = line.find(" ");
line = var[line.substr(1, ind - 1)];
};
if (lg_kbd.parseColor(line.substr(0, 6), colors) == true) {
lg_kbd.setGroupKeys(keyGroup, colors);
} else cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
} else cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
} else if (line.substr(0,1) == "k") {
line = line.substr(2);
ind = line.find(" ");
if (lg_kbd.parseKey(line.substr(0, ind), keyAddress) == true) {
line = line.substr(ind + 1);
if (line.substr(0, 1) == "$") {
ind = line.find(" ");
line = var[line.substr(1, ind - 1)];
}
if (lg_kbd.parseColor(line.substr(0, 6), colors) == true) {
keyValue.key = keyAddress;
keyValue.colors = colors;
keys.push_back(keyValue);
} else cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
} else cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
} else if (line.substr(0,1) == "c") {
lg_kbd.commit();
lg_kbd.setKeys(&keys[0], keys.size());
keys.clear();
lg_kbd.commit();
} else if ((line.substr(0, 1) != "#") && (line.substr(0, 1) != "")) {
cout<<"Error on line "<<lineCount<<" : "<<line<<"\n";
}
lineCount++;
}
lg_kbd.detach();
file.close(); file.close();
return retval;
}
return 1;
}
int pipeProfile(LedKeyboard &kbd) {
if (isatty(fileno(stdin))) return 1;
return parseProfile(kbd, std::cin);
}
int main(int argc, char **argv) {
if (argc < 2) {
help::usage(argv[0]);
return 1;
}
LedKeyboard kbd;
std::string serial;
uint16_t vendorID = 0x0;
uint16_t productID = 0x0;
int argIndex = 1;
while (argIndex < argc)
{
std::string arg = argv[argIndex];
// Non-Command arguments
if (argc > (argIndex + 1) && arg == "-ds") {
serial = argv[argIndex + 1];
argIndex += 2;
continue;
} else if (argc > (argIndex + 1) && arg == "-dv"){
if (! utils::parseUInt16(argv[argIndex + 1], vendorID)) return 1;
argIndex += 2;
continue;
} else if (argc > (argIndex + 1) && arg == "-dp"){
if (! utils::parseUInt16(argv[argIndex + 1], productID)) return 1;
argIndex += 2;
continue;
} else if (argc > (argIndex + 1) && arg == "-tuk"){
uint8_t kbdProtocol = 0;
if (! utils::parseUInt8(argv[argIndex + 1], kbdProtocol)) return 1;
switch(kbdProtocol) {
case 1:
kbd.SupportedKeyboards = { { vendorID, productID, (u_int16_t)LedKeyboard::KeyboardModel::g810 } };
break;
case 2:
kbd.SupportedKeyboards = { { vendorID, productID, (u_int16_t)LedKeyboard::KeyboardModel::g910 } };
break;
case 3:
kbd.SupportedKeyboards = { { vendorID, productID, (u_int16_t)LedKeyboard::KeyboardModel::g213 } };
break;
default:
break;
}
argIndex += 2;
continue;
}
//Commands that do not need to initialize a specific device
if (arg == "--help" || arg == "-h") {help::usage(argv[0]); return 0;}
else if (arg == "--list-keyboards") return listKeyboards(kbd);
else if (arg == "--help-keys") {help::keys(argv[0]); return 0;}
else if (arg == "--help-effects") {help::effects(argv[0]); return 0;}
else if (arg == "--help-samples") {help::samples(argv[0]); return 0;}
//Initialize the device for use
if (!kbd.open(vendorID, productID, serial)) {
std::cout << "Matching or compatible device not found !" << std::endl;
return 2;
}
// Command arguments, these will cause parsing to ignore anything beyond the command and its arguments
if (arg == "-c") return commit(kbd);
else if (arg == "--print-device") {printDeviceInfo(kbd.getCurrentDevice()); return 0;}
else if (argc > (argIndex + 1) && arg == "-a") return setAllKeys(kbd, argv[argIndex + 1]);
else if (argc > (argIndex + 2) && arg == "-g") return setGroupKeys(kbd, argv[argIndex + 1], argv[argIndex + 2]);
else if (argc > (argIndex + 2) && arg == "-k") return setKey(kbd, argv[argIndex + 1], argv[argIndex + 2]);
else if (argc > (argIndex + 1) && arg == "-mr") return setMRKey(kbd, argv[argIndex + 1]);
else if (argc > (argIndex + 1) && arg == "-mn") return setMNKey(kbd, argv[argIndex + 1]);
else if (argc > (argIndex + 1) && arg == "-an") return setAllKeys(kbd, argv[argIndex + 1], false);
else if (argc > (argIndex + 2) && arg == "-gn")
return setGroupKeys(kbd, argv[argIndex + 1], argv[argIndex + 2], false);
else if (argc > (argIndex + 2) && arg == "-kn") return setKey(kbd, argv[argIndex + 1], argv[argIndex + 2], false);
else if (argc > (argIndex + 2) && arg == "-r") return setRegion(kbd, argv[argIndex + 1], argv[argIndex + 2]);
else if (argc > (argIndex + 1) && arg == "-gkm") return setGKeysMode(kbd, argv[argIndex + 1]);
else if (argc > (argIndex + 1) && arg == "-p") return loadProfile(kbd, argv[argIndex + 1]);
else if (arg == "-pp") return pipeProfile(kbd);
else if (argc > (argIndex + 4) && arg == "-fx")
return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3], argv[argIndex + 4]);
else if (argc > (argIndex + 3) && arg == "-fx")
return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3]);
else if (argc > (argIndex + 1) && arg == "--startup-mode") return setStartupMode(kbd, argv[argIndex + 1]);
else { help::usage(argv[0]); return 1; }
}
return 0; return 0;
} }
return 1;
}
int main(int argc, char *argv[]) {
string str = argv[0];
size_t split = str.find_last_of("/\\");
str = str.substr(split + 1);
if (argc > 1) {
string argCmd = argv[1];
if (argCmd == "-h" || argCmd == "--help") { usage(); return 0; }
else if (argCmd == "-lk" || argCmd == "--list-keys") { listkeys(); return 0; }
else if (argCmd == "-s" && argc == 3) return setStartupEffect(argv[2]);
else if (argCmd == "-a" && argc == 3) return setAllKeys(argv[2], true);
else if (argCmd == "-an" && argc == 3) return setAllKeys(argv[2], false);
else if (argCmd == "-g" && argc == 4) return setGroupKeys(argv[2], argv[3], true);
else if (argCmd == "-gn" && argc == 4) return setGroupKeys(argv[2], argv[3], false);
else if (argCmd == "-k" && argc == 4) return setKey(argv[2], argv[3], true);
else if (argCmd == "-kn" && argc == 4) return setKey(argv[2], argv[3], false);
else if (argCmd == "-c" && argc == 2) return commit();
else if (argCmd == "-p" && argc == 3) return loadProfile(argv[2]);
}
usage();
return 1;
}

View File

@ -2,9 +2,9 @@
Description=Set Logitech G810 Led Profile Description=Set Logitech G810 Led Profile
[Service] [Service]
ExecStart=/bin/g810-led -p /etc/g810-led/profile ExecStart=/usr/bin/g810-led -p /etc/g810-led/profile
Type=oneshot
RemainAfterExit=yes
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
Type=oneshot
RemainAfterExit=yes

11
udev/g810-led.rules Normal file
View File

@ -0,0 +1,11 @@
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c336", MODE="666" RUN+="/usr/bin/g213-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="666" RUN+="/usr/bin/g410-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33a", MODE="666" RUN+="/usr/bin/g413-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33c", MODE="666" RUN+="/usr/bin/g513-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c338", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c331", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c337", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c32b", MODE="666" RUN+="/usr/bin/g910-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="666" RUN+="/usr/bin/g910-led -p /etc/g810-led/profile"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c339", MODE="666" RUN+="/usr/bin/gpro-led -p /etc/g810-led/profile"

View File

@ -1,6 +0,0 @@
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c331", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c337", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c32b", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="660", GROUP="users"

View File

@ -1,26 +0,0 @@
# Description of each wireshark dump found in this folder
===
Sets effect to 'breathing' with color rgb(252,253,254) at the highest level the slider bar offers. Noticed that the full cycle of updates after switching to the profile (which was done through linking a profile to Notepad++ and letting logitech automatically send the profile once) is around 1 second for fullspeed, 5 seconds for midspeed, and a long 10 seconds for nospeed.
* g810-effect-to-breathing-252-253-254-fullspeed.pcapng
* g810-effect-to-breathing-252-253-254-midspeed.pcapng
* g810-effect-to-breathing-252-253-254-nospeed.pcapng
Sets effect to 'key press' with pressed color rgb(3,2,1) and background color rgb(252,253,254) with slider at lowest speed
* g810-effect-to-keypress-3-2-1_252-253-254-nospeed.pcapng
Idle g810 capture, was getting periodic updates without having anything interesting going on. Not sure why
* g810-idle.pcapng
Sets key color of 'a' / 'rcntrl' to rgb(252,253,254)
* g810-set-a-to-252-253-254.pcapng
* g810-set-rcntrl-to-252-253-254.pcapng
Sets effect to 'fixedcolor' - believe this was also at rgb(252,253,254). The second one includes going to the window and back, where it loads the profile and then reloads the former profile.
* g810-switches-to-fixedcolor-effect.pcapng
* g810-switches-to-from-fixedcolor-effect.pcapng