diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-09-07 13:00:40 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-09-07 13:00:40 -0600 |
commit | f9415b4976b31ce6c6f68ee6776194af90bcf05b (patch) | |
tree | 1995db0cbbb3e6e2e7149a21fc644f0a16020085 | |
parent | dc80c8b2b11d3b7247b96cb2cd794a8d0f0ecd84 (diff) | |
download | kbd-fade-f9415b4976b31ce6c6f68ee6776194af90bcf05b.tar.gz kbd-fade-f9415b4976b31ce6c6f68ee6776194af90bcf05b.tar.xz |
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.
-rw-r--r-- | src/main.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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; |