aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Marshall <tdm.code@gmail.com>2019-08-06 16:30:02 +0200
committerBruno Martins <bgcngm@gmail.com>2019-08-11 09:52:10 +0200
commit2a99d0cde307d964f40c4b4c18f42ce70b53b2c4 (patch)
treeaa04a8d2f764dc990136fe062f0b4bd97affeb7f
parent49d54abb4317e9991d703525a994888fbfcdbea3 (diff)
downloadandroid_bootable_recovery-2a99d0cde307d964f40c4b4c18f42ce70b53b2c4.tar.gz
android_bootable_recovery-2a99d0cde307d964f40c4b4c18f42ce70b53b2c4.tar.bz2
android_bootable_recovery-2a99d0cde307d964f40c4b4c18f42ce70b53b2c4.zip
recovery: calibrate touchscreen
Change-Id: I5a32a59691dea5fa2aa867e6594cec15b1b24ccf
-rw-r--r--ui.cpp25
-rw-r--r--ui.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/ui.cpp b/ui.cpp
index 4109479c..09b13779 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -238,6 +238,26 @@ void RecoveryUI::Stop() {
}
}
+void RecoveryUI::CalibrateTouch(int fd) {
+ struct input_absinfo info;
+ static bool calibrated = false;
+
+ if (calibrated) return;
+
+ memset(&info, 0, sizeof(info));
+ if (ioctl(fd, EVIOCGABS(ABS_MT_POSITION_X), &info) == 0) {
+ touch_min_.x(info.minimum);
+ touch_max_.x(info.maximum);
+ }
+ memset(&info, 0, sizeof(info));
+ if (ioctl(fd, EVIOCGABS(ABS_MT_POSITION_Y), &info) == 0) {
+ touch_min_.y(info.minimum);
+ touch_max_.y(info.maximum);
+ }
+
+ calibrated = true;
+}
+
void RecoveryUI::OnTouchPress() {
touch_start_ = touch_track_ = touch_pos_;
}
@@ -364,6 +384,7 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
}
if (touch_screen_allowed_ && ev.type == EV_ABS) {
+ CalibrateTouch(fd);
if (ev.code == ABS_MT_SLOT) {
touch_slot_ = ev.value;
}
@@ -374,7 +395,7 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
case ABS_MT_POSITION_X:
touch_finger_down_ = true;
touch_saw_x_ = true;
- touch_pos_.x(ev.value);
+ touch_pos_.x(ev.value * gr_fb_width() / (touch_max_.x() - touch_min_.x()));
if (touch_reported_ && touch_saw_y_) {
OnTouchTrack();
touch_saw_x_ = touch_saw_y_ = false;
@@ -384,7 +405,7 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
case ABS_MT_POSITION_Y:
touch_finger_down_ = true;
touch_saw_y_ = true;
- touch_pos_.y(ev.value);
+ touch_pos_.y(ev.value * gr_fb_height() / (touch_max_.y() - touch_min_.y()));
if (touch_reported_ && touch_saw_x_) {
OnTouchTrack();
touch_saw_x_ = touch_saw_y_ = false;
diff --git a/ui.h b/ui.h
index e16aa507..6356d387 100644
--- a/ui.h
+++ b/ui.h
@@ -305,6 +305,7 @@ class RecoveryUI {
void OnTouchDeviceDetected(int fd);
void OnKeyDetected(int key_code);
+ void CalibrateTouch(int fd);
void OnTouchPress();
void OnTouchTrack();
void OnTouchRelease();
@@ -357,6 +358,8 @@ class RecoveryUI {
Point touch_pos_;
Point touch_start_;
Point touch_track_;
+ Point touch_max_;
+ Point touch_min_;
bool has_swiped_;
std::vector<vkey_t> virtual_keys_;
bool is_bootreason_recovery_ui_;