Skip to content

Commit

Permalink
[powerkey] Handle synthesized gestures despite hw settings. Fixes JB#…
Browse files Browse the repository at this point in the history
…42261

In some devices hw based gesture (such as doubletab) detection can't be
disabled. For this reason mce rejects gesture events if they are received
under conditions where hw gesture detection ought to be disabled. This
however makes also synthesized gestures (such as doubletap from lpm)
depend on hw enable/disable setting.

Mark synthesized gestures as such and do not subject them to "never"
hw gesture detection setting.

If users wish to disable synthesized double taps, there already exists
a separate setting for that purpose.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jun 29, 2018
1 parent 0d546c5 commit ccd4f14
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
15 changes: 9 additions & 6 deletions evdev.h
Expand Up @@ -22,12 +22,15 @@ extern "C" {
* mce to always mean doubletap.
*/
typedef enum {
GESTURE_SWIPE_FROM_LEFT = 0,
GESTURE_SWIPE_FROM_RIGHT = 1,
GESTURE_SWIPE_FROM_TOP = 2,
GESTURE_SWIPE_FROM_BOTTOM = 3,
GESTURE_DOUBLETAP = 4, /* To conform with value used in
* Nokia N9 kernel driver */
/* Values */
GESTURE_SWIPE_FROM_LEFT = 0,
GESTURE_SWIPE_FROM_RIGHT = 1,
GESTURE_SWIPE_FROM_TOP = 2,
GESTURE_SWIPE_FROM_BOTTOM = 3,
GESTURE_DOUBLETAP = 4, /* To conform with value used in
* Nokia N9 kernel driver */
/* Modifiers */
GESTURE_SYNTHESIZED = (1<<8),
} gesture_t;

const char *evdev_get_event_code_name(int etype, int ecode);
Expand Down
2 changes: 1 addition & 1 deletion event-input.c
Expand Up @@ -2028,7 +2028,7 @@ evin_iomon_touchscreen_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
mce_log(LL_DEVEL, "[doubletap] emulated from touch input");
ev->type = EV_MSC;
ev->code = MSC_GESTURE;
ev->value = GESTURE_DOUBLETAP;
ev->value = GESTURE_DOUBLETAP | GESTURE_SYNTHESIZED;
}
#endif

Expand Down
29 changes: 19 additions & 10 deletions powerkey.c
Expand Up @@ -187,7 +187,7 @@ static gchar *pwrkey_mask_to_names (uint32_t mask);
static gint pwrkey_gestures_enable_mode = MCE_DEFAULT_DOUBLETAP_MODE;
static guint pwrkey_gestures_enable_mode_cb_id = 0;

static bool pwrkey_gestures_allowed(void);
static bool pwrkey_gestures_allowed(bool synthesized);

/* ------------------------------------------------------------------------- *
* ACTION_TRIGGERING
Expand Down Expand Up @@ -1104,19 +1104,25 @@ pwrkey_mask_to_names(uint32_t mask)
/** Predicate for: touchscreen gesture actions are allowed
*/
static bool
pwrkey_gestures_allowed(void)
pwrkey_gestures_allowed(bool synthesized)
{
bool allowed = false;

/* Check enable setting */
switch( pwrkey_gestures_enable_mode ) {
case DBLTAP_ENABLE_NEVER:
mce_log(LL_DEVEL, "[gesture] ignored due to setting=never");
goto EXIT;

case DBLTAP_ENABLE_ALWAYS:
break;

case DBLTAP_ENABLE_NEVER:
if( !synthesized ) {
mce_log(LL_DEVEL, "[gesture] ignored due to setting=never");
goto EXIT;
}
/* Synthesized events (e.g. double tap from lpm) are implicitly
* subjected to proximity rules.
*
* Fall through */

default:
case DBLTAP_ENABLE_NO_PROXIMITY:
if( lid_sensor_filtered == COVER_CLOSED ) {
Expand Down Expand Up @@ -1174,14 +1180,17 @@ pwrkey_gestures_allowed(void)
static void
pwrkey_actions_do_gesture(size_t gesture)
{
/* Check settings, proximity sensor state, etc */
if( !pwrkey_gestures_allowed(gesture & GESTURE_SYNTHESIZED) )
goto EXIT;

/* Remove modifier bits */
gesture &= ~GESTURE_SYNTHESIZED;

/* Treat unconfigurable gestures as doubletaps */
if( gesture >= POWERKEY_ACTIONS_GESTURE_COUNT )
gesture = GESTURE_DOUBLETAP;

/* Check settings, proximity sensor state, etc */
if( !pwrkey_gestures_allowed() )
goto EXIT;

pwrkey_mask_execute(pwrkey_actions_from_gesture[gesture].mask_single);

EXIT:
Expand Down

0 comments on commit ccd4f14

Please sign in to comment.