mortendynamite / g19daemon

Linux daemon for Logitech G19 Keyboard
GNU General Public License v3.0
19 stars 9 forks source link

g-keys commands run on a loop #9

Closed fulvouscoder closed 4 years ago

fulvouscoder commented 4 years ago

Hello,

first and foremost, many thank you for this wonderful contribution.

I noticed a problem, whenever I press the G-Keys, I see the following events in the terminal going on a loop:

Run command: "" Run command: "" Run command: "" (...)

Notes: I am running Manjaro 20 KDE with kernel 5.6.19-2; None of the G-Keys are configured to execute a command; I tested all keys in the keyboard, this only occurs when I press a G-Key.

Also tested this scenario: I configured the G4 Key to open firefox using the following command:

/usr/lib/firefox/firefox %u

When I press the G4 key, firefox is opened multiple times (I stopped counting at the 200 window)

Is this a known issue? Is it possible I have something misconfigured, if so can you provide a clue?

Thank you for your assistance

jimmyd-be commented 4 years ago

I tried this with my installation (Kubuntu 20.04) but cannot reproduce this. Did you installed the daemon using the latest RPM file or did you compile the code from latest commit?

jimmyd-be commented 4 years ago

I will try to setup a Manjaro environment to try to reproduce this. It will take some time because I'm on holiday, so please be patience.

fulvouscoder commented 4 years ago

Hello @jimmyd-be

Thanks for your work on this project!

I compiled the code based on the source. I can redo it and provide any logs or files. If you have any hints on where I would begin to look at, I can also put the time into the grind.

Let me know if I can assist in any way. :smile: Have a good rest and enjoy your holidays!

Thanks

jimmyd-be commented 4 years ago

Currently it looks like the application receives multiple keypresses. I had the same issue but only I got 2 presses when I pressed my G key. I fixed that in G19daemon::gKeys(). Probably you receive multiple key actions for one actual keypress.

jimmyd-be commented 4 years ago

Maybe I just found a correct way to handle this. Now the code only receives press actions. So I remove the second action. But it should be better to run the code once until it receive an unpress event. I'm trying to implement this at the moment so maybe the fix can be created this week. I will make a different branch for this issue so that you can test if I fixed it.

fulvouscoder commented 4 years ago

Awesome!

I've been digging around the files and have the following points:

a) The menu titles of the plugins still have "Hello World"

keybacklight.cpp screen = new Gscreen(icon, tr("Hello World"));

b) I noticed 2 different .conf files. the one over at Dynamite seems to save the settings that I change while using the keyboard menu keys. However, after a system reboot, these configurations are not being loaded. I need to use the keyboard menu keys and enter the Keybacklight menu and press the OK key so that the configuration is again loaded.

/home/username/.config/Dynamite/G19Daemon.conf [General] Backlight=55 KeyBacklight_Blue=200 KeyBacklight_Green=255 KeyBacklight_Red=60 vs

/home/username/.config/G19Daemon/G19Daemon.conf [General] ActivePlugin=Clock Backlight=255 m1_G1= m1_G10= m1_G11= m1_G12= m1_G2= m1_G3= m1_G4= m1_G5= m1_G6= m1_G7= m1_G8= m1_G9= m2_G1= m2_G10= m2_G11= m2_G12= m2_G2= m2_G3= m2_G4= m2_G5= m2_G6= m2_G7= m2_G8= m2_G9= m3_G1= m3_G10= m3_G11= m3_G12= m3_G2= m3_G3= m3_G4= m3_G5= m3_G6= m3_G7= m3_G8= m3_G9=

Thanks for your assistance!

jimmyd-be commented 4 years ago

I will also change this. Thanks for investigating.

fulvouscoder commented 4 years ago

No problem!

I have another point:

