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
@ -13,7 +13,7 @@
|
|||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#ifndef MONITOR_ZOOM
|
#ifndef MONITOR_ZOOM
|
||||||
#define MONITOR_ZOOM 1
|
#define MONITOR_ZOOM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@ -28,8 +28,8 @@
|
|||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
static bool left_button_down = false;
|
static bool left_button_down = false;
|
||||||
static int16_t last_x = 0;
|
static int16_t last_x = 0;
|
||||||
static int16_t last_y = 0;
|
static int16_t last_y = 0;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
@ -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
|
||||||
@ -53,14 +51,14 @@ void mouse_init(void)
|
|||||||
* @param data store the mouse data here
|
* @param data store the mouse data here
|
||||||
* @return false: because the points are not buffered, so no more data to be read
|
* @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*/
|
/*Store the collected data*/
|
||||||
data->point.x = last_x;
|
data->point.x = last_x;
|
||||||
data->point.y = last_y;
|
data->point.y = last_y;
|
||||||
data->state = left_button_down ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
|
data->state = left_button_down ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -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
|
* 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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user