Gibtnix / MSIKLM

Control the SteelSeries keyboard of your MSI gaming notebook with Linux
GNU General Public License v3.0
244 stars 50 forks source link

No compatible keyboard found #31

Closed Almamu closed 5 years ago

Almamu commented 5 years ago

On first run I get the message "No compatible keyboard found" but after running it again the colors change properly. Example video: https://mega.nz/#!5ZQQzYAJ!REDaZZ67T5Oq5wlWMMpRQqhuzFBfQQRvVjhFUF0f6-0

Output of msiklm list:

Device: USB Receiver
    Device Vendor ID:        1133
    Device Product ID:       50475
    Device Serial Number:    (null)
    Device Manufacturer:     Logitech
    Device Path:             0001:0003:00
    Device Interface Number: 0
    Device Release Number:   9233

Device: USB Receiver
    Device Vendor ID:        1133
    Device Product ID:       50475
    Device Serial Number:    (null)
    Device Manufacturer:     Logitech
    Device Path:             0001:0003:01
    Device Interface Number: 1
    Device Release Number:   9233

Device: USB Receiver
    Device Vendor ID:        1133
    Device Product ID:       50475
    Device Serial Number:    (null)
    Device Manufacturer:     Logitech
    Device Path:             0001:0003:02
    Device Interface Number: 2
    Device Release Number:   9233

Device: MSI EPF USB
    Device Vendor ID:        6000
    Device Product ID:       65280
    Device Serial Number:    MSI EPF USB
    Device Manufacturer:     MSI EPF USB
    Device Path:             0001:0006:00
    Device Interface Number: 0
    Device Release Number:   272

(partial) output of dmidecode:

Handle 0x0002, DMI type 1, 27 bytes
System Information
        Manufacturer: Micro-Star International Co., Ltd.
        Product Name: GE72 7RD
        Version: REV:1.0

The keyboard is a SteelSeries which has 3 different points for colors (left, center and right side).

Gibtnix commented 5 years ago

Thanks for reporting! Is this error deterministically, i.e. always appears at the first call after starting the system? The error appears because open_keyboard() returns null - either because hid_init() returns not 0 or because hid_open() for some reason fails to open the keyboard. If you can reproduce the error, my first try would be to modify open_keyboard() to discard the return value of hid_init(), i.e. replace hid_device* dev = NULL; if (hid_init() == 0) dev = hid_open(0x1770, 0xff00, 0); return dev;

with hid_init(); return hid_open(0x1770, 0xff00, 0);

If you can reproduce the error, give this a try.

Almamu commented 5 years ago

I'll give it a try when I get home. It seems to happen every time after starting up the system and only once. I'll get back to you tonight.

Almamu commented 5 years ago

Just tried it, the same happens, I guess that hid_open returns NULL if hid_init fails.

Almamu commented 5 years ago

Just done some more testing. Moving the hid_init to the main before anything else seems to fix the issue. I'm trying to find information on why that might be but there doesn't seem to be anything related to this kind of issue with hid_init.

Almamu commented 5 years ago

This is the hid_init () documentation of my installation:

            This function initializes the HIDAPI library. Calling it is not
            strictly necessary, as it will be called automatically by
            hid_enumerate() and any of the hid_open_*() functions if it is
            needed.  This function should be called at the beginning of
            execution however, if there is a chance of HIDAPI handles
            being opened by different threads simultaneously.

So that might have something to do? A quick glance over the code doesn't look like It's using any threading library at all, so It shouldn't really be an issue...

Gibtnix commented 5 years ago

Well I definitely do not use any multi-threading... maybe some of the external code does so? However, if it is really a multi-threading issue then I think even moving the hid_init() to some earlier initialization can cause the same error, only with a lower "risk"... but feel free to test if the error is fixed by moving hid_init() to somewhere earlier and if it works after some more extensive testing, I will change the code accordingly.

neumartin commented 5 years ago

Same heare in a MSI GS65

Gibtnix commented 5 years ago

Don't know why this suddenly seems to go wrong sometimes.... but please test to replace the main.c file from the repo with the attached one; if it fixes the issue, I will update the file in the repo. main.zip

Almamu commented 5 years ago

I've been using the hid_init change I mentioned (which basically is the same as you're doing) and looks like It works fine this way. I haven't found any problems since then with the app.

Gibtnix commented 5 years ago

OK, glad that this issue seems to be fixed then; So I will close the issue, feel free to open a new one in case the error reappears.