ESPHome  2024.10.2
sdl_touchscreen.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_HOST
4 #include "../sdl_esphome.h"
6 
7 namespace esphome {
8 namespace sdl {
9 
10 class SdlTouchscreen : public touchscreen::Touchscreen, public Parented<Sdl> {
11  public:
12  void setup() override {
13  this->x_raw_max_ = this->display_->get_width();
14  this->y_raw_max_ = this->display_->get_height();
15  }
16 
17  void update_touches() override {
18  if (this->parent_->mouse_down) {
19  add_raw_touch_position_(0, this->parent_->mouse_x, this->parent_->mouse_y);
20  }
21  }
22 };
23 
24 } // namespace sdl
25 } // namespace esphome
26 #endif
virtual int get_width()
Get the calculated width of the display in pixels with rotation applied.
Definition: display.h:216
virtual int get_height()
Get the calculated height of the display in pixels with rotation applied.
Definition: display.h:218
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
Definition: touchscreen.cpp:74
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Helper class to easily give an object a parent of type T.
Definition: helpers.h:521