-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* libSceRazorCpu needed for gravity rush * libSceCesCs needed for blue reflection * clang format fix * set scePadSetVibration to log debug * initial sceNetCtl module implementation * improved error codes in file system * some intial work on netctl callbacks (helps a bit CUSA10135) * misc * improved callbacks handling in sceNetCtl * small fixes * added libSceRudp.sprx to lle modules * draft work for npcallbacks
- Loading branch information
1 parent
1c0dfc6
commit 0ebae4c
Showing
11 changed files
with
290 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
// error codes | ||
constexpr int ORBIS_NET_CTL_ERROR_CALLBACK_MAX = 0x80412103; | ||
constexpr int ORBIS_NET_CTL_ERROR_ID_NOT_FOUND = 0x80412104; | ||
constexpr int ORBIS_NET_CTL_ERROR_INVALID_ID = 0x80412105; | ||
constexpr int ORBIS_NET_CTL_ERROR_INVALID_ADDR = 0x80412107; | ||
constexpr int ORBIS_NET_CTL_ERROR_NOT_CONNECTED = 0x80412108; | ||
constexpr int ORBIS_NET_CTL_ERROR_NOT_AVAIL = 0x80412109; | ||
constexpr int ORBIS_NET_CTL_ERROR_NETWORK_DISABLED = 0x8041210D; | ||
constexpr int ORBIS_NET_CTL_ERROR_DISCONNECT_REQ = 0x8041210E; | ||
constexpr int ORBIS_NET_CTL_ERROR_ETHERNET_PLUGOUT = 0x80412115; | ||
constexpr int ORBIS_NET_CTL_ERROR_WIFI_DEAUTHED = 0x80412116; | ||
constexpr int ORBIS_NET_CTL_ERROR_WIFI_BEACON_LOST = 0x80412117; | ||
|
||
// state codes | ||
constexpr int ORBIS_NET_CTL_STATE_DISCONNECTED = 0; | ||
constexpr int ORBIS_NET_CTL_STATE_CONNECTING = 1; | ||
constexpr int ORBIS_NET_CTL_STATE_IPOBTAINING = 2; | ||
constexpr int ORBIS_NET_CTL_STATE_IPOBTAINED = 3; | ||
|
||
// event type | ||
constexpr int ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED = 1; | ||
constexpr int ORBIS_SCE_NET_CTL_EVENT_TYPE_DISCONNECT_REQ_FINISHED = 2; | ||
constexpr int ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include "net_ctl_codes.h" | ||
#include "net_ctl_obj.h" | ||
|
||
Libraries::NetCtl::NetCtlInternal::NetCtlInternal() { | ||
callbacks.fill({nullptr, nullptr}); | ||
nptoolCallbacks.fill({nullptr, nullptr}); | ||
} | ||
|
||
Libraries::NetCtl::NetCtlInternal::~NetCtlInternal() {} | ||
|
||
s32 Libraries::NetCtl::NetCtlInternal::registerCallback(OrbisNetCtlCallback func, void* arg) { | ||
std::unique_lock lock{m_mutex}; | ||
|
||
// Find the next available slot | ||
int next_id = 0; | ||
for (const auto& callback : callbacks) { | ||
if (callback.func == nullptr) { | ||
break; | ||
} | ||
next_id++; | ||
} | ||
|
||
if (next_id == 8) { | ||
return ORBIS_NET_CTL_ERROR_CALLBACK_MAX; | ||
} | ||
|
||
callbacks[next_id].func = func; | ||
callbacks[next_id].arg = arg; | ||
return next_id; | ||
} | ||
|
||
s32 Libraries::NetCtl::NetCtlInternal::registerNpToolkitCallback( | ||
OrbisNetCtlCallbackForNpToolkit func, void* arg) { | ||
|
||
std::unique_lock lock{m_mutex}; | ||
|
||
// Find the next available slot | ||
int next_id = 0; | ||
for (const auto& callback : nptoolCallbacks) { | ||
if (callback.func == nullptr) { | ||
break; | ||
} | ||
next_id++; | ||
} | ||
|
||
if (next_id == 8) { | ||
return ORBIS_NET_CTL_ERROR_CALLBACK_MAX; | ||
} | ||
|
||
nptoolCallbacks[next_id].func = func; | ||
nptoolCallbacks[next_id].arg = arg; | ||
return next_id; | ||
} | ||
|
||
void Libraries::NetCtl::NetCtlInternal::checkCallback() { | ||
std::unique_lock lock{m_mutex}; | ||
for (auto& callback : callbacks) { | ||
if (callback.func != nullptr) { | ||
callback.func(ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED, callback.arg); | ||
} | ||
} | ||
} | ||
|
||
void Libraries::NetCtl::NetCtlInternal::checkNpToolkitCallback() { | ||
std::unique_lock lock{m_mutex}; | ||
for (auto& callback : nptoolCallbacks) { | ||
if (callback.func != nullptr) { | ||
callback.func(ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED, callback.arg); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <condition_variable> | ||
#include <mutex> | ||
|
||
#include "common/types.h" | ||
|
||
namespace Libraries::NetCtl { | ||
|
||
using OrbisNetCtlCallback = PS4_SYSV_ABI void (*)(int eventType, void* arg); | ||
using OrbisNetCtlCallbackForNpToolkit = PS4_SYSV_ABI void (*)(int eventType, void* arg); | ||
|
||
struct NetCtlCallback { | ||
OrbisNetCtlCallback func; | ||
void* arg; | ||
}; | ||
|
||
struct NetCtlCallbackForNpToolkit { | ||
OrbisNetCtlCallbackForNpToolkit func; | ||
void* arg; | ||
}; | ||
|
||
class NetCtlInternal { | ||
public: | ||
NetCtlInternal(); | ||
~NetCtlInternal(); | ||
s32 registerCallback(OrbisNetCtlCallback func, void* arg); | ||
s32 registerNpToolkitCallback(OrbisNetCtlCallbackForNpToolkit func, void* arg); | ||
void checkCallback(); | ||
void checkNpToolkitCallback(); | ||
|
||
public: | ||
std::array<NetCtlCallback, 8> nptoolCallbacks; | ||
std::array<NetCtlCallbackForNpToolkit, 8> callbacks; | ||
std::mutex m_mutex; | ||
}; | ||
} // namespace Libraries::NetCtl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.