MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sdl_loop

Function sdl_loop

bsp/simulator/drivers/sdl_fb.c:256–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254static pthread_cond_t sdl_ok_event;
255
256static void *sdl_loop(void *lpParam)
257#endif
258{
259 int quit = 0;
260 SDL_Event event;
261 int state = 0;
262 rt_device_t device;
263 int timeout = 1000000;
264
265 int last_x = -1, last_y = -1;
266
267 int motion_x, motion_y;
268 int motion_button = 0;
269 int motion_tick = 50;
270
271 int mouse_id = 1;
272
273#ifndef _WIN32
274 sigset_t sigmask, oldmask;
275 /* set the getchar without buffer */
276 sigfillset(&sigmask);
277 pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
278 pthread_mutex_lock(&sdl_ok_mutex);
279#endif
280
281 sdlfb_hw_init();
282
283 device = rt_device_find("sdl");
284 RT_ASSERT(device);
285 rtgui_graphic_set_device(device);
286#ifdef _WIN32
287 SetEvent(sdl_ok_event);
288#else
289 pthread_cond_signal(&sdl_ok_event);
290 pthread_mutex_unlock(&sdl_ok_mutex);
291#endif
292 /* handle SDL event */
293 while (!quit)
294 {
295 if (motion_button & RTGUI_MOUSE_BUTTON_DOWN)
296 {
297 timeout = motion_tick - SDL_GetTicks();
298 }
299 else
300 {
301 timeout = 1000 * 1000;
302 }
303
304 int tick = SDL_GetTicks();
305 SDL_WaitEventTimeout(&event, timeout);
306 if (SDL_GetTicks() >= motion_tick && (motion_button & RTGUI_MOUSE_BUTTON_DOWN)) /* whether timeout */
307 {
308 /* sendout motion event */
309 struct rtgui_event_mouse emouse;
310
311 emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
312 emouse.parent.sender = RT_NULL;
313 emouse.wid = RT_NULL;

Callers

nothing calls this directly

Calls 8

pthread_sigmaskFunction · 0.85
pthread_mutex_lockFunction · 0.85
sdlfb_hw_initFunction · 0.85
rt_device_findFunction · 0.85
pthread_cond_signalFunction · 0.85
pthread_mutex_unlockFunction · 0.85
rt_tick_getFunction · 0.85
rt_hw_exitFunction · 0.85

Tested by

no test coverage detected