commit a01862db90c24a8e7d8b7ca8bc4d60baec2af335 Author: Tom Hughes Date: Sat Dec 13 10:37:31 2014 +0000 Add support for a "middle" area in the bottom clickpad diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 6af3fcf..f48d2ed 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -64,6 +64,7 @@ static inline const char* button_event_to_str(enum button_event event) { switch(event) { CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_R); + CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_M); CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_L); CASE_RETURN_STRING(BUTTON_EVENT_IN_TOP_R); CASE_RETURN_STRING(BUTTON_EVENT_IN_TOP_M); @@ -94,7 +95,15 @@ static inline bool is_inside_bottom_left_area(struct tp_dispatch *tp, struct tp_touch *t) { return is_inside_bottom_button_area(tp, t) && - !is_inside_bottom_right_area(tp, t); + t->x < tp->buttons.bottom_area.leftbutton_right_edge; +} + +static inline bool +is_inside_bottom_middle_area(struct tp_dispatch *tp, struct tp_touch *t) +{ + return is_inside_bottom_button_area(tp, t) && + t->x >= tp->buttons.bottom_area.leftbutton_right_edge && + t->x <= tp->buttons.bottom_area.rightbutton_left_edge; } static inline bool @@ -183,6 +192,7 @@ tp_button_none_handle_event(struct tp_dispatch *tp, { switch (event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: tp_button_set_state(tp, t, BUTTON_STATE_BOTTOM, event); break; @@ -211,6 +221,7 @@ tp_button_area_handle_event(struct tp_dispatch *tp, { switch (event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: case BUTTON_EVENT_IN_TOP_R: case BUTTON_EVENT_IN_TOP_M: @@ -234,6 +245,7 @@ tp_button_bottom_handle_event(struct tp_dispatch *tp, { switch (event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: if (event != t->button.curr) tp_button_set_state(tp, t, BUTTON_STATE_BOTTOM, @@ -262,6 +274,7 @@ tp_button_top_handle_event(struct tp_dispatch *tp, { switch (event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: tp_button_set_state(tp, t, BUTTON_STATE_TOP_TO_IGNORE, event); break; @@ -292,6 +305,7 @@ tp_button_top_new_handle_event(struct tp_dispatch *tp, { switch(event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: tp_button_set_state(tp, t, BUTTON_STATE_AREA, event); break; @@ -336,6 +350,7 @@ tp_button_top_to_ignore_handle_event(struct tp_dispatch *tp, event); break; case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: case BUTTON_EVENT_IN_AREA: break; @@ -358,6 +373,7 @@ tp_button_ignore_handle_event(struct tp_dispatch *tp, { switch (event) { case BUTTON_EVENT_IN_BOTTOM_R: + case BUTTON_EVENT_IN_BOTTOM_M: case BUTTON_EVENT_IN_BOTTOM_L: case BUTTON_EVENT_IN_TOP_R: case BUTTON_EVENT_IN_TOP_M: @@ -429,6 +445,8 @@ tp_button_handle_state(struct tp_dispatch *tp, uint64_t time) } else if (t->dirty) { if (is_inside_bottom_right_area(tp, t)) tp_button_handle_event(tp, t, BUTTON_EVENT_IN_BOTTOM_R, time); + else if (is_inside_bottom_middle_area(tp, t)) + tp_button_handle_event(tp, t, BUTTON_EVENT_IN_BOTTOM_M, time); else if (is_inside_bottom_left_area(tp, t)) tp_button_handle_event(tp, t, BUTTON_EVENT_IN_BOTTOM_L, time); else if (is_inside_top_right_area(tp, t)) @@ -523,6 +541,7 @@ tp_init_softbuttons(struct tp_dispatch *tp, } tp->buttons.bottom_area.rightbutton_left_edge = width/2 + xoffset; + tp->buttons.bottom_area.leftbutton_right_edge = width/2 + xoffset; if (tp->buttons.has_topbuttons) { /* T440s has the top button line 5mm from the top, event @@ -742,6 +761,7 @@ tp_post_softbutton_buttons(struct tp_dispatch *tp, uint64_t time) break; case BUTTON_EVENT_IN_TOP_M: is_top = 1; + case BUTTON_EVENT_IN_BOTTOM_M: button |= MIDDLE; break; case BUTTON_EVENT_IN_TOP_R: diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 1450288..3c49c3d 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -60,6 +60,7 @@ enum touch_state { enum button_event { BUTTON_EVENT_IN_BOTTOM_R = 30, + BUTTON_EVENT_IN_BOTTOM_M, BUTTON_EVENT_IN_BOTTOM_L, BUTTON_EVENT_IN_TOP_R, BUTTON_EVENT_IN_TOP_M, @@ -222,6 +223,7 @@ struct tp_dispatch { struct { int32_t top_edge; int32_t rightbutton_left_edge; + int32_t leftbutton_right_edge; } bottom_area; struct {