7#include "TinyGPU/Input/TouchDriverCommon.h"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
33 SDL_InitSubSystem(SDL_INIT_VIDEO);
39 while (SDL_PollEvent(&event)) {
40 if (event.type == SDL_QUIT) {
47 const uint32_t buttons = SDL_GetMouseState(&x, &y);
49 lastX_ =
static_cast<int16_t>(x);
50 lastY_ =
static_cast<int16_t>(y);
51 down_ = (buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
56 if (!down_)
return false;
65#if SDL_VERSION_ATLEAST(2
, 0
, 18
)
66 SDL_Window* window = SDL_GetMouseFocus();
67 SDL_Renderer* renderer = window !=
nullptr ? SDL_GetRenderer(window) :
nullptr;
68 if (renderer ==
nullptr)
return;
70 SDL_RenderGetLogicalSize(renderer, &w, &h);
71 if (w <= 0 || h <= 0)
return;
73 SDL_RenderWindowToLogical(renderer, x, y, &lx, &ly);
74 x = lx < 0 ? 0 : lx >= w ? w - 1 :
static_cast<
int>(lx);
75 y = ly < 0 ? 0 : ly >= h ? h - 1 :
static_cast<
int>(ly);
Maps the desktop mouse to a TouchDriver, for exercising touch-driven UI (buttons, sliders,...
Definition: TouchDriverSDL.h:28
bool isTouched() override
Return whether the panel currently appears touched.
Definition: TouchDriverSDL.h:37
bool getPoint(Point &outPoint) override
Read the current touch point.
Definition: TouchDriverSDL.h:55
static void windowToDisplay(int &x, int &y)
Definition: TouchDriverSDL.h:64
bool begin() override
Initialize the controller.
Definition: TouchDriverSDL.h:32
Base class for touch controllers.
Definition: TouchDriverCommon.h:72
Point mapCoordinates(int16_t rawX, int16_t rawY, uint16_t pressure=255) const
Convert raw controller coordinates into logical display space.
Definition: TouchDriverCommon.h:208
Definition: DSIBusESP32.h:19
Touch point.
Definition: TouchDriverCommon.h:32