mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Allow stretched window for fullscreen
This commit is contained in:
parent
94842f7036
commit
ea7d3757ad
@ -43,9 +43,7 @@ static int16_t last_y = 0;
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* Get the current position and state of the mouse
|
||||
@ -53,9 +51,9 @@ void mouse_init(void)
|
||||
* @param data store the mouse data here
|
||||
* @return false: because the points are not buffered, so no more data to be read
|
||||
*/
|
||||
bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
bool mouse_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data)
|
||||
{
|
||||
(void) indev_drv; /*Unused*/
|
||||
(void)indev_drv; /*Unused*/
|
||||
|
||||
/*Store the collected data*/
|
||||
data->point.x = last_x;
|
||||
@ -68,27 +66,31 @@ bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
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) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if(event->button.button == SDL_BUTTON_LEFT)
|
||||
left_button_down = false;
|
||||
if(event->button.button == SDL_BUTTON_LEFT) left_button_down = false;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if(event->button.button == SDL_BUTTON_LEFT) {
|
||||
left_button_down = true;
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
if(x != 0) last_x = event->motion.x * TFT_WIDTH / x; // / MONITOR_ZOOM;
|
||||
if(y != 0) last_y = event->motion.y * TFT_HEIGHT / y; // / MONITOR_ZOOM;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
if(x != 0) last_x = event->motion.x * TFT_WIDTH / x; // / MONITOR_ZOOM;
|
||||
if(y != 0) last_y = event->motion.y * TFT_HEIGHT / y; // / MONITOR_ZOOM;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
Loading…
x
Reference in New Issue
Block a user