mirror of
https://github.com/libretro/ppsspp.git
synced 2025-05-13 15:16:09 +00:00
Added windows changes for a unified build. Added Dialog fix which
prevented from saving after going online. Added windows « errno » use redefinition to suit WSAGetLastError and protocl needs.
This commit is contained in:
parent
33f4b44061
commit
0f7f90d0ac
@ -37,7 +37,10 @@
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
#endif
|
||||
#if !defined(IOS)
|
||||
#include <mach-o/dyld.h>
|
||||
#endif // !defined(IOS)
|
||||
#endif // __APPLE__
|
||||
|
||||
#include "util/text/utf8.h"
|
||||
|
||||
|
@ -256,6 +256,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
||||
pspConfig->Get("NickName", &sNickName, "PPSSPP");
|
||||
pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost");
|
||||
pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06");
|
||||
pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
|
||||
pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
|
||||
pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
|
||||
@ -453,6 +454,7 @@ void Config::Save() {
|
||||
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
||||
pspConfig->Set("NickName", sNickName.c_str());
|
||||
pspConfig->Set("proAdhocServer", proAdhocServer.c_str());
|
||||
pspConfig->Set("MacAddress", localMacAddress.c_str());
|
||||
pspConfig->Set("Language", iLanguage);
|
||||
pspConfig->Set("TimeFormat", iTimeFormat);
|
||||
pspConfig->Set("DateFormat", iDateFormat);
|
||||
|
@ -185,6 +185,7 @@ public:
|
||||
// SystemParam
|
||||
std::string sNickName;
|
||||
std::string proAdhocServer;
|
||||
std::string localMacAddress;
|
||||
int iLanguage;
|
||||
int iTimeFormat;
|
||||
int iDateFormat;
|
||||
|
@ -50,7 +50,12 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
request.netAction == NETCONF_JOIN_ADHOC){
|
||||
if(request.NetconfData != NULL){
|
||||
Shutdown(true);
|
||||
return sceNetAdhocctlCreate(request.NetconfData->groupName);
|
||||
if(sceNetAdhocctlCreate(request.NetconfData->groupName) == 0)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -497,15 +497,15 @@ int getLocalIp(sockaddr_in * SocketAddress){
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
char ip[] = "192.168.12.1";
|
||||
SocketAddress->sin_addr.s_addr = inet_addr("192.168.12.1");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void getLocalMac(SceNetEtherAddr * addr){
|
||||
uint8_t mac[] = {1, 2, 3, 4, 5, 6};
|
||||
uint8_t mac[] = {1, 2, 3, 4, 5, 5};
|
||||
memcpy(addr,mac,ETHER_ADDR_LEN);
|
||||
printf("mem copied\n");
|
||||
}
|
||||
|
||||
int getPTPSocketCount(void) {
|
||||
@ -541,13 +541,20 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||
|
||||
// Resolve dns
|
||||
addrinfo * resultAddr;
|
||||
addrinfo * ptr;
|
||||
in_addr serverIp;
|
||||
iResult = getaddrinfo(g_Config.proAdhocServer.c_str(),0,NULL,&resultAddr);
|
||||
if(iResult != 0){
|
||||
ERROR_LOG(SCENET, "Dns error\n");
|
||||
return iResult;
|
||||
}
|
||||
server_addr.sin_addr.s_addr = ((sockaddr_in *)resultAddr->ai_addr)->sin_addr.s_addr;
|
||||
iResult = connect(metasocket,(sockaddr *)&server_addr,sizeof(server_addr));
|
||||
for(ptr = resultAddr; ptr != NULL; ptr = ptr->ai_next){
|
||||
switch(ptr->ai_family){
|
||||
case AF_INET:
|
||||
serverIp = ((sockaddr_in *)ptr->ai_addr)->sin_addr;
|
||||
}
|
||||
}
|
||||
server_addr.sin_addr = serverIp; iResult = connect(metasocket,(sockaddr *)&server_addr,sizeof(server_addr));
|
||||
if(iResult == SOCKET_ERROR){
|
||||
ERROR_LOG(SCENET,"Socket error");
|
||||
return iResult;
|
||||
|
@ -13,7 +13,12 @@
|
||||
#include "sceKernelMutex.h"
|
||||
#include "sceUtility.h"
|
||||
#include "net/resolve.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <thread.h>
|
||||
#else
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
// Net stuff
|
||||
#ifdef _MSC_VER
|
||||
@ -29,6 +34,10 @@
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define PACK
|
||||
#define errno WSAGetLastError()
|
||||
#define EAGAIN WSAEWOULDBLOCK
|
||||
#define EINPROGRESS WSAEWOULDBLOCK
|
||||
#define EISCONN WSAEISCONN
|
||||
#else
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "HLE.h"
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "../Config.h"
|
||||
|
||||
#include "sceKernel.h"
|
||||
#include "sceKernelThread.h"
|
||||
@ -131,7 +132,7 @@ u32 sceNetTerm() {
|
||||
|
||||
u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
||||
// TODO: Read from config
|
||||
static const u8 fakeEtherAddr[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
static const u8 fakeEtherAddr[6] = { 1, 2, 3, 4, 5, 5 };
|
||||
DEBUG_LOG(SCENET, "sceWlanGetEtherAddr(%08x)", addrAddr);
|
||||
for (int i = 0; i < 6; i++)
|
||||
Memory::Write_U8(fakeEtherAddr[i], addrAddr + i);
|
||||
|
@ -139,6 +139,15 @@ void __UpdateAdhocctlHandlers(int flag, int error) {
|
||||
}
|
||||
}
|
||||
|
||||
int getBlockingFlag(int id){
|
||||
#ifdef _MSC_VER
|
||||
return 0;
|
||||
#else
|
||||
int sockflag = fcntl(id, F_GETFL, O_NONBLOCK);
|
||||
return sockflag & O_NONBLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
void __handlerUpdateCallback(u64 userdata, int cycleslate){
|
||||
int buff[2];
|
||||
split64(userdata,buff);
|
||||
@ -363,7 +372,7 @@ int sceNetAdhocPdpSend(int id, const char *mac, u32 port, void *data, int len, i
|
||||
target.sin_port = htons(dport);
|
||||
|
||||
// Get Peer IP
|
||||
if(resolveMAC((SceNetEtherAddr *)daddr, &target.sin_addr.s_addr) == 0) {
|
||||
if(resolveMAC((SceNetEtherAddr *)daddr, (uint32_t *)&target.sin_addr.s_addr) == 0) {
|
||||
// Acquire Network Lock
|
||||
//_acquireNetworkLock();
|
||||
|
||||
@ -1096,7 +1105,7 @@ int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac, int dp
|
||||
// Valid Socket produced
|
||||
if(tcpsocket > 0) {
|
||||
// Enable Port Re-use
|
||||
setsockopt(tcpsocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
setsockopt(tcpsocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one));
|
||||
|
||||
// Binding Information for local Port
|
||||
sockaddr_in addr;
|
||||
@ -1202,17 +1211,22 @@ int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int timeou
|
||||
// Address Information
|
||||
sockaddr_in peeraddr;
|
||||
memset(&peeraddr, 0, sizeof(peeraddr));
|
||||
#ifdef _MSC_VER
|
||||
int peeraddrlen = sizeof(peeraddr);
|
||||
#else
|
||||
uint32_t peeraddrlen = sizeof(peeraddr);
|
||||
|
||||
#endif
|
||||
// Local Address Information
|
||||
sockaddr_in local;
|
||||
memset(&local, 0, sizeof(local));
|
||||
#ifdef _MSC_VER
|
||||
int locallen = sizeof(local);
|
||||
#else
|
||||
uint32_t locallen = sizeof(local);
|
||||
#endif
|
||||
|
||||
// Grab Nonblocking Flag
|
||||
uint32_t nbio = 0;
|
||||
int sockflag = fcntl(socket->id, F_GETFL, O_NONBLOCK);
|
||||
nbio = sockflag & O_NONBLOCK;
|
||||
uint32_t nbio = getBlockingFlag(socket->id);
|
||||
// Switch to Nonblocking Behaviour
|
||||
if(nbio == 0) {
|
||||
// Overwrite Socket Option
|
||||
@ -1246,7 +1260,7 @@ int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int timeou
|
||||
// Accepted New Connection
|
||||
if(newsocket > 0) {
|
||||
// Enable Port Re-use
|
||||
setsockopt(newsocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
setsockopt(newsocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one));
|
||||
|
||||
// Grab Local Address
|
||||
if(getsockname(newsocket, (sockaddr *)&local, &locallen) == 0) {
|
||||
@ -1358,11 +1372,9 @@ int sceNetAdhocPtpConnect(int id, int timeout, int flag) {
|
||||
sin.sin_port = htons(socket->pport);
|
||||
|
||||
// Grab Peer IP
|
||||
if(resolveMAC(&socket->paddr, &sin.sin_addr.s_addr) == 0) {
|
||||
if(resolveMAC(&socket->paddr, (uint32_t *)&sin.sin_addr.s_addr) == 0) {
|
||||
// Grab Nonblocking Flag
|
||||
uint32_t nbio = 0;
|
||||
int fileflags = fcntl(socket->id,F_GETFL,O_NONBLOCK);
|
||||
nbio = fileflags & O_NONBLOCK;
|
||||
uint32_t nbio = getBlockingFlag(socket->id);
|
||||
// Switch to Nonblocking Behaviour
|
||||
if(nbio == 0) {
|
||||
// Overwrite Socket Option
|
||||
@ -1403,8 +1415,11 @@ int sceNetAdhocPtpConnect(int id, int timeout, int flag) {
|
||||
// Peer Information (for Connection-Polling)
|
||||
sockaddr_in peer;
|
||||
memset(&peer, 0, sizeof(peer));
|
||||
#ifdef _MSC_VER
|
||||
int peerlen = sizeof(peer);
|
||||
#else
|
||||
uint32_t peerlen = sizeof(peer);
|
||||
|
||||
#endif
|
||||
// Wait for Connection
|
||||
while((timeout == 0 || ( (uint32_t)(real_time_now()*1000.0) - starttime) < timeout) && getpeername(socket->id, (sockaddr *)&peer, &peerlen) != 0) {
|
||||
// Wait 1ms
|
||||
@ -1524,7 +1539,7 @@ int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int rexmt_i
|
||||
// Valid Socket produced
|
||||
if(tcpsocket > 0) {
|
||||
// Enable Port Re-use
|
||||
setsockopt(tcpsocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
setsockopt(tcpsocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one));
|
||||
|
||||
// Binding Information for local Port
|
||||
sockaddr_in addr;
|
||||
@ -1629,7 +1644,7 @@ int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int
|
||||
if(flag) timeout = 0;
|
||||
|
||||
// Apply Send Timeout Settings to Socket
|
||||
setsockopt(socket->id, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
|
||||
setsockopt(socket->id, SOL_SOCKET, SO_SNDTIMEO, (const char *)&timeout, sizeof(timeout));
|
||||
|
||||
// Acquire Network Lock
|
||||
// _acquireNetworkLock();
|
||||
@ -1710,14 +1725,14 @@ int sceNetAdhocPtpRecv(int id, u32 data, u32 dataSizeAddr, int timeout, int flag
|
||||
if(flag) timeout = 0;
|
||||
|
||||
// Apply Send Timeout Settings to Socket
|
||||
setsockopt(socket->id, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
setsockopt(socket->id, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout));
|
||||
|
||||
// Acquire Network Lock
|
||||
// _acquireNetworkLock();
|
||||
|
||||
// Receive Data
|
||||
changeBlockingMode(socket->id, flag);
|
||||
int received = recv(socket->id, buf, *len, 0);
|
||||
int received = recv(socket->id, (char *)buf, *len, 0);
|
||||
int error = errno;
|
||||
changeBlockingMode(socket->id, 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user