Close

Adding joystick

A project log for Logitech G13 kernel module

It can't be that hard right? Linux kernel has modules for G11/G510, it should fit in right?

stephengeorgeweststephengeorgewest 10/17/2021 at 13:330 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.

Discussions