Skip to content

Commit

Permalink
Shorten default touch unblock delay and make it configurable
Browse files Browse the repository at this point in the history
In order to protect ui from stray touch events mce blocks touch input
during display power up and after power up if fingers / palm are
touching the display. The touch input is unblocked after no touch has
been detected for unblock-delay ms.

Previously the unblock-delay was 200 ms. This was long enough for user
to make a double click to turn on the display and have mce eat away
the first swipe on the already visible ui.

Now the built in default is 100 ms. Different hardware adaptations can
use configuration files to override this. If needed, users can also
tune the value via mcetool --set-touch-unblock-delay option.

[mce] Shorten default touch unblock delay and make it configurable. Fixes JB#19833
  • Loading branch information
spiiroin committed Jun 4, 2014
1 parent 98254e1 commit 1afd03d
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 3 deletions.
6 changes: 6 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1242,6 +1242,12 @@ static const setting_t gconf_defaults[] =
.def = "false",
},
#endif
{
// MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH @ event-input.h
.key = "/system/osso/dsm/event_input/touch_unblock_delay",
.type = "i",
.def = "100",
},
{
// MCE_LED_PATTERN_BATTERY_CHARGING @ mce.h
.key = "/system/osso/dsm/leds/PatternBatteryCharging",
Expand Down
85 changes: 82 additions & 3 deletions event-input.c
Expand Up @@ -1231,7 +1231,7 @@ static void ts_grab_changed(input_grab_t *ctrl, bool grab)

enum
{
TS_RELEASE_DELAY_DEFAULT = 200,
TS_RELEASE_DELAY_DEFAULT = 100,
TS_RELEASE_DELAY_BLANK = 100,
TS_RELEASE_DELAY_UNBLANK = 600,
};
Expand All @@ -1254,6 +1254,52 @@ static input_grab_t ts_grab_state =
.ig_release_verify_cb = ts_grab_poll_palm_detect,
};

/* Touch unblock delay from settings [ms] */
static gint ts_grab_release_delay = TS_RELEASE_DELAY_DEFAULT;

/** GConf notification ID for touch unblock delay */
static guint ts_grab_release_delay_id = 0;

/** Gconf notification callback for touch unblock delay
*
* @param client (not used)
* @param id (not used)
* @param entry GConf entry that changed
* @param data (not used)
*/
static void ts_grab_release_delay_cb(GConfClient *const client,
const guint id,
GConfEntry *const entry,
gpointer const data)
{
(void)client; (void)id; (void)data;

gint delay = ts_grab_release_delay;
const GConfValue *value = 0;

if( !entry )
goto EXIT;

if( !(value = gconf_entry_get_value(entry)) )
goto EXIT;

if( value->type == GCONF_VALUE_INT )
delay = gconf_value_get_int(value);

if( ts_grab_release_delay == delay )
goto EXIT;

mce_log(LL_NOTICE, "touch unblock delay changed: %d -> %d",
ts_grab_release_delay, delay);

ts_grab_release_delay = delay;

// NB: currently active timer is not reprogrammed, change
// will take effect on the next unblank
EXIT:
return;
}

/** Event filter for determining finger on screen state
*/
static void ts_grab_event_filter_cb(struct input_event *ev)
Expand Down Expand Up @@ -1305,6 +1351,37 @@ static void ts_grab_event_filter_cb(struct input_event *ev)
}
}

/** Initialize touch screen grabbing state machine
*/
static void ts_grab_init(void)
{
/* Get touch unblock delay */
mce_gconf_notifier_add(MCE_GCONF_EVENT_INPUT_PATH,
MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH,
ts_grab_release_delay_cb,
&ts_grab_release_delay_id);

mce_gconf_get_int(MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH,
&ts_grab_release_delay);

mce_log(LL_NOTICE, "touch unblock delay config: %d",
ts_grab_release_delay);

ts_grab_state.ig_release_ms = ts_grab_release_delay;
}

