tolga9009 / sidewinderd

Linux support for Microsoft SideWinder X4 / X6 and Logitech G103 / G105 / G710+.
http://cevel.net
Other
151 stars 26 forks source link

Logitech G103 #35

Closed MadFatVlad closed 6 years ago

MadFatVlad commented 6 years ago

Hello! Would it be possible to make support for G103 keyboard? It has 6 G-keys, similar to G105: image

tolga9009 commented 6 years ago

Hi there!

As long as macros are realized entirely by software and not on hardware, this is possible. We've tried to make this software as modular as possible (still ways to go, but I consider it quite usable for now), so it should be no big deal to add another keyboard. I expect the implementation to be quite similar to the G105, just lacking macro banks.

We need some more details though. I'd need you to capture USB traffic using either a Windows OS or Windows guest in a virtual machine. We need to figure out, what USB traffic is generated when pressing the G1-G6 keys and whether there are "Magic Packets" sent by the driver, in order to setup the keyboard.

I've written a guide for another project on how to capture USB traffic using Windows. You can find it here: https://github.com/tolga9009/elgato-gchd/wiki/USB-capturing-on-Windows. Just skip the steps 1, 2, 6, 7 and 8, they are Elgato specific. What I need is the USB handshake. So make sure to have the Logitech drivers running and hit capture in Wireshark, before plugging in the keyboard. Once the keyboard has been plugged in, wait a few seconds, press G1-G6 one after another, save the capture and post it here.

Also, the Game key (red key on the left side of the LED bar), does it function under Linux? Does the LED react to it? When you have WireShark running, press that key and see, whether it generates any USB traffic. Iirc, the G710's and G105's Game keys didn't generate any traffic.

Please let me know, if you have any issues getting the captures.

Cheers, Tolga

MadFatVlad commented 6 years ago

Hello! Thanks for your response. I have captured the connection and G keypresses with WireShark. When i pressed the Game key in linux, the LED lit up and Win key was locked. g103.pcap.gz

tolga9009 commented 6 years ago

Thank you! I've looked over it. For the most part, it looks similar to the G105. Keycode detection is still the same. So, it should be very easy to port over.

However, I was not able to find the "Magic Packet", which should consist of a report ID, followed by zeros. What happens when you press G1-G6 on a Linux system? Nothing - or does it emit the usual numbers 1, 2, 3, etc.?

//Edit: report ID for macro key configuration seems to be 0x08 with report count 6, just like the G105. If it emits numbers in its default configuration under Linux, we can pretty much copy & paste the G105 code, minus the LED and macro bank stuff.

MadFatVlad commented 6 years ago

It returns F1-F6 keys. Output of evtest:

Event: time 1536527822.655553, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003a
Event: time 1536527822.655553, type 1 (EV_KEY), code 59 (KEY_F1), value 1
Event: time 1536527822.655553, -------------- SYN_REPORT ------------
^[OPEvent: time 1536527822.719550, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003a
Event: time 1536527822.719550, type 1 (EV_KEY), code 59 (KEY_F1), value 0
Event: time 1536527822.719550, -------------- SYN_REPORT ------------
Event: time 1536527823.327545, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003b
Event: time 1536527823.327545, type 1 (EV_KEY), code 60 (KEY_F2), value 1
Event: time 1536527823.327545, -------------- SYN_REPORT ------------
^[OQEvent: time 1536527823.399538, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003b
Event: time 1536527823.399538, type 1 (EV_KEY), code 60 (KEY_F2), value 0
Event: time 1536527823.399538, -------------- SYN_REPORT ------------
Event: time 1536527823.991530, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003c
Event: time 1536527823.991530, type 1 (EV_KEY), code 61 (KEY_F3), value 1
Event: time 1536527823.991530, -------------- SYN_REPORT ------------
^[OREvent: time 1536527824.111534, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003c
Event: time 1536527824.111534, type 1 (EV_KEY), code 61 (KEY_F3), value 0
Event: time 1536527824.111534, -------------- SYN_REPORT ------------
Event: time 1536527824.607526, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003d
Event: time 1536527824.607526, type 1 (EV_KEY), code 62 (KEY_F4), value 1
Event: time 1536527824.607526, -------------- SYN_REPORT ------------
^[OSEvent: time 1536527824.719523, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003d
Event: time 1536527824.719523, type 1 (EV_KEY), code 62 (KEY_F4), value 0
Event: time 1536527824.719523, -------------- SYN_REPORT ------------
Event: time 1536527825.327513, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003e
Event: time 1536527825.327513, type 1 (EV_KEY), code 63 (KEY_F5), value 1
Event: time 1536527825.327513, -------------- SYN_REPORT ------------
^[[15~Event: time 1536527825.439510, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003e
Event: time 1536527825.439510, type 1 (EV_KEY), code 63 (KEY_F5), value 0
Event: time 1536527825.439510, -------------- SYN_REPORT ------------
Event: time 1536527825.975502, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003f
Event: time 1536527825.975502, type 1 (EV_KEY), code 64 (KEY_F6), value 1
Event: time 1536527825.975502, -------------- SYN_REPORT ------------
^[[17~Event: time 1536527826.063499, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003f
Event: time 1536527826.063499, type 1 (EV_KEY), code 64 (KEY_F6), value 0
Event: time 1536527826.063499, -------------- SYN_REPORT ------------
tolga9009 commented 6 years ago

Thanks! We need to send the "Magic Packet" then. That's enough to prepare a patch. I don't have access to my Linux machine at this moment, but you can expect a patch within 24 hours. I will post it here for testing.

Cheers, Tolga

tolga9009 commented 6 years ago

I have a patch ready now! You can find the development branch here: https://github.com/tolga9009/sidewinderd/tree/dev

However, there are some major drawbacks with the G103. As it doesn't offer any record key, nor any addressable LED to aid during macro recording, I've stripped away live recording functionality. You will need to create and edit the macro files by hand, until we have a GUI solution. Also, there is no profile switch, as the G103 has no LED indicator for that. Again, this could be worked around in a GUI in the future.

After building the development branch, you should configure /etc/sidewinderd.conf and set a user there. Next, start up sidewinderd and look up /home/<specified_user>/.local/share/sidewinderd/profile_1. This is the folder, where you need to create the macro files. The macro for G1-key is stored as s1.xml, for G2 as s2.xml and so on. Here is a "Hello World" typing macro, which I've saved as macro for a starting point: s1.txt. Rename it to s1.xml (instead of .txt) and put it in the profile_1 folder. Focus a textbox and press G1 now, Hello World should be typing.

At this point, I suggest assigning G1 - G6 keys to F13 - F18 and using external programs for managing your macros. https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h will help you identify the numbers you need for KeyBoardEvent.

Please let me know, if you need further assistance and if it works. I'm also open for ideas and suggestions to improve G103 user's experience.

Cheers, Tolga

MadFatVlad commented 6 years ago

Ok, i tried it out and it works flawlessly! I'm fine with no macro recordind, because i want to use G keys for media controls. Thank you!