Closed Almamu closed 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.
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.
Just tried it, the same happens, I guess that hid_open returns NULL if hid_init fails.
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.
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...
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.
Same heare in a MSI GS65
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
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.
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.
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:
(partial) output of dmidecode:
The keyboard is a SteelSeries which has 3 different points for colors (left, center and right side).