Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(device): SDL is include only when using SDL-related devices #670

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}