/** De-initialize touch screen grabbing state machine
*/
static void ts_grab_quit(void)
{
if( ts_grab_release_delay_id ) {
mce_gconf_notifier_remove(GINT_TO_POINTER(ts_grab_release_delay_id), 0);
ts_grab_release_delay_id = 0;
}

input_grab_reset(&ts_grab_state);
}

/** feed desired touch grab state from datapipe to state machine
*
* @param data The grab wanted boolean as a pointer
Expand Down Expand Up @@ -1357,7 +1434,7 @@ static void ts_grab_display_state_cb(gconstpointer data)

case MCE_DISPLAY_ON:
case MCE_DISPLAY_DIM:
ts_grab_state.ig_release_ms = TS_RELEASE_DELAY_DEFAULT;
ts_grab_state.ig_release_ms = ts_grab_release_delay;
if( prev == MCE_DISPLAY_POWER_UP ) {
/* End the faked touch once the display is
* fully on. If there is a finger on the
Expand Down Expand Up @@ -2454,6 +2531,8 @@ gboolean mce_input_init(void)
GError *error = NULL;
gboolean status = FALSE;

ts_grab_init();

#ifdef ENABLE_DOUBLETAP_EMULATION
/* Get fake doubletap policy configuration & track changes */
mce_gconf_notifier_add(MCE_GCONF_EVENT_INPUT_PATH,
Expand Down Expand Up @@ -2556,7 +2635,7 @@ void mce_input_exit(void)
cancel_keypress_repeat_timeout();
cancel_misc_io_monitor_timeout();

input_grab_reset(&ts_grab_state);
ts_grab_quit();
input_grab_reset(&kp_grab_state);

return;
Expand Down
3 changes: 3 additions & 0 deletions event-input.h
Expand Up @@ -40,6 +40,9 @@
# define MCE_GCONF_USE_FAKE_DOUBLETAP_PATH MCE_GCONF_EVENT_INPUT_PATH "/use_fake_double_tap"
#endif

/** Path to the touch unblock delay setting */
#define MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH MCE_GCONF_EVENT_INPUT_PATH "/touch_unblock_delay"

/**
* Delay between I/O monitoring setups and keypress repeats; 1 second
*/
Expand Down
38 changes: 38 additions & 0 deletions tools/mcetool.c
Expand Up @@ -2536,6 +2536,36 @@ static void xmce_get_lipstick_core_delay(void)
printf("%-"PAD1"s %s (seconds)\n", "Lipstick core delay:", txt);
}

/* ------------------------------------------------------------------------- *
* touch input unblocking
* ------------------------------------------------------------------------- */

static bool xmce_set_touch_unblock_delay(const char *args)
{
debugf("%s(%s)\n", __FUNCTION__, args);
int val = xmce_parse_integer(args);

if( val <= 0 ) {
errorf("%d: invalid touch unblock delay\n", val);
return false;
}

mcetool_gconf_set_int(MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH, val);

return true;
}

static void xmce_get_touch_unblock_delay(void)
{
gint val = 0;
char txt[32];

strcpy(txt, "unknown");
if( mcetool_gconf_get_int(MCE_GCONF_TOUCH_UNBLOCK_DELAY_PATH, &val) )
snprintf(txt, sizeof txt, "%d", (int)val);
printf("%-"PAD1"s %s (milliseconds)\n", "Touch unblock delay:", txt);
}

/* ------------------------------------------------------------------------- *
* cpu scaling governor override
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -2920,6 +2950,7 @@ static bool xmce_get_status(const char *args)
#endif
xmce_get_tklock_blank();
xmce_get_lipstick_core_delay();
xmce_get_touch_unblock_delay();

get_led_breathing_enabled();
get_led_breathing_limit();
Expand Down Expand Up @@ -3446,6 +3477,13 @@ static const mce_opt_t options[] =
.usage =
"set the delay for dumping core from unresponsive lipstick\n"
},
{
.name = "set-touch-unblock-delay",
.with_arg = xmce_set_touch_unblock_delay,
.values = "msecs",
.usage =
"set the delay for ending touch blocking after unblanking\n"
},
{
.name = "begin-notification",
.with_arg = xmce_notification_begin,
Expand Down

0 comments on commit 1afd03d

Please sign in to comment.