eventmap: use Yen (Fn-l) to switch layers as F12 conflicts
[pandora-libraries.git] / lib / pnd_device.c
index e158711..65ea176 100644 (file)
@@ -7,6 +7,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <ctype.h>
 
 #include "pnd_device.h"
 
@@ -103,6 +104,51 @@ unsigned char pnd_device_get_charge_current ( int *result ) {
   return ( 0 );
 }
 
+int pnd_device_get_charger_enable ( const char *devices ) {
+  char fullname [ 100 ];
+  char buffer [ 100 ];
+
+  while ( 1 ) {
+    if ( sscanf ( devices, "%99s", buffer ) != 1 ) {
+      break;
+    }
+
+    while ( isspace ( *devices ) )
+      devices++;
+    devices += strlen ( buffer );
+    snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer );
+
+    /* XXX: only ckecks first good device, but that should be enough for our needs */
+    if ( pnd_device_open_read_close ( fullname, buffer, 100 ) ) {
+      return ( atoi ( buffer ) );
+    }
+  }
+
+  return ( -1 );
+}
+
+unsigned char pnd_device_set_charger_enable ( const char *devices, unsigned char v ) {
+  char fullname [ 100 ];
+  char buffer [ 100 ];
+  int ret = 0;
+
+  while ( 1 ) {
+    if ( sscanf ( devices, "%99s", buffer ) != 1 ) {
+      break;
+    }
+
+    while ( isspace ( *devices ) )
+      devices++;
+    devices += strlen ( buffer );
+    snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer );
+
+    sprintf ( buffer, "%u", v );
+    ret |= pnd_device_open_write_close ( fullname, buffer );
+  }
+
+  return ( ret );
+}
+
 unsigned char pnd_device_set_led_power_brightness ( unsigned char v ) {
   char buffer [ 100 ];