mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-27 16:23:35 +01:00
Net: Support NETCONF_CONNECT_APNET_LAST request.
Also cleanup the dialog to handle timing like other dialogs. May fix issues where it lingers "open" and prevents other dialogs from working.
This commit is contained in:
1 parent
1fc755f267
commit
97bc0a5245
3 files changed
+49
-43
No files matched your search
@@ -28,9 +28,14 @@
|
||||
#define NETCONF_CONNECT_APNET 0
|
||||
#define NETCONF_STATUS_APNET 1
|
||||
#define NETCONF_CONNECT_ADHOC 2
|
||||
#define NETCONF_CONNECT_APNET_LAST 3
|
||||
#define NETCONF_CREATE_ADHOC 4
|
||||
#define NETCONF_JOIN_ADHOC 5
|
||||
|
||||
// Needs testing.
|
||||
const static int NET_INIT_DELAY_US = 300000;
|
||||
const static int NET_SHUTDOWN_DELAY_US = 26000;
|
||||
|
||||
PSPNetconfDialog::PSPNetconfDialog() {
|
||||
}
|
||||
|
||||
@@ -39,7 +44,7 @@ PSPNetconfDialog::~PSPNetconfDialog() {
|
||||
|
||||
int PSPNetconfDialog::Init(u32 paramAddr) {
|
||||
// Already running
|
||||
if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
if (status != SCE_UTILITY_STATUS_NONE)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
int size = Memory::Read_U32(paramAddr);
|
||||
@@ -47,7 +52,7 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
|
||||
// Only copy the right size to support different request format
|
||||
Memory::Memcpy(&request, paramAddr, size);
|
||||
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
ChangeStatusInit(NET_INIT_DELAY_US);
|
||||
|
||||
// Eat any keys pressed before the dialog inited.
|
||||
UpdateButtons();
|
||||
@@ -67,6 +72,10 @@ void PSPNetconfDialog::DrawBanner() {
|
||||
}
|
||||
|
||||
int PSPNetconfDialog::Update(int animSpeed) {
|
||||
if (GetStatus() != SCE_UTILITY_STATUS_RUNNING) {
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
}
|
||||
|
||||
UpdateButtons();
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
auto err = GetI18NCategory("Error");
|
||||
@@ -74,9 +83,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
const ImageID confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? ImageID("I_CROSS") : ImageID("I_CIRCLE");
|
||||
const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
|
||||
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE) {
|
||||
status = SCE_UTILITY_STATUS_RUNNING;
|
||||
} else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET)) {
|
||||
if (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET || request.netAction == NETCONF_CONNECT_APNET_LAST) {
|
||||
UpdateFade(animSpeed);
|
||||
StartDraw();
|
||||
DrawBanner();
|
||||
@@ -87,26 +94,24 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
|
||||
if (IsButtonPressed(confirmBtn)) {
|
||||
StartFade(false);
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
// TODO: When the dialog is aborted, does it really set the result to this?
|
||||
// It seems to make Phantasy Star Portable 2 happy, so it should be okay for now.
|
||||
request.common.result = SCE_UTILITY_DIALOG_RESULT_ABORT;
|
||||
}
|
||||
|
||||
} else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC)) {
|
||||
if (request.NetconfData != NULL) {
|
||||
|
||||
EndDraw();
|
||||
} else if (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC) {
|
||||
if (request.NetconfData.IsValid()) {
|
||||
Shutdown(true);
|
||||
if (sceNetAdhocctlCreate(request.NetconfData->groupName) == 0) {
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
} else if (status == SCE_UTILITY_STATUS_FINISHED) {
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
}
|
||||
|
||||
EndDraw();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -114,7 +119,12 @@ int PSPNetconfDialog::Shutdown(bool force) {
|
||||
if (status != SCE_UTILITY_STATUS_FINISHED && !force)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
return PSPDialog::Shutdown(force);
|
||||
PSPDialog::Shutdown(force);
|
||||
if (!force) {
|
||||
ChangeStatusShutdown(NET_SHUTDOWN_DELAY_US);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPNetconfDialog::DoState(PointerWrap &p) {
|
||||
|
||||
Reference in new issue
Block a user