Allow stretched window for fullscreen

This commit is contained in:
fvanroie 2021-02-20 01:56:55 +01:00
parent 94842f7036
commit ea7d3757ad

View File

@ -43,9 +43,7 @@ static int16_t last_y = 0;
* Initialize the mouse * Initialize the mouse
*/ */
void mouse_init(void) void mouse_init(void)
{ {}
}
/** /**
* Get the current position and state of the mouse * Get the current position and state of the mouse
@ -70,25 +68,29 @@ bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
*/ */
void mouse_handler(SDL_Event* event) void mouse_handler(SDL_Event* event)
{ {
int x;
int y;
SDL_Window* window = SDL_GetWindowFromID(event->window.windowID);
SDL_GetWindowSize(window, &x, &y);
switch(event->type) { switch(event->type) {
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
if(event->button.button == SDL_BUTTON_LEFT) if(event->button.button == SDL_BUTTON_LEFT) left_button_down = false;
left_button_down = false;
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if(event->button.button == SDL_BUTTON_LEFT) { if(event->button.button == SDL_BUTTON_LEFT) {
left_button_down = true; left_button_down = true;
last_x = event->motion.x / MONITOR_ZOOM; if(x != 0) last_x = event->motion.x * TFT_WIDTH / x; // / MONITOR_ZOOM;
last_y = event->motion.y / MONITOR_ZOOM; if(y != 0) last_y = event->motion.y * TFT_HEIGHT / y; // / MONITOR_ZOOM;
} }
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
last_x = event->motion.x / MONITOR_ZOOM; if(x != 0) last_x = event->motion.x * TFT_WIDTH / x; // / MONITOR_ZOOM;
last_y = event->motion.y / MONITOR_ZOOM; if(y != 0) last_y = event->motion.y * TFT_HEIGHT / y; // / MONITOR_ZOOM;
break; break;
} }
} }
/********************** /**********************