diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/deviceinfo-flashlight.c | 12 | ||||
-rw-r--r-- | src/flashlight.c | 20 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/deviceinfo-flashlight.c b/src/deviceinfo-flashlight.c index 1bbf14d..91e9f02 100644 --- a/src/deviceinfo-flashlight.c +++ b/src/deviceinfo-flashlight.c @@ -30,3 +30,15 @@ char* flashlight_switch_path() struct DeviceInfo* di = deviceinfo_new(); return deviceinfo_get(di, "FlashlightSwitchPath", ""); } + +char* flashlight_simple_enable_value() +{ + struct DeviceInfo* di = deviceinfo_new(); + return deviceinfo_get(di, "FlashlightSimpleEnableValue", ""); +} + +char* flashlight_simple_disable_value() +{ + struct DeviceInfo* di = deviceinfo_new(); + return deviceinfo_get(di, "FlashlightSimpleDisableValue", ""); +} diff --git a/src/flashlight.c b/src/flashlight.c index 88e93fd..337c01c 100644 --- a/src/flashlight.c +++ b/src/flashlight.c @@ -34,6 +34,8 @@ #ifdef ENABLE_LIBDEVICEINFO extern char* flashlight_path(); extern char* flashlight_switch_path(); +extern char* flashlight_simple_enable_value(); +extern char* flashlight_simple_disable_value(); #endif const size_t qcom_sysfs_size = 7; @@ -141,7 +143,25 @@ toggle_flashlight_action_simple() fd = fopen(flash_sysfs_path, "w"); if (fd != NULL) { +# ifdef ENABLE_LIBDEVICEINFO + char* enable_value = flashlight_simple_enable_value(); + char* disable_value = flashlight_simple_disable_value(); + + const char* value_to_write; + if (activated) + value_to_write = (strcmp(disable_value, "") != 0) ? disable_value : SIMPLE_DISABLE; + else + value_to_write = (strcmp(enable_value, "") != 0) ? enable_value : SIMPLE_ENABLE; + + fprintf(fd, "%s", value_to_write); + + if (enable_value) + free(enable_value); + if (disable_value) + free(disable_value); +# else fprintf(fd, activated ? SIMPLE_DISABLE : SIMPLE_ENABLE); +# endif fclose(fd); return 1; } |