mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Shows AdHoc and Access Point Connecting... Dialog
This commit is contained in:
parent
d9d8c031d4
commit
bd36b9dff1
4 changed files with 297 additions and 39 deletions
|
@ -22,12 +22,14 @@
|
|||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Dialog/PSPNetconfDialog.h"
|
||||
#include "Core/MemMapHelpers.h"
|
||||
#include "Core/HLE/sceNetAdhoc.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
#include <Core/HLE/sceNet.h>
|
||||
#include "Core/Dialog/PSPNetconfDialog.h"
|
||||
#include <ext/native/util/text/utf8.h>
|
||||
|
||||
|
||||
#define NETCONF_CONNECT_APNET 0
|
||||
#define NETCONF_STATUS_APNET 1
|
||||
|
@ -36,9 +38,12 @@
|
|||
#define NETCONF_CREATE_ADHOC 4
|
||||
#define NETCONF_JOIN_ADHOC 5
|
||||
|
||||
static const float FONT_SCALE = 0.65f;
|
||||
|
||||
// Needs testing.
|
||||
const static int NET_INIT_DELAY_US = 300000;
|
||||
const static int NET_SHUTDOWN_DELAY_US = 26000;
|
||||
const static int NET_RUNNING_DELAY_US = 1000000; // KHBBS is showing adhoc dialog for about 3-4 seconds, but feels too long, so we're faking it to 1 sec instead to let players read the text
|
||||
|
||||
PSPNetconfDialog::PSPNetconfDialog() {
|
||||
}
|
||||
|
@ -51,6 +56,7 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
|
|||
if (status != SCE_UTILITY_STATUS_NONE)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
requestAddr = paramAddr;
|
||||
int size = Memory::Read_U32(paramAddr);
|
||||
memset(&request, 0, sizeof(request));
|
||||
// Only copy the right size to support different request format
|
||||
|
@ -60,6 +66,17 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
|
|||
|
||||
// Eat any keys pressed before the dialog inited.
|
||||
UpdateButtons();
|
||||
okButtonImg = ImageID("I_CIRCLE");
|
||||
cancelButtonImg = ImageID("I_CROSS");
|
||||
okButtonFlag = CTRL_CIRCLE;
|
||||
cancelButtonFlag = CTRL_CROSS;
|
||||
if (request.common.buttonSwap == 1)
|
||||
{
|
||||
okButtonImg = ImageID("I_CROSS");
|
||||
cancelButtonImg = ImageID("I_CIRCLE");
|
||||
okButtonFlag = CTRL_CROSS;
|
||||
cancelButtonFlag = CTRL_CIRCLE;
|
||||
}
|
||||
|
||||
StartFade(true);
|
||||
return 0;
|
||||
|
@ -67,15 +84,141 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
|
|||
|
||||
void PSPNetconfDialog::DrawBanner() {
|
||||
|
||||
PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358));
|
||||
PPGeDrawRect(0, 0, 480, 22, CalcFadedColor(0x65636358));
|
||||
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
|
||||
textStyle.hasShadow = false;
|
||||
|
||||
// TODO: Draw a hexagon icon
|
||||
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, textStyle.color);
|
||||
PPGeDrawImage(10, 5, 11.0f, 10.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
PPGeDrawText(di->T("Network Connection"), 30, 11, textStyle);
|
||||
PPGeDrawText(di->T("Network Connection"), 31, 10, textStyle);
|
||||
}
|
||||
|
||||
void PSPNetconfDialog::DrawIndicator() {
|
||||
|
||||
// TODO: Draw animated circle as processing indicator
|
||||
PPGeDrawImage(456, 248, 20.0f, 20.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
void PSPNetconfDialog::DisplayMessage(std::string text1, std::string text2a, std::string text2b, std::string text3a, std::string text3b, bool hasYesNo, bool hasOK) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
|
||||
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
|
||||
PPGeStyle messageStyle = FadedStyle(PPGeAlign::BOX_HCENTER, FONT_SCALE);
|
||||
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
|
||||
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
|
||||
|
||||
std::string text2 = text2a + " " + text2b;
|
||||
std::string text3 = text3a + " " + text3b;
|
||||
|
||||
// Without the scrollbar, we have 350 total pixels.
|
||||
float WRAP_WIDTH = 300.0f;
|
||||
if (UTF8StringNonASCIICount(text1.c_str()) >= text1.size() / 4) {
|
||||
WRAP_WIDTH = 336.0f;
|
||||
if (text1.size() > 12) {
|
||||
messageStyle.scale = 0.6f;
|
||||
}
|
||||
}
|
||||
|
||||
float totalHeight1 = 0.0f;
|
||||
PPGeMeasureText(nullptr, &totalHeight1, text1.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
float totalHeight2 = 0.0f;
|
||||
if (text2 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight2, text2.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float totalHeight3 = 0.0f;
|
||||
if (text3 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight3, text3.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float marginTop = 0.0f;
|
||||
if (text2 != " " || text3 != " ")
|
||||
marginTop = 11.0f;
|
||||
float totalHeight = totalHeight1 + totalHeight2 + totalHeight3 + marginTop;
|
||||
// The PSP normally only shows about 8 lines at a time.
|
||||
// For improved UX, we intentionally show part of the next line.
|
||||
float visibleHeight = std::min(totalHeight, 175.0f);
|
||||
float h2 = visibleHeight / 2.0f;
|
||||
|
||||
float centerY = 135.0f;
|
||||
float sy = centerY - h2 - 15.0f;
|
||||
float ey = centerY + h2 + 20.0f;
|
||||
float buttonY = centerY + h2 + 5.0f;
|
||||
|
||||
auto drawSelectionBoxAndAdjust = [&](float x) {
|
||||
// Box has a fixed size.
|
||||
float w = 15.0f;
|
||||
float h = 8.0f;
|
||||
PPGeDrawRect(x - w, buttonY - h, x + w, buttonY + h, CalcFadedColor(0x6DCFCFCF));
|
||||
|
||||
centerY -= h + 5.0f;
|
||||
sy -= h + 5.0f;
|
||||
ey = buttonY + h * 2.0f + 5.0f;
|
||||
};
|
||||
|
||||
if (hasYesNo) {
|
||||
if (yesnoChoice == 1) {
|
||||
drawSelectionBoxAndAdjust(204.0f);
|
||||
}
|
||||
else {
|
||||
drawSelectionBoxAndAdjust(273.0f);
|
||||
}
|
||||
|
||||
PPGeDrawText(di->T("Yes"), 203.0f, buttonY - 1.0f, buttonStyle);
|
||||
PPGeDrawText(di->T("No"), 272.0f, buttonY - 1.0f, buttonStyle);
|
||||
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
|
||||
yesnoChoice = 1;
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) {
|
||||
yesnoChoice = 0;
|
||||
}
|
||||
buttonY += 8.0f + 5.0f;
|
||||
}
|
||||
|
||||
if (hasOK) {
|
||||
drawSelectionBoxAndAdjust(240.0f);
|
||||
|
||||
PPGeDrawText(di->T("OK"), 239.0f, buttonY - 1.0f, buttonStyle);
|
||||
buttonY += 8.0f + 5.0f;
|
||||
}
|
||||
|
||||
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
|
||||
PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
|
||||
if (text2a != "")
|
||||
PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
if (text2b != "")
|
||||
PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
if (text3a != "")
|
||||
PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
if (text3b != "")
|
||||
PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeScissorReset();
|
||||
|
||||
// Do we need a scrollbar?
|
||||
if (visibleHeight < totalHeight) {
|
||||
float scrollSpeed = 5.0f;
|
||||
float scrollMax = totalHeight - visibleHeight;
|
||||
|
||||
float bobHeight = (visibleHeight / totalHeight) * visibleHeight;
|
||||
float bobOffset = (scrollPos_ / scrollMax) * (visibleHeight - bobHeight);
|
||||
float bobY1 = centerY - h2 + bobOffset;
|
||||
PPGeDrawRect(415.0f, bobY1, 420.0f, bobY1 + bobHeight, CalcFadedColor(0xFFCCCCCC));
|
||||
|
||||
auto buttonDown = [this](int btn, int& held) {
|
||||
if (IsButtonPressed(btn)) {
|
||||
held = 0;
|
||||
return true;
|
||||
}
|
||||
return IsButtonHeld(btn, held, 1, 1);
|
||||
};
|
||||
if (buttonDown(CTRL_DOWN, framesDownHeld_) && scrollPos_ < scrollMax) {
|
||||
scrollPos_ = std::min(scrollMax, scrollPos_ + scrollSpeed);
|
||||
}
|
||||
if (buttonDown(CTRL_UP, framesUpHeld_) && scrollPos_ > 0.0f) {
|
||||
scrollPos_ = std::max(0.0f, scrollPos_ - scrollSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
PPGeDrawRect(60.0f, sy, 420.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawRect(60.0f, ey, 420.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
int PSPNetconfDialog::Update(int animSpeed) {
|
||||
|
@ -86,42 +229,133 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
|||
UpdateButtons();
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
auto err = GetI18NCategory("Error");
|
||||
const float WRAP_WIDTH = 254.0f;
|
||||
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;
|
||||
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_CENTER, 0.5f);
|
||||
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.5f);
|
||||
|
||||
|
||||
// It seems JPCSP doesn't check for NETCONF_STATUS_APNET
|
||||
if (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET || request.netAction == NETCONF_CONNECT_APNET_LAST) {
|
||||
int state = NetApctl_GetState();
|
||||
|
||||
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, 0, textStyle);
|
||||
PPGeDrawImage(confirmBtnImage, 195, 250, 20, 20, buttonStyle);
|
||||
PPGeDrawText(di->T("OK"), 225, 252, buttonStyle);
|
||||
|
||||
if (IsButtonPressed(confirmBtn)) {
|
||||
if (!hideNotice) {
|
||||
const float WRAP_WIDTH = 254.0f;
|
||||
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;
|
||||
const ImageID cancelBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? ImageID("I_CIRCLE") : ImageID("I_CROSS");
|
||||
const int cancelBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;
|
||||
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_CENTER, 0.5f);
|
||||
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.5f);
|
||||
|
||||
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
|
||||
DrawBanner();
|
||||
PPGeDrawTextWrapped(err->T("PPSSPPDoesNotSupportInternet", "PPSSPP currently does not support connecting to the Internet for DLC, PSN, or game updates.\nContinuing may cause unexpected behavior or freezes."), 241, 132, WRAP_WIDTH, 0, textStyle);
|
||||
PPGeDrawImage(confirmBtnImage, 185, 240, 20, 20, buttonStyle);
|
||||
PPGeDrawText(di->T("OK"), 215, 243, buttonStyle);
|
||||
PPGeDrawImage(cancelBtnImage, 255, 240, 20, 20, buttonStyle);
|
||||
PPGeDrawText(di->T("Cancel"), 285, 243, buttonStyle);
|
||||
|
||||
// Since we don't support Infrastructure API yet.. Let the Player read the message first and choose to continue or not (ie. for testing networks API)
|
||||
if (IsButtonPressed(cancelBtn)) {
|
||||
StartFade(false);
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_SHUTDOWN_DELAY_US);
|
||||
// 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 (IsButtonPressed(confirmBtn)) {
|
||||
hideNotice = true;
|
||||
StartFade(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0xC0C8B2AC));
|
||||
DrawBanner();
|
||||
DrawIndicator();
|
||||
|
||||
if (state == PSP_NET_APCTL_STATE_GOT_IP || state == PSP_NET_APCTL_STATE_GETTING_IP) {
|
||||
DisplayMessage(di->T("ObtainingIP", "Obtaining IP address.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
|
||||
}
|
||||
else {
|
||||
// Skipping the Select Connection screen since we only have 1 fake profile
|
||||
DisplayMessage(di->T("ConnectingAP", "Connecting to the access point.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
|
||||
}
|
||||
DisplayButtons(DS_BUTTON_CANCEL, di->T("Cancel"));
|
||||
|
||||
// The Netconf dialog stays visible until the network reaches
|
||||
// the state PSP_NET_APCTL_STATE_GOT_IP.
|
||||
if (state == PSP_NET_APCTL_STATE_GOT_IP) {
|
||||
if (pendingStatus != SCE_UTILITY_STATUS_FINISHED) {
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_RUNNING_DELAY_US);
|
||||
}
|
||||
else if (GetStatus() == SCE_UTILITY_STATUS_FINISHED) {
|
||||
// We are done!
|
||||
StartFade(false);
|
||||
}
|
||||
}
|
||||
|
||||
else if (state == PSP_NET_APCTL_STATE_GETTING_IP) {
|
||||
// Switch to the next message
|
||||
StartFade(true);
|
||||
}
|
||||
|
||||
else if (state == PSP_NET_APCTL_STATE_DISCONNECTED) {
|
||||
// When connecting with infrastructure, simulate a connection
|
||||
// using the first network configuration entry.
|
||||
connResult = sceNetApctlConnect(1);
|
||||
}
|
||||
}
|
||||
|
||||
EndDraw();
|
||||
}
|
||||
else if (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC) {
|
||||
int state = NetAdhocctl_GetState();
|
||||
|
||||
UpdateFade(animSpeed);
|
||||
StartDraw();
|
||||
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0xC0C8B2AC));
|
||||
DrawBanner();
|
||||
DrawIndicator();
|
||||
|
||||
std::string channel = std::to_string(g_Config.iWlanAdhocChannel);
|
||||
if (g_Config.iWlanAdhocChannel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC)
|
||||
channel = "Automatic";
|
||||
|
||||
DisplayMessage(di->T("ConnectingChannel", "Connecting.\nPlease wait...\n\nChannel")+std::string(" ")+di->T(channel));
|
||||
|
||||
// Only Join mode is showing Cancel button on KHBBS and the button will fade out before the dialog is fading out, probably because it's already connected thus can't be canceled anymore
|
||||
if (request.netAction == NETCONF_JOIN_ADHOC)
|
||||
DisplayButtons(DS_BUTTON_CANCEL, di->T("Cancel"));
|
||||
|
||||
if (state == ADHOCCTL_STATE_DISCONNECTED && request.NetconfData.IsValid()) {
|
||||
connResult = sceNetAdhocctlCreate(request.NetconfData->groupName);
|
||||
}
|
||||
|
||||
// The Netconf dialog stays visible until the network reaches
|
||||
// the state ADHOCCTL_STATE_CONNECTED.
|
||||
if (state == ADHOCCTL_STATE_CONNECTED) {
|
||||
// Checking pendingStatus to make sure ChangeStatus not to continously extending the delay ticks on every call for eternity
|
||||
if (pendingStatus != SCE_UTILITY_STATUS_FINISHED) {
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_RUNNING_DELAY_US);
|
||||
}
|
||||
// Start fading only when the actual status has changed
|
||||
else if (GetStatus() == SCE_UTILITY_STATUS_FINISHED) {
|
||||
StartFade(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (request.netAction == NETCONF_JOIN_ADHOC && IsButtonPressed(cancelButtonFlag)) {
|
||||
StartFade(false);
|
||||
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.
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_SHUTDOWN_DELAY_US);
|
||||
request.common.result = SCE_UTILITY_DIALOG_RESULT_ABORT;
|
||||
}
|
||||
|
||||
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) {
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetStatus() == SCE_UTILITY_STATUS_FINISHED || pendingStatus == SCE_UTILITY_STATUS_FINISHED)
|
||||
Memory::Memcpy(requestAddr, &request, request.common.size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -146,3 +380,8 @@ void PSPNetconfDialog::DoState(PointerWrap &p) {
|
|||
|
||||
Do(p, request);
|
||||
}
|
||||
|
||||
pspUtilityDialogCommon* PSPNetconfDialog::GetCommonParam()
|
||||
{
|
||||
return &request.common;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Core/Dialog/PSPDialog.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/MemMapHelpers.h"
|
||||
|
||||
struct SceUtilityNetconfData {
|
||||
char groupName[8];
|
||||
|
@ -27,11 +27,11 @@ struct SceUtilityNetconfData {
|
|||
|
||||
struct SceUtilityNetconfParam {
|
||||
pspUtilityDialogCommon common;
|
||||
int netAction;
|
||||
int netAction; // sets how to connect
|
||||
PSPPointer<SceUtilityNetconfData> NetconfData;
|
||||
int netHotspot;
|
||||
int netHotspotConnected;
|
||||
int netWifiSpot;
|
||||
int netHotspot; // Flag to allow hotspot connections
|
||||
int netHotspotConnected; // Flag to check if a hotspot connection is active
|
||||
int netWifiSpot; // Flag to allow WIFI connections
|
||||
};
|
||||
|
||||
class PSPNetconfDialog: public PSPDialog {
|
||||
|
@ -43,6 +43,7 @@ public:
|
|||
virtual int Update(int animSpeed) override;
|
||||
virtual int Shutdown(bool force = false) override;
|
||||
virtual void DoState(PointerWrap &p) override;
|
||||
virtual pspUtilityDialogCommon* GetCommonParam() override;
|
||||
|
||||
protected:
|
||||
bool UseAutoStatus() override {
|
||||
|
@ -50,6 +51,17 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
void DisplayMessage(std::string text1, std::string text2a = "", std::string text2b = "", std::string text3a = "", std::string text3b = "", bool hasYesNo = false, bool hasOK = false);
|
||||
void DrawBanner();
|
||||
SceUtilityNetconfParam request;
|
||||
void DrawIndicator();
|
||||
|
||||
SceUtilityNetconfParam request = {};
|
||||
u32 requestAddr = 0;
|
||||
int connResult = 0;
|
||||
bool hideNotice = false;
|
||||
|
||||
int yesnoChoice = 0;
|
||||
float scrollPos_ = 0.0f;
|
||||
int framesUpHeld_ = 0;
|
||||
int framesDownHeld_ = 0;
|
||||
};
|
||||
|
|
|
@ -61,7 +61,7 @@ static struct SceNetMallocStat netMallocStat;
|
|||
|
||||
static std::map<int, ApctlHandler> apctlHandlers;
|
||||
|
||||
static struct SceNetApctlInfoInternal netApctlInfo;
|
||||
SceNetApctlInfoInternal netApctlInfo;
|
||||
|
||||
bool netApctlInited;
|
||||
u32 netApctlState;
|
||||
|
@ -407,7 +407,7 @@ void __NetApctlCallbacks()
|
|||
apctlEvents.pop_front();
|
||||
|
||||
// Adjust delay according to current event. Added an extra delay to prevent I/O Timing method from causing disconnection
|
||||
if (*event == PSP_NET_APCTL_EVENT_CONNECT_REQUEST) // || *event == PSP_NET_APCTL_EVENT_SCAN_REQUEST)
|
||||
if (*event == PSP_NET_APCTL_EVENT_CONNECT_REQUEST || *event == PSP_NET_APCTL_EVENT_GET_IP || *event == PSP_NET_APCTL_EVENT_SCAN_REQUEST)
|
||||
delayus = (adhocEventDelayMS + 2 * adhocExtraPollDelayMS) * 1000;
|
||||
else
|
||||
delayus = (adhocEventPollDelayMS + 2 * adhocExtraPollDelayMS) * 1000;
|
||||
|
@ -794,6 +794,11 @@ static int sceNetApctlInit(int stackSize, int initPriority) {
|
|||
|
||||
// Set default value before connected to an AP
|
||||
memset(&netApctlInfo, 0, sizeof(netApctlInfo)); // NetApctl_InitInfo();
|
||||
std::string APname = "Wifi"; // fake AP/hotspot
|
||||
truncate_cpy(netApctlInfo.name, sizeof(netApctlInfo.name), APname.c_str());
|
||||
truncate_cpy(netApctlInfo.ssid, sizeof(netApctlInfo.ssid), APname.c_str());
|
||||
memcpy(netApctlInfo.bssid, "\1\1\2\2\3\3", sizeof(netApctlInfo.bssid)); // fake AP's mac address
|
||||
netApctlInfo.ssidLength = static_cast<unsigned int>(APname.length());
|
||||
truncate_cpy(netApctlInfo.ip, sizeof(netApctlInfo.ip), "0.0.0.0");
|
||||
truncate_cpy(netApctlInfo.gateway, sizeof(netApctlInfo.gateway), "0.0.0.0");
|
||||
truncate_cpy(netApctlInfo.primaryDns, sizeof(netApctlInfo.primaryDns), "0.0.0.0");
|
||||
|
@ -1078,9 +1083,10 @@ static int sceNetInetConnect(int socket, u32 sockAddrInternetPtr, int addressLen
|
|||
}
|
||||
|
||||
int sceNetApctlConnect(int connIndex) {
|
||||
ERROR_LOG(SCENET, "UNIMPL %s(%i)", __FUNCTION__, connIndex);
|
||||
WARN_LOG(SCENET, "UNTESTED %s(%i)", __FUNCTION__, connIndex);
|
||||
// Is this connIndex is the index to the scanning's result data or sceNetApctlGetBSSDescIDListUser result?
|
||||
__UpdateApctlHandlers(0, 0, PSP_NET_APCTL_EVENT_CONNECT_REQUEST, 0);
|
||||
//hleDelayResult(0, "give time to init/cleanup", adhocEventDelayMS * 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,6 +219,7 @@ private:
|
|||
|
||||
extern bool netInetInited;
|
||||
extern bool netApctlInited;
|
||||
extern SceNetApctlInfoInternal netApctlInfo;
|
||||
|
||||
template <typename I> std::string num2hex(I w, size_t hex_len = sizeof(I) << 1);
|
||||
std::string error2str(u32 errorcode);
|
||||
|
|
Loading…
Add table
Reference in a new issue