diff options
Diffstat (limited to 'hal/sdl2/display.cpp')
-rw-r--r-- | hal/sdl2/display.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/hal/sdl2/display.cpp b/hal/sdl2/display.cpp index ecb6870..64b92cd 100644 --- a/hal/sdl2/display.cpp +++ b/hal/sdl2/display.cpp @@ -1,5 +1,4 @@ #ifdef SDL2_BUILD -#include <SDL.h> #include "display.hpp" #include "../../buttons.hpp" #include <iostream> @@ -11,7 +10,7 @@ SDLDisplay::SDLDisplay() { SDL_Init(SDL_INIT_VIDEO); SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); /* scale here to make the window larger than the surface itself. - Int*eger scalings only as set by function below. */ + Integer scalings only as set by function below. */ m_window = SDL_CreateWindow("SDL2 pico-watch build", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (m_window == nullptr) { @@ -31,7 +30,7 @@ SDLDisplay::SDLDisplay() { const int height = SCREEN_HEIGHT; /* Since we are going to display a low resolution buffer, - i t i*s best to limit the window size so that it cannot be + it's best to limit the window size so that it cannot be smaller than our internal buffer size. */ SDL_SetWindowMinimumSize(m_window, width, height); SDL_RenderSetLogicalSize(m_renderer, width, height); @@ -44,9 +43,7 @@ SDLDisplay::SDLDisplay() { SDL_SetPaletteColors(m_surface->format->palette, colors, 0, 2); } -bool SDLDisplay::update_display(const uint8_t* oled_screen) { - if (m_should_quit) return true; - +bool SDLDisplay::process_input() { SDL_Event e; while (SDL_PollEvent(&e) != 0) { switch (e.type) { @@ -61,7 +58,10 @@ bool SDLDisplay::update_display(const uint8_t* oled_screen) { break; } } + return m_should_quit; +} +bool SDLDisplay::update_display(const uint8_t* oled_screen) { // NOTE: hardcoded display size (might be fine, see todo.md and oledWriteDataBlock in ss_oled.c) // memcpy(m_surface->pixels, oled_screen, (size_t)(128*8)); convert_display(oled_screen); @@ -110,6 +110,7 @@ void SDLDisplay::convert_display(const uint8_t* in) { } } +// Get the GPIO pin number corresponding to the button that has been pressed uint SDLDisplay::get_button(SDL_Keycode key) { switch (key) { case SDLK_w: |