c) After I setup my RGB using the LCD Keys (R=60,G=255,B=200), I press OK key and the configuration is saved to the Dynamite folder: /home/username/.config/Dynamite/G19Daemon.conf As soon as I use the Volume adjustment roller to change the sound volume, I notice that the keyboard lighting reacts to the change, going on a scale and when the sound is muted all the keyboard glows red. This is a very cool effect :smile: !!!

Now here lies the problem, after using the roller (or the Mute key), the keyboard lighting reacts accordingly, however it returns to a default state, which is not what I configured (the default seems to be a purpleish color). It seems to me that the configuration file saved under Dynamite is only being loaded when the user saves changes with the LCD keys.

I am trying to find the piece of code that reads from that file and attempt to set it as the default, if it exists.

Hope I am not being too much work, but I just got excited with this project. Thanks!

jimmyd-be commented 4 years ago

Is it possible to create a new ticket for this issue?

Now here lies the problem, after using the roller (or the Mute key), the keyboard lighting reacts accordingly, however it returns to a default state, which is not what I configured (the default seems to be a purpleish color). It seems to me that the configuration file saved under Dynamite is only being loaded when the user saves changes with the LCD keys.

I will do the rest of the points in this one. But it easier to follow progress if the large issues are placed in another ticket.

fulvouscoder commented 4 years ago

Of course!

I'll copy paste it to a new ticket.

Btw I was wondering if there is a debug mode, how are you doing it?

jimmyd-be commented 4 years ago

The main code can be debugged in QT creator or any other C++ ide. For debugging the plugins I use qDebug() << "test";

fulvouscoder commented 4 years ago

Sounds like a plan. Gonna grind it, wait for me on the otherside!

jimmyd-be commented 4 years ago

I have any progress on the looping. I'm testing it now on my computer and will commit it in a custom branch to test it.

jimmyd-be commented 4 years ago

@fulvouscoder can you please test changes on branch issue9 for the looping issue?

fulvouscoder commented 4 years ago

On it! Just to be sure, there is no Make Uninstall right?

I have to manually delete the following files/folders:

/home/username/.config/G19Daemon/G19Daemon.conf

/home/username/.config/Dynamite/G19Daemon.conf

Taken from install_manifest.txt: /usr/bin/g19daemon /usr/share/applications/g19daemon.desktop /etc/udev/rules.d/80-hid-g19.rules /usr/lib/g19daemon/0.1/plugins/libhelloworld.so /usr/lib/g19daemon/0.1/plugins/libkeybacklight.so /usr/lib/g19daemon/0.1/plugins/libbacklight.so /usr/lib/g19daemon/0.1/plugins/libpavolume.so /usr/lib/g19daemon/0.1/plugins/libmpris.so /usr/lib/g19daemon/0.1/plugins/libclock.so /usr/lib/g19daemon/0.1/plugins/libhardwaremonitor.so

Am I missing something?

jimmyd-be commented 4 years ago

You don't need to uninstalll it when recompile the code. It will replace all the files.

I don't know a method to automaticly uninstalll the application.

fulvouscoder commented 4 years ago

I have an incoming wall of text... regarding the tests I've performed for your branch.

TL:DR

whenever I use a G Key, the event is detected and the command is executed, however the app hangs and I cannot use the LCD keys, switch M keys or any G Keys. I need to reboot the app. In short, I can only use G Keys once and then the app hangs.

jimmyd-be commented 4 years ago

The text is normal and is showing the debug logs on startup. The hanging isnt good

fulvouscoder commented 4 years ago

Tests performed and results:

I am adding the detailed test information, but that is the general state of affairs.

On another good note, it seems you also fixed the issue with the Key backlight, every time I restart the app, the settings are being loaded and I don't see that Dynamite folder.

edited: +added the detailed tests below +spelling corrections +text format +added multimedia keys details +updated Tested M keys status

Detailed test information:

Keyboard keys

Open a text editor and press every key and key combination

LCD keys

press all LCD keys

M keys

use M keys to switch between profiles

