From c5e99b90952d3fb326b01c4342c00f9d697c353f Mon Sep 17 00:00:00 2001 From: Wolfgang Wiedmeyer Date: Tue, 11 Jul 2017 14:12:54 +0200 Subject: ui: Add option to change touchscreen orientation On devices like the Galaxy Note 8.0, the touchscreen assumes portrait mode while the recovery is in landscape mode. Allowing to swap x and y dimension and flipping the x dimension makes the touchscreen usable on these devices. Signed-off-by: Wolfgang Wiedmeyer --- Android.mk | 4 ++++ ui.cpp | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Android.mk b/Android.mk index 2aeefde..8bc1e9e 100644 --- a/Android.mk +++ b/Android.mk @@ -136,6 +136,10 @@ ifeq ($(BOARD_HAS_DOWNLOAD_MODE), true) LOCAL_CFLAGS += -DDOWNLOAD_MODE endif +ifeq ($(TARGET_RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X), true) +LOCAL_CFLAGS += -DRECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X +endif + ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),) LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET) endif diff --git a/ui.cpp b/ui.cpp index c7268fb..bb69b13 100644 --- a/ui.cpp +++ b/ui.cpp @@ -425,13 +425,24 @@ void RecoveryUI::ProcessAbs(input_device* dev, int code, int value) { return; } } +#ifndef RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X if (code == ABS_MT_POSITION_X) { +#else + if (code == ABS_MT_POSITION_Y) { +#endif dev->saw_pos_x = true; dev->touch_pos.x = value * fb_dimensions.x / (dev->touch_max.x - dev->touch_min.x); } +#ifndef RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X else if (code == ABS_MT_POSITION_Y) { +#else + else if (code == ABS_MT_POSITION_X) { +#endif dev->saw_pos_y = true; dev->touch_pos.y = value * fb_dimensions.y / (dev->touch_max.y - dev->touch_min.y); +#ifdef RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X + dev->touch_pos.y = fb_dimensions.y - dev->touch_pos.y; +#endif } } @@ -480,13 +491,21 @@ void RecoveryUI::calibrate_touch(input_device* dev) { struct input_absinfo info; memset(&info, 0, sizeof(info)); +#ifndef RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X if (ioctl(dev->fd, EVIOCGABS(ABS_MT_POSITION_X), &info) == 0) { +#else + if (ioctl(dev->fd, EVIOCGABS(ABS_MT_POSITION_Y), &info) == 0) { +#endif dev->touch_min.x = info.minimum; dev->touch_max.x = info.maximum; dev->touch_pos.x = info.value; } memset(&info, 0, sizeof(info)); +#ifndef RECOVERY_TOUCHSCREEN_SWAP_XY_FLIP_X if (ioctl(dev->fd, EVIOCGABS(ABS_MT_POSITION_Y), &info) == 0) { +#else + if (ioctl(dev->fd, EVIOCGABS(ABS_MT_POSITION_X), &info) == 0) { +#endif dev->touch_min.y = info.minimum; dev->touch_max.y = info.maximum; dev->touch_pos.y = info.value; -- cgit v1.1