72089f74f3
- Run SDL from main() and place FreeRTOS in separate thread. This fixes macOS support. - Updated GitHub Actions to publish macOS simulator build for testing, updated amd64 to x86_64 for consistent naming.
58 lines
1.7 KiB
C
58 lines
1.7 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief Latest pointer (mouse) state as tracked by sdl_input_pump().
|
|
*/
|
|
struct SdlPointerState {
|
|
int32_t x;
|
|
int32_t y;
|
|
bool pressed;
|
|
};
|
|
|
|
/**
|
|
* @brief Drains all pending SDL events exactly once, updating the pointer state and key queue
|
|
* below. Must be called only from the real OS main thread (sdl_bridge_run_main_loop()): SDL
|
|
* requires event pumping to happen there on macOS. The getters below are safe to call from a
|
|
* different thread (the lvgl task, via sdl-pointer/sdl-keyboard's polling functions).
|
|
*/
|
|
void sdl_input_pump(void);
|
|
|
|
/**
|
|
* @brief Gets the pointer state as of the most recent sdl_input_pump() call.
|
|
*/
|
|
void sdl_input_get_pointer_state(struct SdlPointerState* out_state);
|
|
|
|
/**
|
|
* @brief Pops the next queued key event (produced by SDL_KEYDOWN/SDL_TEXTINPUT during
|
|
* sdl_input_pump()).
|
|
* @retval false when no key event is pending
|
|
*/
|
|
bool sdl_input_pop_key(uint32_t* out_key);
|
|
|
|
/**
|
|
* @brief Returns true if another key event is queued after the one just popped.
|
|
*/
|
|
bool sdl_input_has_queued_key(void);
|
|
|
|
/**
|
|
* @brief Web-injected touch override (for headless sim viewer without SDL window).
|
|
* When active, sdl_pointer_get_touched_points() reports this state instead of
|
|
* the SDL mouse state. Coordinates are in LVGL logical pixels (e.g. 640x480).
|
|
* Pass pressed=false to release. Auto-releases after SIM_TOUCH_HOLD_MS unless
|
|
* refreshed (tap = press, wait, release handled by the web viewer).
|
|
*/
|
|
void sdl_input_set_touch_override(int32_t x, int32_t y, bool pressed);
|
|
void sdl_input_clear_touch_override(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|