MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / processCustomEvents

Method processCustomEvents

platform/sdl/knativeinputSDL.cpp:507–542  ·  view source on GitHub ↗

return true to continue processing for custom handlers should only call on main thread

Source from the content-addressed store, hash-verified

505//
506// should only call on main thread
507void KNativeInputSDL::processCustomEvents(std::function<bool(bool isKeyDown, int key, bool isF11)> onKey, std::function<bool(bool isButtonDown, int button, int x, int y)> onMouseButton, std::function<bool(int x, int y)> onMouseMove) {
508 SDL_Event e = {};
509
510#ifdef _DEBUG
511 if (!isMainthread()) {
512 kpanic("KNativeInputSDL::processCustomEvents should only be called on main thread");
513 }
514#endif
515 while (SDL_WaitEvent(&e)) {
516 if (e.type == SDL_KEYUP) {
517 if (!onKey(false, e.key.keysym.sym, e.key.keysym.sym == SDLK_F11)) {
518 return;
519 }
520 } else if (e.type == SDL_MOUSEBUTTONDOWN) {
521 if (!onMouseButton(true, getMouseButtonFromEvent(&e), e.motion.x, e.motion.y)) {
522 return;
523 }
524 } else if (e.type == SDL_MOUSEBUTTONUP) {
525 if (!onMouseButton(false, getMouseButtonFromEvent(&e), e.motion.x, e.motion.y)) {
526 return;
527 }
528 } else if (e.type == SDL_MOUSEMOTION) {
529 if (!onMouseMove(e.motion.x, e.motion.y)) {
530 return;
531 }
532 }
533#ifdef BOXEDWINE_MULTI_THREADED
534 else if (e.type == sdlCustomEvent) {
535 SdlCallback* callback = (SdlCallback*)e.user.data1;
536 callback->result = (U32)callback->pfn();
537 BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(callback->cond);
538 BOXEDWINE_CONDITION_SIGNAL(callback->cond);
539 }
540#endif
541 }
542}
543
544bool KNativeInputSDL::handlSdlEvent(SDL_Event* e) {
545#ifdef BOXEDWINE_RECORDER

Callers 1

takeScreenShotMethod · 0.80

Calls 5

kpanicFunction · 0.85
SDL_WaitEventFunction · 0.85
getMouseButtonFromEventFunction · 0.85
onMouseMoveFunction · 0.85
isMainthreadFunction · 0.50

Tested by

no test coverage detected