• Adding joystick

    stephengeorgewest10/17/2021 at 13:33 0 comments

    Adding the joystick was simpler than I thought.

    in probe

    /*
         * The G13 has a thumbstick and 3 buttons.
         */
        if (g15->model == LG_G13) {
            input_set_capability(input, EV_KEY, ABS_X);
            input_set_capability(input, EV_KEY, ABS_Y);
            /* 4 center values */
            input_set_abs_params(input, ABS_X, 0, 0xff, 0, 4);
            input_set_abs_params(input, ABS_Y, 0, 0xff, 0, 4);
    
            input_set_capability(input, EV_KEY, BTN_TRIGGER);
            input_set_capability(input, EV_KEY, BTN_THUMB);
            input_set_capability(input, EV_KEY, BTN_THUMB2);
        }

    and the event handler:

        input_report_abs(g15->input, ABS_X, data[1]);
        input_report_abs(g15->input, ABS_Y, data[2]);
        input_report_key(g15->input, BTN_TRIGGER, data[7] & 0x02);
        input_report_key(g15->input, BTN_THUMB, data[7] & 0x04);
        input_report_key(g15->input, BTN_THUMB2, data[7] & 0x08);

    Shows up in jstest-gtk:

    Also remapping the joystick to a mouse works in https://github.com/sezanzeb/key-mapper.

    Sidenote: while browsing around for examples, I found:I guess that didn't get merged upstream. I'm assuming it is https://github.com/martynsmith/lg4l/blob/master/hid-g13.c. Maybe that will help with the lcd driver bits.

  • button inputs

    stephengeorgewest10/15/2021 at 14:47 0 comments

    G1:
    01 7a 7c 01 00 00 00 00
    G22:
    01 7a 7c 00 00 20 00 00
    Left of lcd button:
    01 7a 7c 00 00 00 01 00
    M1
    01 7a 7c 00 00 00 20 00
    M3
    01 7a 7c 00 00 00 80 00
    
    MR
    01 7a 7c 00 00 00 00 81
    MR (release)
    01 7a 7c 00 00 00 00 80
    G1 (after MR):
    01 7a 7c 01 00 00 00 80
    
    click bottom:
    01 7a 7c 00 00 00 00 84
    click left:
    01 7a 7c 01 00 00 00 02
    click stick:
    ?probably in byte7 next to left/bottom
    move stick:
    ?probably byte1/2
    

    https://github.com/ecraven/g13/blob/master/g13_keys.cc seems to match

    stephen@ao751h:~/Documents/projects/g13$ sudo evtest
    No device specified, trying to scan all of /dev/input/event*
    Available devices:
    /dev/input/event0:      AT Translated Set 2 keyboard
    /dev/input/event1:      Lid Switch
    /dev/input/event2:      Power Button
    /dev/input/event3:      Sleep Button
    /dev/input/event4:      Video Bus
    /dev/input/event5:      SynPS/2 Synaptics TouchPad
    /dev/input/event6:      Logitech Gaming Keyboard Gaming Keys
    /dev/input/event7:      PC Speaker
    /dev/input/event8:      WebCam: Webcam
    /dev/input/event9:      HDA Digital PCBeep
    /dev/input/event10:     HDA Intel MID Mic
    /dev/input/event11:     HDA Intel MID Headphone
    Select the device event number [0-11]: 6
    Input driver version is 1.0.1
    Input device ID: bus 0x3 vendor 0x46d product 0xc21c version 0x111
    Input device name: "Logitech Gaming Keyboard Gaming Keys"
    Supported events:
      Event type 0 (EV_SYN)
      Event type 1 (EV_KEY)
        Event code 656 (?)
        Event code 657 (?)
        Event code 658 (?)
        Event code 659 (?)
        Event code 660 (?)
        Event code 661 (?)
        Event code 662 (?)
        Event code 663 (?)
        Event code 664 (?)
        Event code 665 (?)
        Event code 666 (?)
        Event code 667 (?)
        Event code 668 (?)
        Event code 669 (?)
        Event code 670 (?)
        Event code 671 (?)
        Event code 672 (?)
        Event code 673 (?)
        Event code 674 (?)
        Event code 675 (?)
        Event code 676 (?)
        Event code 677 (?)
        Event code 688 (?)
        Event code 691 (?)
        Event code 692 (?)
        Event code 693 (?)
        Event code 696 (?)
        Event code 697 (?)
        Event code 698 (?)
        Event code 699 (?)
        Event code 700 (?)
    Properties:
    Testing ... (interrupt to exit)
    Event: time 1634308318.780218, type 1 (EV_KEY), code 696 (?), value 1
    Event: time 1634308318.780218, -------------- SYN_REPORT ------------
    Event: time 1634308318.974217, type 1 (EV_KEY), code 696 (?), value 0
    Event: time 1634308318.974217, -------------- SYN_REPORT ------------
    Event: time 1634308320.244265, type 1 (EV_KEY), code 697 (?), value 1
    Event: time 1634308320.244265, -------------- SYN_REPORT ------------
    Event: time 1634308320.436316, type 1 (EV_KEY), code 697 (?), value 0
    Event: time 1634308320.436316, -------------- SYN_REPORT ------------
    Event: time 1634308320.898140, type 1 (EV_KEY), code 698 (?), value 1
    Event: time 1634308320.898140, -------------- SYN_REPORT ------------
    Event: time 1634308321.088286, type 1 (EV_KEY), code 698 (?), value 0
    Event: time 1634308321.088286, -------------- SYN_REPORT ------------
    Event: time 1634308321.480297, type 1 (EV_KEY), code 699 (?), value 1
    Event: time 1634308321.480297, -------------- SYN_REPORT ------------
    Event: time 1634308321.654302, type 1 (EV_KEY), code 699 (?), value 0
    Event: time 1634308321.654302, -------------- SYN_REPORT ------------
    Event: time 1634308322.038312, type 1 (EV_KEY), code 700 (?), value 1
    Event: time 1634308322.038312, -------------- SYN_REPORT ------------
    Event: time 1634308322.238330, type 1 (EV_KEY), code 700 (?), value 0
    Event: time 1634308322.238330, -------------- SYN_REPORT ------------
    Event: time 1634308330.802539, type 1 (EV_KEY), code 691 (?), value 1
    Event: time 1634308330.802539, -------------- SYN_REPORT ------------
    Event: time 1634308330.932562, type 1 (EV_KEY), code 691 (?), value 0
    Event: time 1634308330.932562, -------------- SYN_REPORT ------------
    Event: time 1634308331.448373, type 1 (EV_KEY), code 692 (?), value 1
    Event: time 1634308331.448373, -------------- SYN_REPORT ------------
    Event: time 1634308331.550427, type 1 (EV_KEY), code 692 (?), value 0
    Event: time 1634308331.550427, -------------- SYN_REPORT ------------
    Event: time 1634308331.992437,...
    Read more »

  • Back to wireshark/Leds

    stephengeorgewest10/15/2021 at 12:35 0 comments

    Loading up logitech gaming software to set some color. get color (blue):

    Setup Data
        bmRequestType: 0x21
            0... .... = Direction: Host-to-device
            .01. .... = Type: Class (0x1)
            ...0 0001 = Recipient: Interface (0x01)
        bRequest: SET_REPORT (0x09)
        wValue: 0x0307
            ReportID: 7
            ReportType: Feature (3)
        wIndex: 0
        wLength: 5
        bRequest: 9
        wValue: 0x0307
        wIndex: 0 (0x0000)
        wLength: 5
        Data Fragment: 070000ff00
    

    blue:: 07 00 00 ff 00
    red?: 07 55 ff 00 00
    green?: 07 ff 00 00 00
    white: 07 6e ff 5a 00 I guess color correction is done in logitech gaming software...
    off: 07 00 00 00 00

    macro keys are on endpoint 5, and packed into a single byte:

    Setup Data
        bmRequestType: 0x21
            0... .... = Direction: Host-to-device
            .01. .... = Type: Class (0x1)
            ...0 0001 = Recipient: Interface (0x01)
        bRequest: SET_REPORT (0x09)
        wValue: 0x0305
            ReportID: 5
            ReportType: Feature (3)
        wIndex: 0
        wLength: 5
        bRequest: 9
        wValue: 0x0305
        wIndex: 0 (0x0000)
        wLength: 5
        Data Fragment: 0501000000
    

    Success? partially

  • Setting up the environment

    stephengeorgewest10/14/2021 at 11:52 1 comment

    If I just add the device here it might just work...

    Ok so, my current linux device is a lousy netbook from 2009. I don't want to type on that mini screen. VS-code-remote doesn't work with x86, but WinSCP + ssh might just be good enough.

    So many red squiggles... To add some linux header libraries, it says I need to open a folder. Ok, it added a .vscode folder... edit include path, copied the header files to a folder, and put them in the right order:

    ${default}
    C:\Users\Stephen\source\src\linux-headers-5.14.0-2-common\include
    C:/Users/Stephen/source/include/x86_64-linux-gnu
    C:\Users\Stephen\source\src\linux-headers-5.14.0-2-common\arch\x86
    C:\Users\Stephen\source\include
    C:/Users/Stephen/source/src/linux-headers-5.14.0-2-common/arch/x86/include
    C:/Users/Stephen/source/src/linux-headers-5.14.0-2-amd64/include
    C:/Users/Stephen/source/src/linux-headers-5.14.0-2-amd64/arch/x86/include/generated
    minimal red squiggles

    I don't know if that is helpful... It says U8 isn't a type, and game_mode_enabled is a function? oh well. I'll just try putting in the VID/PID and treat it like a LG_G15 and compiling.

    stephen@ao751h:~/Documents/projects/g13$ sudo insmod ./hid-lg-g15.ko
    [141992.481805] usb 2-1: USB disconnect, device number 6
    [141993.497565] usb 2-1: new full-speed USB device number 7 using uhci_hcd
    [141993.688838] usb 2-1: New USB device found, idVendor=046d, idProduct=c21c, bcdDevice= 2.03
    [141993.688879] usb 2-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
    [141993.688896] usb 2-1: Product: G13
    [141993.713546] hid-generic 0003:046D:C21C.0130: hiddev2,hidraw4: USB HID v1.11 Device [G13] on usb-0000:00:1d.0-1/input0
    [142482.986330] lg-g15 0003:046D:C21C.0130: hidraw4: USB HID v1.11 Device [G13] on usb-0000:00:1d.0-1/input0
    [142483.055391] input: Logitech Gaming Keyboard Gaming Keys as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/0003:046D:C21C.0130/input/input47
    
    root@ao751h:/home/stephen/Documents/projects/g13# echo 0 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 128 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 64 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 0 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# echo 64 > /sys/class/leds/g15\:\:lcd_backlight/brightness
    root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:macro_record/brightness 
    1
    root@ao751h:/home/stephen/Documents/projects/g13# echo 0 >  /sys/class/leds/g15\:\:macro_record/brightness

    The led's show up at /sys/class/leds/, dmesg shows it loaded, and echo 255 > /sys/class/leds/g15\:\:kbd_backlight/brightness changes it to green, setting the macro led's change backlight to full brightness. And finally evtest shows no input events.

    It has an rgb color backlight, so maybe it should be treated like a LG_G510

    Skip that line of code, recompile...

    success, maybe
    root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:kbd_backlight/max_brightness 
    255
    root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:kbd_backlight/brightness 
    root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:kbd_backlight/color
    #ffffff
    root@ao751h:/home/stephen/Documents/projects/g13# echo "#ff0000" > /sys/class/leds/g15\:\:kbd_backlight/color
    root@ao751h:/home/stephen/Documents/projects/g13# echo "#00ff00" > /sys/class/leds/g15\:\:kbd_backlight/color
    root@ao751h:/home/stephen/Documents/projects/g13# echo "#0000ff" > /sys/class/leds/g15\:\:kbd_backlight/color
    root@ao751h:/home/stephen/Documents/projects/g13# echo "#ff0000"...
    Read more »