| 59 | } |
| 60 | |
| 61 | void run_thread(vm::cptr<CellCrossControllerPackageInfo> pPkgInfo) |
| 62 | { |
| 63 | ensure(!!pPkgInfo); |
| 64 | ensure(!!callback); |
| 65 | |
| 66 | const std::string msg = fmt::format("%s\n\n%s", |
| 67 | get_localized_string(localized_string_id::CELL_CROSS_CONTROLLER_MSG, pPkgInfo->pTitle.get_ptr()), |
| 68 | get_localized_string(localized_string_id::CELL_CROSS_CONTROLLER_FW_MSG)); |
| 69 | |
| 70 | vm::bptr<CellMsgDialogCallback> msg_dialog_callback = vm::null; |
| 71 | msg_dialog_callback.set(g_fxo->get<ppu_function_manager>().func_addr(FIND_FUNC(finish_callback))); |
| 72 | |
| 73 | // TODO: Show icons from comboplay_plugin.rco in dialog. Maybe use a new dialog or add an optional icon to this one. |
| 74 | error_code res = open_msg_dialog(false, CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, vm::make_str(msg), msg_dialog_source::_cellCrossController, msg_dialog_callback, userdata); |
| 75 | |
| 76 | sysutil_register_cb([this, res](ppu_thread& ppu) -> s32 |
| 77 | { |
| 78 | callback(ppu, CELL_CROSS_CONTROLLER_STATUS_INITIALIZED, res == CELL_OK ? +CELL_OK : +CELL_CROSS_CONTROLLER_ERROR_INTERNAL, vm::null, userdata); |
| 79 | return CELL_OK; |
| 80 | }); |
| 81 | |
| 82 | status = CELL_CROSS_CONTROLLER_STATUS_INITIALIZED; |
| 83 | |
| 84 | connection_thread = std::make_unique<named_thread<std::function<void()>>>(fmt::format("Cross-Controller Thread"), [this]() |
| 85 | { |
| 86 | while (thread_ctrl::state() != thread_state::aborting) |
| 87 | { |
| 88 | if (Emu.IsPaused()) |
| 89 | { |
| 90 | thread_ctrl::wait_for(10'000); |
| 91 | continue; |
| 92 | } |
| 93 | |
| 94 | // TODO: establish connection to PS Vita |
| 95 | if (false) |
| 96 | { |
| 97 | on_connection_established(CELL_OK); |
| 98 | } |
| 99 | |
| 100 | thread_ctrl::wait_for(1000); |
| 101 | } |
| 102 | |
| 103 | status = CELL_CROSS_CONTROLLER_STATUS_FINALIZED; |
| 104 | }); |
| 105 | } |
| 106 | |
| 107 | void stop_thread() |
| 108 | { |
no test coverage detected