M keys issues

Note: at the moment MR key does not have a functionality

G keys

setup G keys using GUI press G keys to execute commands

G keys issues

can only use G Keys once, after that app hangs

example nr.1 $ g19daemon Load Settings Loading settings Loading General settings "Total screens loaded from settings: 0 of 0" Loading sub screen order Loading main screen order "Loaded screen orders: 0" Load StartScreen Plugin initialized "G1" Pressed, Run command: "/usr/bin/vlc %U" VLC media player 3.0.11 Vetinari (revision 3.0.11-0-gdc0c5ced72) example nr.2 g19daemon Load Settings Loading settings Loading General settings "Total screens loaded from settings: 0 of 0" Loading sub screen order Loading main screen order "Loaded screen orders: 0" Load StartScreen Plugin initialized "G7" Pressed, Run command: "6"

Volume adjustment roller

use volume roller to adjust system sound volume when in Mute red glow effect is applied to key backlight key backlight reacts to volume changes confirm key backlight returns to user defined settings (G19Daemon.conf), after reacting to volume changes

Logitech G19 Daemon (GUI)

App is executed in systray bar Right-clicking it displays the following options:

Show Reset LCD Backlight Quit

Tests:

Detailed save action: $ g19daemon Load Settings Loading settings Loading General settings "Total screens loaded from settings: 0 of 0" Loading sub screen order Loading main screen order "Loaded screen orders: 0" Load StartScreen Plugin initialized Save Settings <-----

Save action changes configuration file path and contents: /home/username/.config/G19Daemon/G19Daemon.conf [General] ActivePlugin=menu Backlight=255 KeyBacklight_Blue=255 KeyBacklight_Green=40 KeyBacklight_Red=0 m1_G1=/usr/bin/vlc %U m1_G10=8 m1_G11=9 m1_G12=10 m1_G2= m1_G3=1 m1_G4=2 m1_G5=3 m1_G6=4 m1_G7=5 m1_G8=6 m1_G9=7 m2_G1=% m2_G10=b m2_G11=c m2_G12=d m2_G2=& m2_G3=/ m2_G4=... m2_G5=";" m2_G6=| m2_G7=\\ m2_G8=@@ m2_G9=a m3_G1=Bla bla 3748378438 m3_G10=epoiyoepqeipei+ m3_G11=jejoqjogjqfpoqlmeqlqpl m3_G12=ekjt+pq+it+eqjt+q m3_G2="oaoaoue03508!#%$#%#%!%,!%!,3." m3_G3=o4i590@@\xbd\xb9\xbd\xb9\xbd\x31\x35\x38\x30\x31\x35\x38\x31\x30\x38\x34\x30\x38\x30\\80805038058108051'\\' m3_G4="3951759791951.:;:_+-+-45:;agouaoa+p+p+iykgjg,sc,nbg++i+" m3_G5="'\xab''\xab?\xbb\xbb?\xab\\\\\\||*+*\xaa\xaa\xaa_:;" m3_G6=^\xc7\xaa\xe7\xe7\xe7l\xe7\xe7z\xe7z\xe7+<<<p+<+>>>>>> m3_G7="oejkdngkdlgigdpoaiea\xe7llm,nmb," m3_G8=+p+ptqpgeqngqlleqngqemqe+pgq m3_G9=aoiia+poihpahpoapohamah

Logitech G19 Daemon (GUI) issues

Note: perhaps this is intended, needs confirmation

Tested plugins

use all the LCD keys to test plugins test step changing adding and subtracting values between min and max value verified configuration file for changes /home/username/.config/G19Daemon/G19Daemon.conf Clock - No issues Hello World - No issues LCD Brightness - Issues detected Media Player - N/A : I am not sure how to test this one Hardware Monitor - N/A : I need to install Hardware Monitor Key Backlight: No issues

LCD Brightness issues

When user first opens plugin:

