MCPcopy Create free account
hub / github.com/cemu-project/Cemu / UpdateSystemMessageQueue

Function UpdateSystemMessageQueue

src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp:500–530  ·  view source on GitHub ↗

called at the beginning of OSReceiveMessage if the queue is the system message queue

Source from the content-addressed store, hash-verified

498
499 // called at the beginning of OSReceiveMessage if the queue is the system message queue
500 void UpdateSystemMessageQueue()
501 {
502 if(!OSIsInterruptEnabled())
503 return;
504 cemu_assert_debug(!__OSHasSchedulerLock());
505 // normally syscall 0x2E is used to get the next message
506 // for now we just have some preliminary logic here to allow a fake transition to background & foreground
507 if(s_transitionToBackground)
508 {
509 // add transition to background message
510 OSMessage msg{};
511 msg.data0 = stdx::to_underlying(SysMessageId::MsgReleaseForeground);
512 msg.data1 = 0; // 1 -> System is shutting down 0 -> Begin transitioning to background
513 OSMessageQueue* systemMessageQueue = coreinit::OSGetSystemMessageQueue();
514 if(OSSendMessage(systemMessageQueue, &msg, 0))
515 s_transitionToBackground = false;
516 return;
517 }
518 if(s_transitionToForeground)
519 {
520 // add transition to foreground message
521 OSMessage msg{};
522 msg.data0 = stdx::to_underlying(SysMessageId::MsgAcquireForeground);
523 msg.data1 = 1; // ?
524 msg.data2 = 1; // ?
525 OSMessageQueue* systemMessageQueue = coreinit::OSGetSystemMessageQueue();
526 if(OSSendMessage(systemMessageQueue, &msg, 0))
527 s_transitionToForeground = false;
528 return;
529 }
530 }
531
532 // called when OSReceiveMessage returns a message from the system message queue
533 void HandleReceivedSystemMessage(OSMessage* msg)

Callers 1

OSReceiveMessageFunction · 0.85

Calls 6

OSIsInterruptEnabledFunction · 0.85
cemu_assert_debugFunction · 0.85
__OSHasSchedulerLockFunction · 0.85
OSGetSystemMessageQueueFunction · 0.85
OSSendMessageFunction · 0.85
to_underlyingFunction · 0.50

Tested by

no test coverage detected