summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2019-09-07 13:00:40 -0600
committerAaron Ball <nullspoon@oper.io>2019-09-07 13:00:40 -0600
commitf9415b4976b31ce6c6f68ee6776194af90bcf05b (patch)
tree1995db0cbbb3e6e2e7149a21fc644f0a16020085
parentdc80c8b2b11d3b7247b96cb2cd794a8d0f0ecd84 (diff)
downloadkbd-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.c10
1 files 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;

Generated by cgit