Implement platform_setBacklightLevel for linux

pull/63/head
Alessio Caiazza 2021-12-07 21:50:23 +01:00 zatwierdzone przez Silvano Seva
rodzic 6e3fda2a70
commit ade9c47f71
3 zmienionych plików z 22 dodań i 4 usunięć

Wyświetl plik

@ -385,6 +385,7 @@ layout_t _ui_calculateLayout()
void ui_init()
{
last_event_tick = getTick();
redraw_needed = true;
layout = _ui_calculateLayout();
layout_ready = true;

Wyświetl plik

@ -32,6 +32,8 @@ SDL_Texture *displayTexture;
/* Custom SDL Event to request a screenshot */
Uint32 SDL_Screenshot_Event;
/* Custom SDL Event to change backlight */
Uint32 SDL_Backlight_Event;
/*
* Mutex protected variables
@ -338,6 +340,11 @@ void sdl_task()
screenshot_display(filename);
free(ev.user.data1);
}
else if (ev.type == SDL_Backlight_Event)
{
set_brightness(*((uint8_t*)ev.user.data1));
free(ev.user.data1);
}
}
// we update the window only if there is a something ready to render
@ -353,7 +360,6 @@ void sdl_task()
}
chan_send(&fb_sync, pixels);
set_brightness(state.settings.brightness);
chan_recv(&fb_sync, NULL);
SDL_UnlockTexture(displayTexture);
@ -376,8 +382,9 @@ void init_sdl()
exit(1);
}
// Register an SDL custom event type to handle screenshot requests
SDL_Screenshot_Event = SDL_RegisterEvents(1);
// Register SDL custom events to handle screenshot requests and backlight
SDL_Screenshot_Event = SDL_RegisterEvents(2);
SDL_Backlight_Event = SDL_Screenshot_Event+1;
chan_init(&fb_sync);

Wyświetl plik

@ -22,6 +22,9 @@
#include "emulator.h"
#include <SDL2/SDL.h>
/* Custom SDL Event to adjust backlight */
extern Uint32 SDL_Backlight_Event;
hwInfo_t hwInfo;
void platform_init()
@ -51,7 +54,14 @@ void platform_terminate()
void platform_setBacklightLevel(uint8_t level)
{
(void) level;
SDL_Event e;
SDL_zero(e);
e.type = SDL_Backlight_Event;
e.user.data1 = malloc(sizeof(uint8_t));
uint8_t *data = (uint8_t *)e.user.data1;
*data = level;
SDL_PushEvent(&e);
}
// Simulate a fully charged lithium battery