summaryrefslogtreecommitdiff
path: root/src/display
diff options
context:
space:
mode:
authorsh.pi <sh.pi@samsung.com>2013-06-27 14:51:04 +0900
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>2013-09-10 05:32:02 +0000
commit5364c5310ac2d6fc0bb4da9199409e7ab5335a12 (patch)
treecea4f75e2c3e632df098f36723a4cdf23bed6692 /src/display
parent20e52391f80305f36ad0a0c7235200df4cc71a4b (diff)
downloaddeviced-5364c5310ac2d6fc0bb4da9199409e7ab5335a12.tar.gz
deviced-5364c5310ac2d6fc0bb4da9199409e7ab5335a12.tar.bz2
deviced-5364c5310ac2d6fc0bb4da9199409e7ab5335a12.zip
Add keybacklight basic feature.
Signed-off-by: Seunghun Pi <sh.pi@samsung.com> Change-Id: I6e436d16be791b73fab0b0626ced314c30b7c00d
Diffstat (limited to 'src/display')
-rw-r--r--src/display/core.c3
-rw-r--r--src/display/key-filter.c105
2 files changed, 107 insertions, 1 deletions
diff --git a/src/display/core.c b/src/display/core.c
index 022366c8..8b7100db 100644
--- a/src/display/core.c
+++ b/src/display/core.c
@@ -872,6 +872,7 @@ static int default_action(int timeout)
backlight_ops.on();
backlight_ops.update();
#endif
+ key_backlight_enable(true);
} else if (pm_old_state == S_LCDDIM)
backlight_ops.update();
@@ -894,6 +895,7 @@ static int default_action(int timeout)
if (pm_old_state != S_SLEEP && pm_old_state != S_LCDOFF) {
/* lcd off state : turn off the backlight */
backlight_ops.off();
+ key_backlight_enable(false);
if (pre_suspend_flag == false) {
pre_suspend_flag = true;
@@ -1187,6 +1189,7 @@ static int update_setting(int key_idx, int val)
states[S_LCDDIM].timeout = 0;
_E("LOCKED: NORMAL timeout is set by %d seconds",
LOCK_SCREEN_TIMEOUT);
+ key_backlight_enable(false);
} else {
set_lock_screen_state(val);
get_run_timeout(&run_timeout);
diff --git a/src/display/key-filter.c b/src/display/key-filter.c
index b33ece12..afadc0a6 100644
--- a/src/display/key-filter.c
+++ b/src/display/key-filter.c
@@ -28,6 +28,7 @@
#include "util.h"
#include "core.h"
#include "poll.h"
+#include "device-node.h"
#include "core/queue.h"
#include "core/common.h"
#include "core/data.h"
@@ -44,6 +45,8 @@
#define LONG_PRESS_INTERVAL 0.4 /* 0.4 second */
#define COMBINATION_INTERVAL 0.3 /* 0.3 second */
#define POWER_KEY_PRESS_IGNORE_TIME 0.7 /* 0.7 second */
+#define KEYBACKLIGHT_TIME 1.5 /* 1.5 second */
+#define KEYBACKLIGHT_PRESSED_TIME 15 /* 15 second */
#define KEY_RELEASED 0
#define KEY_PRESSED 1
@@ -60,6 +63,7 @@
static struct timeval pressed_time;
static Ecore_Timer *longkey_timeout_id = NULL;
static Ecore_Timer *combination_timeout_id = NULL;
+static Ecore_Timer *hardkey_timeout_id = NULL;
static int cancel_lcdoff;
static int key_combination = KEY_COMBINATION_STOP;
static int powerkey_ignored = false;
@@ -355,6 +359,71 @@ static int process_screenlock_key(struct input_event *pinput)
return true;
}
+static Eina_Bool key_backlight_expired(void *data)
+{
+ int ret, val;
+ hardkey_timeout_id = NULL;
+
+ ret = device_get_property(DEVICE_TYPE_LED, PROP_LED_HARDKEY, &val);
+ /* check key backlight is already off */
+ if (!ret && !val)
+ return ECORE_CALLBACK_CANCEL;
+
+ /* key backlight off */
+ ret = device_set_property(DEVICE_TYPE_LED, PROP_LED_HARDKEY, STATUS_OFF);
+ if (ret < 0)
+ _E("Fail to turn off key backlight!");
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void process_hardkey_backlight(struct input_event *pinput)
+{
+ int val, ret;
+
+ if (pinput->value == KEY_PRESSED) {
+ _I("hard key pressed : code(%d)", pinput->code);
+
+ if (hardkey_timeout_id > 0) {
+ ecore_timer_del(hardkey_timeout_id);
+ hardkey_timeout_id = NULL;
+ }
+
+ /* key backlight on */
+ ret = device_set_property(DEVICE_TYPE_LED, PROP_LED_HARDKEY, STATUS_ON);
+ if (ret < 0)
+ _E("Fail to turn off key backlight!");
+ /* device notify(vibrator) */
+ /* sound(dbus) */
+ /* start timer */
+ hardkey_timeout_id = ecore_timer_add(
+ KEYBACKLIGHT_PRESSED_TIME,
+ key_backlight_expired, NULL);
+
+ } else if (pinput->value == KEY_RELEASED) {
+ _I("hard key released : code(%d)", pinput->code);
+
+ if (hardkey_timeout_id > 0) {
+ ecore_timer_del(hardkey_timeout_id);
+ hardkey_timeout_id = NULL;
+ }
+
+ ret = device_get_property(DEVICE_TYPE_LED, PROP_LED_HARDKEY, &val);
+ /* check key backlight is already off */
+ if (!ret && !val)
+ return;
+
+ if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
+ _I("Lock state, key backlight is off when phone is unlocked!");
+ return;
+ }
+ /* timer start if backlight is on */
+ hardkey_timeout_id = ecore_timer_add(
+ KEYBACKLIGHT_TIME,
+ key_backlight_expired, NULL);
+ }
+}
+
static int check_key(struct input_event *pinput)
{
int ignore = true;
@@ -375,10 +444,17 @@ static int check_key(struct input_event *pinput)
case KEY_SCREENLOCK:
ignore = process_screenlock_key(pinput);
break;
+ case KEY_BACK:
+ case KEY_PHONE:
+ stop_key_combination();
+ if (current_state_in_on()) {
+ process_hardkey_backlight(pinput);
+ ignore = false;
+ }
+ break;
case KEY_VOLUMEUP:
case KEY_CAMERA:
case KEY_EXIT:
- case KEY_PHONE:
case KEY_CONFIG:
case KEY_SEARCH:
case KEY_MEDIA:
@@ -433,3 +509,30 @@ int check_key_filter(int length, char buf[])
return 0;
}
+void key_backlight_enable(bool enable)
+{
+ int ret;
+
+ if (hardkey_timeout_id > 0) {
+ ecore_timer_del(hardkey_timeout_id);
+ hardkey_timeout_id = NULL;
+ }
+
+ /* backlight enable or disable */
+ ret = device_set_property(DEVICE_TYPE_LED, PROP_LED_HARDKEY, enable);
+
+ if (ret < 0)
+ _E("Fail to turn %s key backlight!", (enable ? "on" : "off"));
+
+ /* start timer in case of backlight enabled */
+ if (enable) {
+ if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
+ _I("[Lock] key backlight's off when phone is unlocked!");
+ return;
+ }
+
+ hardkey_timeout_id = ecore_timer_add(KEYBACKLIGHT_TIME,
+ key_backlight_expired, NULL);
+ }
+}
+