From f9415b4976b31ce6c6f68ee6776194af90bcf05b Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sat, 7 Sep 2019 13:00:40 -0600 Subject: Fix load_current_state Was using atoi to load a hex string, which doesn't work (atoi only reads decimal strings). Switched over to strtol specifying base 16 for hex. --- src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 59442d9..79a7933 100644 --- a/src/main.c +++ b/src/main.c @@ -34,8 +34,8 @@ void writecolor(int r, int g, int b) { /** * load_current_state: - * Loads the current color state from the keyboard's sys file at - * /sys/class/leds/*kbd_backlight/.. + * Loads the current color state from the keyboard's sys file defined with + * COLORFILE * * @r Pointer to red int buffer * @g Pointer to green int buffer @@ -56,15 +56,15 @@ int load_current_state(int* r, int* g, int* b) { chan[0] = fgetc(fd); chan[1] = fgetc(fd); - *r = atoi(chan); + *r = strtol(chan, NULL, 16); chan[0] = fgetc(fd); chan[1] = fgetc(fd); - *g = atoi(chan); + *g = strtol(chan, NULL, 16); chan[0] = fgetc(fd); chan[1] = fgetc(fd); - *b = atoi(chan); + *b = strtol(chan, NULL, 16); fclose(fd); return 0; -- cgit v1.2.3