Skip to content

Commit 063f1ec

Browse files
DiewiAdrianDC
authored andcommitted
multirom: lib: Fix landscape input layer on boot
* Fix the input layer if the target device boots in landscape mode instead of portrait mode. * This commit introduces the following changes: a) The rotation code is fixed with respect to the proper offset and the coordinates are now scaled accordingly b) An additional define for devices is introduced such that the required rotation of the input layer to matches display rotation (MR_INPUT_ROTATION); * This value has to be given in degrees (90, 180, 270), the rotation direction is clockwise, and the 0 angle is the portrait mode of the device. Change-Id: I0701fda49ba5cc890be2e7b3033fbc6915cc4898
1 parent e80fbed commit 063f1ec

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

device_defines.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ else
8787
LOCAL_CFLAGS += -DMULTIROM_DEFAULT_BRIGHTNESS=40
8888
endif
8989

90+
ifneq ($(MR_INPUT_ROTATION),)
91+
LOCAL_CFLAGS += -DMR_INPUT_ROTATION=$(MR_INPUT_ROTATION)
92+
endif
93+
9094
ifneq ($(MR_KEXEC_MEM_MIN),)
9195
LOCAL_CFLAGS += -DMR_KEXEC_MEM_MIN=\"$(MR_KEXEC_MEM_MIN)\"
9296
else

lib/input.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ int calc_mt_pos(int val, int *range, int d_max)
222222

223223
static void mt_recalc_pos_rotation(touch_event *ev)
224224
{
225-
switch(fb_rotation)
225+
int rotation = fb_rotation;
226+
#ifdef MR_INPUT_ROTATION
227+
rotation += MR_INPUT_ROTATION;
228+
#endif
229+
switch(rotation % 360)
226230
{
227231
case 0:
228232
ev->x = ev->orig_x;
@@ -231,8 +235,14 @@ static void mt_recalc_pos_rotation(touch_event *ev)
231235
case 90:
232236
ev->x = ev->orig_y;
233237
ev->y = ev->orig_x;
234-
235-
ev->y = fb_height - ev->y;
238+
239+
// Offset & inversion
240+
ev->y = fb_width - ev->y;
241+
242+
// Scaling
243+
ev->x = ev->x * mt_screen_res[0]/mt_screen_res[1];
244+
ev->y = ev->y * mt_screen_res[1]/mt_screen_res[0];
245+
236246
break;
237247
case 180:
238248
ev->x = fb_width - ev->orig_x;
@@ -242,7 +252,13 @@ static void mt_recalc_pos_rotation(touch_event *ev)
242252
ev->x = ev->orig_y;
243253
ev->y = ev->orig_x;
244254

245-
ev->x = fb_width - ev->x;
255+
// Offset & inversion
256+
ev->x = fb_height - ev->x;
257+
258+
// Scaling
259+
ev->x = ev->x * mt_screen_res[0]/mt_screen_res[1];
260+
ev->y = ev->y * mt_screen_res[1]/mt_screen_res[0];
261+
246262
break;
247263
}
248264
}

0 commit comments

Comments
 (0)