void DSPDebuggerLLE::Repopulate() { if (!wxIsMainThread()) wxMutexGuiEnter(); UpdateSymbolMap(); UpdateDisAsmListView(); UpdateRegisterFlags(); UpdateState(); if (!wxIsMainThread()) wxMutexGuiLeave(); }
void DSPDebuggerLLE::Update() { #if defined __WXGTK__ if (!wxIsMainThread()) wxMutexGuiEnter(); #endif UpdateSymbolMap(); UpdateDisAsmListView(); UpdateRegisterFlags(); UpdateState(); #if defined __WXGTK__ if (!wxIsMainThread()) wxMutexGuiLeave(); #endif }
void CFrame::GetRenderWindowSize(int& x, int& y, int& width, int& height) { #ifdef __WXGTK__ if (!wxIsMainThread()) wxMutexGuiEnter(); #endif wxRect client_rect = m_RenderParent->GetClientRect(); width = client_rect.width; height = client_rect.height; x = client_rect.x; y = client_rect.y; #ifdef __WXGTK__ if (!wxIsMainThread()) wxMutexGuiLeave(); #endif }
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/) { #ifdef __WXGTK__ if (wxIsMainThread()) { #endif NetPlayDialog*& npd = NetPlayDialog::GetInstance(); if (npd != nullptr && npd->IsShown()) { npd->AppendChat("/!\\ " + std::string{text}); return true; } return wxYES == wxMessageBox(StrToWxStr(text), StrToWxStr(caption), (yes_no) ? wxYES_NO : wxOK, wxWindow::FindFocus()); #ifdef __WXGTK__ } else { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC); event.SetString(StrToWxStr(caption) + ":" + StrToWxStr(text)); event.SetInt(yes_no); main_frame->GetEventHandler()->AddPendingEvent(event); main_frame->panic_event.Wait(); return main_frame->bPanicResult; } #endif }
void log(agi::log::SinkMessage *sm) override { #ifndef _WIN32 tm tmtime; localtime_r(&sm->tv.tv_sec, &tmtime); auto log = wxString::Format("%c %02d:%02d:%02d %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], (int)tmtime.tm_hour, (int)tmtime.tm_min, (int)tmtime.tm_sec, (long)sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, to_wx(sm->message)); #else auto log = wxString::Format("%c %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, to_wx(sm->message)); #endif if (wxIsMainThread()) text_ctrl->AppendText(log); else agi::dispatch::Main().Async([=]{ text_ctrl->AppendText(log); }); }
void COptions::ContinueSetOption(unsigned int nID, T const& value) { T validated = Validate(nID, value); { scoped_lock l(m_sync_); if (m_optionsCache[nID] == validated) { // Nothing to do return; } m_optionsCache[nID] = validated; } // Fixme: Setting options from other threads if (!wxIsMainThread()) return; if (options[nID].flags == normal || options[nID].flags == default_priority) { SetXmlValue(nID, validated); if (!m_save_timer.IsRunning()) m_save_timer.Start(15000, true); } if (changedOptions_.none()) { CallAfter(&COptions::NotifyChangedOptions); } changedOptions_.set(nID); }
DWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread, int flags) { // We only ever dispatch messages from the main thread and, additionally, // even from the main thread we shouldn't wait for the message if we don't // have a running event loop as we would never remove them from the message // queue then and so we would enter an infinite loop as // MsgWaitForMultipleObjects() keeps returning WAIT_OBJECT_0 + 1. if ( flags == wxTHREAD_WAIT_BLOCK || !wxIsMainThread() || !wxEventLoop::GetActive() ) { // Simple blocking wait. return DoSimpleWaitForThread(hThread); } return ::MsgWaitForMultipleObjects ( 1, // number of objects to wait for (HANDLE *)&hThread, // the objects false, // wait for any objects, not all INFINITE, // no timeout QS_ALLINPUT | // return as soon as there are any events QS_ALLPOSTMESSAGE ); }
void wxSockAddress::Init() { if ( wxIsMainThread() && !wxSocketBase::IsInitialized() ) { // we must do it before using any socket functions (void)wxSocketBase::Initialize(); } }
bool Host_GetKeyState(int keycode) { #ifdef _WIN32 return (0 != GetAsyncKeyState(keycode)); #elif defined __WXGTK__ std::unique_lock<std::recursive_mutex> lk(main_frame->keystate_lock, std::try_to_lock); if (!lk.owns_lock()) return false; bool key_pressed; if (!wxIsMainThread()) wxMutexGuiEnter(); key_pressed = wxGetKeyState(wxKeyCode(keycode)); if (!wxIsMainThread()) wxMutexGuiLeave(); return key_pressed; #else return wxGetKeyState(wxKeyCode(keycode)); #endif }
bool wxGUIAppTraits::ShowAssertDialog(const wxString& msg) { #if wxDEBUG_LEVEL // we can't show the dialog from another thread if ( wxIsMainThread() ) { // under GTK2 we prefer to use a dialog widget written using directly // in GTK+ as use a dialog written using wxWidgets would need the // wxWidgets idle processing to work correctly which might not be the // case when assert happens GtkWidget *dialog = gtk_assert_dialog_new(); gtk_assert_dialog_set_message(GTK_ASSERT_DIALOG(dialog), msg.mb_str()); #if wxUSE_STACKWALKER // save the current stack ow... StackDump dump(GTK_ASSERT_DIALOG(dialog)); dump.SaveStack(100); // showing more than 100 frames is not very useful // ...but process it only if the user needs it gtk_assert_dialog_set_backtrace_callback ( GTK_ASSERT_DIALOG(dialog), (GtkAssertDialogStackFrameCallback)get_stackframe_callback, &dump ); #endif // wxUSE_STACKWALKER gint result = gtk_dialog_run(GTK_DIALOG (dialog)); bool returnCode = false; switch (result) { case GTK_ASSERT_DIALOG_STOP: wxTrap(); break; case GTK_ASSERT_DIALOG_CONTINUE: // nothing to do break; case GTK_ASSERT_DIALOG_CONTINUE_SUPPRESSING: // no more asserts returnCode = true; break; default: wxFAIL_MSG( wxT("unexpected return code from GtkAssertDialog") ); } gtk_widget_destroy(dialog); return returnCode; } #endif // wxDEBUG_LEVEL return wxAppTraitsBase::ShowAssertDialog(msg); }
bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg) { #if wxDEBUG_LEVEL // under MSW we prefer to use the base class version using ::MessageBox() // even if wxMessageBox() is available because it has less chances to // double fault our app than our wxMessageBox() // // under DFB the message dialog is not always functional right now // // and finally we can't use wxMessageBox() if it wasn't compiled in, of // course #if !defined(__WXMSW__) && !defined(__WXDFB__) && wxUSE_MSGDLG // we can't (safely) show the GUI dialog from another thread, only do it // for the asserts in the main thread if ( wxIsMainThread() ) { wxString msgDlg = msg; #if wxUSE_STACKWALKER const wxString stackTrace = GetAssertStackTrace(); if ( !stackTrace.empty() ) msgDlg << wxT("\n\nCall stack:\n") << stackTrace; #endif // wxUSE_STACKWALKER // this message is intentionally not translated -- it is for // developpers only msgDlg += wxT("\nDo you want to stop the program?\n") wxT("You can also choose [Cancel] to suppress ") wxT("further warnings."); switch ( wxMessageBox(msgDlg, wxT("wxWidgets Debug Alert"), wxYES_NO | wxCANCEL | wxICON_STOP ) ) { case wxYES: wxTrap(); break; case wxCANCEL: // no more asserts return true; //case wxNO: nothing to do } return false; } #endif // wxUSE_MSGDLG #endif // wxDEBUG_LEVEL return wxAppTraitsBase::ShowAssertDialog(msg); }
void wxGISProgressor::SetRange(int range) { if(wxIsMainThread()) { wxGauge::SetRange(range); } else { wxCommandEvent ValueEvent( wxEVT_COMMAND_BUTTON_CLICKED ); // Keep it simple, don't give a specific event ID ValueEvent.SetId(RANGE_ID); ValueEvent.SetInt(range); wxPostEvent(this, ValueEvent); } }
void dc_gui_chatpanel::WriteToRichText(std::string msg, wxColour col) { if (!wxIsMainThread()) wxMutexGuiEnter(); txtMain->Freeze(); txtMain->SetCaretPosition(txtMain->GetLastPosition() - 1); size_t before_number_of_lines = txtMain->GetNumberOfLines(); txtMain->Newline(); txtMain->BeginTextColour(col); txtMain->WriteText(msg); txtMain->EndTextColour(); size_t after_number_of_lines = txtMain->GetNumberOfLines(); txtMain->Thaw(); txtMain->ScrollLines(txtMain->GetNumberOfLines()); if (!wxIsMainThread()) wxMutexGuiLeave(); }
void AudacityLogger::DoLogText(const wxString & str) { if (!wxIsMainThread()) { wxMutexGuiEnter(); } if (mBuffer.IsEmpty()) { wxString stamp; TimeStamp(&stamp); mBuffer << stamp << wxT("Audacity ") << AUDACITY_VERSION_STRING << wxT("\n"); } mBuffer << str << wxT("\n"); mUpdated = true; Flush(); if (!wxIsMainThread()) { wxMutexGuiLeave(); } }
void WxTerminateMessage::OnAssert( const Properties &, const Result &result) const { // We only show this in the main thread, although we could use // wxMutexGuiEnter and wxMutexGuiLeave, because wxMutexGuiLeave // can take a long time after wxMessageBox. if (wxIsMainThread()) { wxString msg = GetText(); if (result.GetParameterList()) msg += "\n"+RichBool::ToString(*result.GetParameterList()); wxMessageBox(msg, "ModAssert"); } }
void wxGISProgressor::Play(void) { if(wxIsMainThread()) { wxGauge::Pulse(); if(m_bYield) ::wxSafeYield(NULL, true); } else { //send message to itself wxCommandEvent ValueEvent( wxEVT_COMMAND_BUTTON_CLICKED ); // Keep it simple, don't give a specific event ID ValueEvent.SetId(PULSE_ID); wxPostEvent(this, ValueEvent); } }
bool wxGISProgressor::ShowProgress(bool bShow) { if(wxIsMainThread()) { return Show(bShow); } else { wxCommandEvent ValueEvent( wxEVT_COMMAND_BUTTON_CLICKED ); // Keep it simple, don't give a specific event ID ValueEvent.SetId(SHOW_ID); ValueEvent.SetInt(bShow); wxPostEvent(this, ValueEvent); return true; } }
WXDWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread, int flags) { // We only ever dispatch messages from the main thread and, additionally, // even from the main thread we shouldn't wait for the message if we don't // have a running event loop as we would never remove them from the message // queue then and so we would enter an infinite loop as // MsgWaitForMultipleObjects() keeps returning WAIT_OBJECT_0 + 1. if ( flags == wxTHREAD_WAIT_YIELD && wxIsMainThread() ) { wxMSWEventLoopBase* const evtLoop = static_cast<wxMSWEventLoopBase *>(wxEventLoop::GetActive()); if ( evtLoop ) return evtLoop->MSWWaitForThread(hThread); } // Simple blocking wait. return DoSimpleWaitForThread(hThread); }
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/) { #ifdef __WXGTK__ if (wxIsMainThread()) #endif return wxYES == wxMessageBox(StrToWxStr(text), StrToWxStr(caption), (yes_no) ? wxYES_NO : wxOK, wxWindow::FindFocus()); #ifdef __WXGTK__ else { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC); event.SetString(StrToWxStr(caption) + ":" + StrToWxStr(text)); event.SetInt(yes_no); main_frame->GetEventHandler()->AddPendingEvent(event); main_frame->panic_event.Wait(); return main_frame->bPanicResult; } #endif }
void wxGISProgressor::SetValue(int value) { if(GetRange() < value) return; m_nValue = value; if(wxIsMainThread()) { wxGauge::SetValue(value); if(m_bYield) ::wxSafeYield(NULL, true); } else { //send message to itself wxCommandEvent ValueEvent( wxEVT_COMMAND_BUTTON_CLICKED ); // Keep it simple, don't give a specific event ID ValueEvent.SetId(SETVALUE_ID); ValueEvent.SetInt(value); wxPostEvent(this, ValueEvent); } }
int wxMessageDialog::ShowModal() { int resultbutton = wxID_CANCEL; const long style = GetMessageDialogStyle(); wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") ); AlertType alertType = kAlertPlainAlert; if (style & wxICON_EXCLAMATION) alertType = kAlertCautionAlert; else if (style & wxICON_HAND) alertType = kAlertStopAlert; else if (style & wxICON_INFORMATION) alertType = kAlertNoteAlert; else if (style & wxICON_QUESTION) alertType = kAlertNoteAlert; #if TARGET_API_MAC_OSX if ( !wxIsMainThread() ) { CFStringRef defaultButtonTitle = NULL; CFStringRef alternateButtonTitle = NULL; CFStringRef otherButtonTitle = NULL; wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() ); wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() ); wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() ); wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() ); wxMacCFStringHolder cfOKString( _("OK") , m_font.GetEncoding()) ; wxMacCFStringHolder cfCancelString( _("Cancel"), m_font.GetEncoding() ); int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ }; if (style & wxYES_NO) { if ( style & wxNO_DEFAULT ) { defaultButtonTitle = cfNoString; alternateButtonTitle = cfYesString; buttonId[0] = wxID_NO; buttonId[1] = wxID_YES; } else { defaultButtonTitle = cfYesString; alternateButtonTitle = cfNoString; buttonId[0] = wxID_YES; buttonId[1] = wxID_NO; } if (style & wxCANCEL) { otherButtonTitle = cfCancelString; buttonId[2] = wxID_CANCEL; } } else { // the MSW implementation even shows an OK button if it is not specified, we'll do the same buttonId[0] = wxID_OK; // using null as default title does not work on earlier systems defaultButtonTitle = cfOKString; if (style & wxCANCEL) { alternateButtonTitle = cfCancelString; buttonId[1] = wxID_CANCEL; } } CFOptionFlags exitButton; OSStatus err = CFUserNotificationDisplayAlert( 0, alertType, NULL, NULL, NULL, cfTitle, cfText, defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton ); if (err == noErr) resultbutton = buttonId[exitButton]; } else #endif { short result; AlertStdCFStringAlertParamRec param; wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() ); wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() ); wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() ); wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() ); param.movable = true; param.flags = 0; param.version = kStdCFStringAlertVersionOne; bool skipDialog = false; if (style & wxYES_NO) { if (style & wxCANCEL) { param.defaultText = cfYesString; param.cancelText = (CFStringRef) kAlertDefaultCancelText; param.otherText = cfNoString; param.helpButton = false; param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton; param.cancelButton = kAlertStdAlertCancelButton; } else { param.defaultText = cfYesString; param.cancelText = NULL; param.otherText = cfNoString; param.helpButton = false; param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton; param.cancelButton = 0; } } // the MSW implementation even shows an OK button if it is not specified, we'll do the same else { if (style & wxCANCEL) { // that's a cancel missing param.defaultText = (CFStringRef) kAlertDefaultOKText; param.cancelText = (CFStringRef) kAlertDefaultCancelText; param.otherText = NULL; param.helpButton = false; param.defaultButton = kAlertStdAlertOKButton; param.cancelButton = 0; } else { param.defaultText = (CFStringRef) kAlertDefaultOKText; param.cancelText = NULL; param.otherText = NULL; param.helpButton = false; param.defaultButton = kAlertStdAlertOKButton; param.cancelButton = 0; } } param.position = kWindowDefaultPosition; if ( !skipDialog ) { DialogRef alertRef; CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef ); RunStandardAlert( alertRef, NULL, &result ); } else { return wxID_CANCEL; } if (style & wxOK) { switch ( result ) { case 1: resultbutton = wxID_OK; break; case 2: // TODO: add Cancel button // if (style & wxCANCEL) // resultbutton = wxID_CANCEL; break; case 3: default: break; } } else if (style & wxYES_NO) { switch ( result ) { case 1: resultbutton = wxID_YES; break; case 2: if (!(style & wxCANCEL)) resultbutton = wxID_CANCEL; break; case 3: resultbutton = wxID_NO; break; default: break; } } } return resultbutton; }
int wxMessageDialog::ShowModal() { WX_HOOK_MODAL_DIALOG(); int resultbutton = wxID_CANCEL; const long style = GetMessageDialogStyle(); wxASSERT_MSG( (style & 0x3F) != wxYES, "this style is not supported on Mac" ); AlertType alertType = kAlertPlainAlert; switch ( GetEffectiveIcon() ) { case wxICON_ERROR: alertType = kAlertStopAlert; break; case wxICON_WARNING: alertType = kAlertCautionAlert; break; case wxICON_QUESTION: case wxICON_INFORMATION: alertType = kAlertNoteAlert; break; } // (the standard alert has two slots [title, text] // for the three wxStrings [caption, message, extended message]) // // if the extended text is empty we use the caption and // the message (for backwards compatibility) // // if the extended text is not empty we ignore the caption // and use the message and the extended message wxString msgtitle,msgtext; if(m_extendedMessage.IsEmpty()) { if ( m_caption.IsEmpty() ) msgtitle = m_message; else { msgtitle = m_caption; msgtext = m_message; } } else { msgtitle = m_message; msgtext = m_extendedMessage; } if ( !wxIsMainThread() ) { CFStringRef defaultButtonTitle = NULL; CFStringRef alternateButtonTitle = NULL; CFStringRef otherButtonTitle = NULL; wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() ); wxCFStringRef cfText( msgtext, GetFont().GetEncoding() ); wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfOKString( GetOKLabel().c_str() , GetFont().GetEncoding()) ; wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() ); int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ }; if (style & wxYES_NO) { if ( style & wxNO_DEFAULT ) { defaultButtonTitle = cfNoString; alternateButtonTitle = cfYesString; buttonId[0] = wxID_NO; buttonId[1] = wxID_YES; } else { defaultButtonTitle = cfYesString; alternateButtonTitle = cfNoString; buttonId[0] = wxID_YES; buttonId[1] = wxID_NO; } if (style & wxCANCEL) { otherButtonTitle = cfCancelString; buttonId[2] = wxID_CANCEL; } } else { // the MSW implementation even shows an OK button if it is not specified, we'll do the same buttonId[0] = wxID_OK; // using null as default title does not work on earlier systems defaultButtonTitle = cfOKString; if (style & wxCANCEL) { alternateButtonTitle = cfCancelString; buttonId[1] = wxID_CANCEL; } } CFOptionFlags exitButton; OSStatus err = CFUserNotificationDisplayAlert( 0, alertType, NULL, NULL, NULL, cfTitle, cfText, defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton ); if (err == noErr) resultbutton = buttonId[exitButton]; } else { short result; AlertStdCFStringAlertParamRec param; wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfOKString( GetOKLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() ); wxCFStringRef cfText = msgtext.IsEmpty() ? wxCFStringRef() : wxCFStringRef( msgtext, GetFont().GetEncoding() ); param.movable = true; param.flags = 0; param.version = kStdCFStringAlertVersionOne; bool skipDialog = false; if (style & wxYES_NO) { if (style & wxCANCEL) { param.defaultText = cfYesString; param.cancelText = cfCancelString; param.otherText = cfNoString; param.helpButton = false; param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton; param.cancelButton = kAlertStdAlertCancelButton; } else { param.defaultText = cfYesString; param.cancelText = NULL; param.otherText = cfNoString; param.helpButton = false; param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton; param.cancelButton = 0; } } // the MSW implementation even shows an OK button if it is not specified, we'll do the same else { if (style & wxCANCEL) { // that's a cancel missing param.defaultText = cfOKString; param.cancelText = cfCancelString; param.otherText = NULL; param.helpButton = false; param.defaultButton = kAlertStdAlertOKButton; param.cancelButton = 0; } else { param.defaultText = cfOKString; param.cancelText = NULL; param.otherText = NULL; param.helpButton = false; param.defaultButton = kAlertStdAlertOKButton; param.cancelButton = 0; } } param.position = kWindowDefaultPosition; if ( !skipDialog ) { DialogRef alertRef; CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef ); wxDialog::OSXBeginModalDialog(); RunStandardAlert( alertRef, NULL, &result ); wxDialog::OSXEndModalDialog(); } else { return wxID_CANCEL; } if (style & wxOK) { switch ( result ) { case 1: resultbutton = wxID_OK; break; case 2: // TODO: add Cancel button // if (style & wxCANCEL) // resultbutton = wxID_CANCEL; break; case 3: default: break; } } else if (style & wxYES_NO) { switch ( result ) { case 1: resultbutton = wxID_YES; break; case 2: if (!(style & wxCANCEL)) resultbutton = wxID_CANCEL; break; case 3: resultbutton = wxID_NO; break; default: break; } } } SetReturnCode(resultbutton); return resultbutton; }
void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key) { if (!IsShown() || !m_has_layout) return; if (!wxIsMainThread()) { TASWiimoteReport* report = new TASWiimoteReport{ data, rptf, ext, key }; wxCommandEvent* evt = new wxCommandEvent(WIIMOTE_UPDATE_CALLBACK); evt->SetClientData(report); wxQueueEvent(this, evt); return; } GetKeyBoardInput(data, rptf, ext, key); u8* const coreData = rptf.core ? (data + rptf.core) : nullptr; u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr; u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr; u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr; if (ext != 2) { if (coreData) SetWiiButtons(&((wm_buttons*)coreData)->hex); if (accelData) { wm_accel& dt = *(wm_accel*)accelData; wm_buttons& but = *(wm_buttons*)coreData; dt.x = m_x_cont.value >> 2; dt.y = m_y_cont.value >> 2; dt.z = m_z_cont.value >> 2; but.acc_x_lsb = m_x_cont.value & 0x3; but.acc_y_lsb = m_y_cont.value >> 1 & 0x1; but.acc_z_lsb = m_z_cont.value >> 1 & 0x1; } if (irData) { u16 x[4]; u16 y; x[0] = m_main_stick.x_cont.value; y = m_main_stick.y_cont.value; x[1] = x[0] + 100; x[2] = x[0] - 10; x[3] = x[1] + 10; u8 mode; // Mode 5 not supported in core anyway. if (rptf.ext) mode = (rptf.ext - rptf.ir) == 10 ? 1 : 3; else mode = (rptf.size - rptf.ir) == 10 ? 1 : 3; if (mode == 1) { memset(irData, 0xFF, sizeof(wm_ir_basic) * 2); wm_ir_basic* ir_data = (wm_ir_basic*)irData; for (unsigned int i = 0; i < 2; ++i) { if (x[i * 2] < 1024 && y < 768) { ir_data[i].x1 = static_cast<u8>(x[i*2]); ir_data[i].x1hi = x[i*2] >> 8; ir_data[i].y1 = static_cast<u8>(y); ir_data[i].y1hi = y >> 8; } if (x[i*2 + 1] < 1024 && y < 768) { ir_data[i].x2 = static_cast<u8>(x[i*2 + 1]); ir_data[i].x2hi = x[i*2 + 1] >> 8; ir_data[i].y2 = static_cast<u8>(y); ir_data[i].y2hi = y >> 8; } } }