TouchHandler: Do not store touch panel reference
This commit is contained in:
@@ -27,18 +27,13 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel) : touchPanel {touchPanel} {
|
||||
}
|
||||
|
||||
Pinetime::Applications::TouchEvents TouchHandler::GestureGet() {
|
||||
auto returnGesture = gesture;
|
||||
gesture = Pinetime::Applications::TouchEvents::None;
|
||||
return returnGesture;
|
||||
}
|
||||
|
||||
bool TouchHandler::GetNewTouchInfo() {
|
||||
info = touchPanel.GetTouchInfo();
|
||||
|
||||
bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
|
||||
if (!info.isValid) {
|
||||
return false;
|
||||
}
|
||||
@@ -65,5 +60,7 @@ bool TouchHandler::GetNewTouchInfo() {
|
||||
gestureReleased = true;
|
||||
}
|
||||
|
||||
currentTouchPoint = {info.x, info.y, info.touching};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -3,36 +3,34 @@
|
||||
#include "displayapp/TouchEvents.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
class Cst816S;
|
||||
}
|
||||
|
||||
namespace Controllers {
|
||||
class TouchHandler {
|
||||
public:
|
||||
explicit TouchHandler(Drivers::Cst816S&);
|
||||
struct TouchPoint {
|
||||
int x;
|
||||
int y;
|
||||
bool touching;
|
||||
};
|
||||
|
||||
bool GetNewTouchInfo();
|
||||
bool ProcessTouchInfo(Drivers::Cst816S::TouchInfos info);
|
||||
|
||||
bool IsTouching() const {
|
||||
return info.touching;
|
||||
return currentTouchPoint.touching;
|
||||
}
|
||||
|
||||
uint8_t GetX() const {
|
||||
return info.x;
|
||||
return currentTouchPoint.x;
|
||||
}
|
||||
|
||||
uint8_t GetY() const {
|
||||
return info.y;
|
||||
return currentTouchPoint.y;
|
||||
}
|
||||
|
||||
Pinetime::Applications::TouchEvents GestureGet();
|
||||
|
||||
private:
|
||||
Pinetime::Drivers::Cst816S::TouchInfos info;
|
||||
Pinetime::Drivers::Cst816S& touchPanel;
|
||||
Pinetime::Applications::TouchEvents gesture;
|
||||
bool isCancelled = false;
|
||||
TouchPoint currentTouchPoint = {};
|
||||
bool gestureReleased = true;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user