Skip to content

Commit

Permalink
fix(device): SDL is include only when using SDL-related devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Anzooooo committed Nov 22, 2024
1 parent b9507fb commit 21c6893
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <utils.h>
#ifndef CONFIG_SHARE
#include <device/alarm.h>
#if defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
#include <SDL2/SDL.h>
#endif // defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
#endif // CONFIG_SHARE

void init_serial();
Expand Down Expand Up @@ -54,6 +56,7 @@ void device_update() {
IFDEF(CONFIG_HAS_VGA, vga_update_screen());

#ifndef CONFIG_SHARE
#if defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
Expand All @@ -69,18 +72,21 @@ void device_update() {
send_key(k, is_keydown);
break;
}
#endif
#endif // CONFIG_HAS_KEYBOARD
default: break;
}
}
#endif
#endif // defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
#endif // CONFIG_SHARE
}

void sdl_clear_event_queue() {
#ifndef CONFIG_SHARE
#if defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
SDL_Event event;
while (SDL_PollEvent(&event));
#endif
#endif // defined(CONFIG_HAS_AUDIO) || defined(CONFIG_HAS_VGA) || defined(CONFIG_HAS_KEYBOARD)
#endif // CONFIG_SHARE
}

void init_device() {
Expand All @@ -97,10 +103,7 @@ void init_device() {
IFDEF(CONFIG_HAS_FLASH, init_flash());
#ifndef CONFIG_SHARE
IFDEF(CONFIG_HAS_FLASH, load_flash_contents(CONFIG_FLASH_IMG_PATH));
#endif

#ifndef CONFIG_SHARE
add_alarm_handle(set_device_update_flag);
init_alarm();
#endif
#endif // CONFIG_SHARE
}

0 comments on commit 21c6893

Please sign in to comment.