Cst816s: scale down SDL mouse coordinates according to MONITOR_ZOOM
The lv_drivers provided monitor driver supports a `MONITOR_ZOOM`-factor which scales the window by the set factor. This is 'useful when simulating small screens'. The zoom can be set as cmake configuration setting `-DMONITOR_ZOOM=1`. Probably even more usefull for high-dpi screens where 240 pixels is really tiny.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "lv_drv_conf.h" // MONITOR_ZOOM
|
||||
#include <SDL2/SDL.h>
|
||||
#include <libraries/log/nrf_log.h>
|
||||
#include <cmath>
|
||||
@@ -25,6 +26,10 @@ bool Cst816S::Init() {
|
||||
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||
int x, y;
|
||||
uint32_t buttons = SDL_GetMouseState(&x, &y);
|
||||
// scale down real mouse coordinates to InfiniTime scale to make zoom work
|
||||
// the MONITOR_ZOOM-factor is defined in lv_drv_conf.h
|
||||
x /= MONITOR_ZOOM;
|
||||
y /= MONITOR_ZOOM;
|
||||
|
||||
Cst816S::TouchInfos info;
|
||||
info.x = x;
|
||||
|
Reference in New Issue
Block a user