graph bar max value 255 Current step: 10, Value: 255 graph bar graph bar graph bar graph bar graph bar min value 0

Current step: 10, Value: 127 graph bar max value 127 graph bar graph bar graph bar graph bar graph bar min value 0

Multimedia keys

tested Multimedia keys using VLC media player: play/pause stop next song previous song

Multimedia keys issues

Note: I do not recall if skip forward and backward were possible under windows and logitech software, but under the current daemon version it's not working. To be further tested, using a windows VM and logitech software.

jimmyd-be commented 4 years ago

Tnx for testing the full daemon.

Currently there aren't any actions binded to the MR-key. If you have any idea what can be handy to link to that button please suggest. This afternoon I will investigate application hanging after using G-keys.

fulvouscoder commented 4 years ago

No problem!

Let me know if you need to have some kind of specific test done or any other that I missed.

I'll think about the MR key. right now I am not even sure how to properly use the G Keys.

Do you happen to use macros, assigned to G keys? For example, G3 = Key Press 'Shift' + Key Press 'K' + Key Release 'K' + Key Press 'O' + Key Release 'O' + Key Release 'Shift'

I am also looking into how to do this for the first time.

jimmyd-be commented 4 years ago

Currently u only use the g Keys to open applications. Maybe you van try to simulate keystrokes using Shell scripts and run the script using the g Keys. Or we can add this as a new feature to simulate special keystrokes. But then please create a ticket for this and I will investigate this.

But the macro that you sugest can better be made using Shell scripts. I can add a feature to link a shortkey like cntrl+shift+H to a g key. But a full macro is difficult to make it work.

jimmyd-be commented 4 years ago

Yesteday I tried to find the application hanging but couldn't found it. On Kubuntu 20.04 it is working. I need to try to run manjaro to find the issue but it will take some time to debug in Manjaro to fix this.

fulvouscoder commented 4 years ago

no worries!

Is there a way to restart the app? If the app is running and you send the command to start the daemon, the message "App is running" pops up:

$ g19daemon App is running

however in some instances during my grind, I've noticed there is no daemon running, however you still get the same message:

$ g19daemon App is running $ ps -ef | grep g19 username 22404 1557 0 14:16 pts/1 00:00:00 grep --colour=auto g19

I was wondering if it's some variable, linked to the hardware, that is "turned on". Have you ever encountered this?

I am still testing the waters with CT Creator.

Am I bringing too much dialogue into this thread? :nerd_face:

jimmyd-be commented 4 years ago

This is because the deamon has not safly closed. Look in main.cpp file for the name of the file that is placed when the app is starting and need to be removed manually when you close the app without using the close button.

And I havent any problems with the large thread. This can be helpfull for the devs and for you.

fulvouscoder commented 4 years ago

Thanks, I found the file:

$ ls -lsrth /run/user/1000/g19deamon.pid

I found the following warning in:

g19daemon.cpp => void G19daemon::run() => QProcess::startDetached(command); " g19daemon.cpp:196:17: warning: 'startDetached' is deprecated: Use QProcess::startDetached(const QString &program, const QStringList &arguments) instead qprocess.h:275:5: note: 'startDetached' has been explicitly marked deprecated here qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X' qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X' "

edit: clean up text doh; clean it more than should have...

jimmyd-be commented 4 years ago

Can you try to comment QProcess::startDetached(command) and try to run the application. If the deamon is not hanging anymore then we found the hanging issue.

fulvouscoder commented 4 years ago

No more warnings, but it still hangs.

//QProcess::startDetached(command); " 16:20:12: Starting /home/username/GitRepos/build-g19daemon-issue9-Desktop-Debug/g19daemon ... "m2" Pressed, Run command: "" "m3" Pressed, Run command: "" "m1" Pressed, Run command: "" "m3" Pressed, Run command: "" "m1" Pressed, Run command: "" "G7" Pressed, Run command: "5" "

