Skip to content

Commit

Permalink
Merge pull request #5294 from thedax/netConfDialog
Browse files Browse the repository at this point in the history
Flesh out the netconf dialog a bit by having it display an error, and add a stub for sceNetApctlDisconnect.
  • Loading branch information
hrydgard committed Feb 2, 2014
2 parents 593944f + abe9877 commit c9c179d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 15 deletions.
82 changes: 68 additions & 14 deletions Core/Dialog/PSPNetconfDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2012- PPSSPP Project.
// Copyright (c) 2012- PPSSPP Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,13 @@
#include "ChunkFile.h"
#include "Core/MemMap.h"
#include "Core/HLE/sceNetAdhoc.h"
#include "Core/Util/PPGeDraw.h"
#include "Core/HLE/sceCtrl.h"
#include "Core/HLE/sceUtility.h"
#include "i18n/i18n.h"

#define NETCONF_CONNECT_APNET 0
#define NETCONF_STATUS_APNET 1
#define NETCONF_CONNECT_ADHOC 2
#define NETCONF_CREATE_ADHOC 4
#define NETCONF_JOIN_ADHOC 5
Expand All @@ -41,23 +47,71 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
Memory::Memcpy(&request, paramAddr, size);

status = SCE_UTILITY_STATUS_INITIALIZE;

// Eat any keys pressed before the dialog inited.
__CtrlReadLatch();

StartFade(true);
return 0;
}

void PSPNetconfDialog::DrawBanner() {

PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358));

// TODO: Draw a hexagon icon
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
I18NCategory *d = GetI18NCategory("Dialog");
PPGeDrawText(d->T("Network Connection"), 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
}

int PSPNetconfDialog::Update(int animSpeed) {
if(request.netAction == NETCONF_CONNECT_ADHOC ||
request.netAction == NETCONF_CREATE_ADHOC ||
request.netAction == NETCONF_JOIN_ADHOC){
if(request.NetconfData != NULL){
Shutdown(true);
if(sceNetAdhocctlCreate(request.NetconfData->groupName) == 0)
{
status = SCE_UTILITY_STATUS_FINISHED;
return 0;
}
return -1;
}
}
buttons = __CtrlPeekButtons();
I18NCategory *d = GetI18NCategory("Dialog");
I18NCategory *err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;
const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : 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)) {
UpdateFade(animSpeed);
StartDraw();
DrawBanner();
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
PPGeDrawTextWrapped(err->T("PPSSPPDoesNotSupportInternet", "PPSSPP currently does not support connecting to the Internet for DLC, PSN, or game updates."), 241, 132, WRAP_WIDTH, PPGE_ALIGN_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(confirmBtnImage, 195, 250, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawText(d->T("OK"), 225, 252, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));

if (IsButtonPressed(confirmBtn)) {
StartFade(false);
status = SCE_UTILITY_STATUS_FINISHED;
// 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 || NETCONF_JOIN_ADHOC)) {
if (request.NetconfData != NULL) {
Shutdown(true);
if (sceNetAdhocctlCreate(request.NetconfData->groupName) == 0)
{
status = SCE_UTILITY_STATUS_FINISHED;
return 0;
}
return -1;
}
}
else if (status == SCE_UTILITY_STATUS_FINISHED)
{
status = SCE_UTILITY_STATUS_SHUTDOWN;
}

EndDraw();
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions Core/Dialog/PSPNetconfDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ class PSPNetconfDialog: public PSPDialog {
virtual void DoState(PointerWrap &p);

private:
void DrawBanner();
SceUtilityNetconfParam request;
};
14 changes: 13 additions & 1 deletion Core/HLE/sceNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ enum {
ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12,
};

enum {
PSP_NET_APCTL_EVENT_DISCONNECT_REQUEST = 5,
};

struct ProductStruct {
s32_le unknown; // Unknown, set to 0
char product[9]; // Game ID (Example: ULUS10000)
Expand Down Expand Up @@ -352,6 +356,14 @@ int sceNetInetConnect(int socket, u32 sockAddrInternetPtr, int addressLength) {
return -1;
}

int sceNetApctlDisconnect() {
ERROR_LOG(SCENET, "UNIMPL %s()", __FUNCTION__);
// Like its 'sister' function sceNetAdhocctlDisconnect, we need to alert Apctl handlers that a disconnect took place
// or else games like Phantasy Star Portable 2 will hang at certain points (e.g. returning to the main menu after trying to connect to PSN).
__UpdateApctlHandlers(0, 0, PSP_NET_APCTL_EVENT_DISCONNECT_REQUEST, 0);
return 0;
}

const HLEFunction sceNet[] = {
{0x39AF39A6, WrapU_UUUUU<sceNetInit>, "sceNetInit"},
{0x281928A9, WrapU_V<sceNetTerm>, "sceNetTerm"},
Expand Down Expand Up @@ -413,7 +425,7 @@ const HLEFunction sceNetInet[] = {

const HLEFunction sceNetApctl[] = {
{0xCFB957C6, 0, "sceNetApctlConnect"},
{0x24fe91a1, 0, "sceNetApctlDisconnect"},
{0x24fe91a1, &WrapI_V<sceNetApctlDisconnect>, "sceNetApctlDisconnect" },
{0x5deac81b, 0, "sceNetApctlGetState"},
{0x8abadd51, WrapU_UU<sceNetApctlAddHandler>, "sceNetApctlAddHandler"},
{0xe2f91f9b, WrapI_V<sceNetApctlInit>, "sceNetApctlInit"},
Expand Down

0 comments on commit c9c179d

Please sign in to comment.