Skip to content

Commit

Permalink
Merge branch 'jb47437_fpwakeup_config' into 'master'
Browse files Browse the repository at this point in the history
Use configurable gesture actions for fingerprint wake up

See merge request mer-core/mce!131
  • Loading branch information
spiiroin committed Oct 25, 2019
2 parents 2b5a828 + 64e71c6 commit c37915c
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .depend
Expand Up @@ -1380,6 +1380,7 @@ tools/mcetool.o:\
tools/mcetool.c\
builtin-gconf.h\
datapipe.h\
evdev.h\
event-input.h\
mce-command-line.h\
mce-dbus.h\
Expand All @@ -1401,6 +1402,7 @@ tools/mcetool.pic.o:\
tools/mcetool.c\
builtin-gconf.h\
datapipe.h\
evdev.h\
event-input.h\
mce-command-line.h\
mce-dbus.h\
Expand Down
45 changes: 45 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1757,6 +1757,51 @@ static const setting_t gconf_defaults[] =
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE11,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE12,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE13,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE14,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE15,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE16,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE17,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE18,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE19,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19,
},
{
.key = MCE_SETTING_POWERKEY_DBUS_ACTION1,
.type = "s",
Expand Down
4 changes: 3 additions & 1 deletion evdev.h
Expand Up @@ -37,13 +37,15 @@ extern "C" {
* mce to always mean doubletap.
*/
typedef enum {
/* Values */
/* Values 0-15 reserved for touchscreen gestures */
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 */
GESTURE_FPWAKEUP = 16,

/* Modifiers */
GESTURE_SYNTHESIZED = (1<<8),
} gesture_t;
Expand Down
12 changes: 5 additions & 7 deletions modules/fingerprint.c
Expand Up @@ -2647,12 +2647,6 @@ fpwakeup_trigger(void)
datapipe_exec_full(&ngfd_event_request_pipe,
"unlock_device");

/* Make sure we unblank / exit from lpm */
mce_datapipe_request_display_state(MCE_DISPLAY_ON);

/* Exit from lockscreen */
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);

/* Deactivate type=6 led patterns (e.g. sms/email notifications)
* by signaling "true user activity" via synthetized gesture
* input event. (The event type ought not matter, but using
Expand All @@ -2663,9 +2657,13 @@ fpwakeup_trigger(void)
const struct input_event ev = {
.type = EV_MSC,
.code = MSC_GESTURE,
.value = GESTURE_DOUBLETAP | GESTURE_SYNTHESIZED,
.value = GESTURE_FPWAKEUP | GESTURE_SYNTHESIZED,
};
datapipe_exec_full(&user_activity_event_pipe, &ev);

/* Forward to powerkey.c for configurable action handling */
const struct input_event *evp = &ev;
datapipe_exec_full(&keypress_event_pipe, &evp);
}
}

Expand Down
64 changes: 64 additions & 0 deletions powerkey.c
Expand Up @@ -162,6 +162,7 @@ static void pwrkey_action_tklock (void);
static void pwrkey_action_blank (void);
static void pwrkey_action_unblank (void);
static void pwrkey_action_tkunlock (void);
static void pwrkey_action_tkunlock2(void);
static void pwrkey_action_devlock (void);
static void pwrkey_action_dbus1 (void);
static void pwrkey_action_dbus2 (void);
Expand Down Expand Up @@ -300,6 +301,15 @@ static const char * const pwrkey_actions_gesture_key[POWERKEY_ACTIONS_GESTURE_CO
MCE_SETTING_POWERKEY_ACTIONS_GESTURE8,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE9,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE10,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE11,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE12,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE13,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE14,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE15,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE16,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE17,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE18,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE19,
};

/** Array of default values for configurable touchscreen gestures */
Expand All @@ -316,6 +326,15 @@ static const char * const pwrkey_actions_gesture_val[POWERKEY_ACTIONS_GESTURE_CO
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE8,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE9,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19,
};

/** Array of current values for configurable touchscreen gestures */
Expand Down Expand Up @@ -574,6 +593,7 @@ static void pwrkey_setting_quit (void);
static void pwrkey_datapipe_keypress_event_cb(gconstpointer const data);
static void pwrkey_datapipe_ngfd_service_state_cb(gconstpointer data);
static void pwrkey_datapipe_system_state_cb(gconstpointer data);
static void pwrkey_datapipe_devicelock_state_cb(gconstpointer data);
static void pwrkey_datapipe_display_state_curr_cb(gconstpointer data);
static void pwrkey_datapipe_display_state_next_cb(gconstpointer data);
static void pwrkey_datapipe_lid_sensor_filtered_cb(gconstpointer data);
Expand Down Expand Up @@ -664,6 +684,9 @@ static bool pwrkey_delete_flagfile(const char *path)
/** System state; is undefined at bootup, can't assume anything */
static system_state_t system_state = MCE_SYSTEM_STATE_UNDEF;

