+void
+tp_release_all_buttons(struct tp_dispatch *tp,
+ uint64_t time)
+{
+ if (tp->buttons.state) {
+ tp->buttons.state = 0;
+ tp->queued |= TOUCHPAD_EVENT_BUTTON_RELEASE;
+ }
+}
+
+void
+tp_init_softbuttons(struct tp_dispatch *tp,
+ struct evdev_device *device,
+ double topbutton_size_mult)
+{
+ int width, height;
+ const struct input_absinfo *absinfo_x, *absinfo_y;
+ int xoffset, yoffset;
+ int yres;
+
+ absinfo_x = device->abs.absinfo_x;
+ absinfo_y = device->abs.absinfo_y;
+
+ xoffset = absinfo_x->minimum,
+ yoffset = absinfo_y->minimum;
+ yres = absinfo_y->resolution;
+ width = abs(absinfo_x->maximum - absinfo_x->minimum);
+ height = abs(absinfo_y->maximum - absinfo_y->minimum);
+
+ /* button height: 10mm or 15% of the touchpad height,
+ whichever is smaller */
+ if (yres > 1 && (height * 0.15/yres) > 10) {
+ tp->buttons.bottom_area.top_edge =
+ absinfo_y->maximum - 10 * yres;
+ } else {
+ tp->buttons.bottom_area.top_edge = height * .85 + yoffset;
+ }
+
+ tp->buttons.bottom_area.rightbutton_left_edge = width/2 + xoffset;
+
+ if (tp->buttons.has_topbuttons) {
+ /* T440s has the top button line 5mm from the top, event
+ analysis has shown events to start down to ~10mm from the
+ top - which maps to 15%. We allow the caller to enlarge the
+ area using a multiplier for the touchpad disabled case. */
+ double topsize_mm = 10 * topbutton_size_mult;
+ double topsize_pct = .15 * topbutton_size_mult;
+
+ if (yres > 1) {
+ tp->buttons.top_area.bottom_edge =
+ yoffset + topsize_mm * yres;
+ } else {
+ tp->buttons.top_area.bottom_edge = height * topsize_pct + yoffset;
+ }
+ tp->buttons.top_area.rightbutton_left_edge = width * .58 + xoffset;
+ tp->buttons.top_area.leftbutton_right_edge = width * .42 + xoffset;
+ } else {
+ tp->buttons.top_area.bottom_edge = INT_MIN;
+ }
+}
+