Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add "proximity2" power key action mode
The already existing "proximity" mode blocks power key always when
proximity sensor is covered. Which means careless power button press
can leave the display on if the hand happens to trigger the sensor.

Add new "proximity2" mode that blocks power key actions only when
proximity sensor is covered and display is already off.

[mce] Add "proximity2" power key action mode
  • Loading branch information
spiiroin committed Sep 8, 2014
1 parent f0b07eb commit c16cd9f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions powerkey.c
Expand Up @@ -230,6 +230,8 @@ static bool powerkey_ignore_action(void)
datapipe_get_gint(proximity_sensor_pipe);
call_state_t call_state =
datapipe_get_gint(call_state_pipe);
display_state_t display_state =
datapipe_get_gint(display_state_pipe);

/* Ignore keypress if the alarm UI is visible */
switch( alarm_ui_state ) {
Expand Down Expand Up @@ -278,6 +280,11 @@ static bool powerkey_ignore_action(void)
case PWRKEY_ENABLE_ALWAYS:
break;

case PWRKEY_ENABLE_NO_PROXIMITY2:
/* do not ignore if display is not off */
if( display_state != MCE_DISPLAY_OFF )
break;
/* fall through */
default:
case PWRKEY_ENABLE_NO_PROXIMITY:
if( proximity_sensor_state != COVER_CLOSED )
Expand Down
5 changes: 4 additions & 1 deletion powerkey.h
Expand Up @@ -41,9 +41,12 @@ typedef enum
/** Power key actions always enabled */
PWRKEY_ENABLE_ALWAYS,

/** Power key actions enabled when PS is not covered */
/** Power key actions enabled if PS is not covered */
PWRKEY_ENABLE_NO_PROXIMITY,

/** Power key actions enabled if PS is not covered or display is on */
PWRKEY_ENABLE_NO_PROXIMITY2,

PWRKEY_ENABLE_DEFAULT = PWRKEY_ENABLE_ALWAYS,
} pwrkey_mode_t;

Expand Down
18 changes: 11 additions & 7 deletions tools/mcetool.c
Expand Up @@ -2396,10 +2396,11 @@ static void xmce_get_blank_timeout(void)
/** Lookup table for powerkey wakeup policies
*/
static const symbol_t powerkey_action[] = {
{ "never", PWRKEY_ENABLE_NEVER },
{ "always", PWRKEY_ENABLE_ALWAYS },
{ "proximity", PWRKEY_ENABLE_NO_PROXIMITY },
{ NULL, -1 }
{ "never", PWRKEY_ENABLE_NEVER },
{ "always", PWRKEY_ENABLE_ALWAYS },
{ "proximity", PWRKEY_ENABLE_NO_PROXIMITY },
{ "proximity2", PWRKEY_ENABLE_NO_PROXIMITY2 },
{ NULL, -1 }
};

/** Set powerkey wakeup mode
Expand Down Expand Up @@ -3606,10 +3607,13 @@ static const mce_opt_t options[] =
.name = "set-powerkey-action",
.flag = 'Z',
.with_arg = xmce_set_powerkey_action,
.values = "never|always|proximity",
.values = "never|always|proximity|proximity2",
.usage =
"set the doubletap wakeup mode; valid modes are:\n"
"'never', 'always', 'proximity'\n"
"set the power key action mode; valid modes are:\n"
" never - ignore power key presses\n"
" always - always act\n"
" proximity - act if proximity sensor is not covered\n"
" proximity2 - act if display is on or PS not covered\n"
},
{
.name = "set-powerkey-blanking",
Expand Down

0 comments on commit c16cd9f

Please sign in to comment.