edited: +test nr.1 +dumb question 1

Test nr.1

This seems like the execution part of a script attached to a G key. / if (!gKey.isEmpty()) { QString command = settings->value(translateKey(device->getActiveMKey()) + "_" + gKey) .toString(); qDebug() << gKey << " Pressed, Run command: " << command; // QProcess::startDetached(command); } /

Dumb question 1

While checking the file g19device.hpp=> enum G19Keys, is there no point in adding a None value, for control?

enum G19Keys { None = 0, <-------- Adding this line here G19_KEY_G1 = 1 << 0, G19_KEY_G2 = 1 << 1, G19_KEY_G3 = 1 << 2, G19_KEY_G4 = 1 << 3, G19_KEY_G5 = 1 << 4, G19_KEY_G6 = 1 << 5, G19_KEY_G7 = 1 << 6, G19_KEY_G8 = 1 << 7, G19_KEY_G9 = 1 << 8, G19_KEY_G10 = 1 << 9, G19_KEY_G11 = 1 << 10, G19_KEY_G12 = 1 << 11,

G19_KEY_M1 = 1 << 12, G19_KEY_M2 = 1 << 13, G19_KEY_M3 = 1 << 14, G19_KEY_MR = 1 << 15,

G19_KEY_LHOME = 1 << 16, G19_KEY_LCANCEL = 1 << 17, G19_KEY_LMENU = 1 << 18, G19_KEY_LOK = 1 << 19, G19_KEY_LRIGHT = 1 << 20, G19_KEY_LLEFT = 1 << 21, G19_KEY_LDOWN = 1 << 22, G19_KEY_LUP = 1 << 23, G19_KEY_LIGHT = 1 << 24 };

jimmyd-be commented 4 years ago

I have installed Manjaro to test it from there. After building and installing the G19Daemon I configured the M1-G1 key to open Konsole. I tried that and it opens Konsole. After pressing another G-key it shows the key has been pressed and every time I press the G1 key the Konsole application is shown.

I installed Manjaro Kde 2020.0.3 with kernel 5.4.52. So I think the problem is something on your setup. An application that is not compatible or some settings that breaks the G19daemon. Currently I cannot fix this because I cannot reproduce it.

fulvouscoder commented 4 years ago

Thanks for running that test!

It's weird, even if I don't have anything assigned to the G key, same thing happens.

I am going to create a sandbox with manjaro and retrace the steps. Thinking about software in my daily driver, If I had to make a guess ( an uneducated one ) I do have Piper/libratbag installed.

I'll get back to you asap.

edit: +quick question dmesg +quick question libusb: error [udev_hotplug_event]

quick question dmesg

can you check your dmesg output? I've found this line:

[ 33.435759] usb 1-1.2.2: usbfs: process 1274 (g19daemon) did not claim interface 0 before use

$ sudo dmesg | grep usb [ 0.701262] usbcore: registered new interface driver usbfs [ 0.701262] usbcore: registered new interface driver hub [ 0.701262] usbcore: registered new device driver usb [ 0.954326] usbcore: registered new interface driver usbserial_generic [ 0.954330] usbserial: USB Serial support registered for generic [ 3.069569] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.06 [ 3.069571] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 3.069572] usb usb1: Product: EHCI Host Controller [ 3.069574] usb usb1: Manufacturer: Linux 5.6.19-2-MANJARO ehci_hcd [ 3.069575] usb usb1: SerialNumber: 0000:00:1a.0 [ 3.086282] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.06 [ 3.086284] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 3.086285] usb usb2: Product: EHCI Host Controller [ 3.086286] usb usb2: Manufacturer: Linux 5.6.19-2-MANJARO ehci_hcd [ 3.086287] usb usb2: SerialNumber: 0000:00:1d.0 [ 3.399584] usb 1-1: new high-speed USB device number 2 using ehci-pci [ 3.419579] usb 2-1: new high-speed USB device number 2 using ehci-pci [ 3.547128] usb 1-1: New USB device found, idVendor=8087, idProduct=0020, bcdDevice= 0.00 [ 3.547132] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 3.567027] usb 2-1: New USB device found, idVendor=8087, idProduct=0020, bcdDevice= 0.00 [ 3.567031] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 3.826330] usb 1-1.2: new high-speed USB device number 3 using ehci-pci [ 3.925160] usb 1-1.2: New USB device found, idVendor=05e3, idProduct=0607, bcdDevice= 8.01 [ 3.925164] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0 [ 3.925166] usb 1-1.2: Product: USB2.0 Hub [ 4.209593] usb 1-1.2.1: new low-speed USB device number 4 using ehci-pci [ 4.312552] usb 1-1.2.1: New USB device found, idVendor=046d, idProduct=c228, bcdDevice= 1.10 [ 4.312554] usb 1-1.2.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 4.312556] usb 1-1.2.1: Product: G19 Gaming Keyboard [ 4.386245] usb 1-1.2.2: new high-speed USB device number 5 using ehci-pci [ 4.494158] usb 1-1.2.2: New USB device found, idVendor=046d, idProduct=c229, bcdDevice= 0.23 [ 4.494161] usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 4.494162] usb 1-1.2.2: Product: G19 Gaming Keyboard [ 4.494164] usb 1-1.2.2: Manufacturer: Logitech [ 5.762618] usbcore: registered new interface driver usbhid [ 5.762619] usbhid: USB HID core driver [ 7.515884] input: G19 Gaming Keyboard as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.1/1-1.2.1:1.0/0003:046D:C228.0001/input/input18 [ 7.569923] hid-generic 0003:046D:C228.0001: input,hidraw0: USB HID v1.10 Keyboard [G19 Gaming Keyboard] on usb-0000:00:1a.0-1.2.1/input0 [ 7.570089] input: G19 Gaming Keyboard Consumer Control as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.1/1-1.2.1:1.1/0003:046D:C228.0002/input/input19 [ 7.626604] hid-generic 0003:046D:C228.0002: input,hiddev0,hidraw1: USB HID v1.10 Device [G19 Gaming Keyboard] on usb-0000:00:1a.0-1.2.1/input1 [ 7.626836] input: Logitech G19 Gaming Keyboard Keypad as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.1/0003:046D:C229.0003/input/input21 [ 7.683084] hid-generic 0003:046D:C229.0003: input,hiddev1,hidraw2: USB HID v1.11 Keypad [Logitech G19 Gaming Keyboard] on usb-0000:00:1a.0-1.2.2/input1 [ 184.803079] usb 1-1.2.2: usbfs: process 1242 (g19daemon) did not claim interface 0 before use

quick question libusb: error [udev_hotplug_event]

I also noticed the following error message when I plugged a usb mouse in the USB ports of the keyboard. Please note that the mouse seems to be working fine, I just noticed that an error popped up in the daemon:

libusb: error [udev_hotplug_event] ignoring udev action bind

$ g19daemon Load Settings Loading settings Loading General settings "Total screens loaded from settings: 0 of 0" Loading sub screen order Loading main screen order "Loaded screen orders: 0" Load StartScreen Plugin initialized libusb: error [udev_hotplug_event] ignoring udev action bind

While doing the tests, I forgot the USB ports of the keyboard :nerd_face:

jimmyd-be commented 4 years ago

I ran the command sudo dmesg | grep usb and I also have

[ 25.379767] usb 3-9.1.1.2: usbfs: process 2734 (g19daemon) did not claim interface 0 before use

fulvouscoder commented 4 years ago

Thanks! I will get back at you, as soon as I test with a clean environment. Hopefully this weekend :crossed_fingers:

jimmyd-be commented 4 years ago

@fulvouscoder did you already had the time to check if it works on a clean system?