/** Cached devicelock_state ; assume unknown */
static devicelock_state_t devicelock_state = DEVICELOCK_STATE_UNDEFINED;

/** Current display state; undefined initially, can't assume anything */
static display_state_t display_state_curr = MCE_DISPLAY_UNDEF;

Expand Down Expand Up @@ -844,6 +867,18 @@ pwrkey_action_tkunlock(void)
return;
}

static void
pwrkey_action_tkunlock2(void)
{
if( devicelock_state != DEVICELOCK_STATE_UNLOCKED ) {
mce_log(LL_DEBUG, "devicelock_state=%s; rejecting 'tkunlock2' action",
devicelock_state_repr(devicelock_state));
}
else {
pwrkey_action_tkunlock();
}
}

static void
pwrkey_action_blank(void)
{
Expand Down Expand Up @@ -1033,6 +1068,10 @@ static const pwrkey_bitconf_t pwrkey_action_lut[] =
.name = "unblank",
.func = pwrkey_action_unblank,
},
{
.name = "tkunlock2",
.func = pwrkey_action_tkunlock2,
},
{
.name = "tkunlock",
.func = pwrkey_action_tkunlock,
Expand Down Expand Up @@ -2918,6 +2957,27 @@ static void pwrkey_datapipe_system_state_cb(gconstpointer data)
return;
}

/** Notification callback for devicelock_state_pipe
*
* @param data devicelock_state_t value as void pointer
*/
static void
pwrkey_datapipe_devicelock_state_cb(gconstpointer data)
{
devicelock_state_t prev = devicelock_state;
devicelock_state = GPOINTER_TO_INT(data);

if( devicelock_state == prev )
goto EXIT;

mce_log(LL_DEBUG, "devicelock_state = %s -> %s",
devicelock_state_repr(prev),
devicelock_state_repr(devicelock_state));

EXIT:
return;
}

/** Handle display state change notifications
*
* @param data display state (as void pointer)
Expand Down Expand Up @@ -3257,6 +3317,10 @@ static datapipe_handler_t pwrkey_datapipe_handlers[] =
.datapipe = &system_state_pipe,
.output_cb = pwrkey_datapipe_system_state_cb,
},
{
.datapipe = &devicelock_state_pipe,
.output_cb = pwrkey_datapipe_devicelock_state_cb,
},
{
.datapipe = &display_state_curr_pipe,
.output_cb = pwrkey_datapipe_display_state_curr_cb,
Expand Down
31 changes: 29 additions & 2 deletions powerkey.h
Expand Up @@ -129,7 +129,7 @@ typedef enum
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE3 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE4 MCE_SETTING_POWERKEY_PATH "/actions_gesture4"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE4 "unblank"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE4 "unblank" // GESTURE_DOUBLETAP

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE5 MCE_SETTING_POWERKEY_PATH "/actions_gesture5"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE5 "unblank"
Expand All @@ -149,8 +149,35 @@ typedef enum
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE10 MCE_SETTING_POWERKEY_PATH "/actions_gesture10"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE11 MCE_SETTING_POWERKEY_PATH "/actions_gesture11"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE12 MCE_SETTING_POWERKEY_PATH "/actions_gesture12"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE13 MCE_SETTING_POWERKEY_PATH "/actions_gesture13"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE14 MCE_SETTING_POWERKEY_PATH "/actions_gesture14"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE15 MCE_SETTING_POWERKEY_PATH "/actions_gesture15"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE16 MCE_SETTING_POWERKEY_PATH "/actions_gesture16"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16 "unblank,tkunlock" // GESTURE_FPWAKEUP

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE17 MCE_SETTING_POWERKEY_PATH "/actions_gesture17"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE18 MCE_SETTING_POWERKEY_PATH "/actions_gesture18"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18 "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE19 MCE_SETTING_POWERKEY_PATH "/actions_gesture19"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19 "unblank"

/** Number of configurable touchscreen gestures */
# define POWERKEY_ACTIONS_GESTURE_COUNT 11
# define POWERKEY_ACTIONS_GESTURE_COUNT 20

/** What to send when dbus action N is taken*/
# define MCE_SETTING_POWERKEY_DBUS_ACTION1 MCE_SETTING_POWERKEY_PATH "/dbus_action1"
Expand Down

0 comments on commit c37915c

Please sign in to comment.