Update SDLDisplay so it finds the window based on events that way it works on windows and Ubuntu
This commit is contained in:
parent
af7abe115f
commit
ddbfc13e55
2 changed files with 41 additions and 39 deletions
|
@ -9,23 +9,19 @@ std::shared_ptr<SDLDisplay> SDLDisplay::getInstance(){
|
|||
return std::static_pointer_cast<SDLDisplay>(mInstance);
|
||||
}
|
||||
|
||||
void SDLDisplay::setBrightness(uint8_t brightness){
|
||||
mBrightness = brightness;
|
||||
}
|
||||
void SDLDisplay::setBrightness(uint8_t brightness) { mBrightness = brightness; }
|
||||
|
||||
uint8_t SDLDisplay::getBrightness(){
|
||||
return mBrightness;
|
||||
}
|
||||
uint8_t SDLDisplay::getBrightness() { return mBrightness; }
|
||||
|
||||
void SDLDisplay::turnOff(){
|
||||
void SDLDisplay::turnOff() {}
|
||||
|
||||
}
|
||||
|
||||
void SDLDisplay::flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p){
|
||||
void SDLDisplay::flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area,
|
||||
lv_color_t *color_p) {
|
||||
sdl_display_flush(disp, area, color_p);
|
||||
}
|
||||
|
||||
void SDLDisplay::screenInput(lv_indev_drv_t *indev_driver, lv_indev_data_t *data){
|
||||
void SDLDisplay::screenInput(lv_indev_drv_t *indev_driver,
|
||||
lv_indev_data_t *data) {
|
||||
sdl_mouse_read(indev_driver, data);
|
||||
}
|
||||
|
||||
|
@ -35,5 +31,9 @@ void SDLDisplay::setTitle(std::string aNewTitle){
|
|||
|
||||
SDLDisplay::SDLDisplay() : DisplayAbstract() {
|
||||
sdl_init();
|
||||
mSimWindow = SDL_GetWindowFromID(1); // Get the SDL window via ID hopefully it is always 1...
|
||||
|
||||
// Get the SDL window via an event
|
||||
SDL_Event aWindowIdFinder;
|
||||
SDL_PollEvent(&aWindowIdFinder);
|
||||
mSimWindow = SDL_GetWindowFromID(aWindowIdFinder.window.windowID);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "SDL2/SDL.h"
|
||||
#include "DisplayAbstract.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class SDLDisplay : public DisplayAbstract {
|
||||
|
||||
|
@ -15,8 +15,10 @@ public:
|
|||
void setTitle(std::string aNewTitle);
|
||||
|
||||
protected:
|
||||
virtual void flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) override;
|
||||
virtual void screenInput(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) override;
|
||||
virtual void flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area,
|
||||
lv_color_t *color_p) override;
|
||||
virtual void screenInput(lv_indev_drv_t *indev_driver,
|
||||
lv_indev_data_t *data) override;
|
||||
|
||||
private:
|
||||
SDLDisplay();
|
||||
|
|
Loading…
Add table
Reference in a new issue