1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-09-28 22:40:47 +00:00

Formatting

This commit is contained in:
cathery 2020-04-22 03:55:27 +03:00
parent fb578f6987
commit f0a91bb5e6
9 changed files with 52 additions and 50 deletions

View File

@ -1,4 +1,8 @@
{ {
"C_Cpp.dimInactiveRegions": true,
"C_Cpp.clang_format_fallbackStyle": "Visual Studio",
"C_Cpp.clang_format_style": "{BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0, NamespaceIndentation: All, AccessModifierOffset: -4, AlignConsecutiveMacros: true, PointerAlignment: Right, IndentPPDirectives: BeforeHash, SortIncludes: false}",
"editor.formatOnSave": true,
"files.associations": { "files.associations": {
"array": "cpp", "array": "cpp",
"*.tcc": "cpp", "*.tcc": "cpp",
@ -56,5 +60,4 @@
"mutex": "cpp", "mutex": "cpp",
"shared_mutex": "cpp" "shared_mutex": "cpp"
}, },
"C_Cpp.dimInactiveRegions": true
} }

View File

@ -172,11 +172,11 @@ namespace syscon::config
return ini_parse(path, ParseConfigLine, NULL); return ini_parse(path, ParseConfigLine, NULL);
} }
void ConfigChangedCheckThreadFunc(void *arg) void ConfigChangedCheckThreadFunc(void *arg)
{ {
WriteToLog("Starting config check thread!"); WriteToLog("Starting config check thread!");
do { do
{
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX))) if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX)))
{ {
if (config::CheckForFileChanges()) if (config::CheckForFileChanges())
@ -187,7 +187,7 @@ namespace syscon::config
} }
} while (is_config_changed_check_thread_running); } while (is_config_changed_check_thread_running);
} }
} } // namespace
void LoadGlobalConfig(const GlobalConfig &config) void LoadGlobalConfig(const GlobalConfig &config)
{ {
@ -327,4 +327,4 @@ namespace syscon::config
g_config_changed_check_thread.CancelSynchronization(); g_config_changed_check_thread.CancelSynchronization();
g_config_changed_check_thread.Join(); g_config_changed_check_thread.Join();
} }
} } // namespace syscon::config

View File

@ -3,10 +3,10 @@
#define CONFIG_PATH "/config/sys-con/" #define CONFIG_PATH "/config/sys-con/"
#define GLOBALCONFIG CONFIG_PATH "config_global.ini" #define GLOBALCONFIG CONFIG_PATH "config_global.ini"
#define XBOXCONFIG CONFIG_PATH "config_xboxorig.ini" #define XBOXCONFIG CONFIG_PATH "config_xboxorig.ini"
#define XBOX360CONFIG CONFIG_PATH "config_xbox360.ini" #define XBOX360CONFIG CONFIG_PATH "config_xbox360.ini"
#define XBOXONECONFIG CONFIG_PATH "config_xboxone.ini" #define XBOXONECONFIG CONFIG_PATH "config_xboxone.ini"
#define DUALSHOCK3CONFIG CONFIG_PATH "config_dualshock3.ini" #define DUALSHOCK3CONFIG CONFIG_PATH "config_dualshock3.ini"
#define DUALSHOCK4CONFIG CONFIG_PATH "config_dualshock4.ini" #define DUALSHOCK4CONFIG CONFIG_PATH "config_dualshock4.ini"
@ -16,9 +16,7 @@ namespace syscon::config
{ {
}; };
inline GlobalConfig globalConfig inline GlobalConfig globalConfig{};
{
};
void LoadGlobalConfig(const GlobalConfig &config); void LoadGlobalConfig(const GlobalConfig &config);
void LoadAllConfigs(); void LoadAllConfigs();
@ -29,4 +27,4 @@ namespace syscon::config
Result Enable(); Result Enable();
void Disable(); void Disable();
}; }; // namespace syscon::config

View File

@ -9,13 +9,13 @@
namespace syscon::controllers namespace syscon::controllers
{ {
namespace namespace
{ {
constexpr size_t MaxControllerHandlersSize = 10; constexpr size_t MaxControllerHandlersSize = 10;
std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> controllerHandlers; std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> controllerHandlers;
bool UseAbstractedPad; bool UseAbstractedPad;
ams::os::Mutex controllerMutex; ams::os::Mutex controllerMutex;
} } // namespace
bool IsAtControllerLimit() bool IsAtControllerLimit()
{ {
@ -46,12 +46,12 @@ namespace syscon::controllers
return rc; return rc;
} }
std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>>& Get() std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> &Get()
{ {
return controllerHandlers; return controllerHandlers;
} }
ams::os::Mutex& GetScopedLock() ams::os::Mutex &GetScopedLock()
{ {
return controllerMutex; return controllerMutex;
} }
@ -78,4 +78,4 @@ namespace syscon::controllers
{ {
Reset(); Reset();
} }
} } // namespace syscon::controllers

View File

@ -9,12 +9,12 @@ namespace syscon::controllers
bool IsAtControllerLimit(); bool IsAtControllerLimit();
Result Insert(std::unique_ptr<IController> &&controllerPtr); Result Insert(std::unique_ptr<IController> &&controllerPtr);
std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>>& Get(); std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> &Get();
ams::os::Mutex& GetScopedLock(); ams::os::Mutex &GetScopedLock();
//void Remove(void Remove(bool (*func)(std::unique_ptr<SwitchVirtualGamepadHandler> a)));; //void Remove(void Remove(bool (*func)(std::unique_ptr<SwitchVirtualGamepadHandler> a)));;
void Initialize(); void Initialize();
void Reset(); void Reset();
void Exit(); void Exit();
} } // namespace syscon::controllers

View File

@ -14,7 +14,7 @@ extern "C"
{ {
u32 __nx_applet_type = AppletType_None; u32 __nx_applet_type = AppletType_None;
#define INNER_HEAP_SIZE 0x40'000 #define INNER_HEAP_SIZE 0x40'000
size_t nx_inner_heap_size = INNER_HEAP_SIZE; size_t nx_inner_heap_size = INNER_HEAP_SIZE;
char nx_inner_heap[INNER_HEAP_SIZE]; char nx_inner_heap[INNER_HEAP_SIZE];
@ -38,17 +38,18 @@ extern "C"
} }
// libstratosphere variables // libstratosphere variables
namespace ams namespace ams
{ {
ncm::ProgramId CurrentProgramId = {0x690000000000000D}; ncm::ProgramId CurrentProgramId = {0x690000000000000D};
namespace result { bool CallFatalOnResultAssertion = true; } namespace result
} {
bool CallFatalOnResultAssertion = true;
}
} // namespace ams
extern "C" void __appInit(void) extern "C" void __appInit(void)
{ {
ams::sm::DoWithSession([] ams::sm::DoWithSession([] {
{
//Initialize system firmware version //Initialize system firmware version
R_ABORT_UNLESS(setsysInitialize()); R_ABORT_UNLESS(setsysInitialize());
SetSysFirmwareVersion fw; SetSysFirmwareVersion fw;
@ -58,7 +59,7 @@ extern "C" void __appInit(void)
R_ABORT_UNLESS(timeInitialize()); R_ABORT_UNLESS(timeInitialize());
R_ABORT_UNLESS(hiddbgInitialize()); R_ABORT_UNLESS(hiddbgInitialize());
if (hosversionAtLeast(7,0,0)) if (hosversionAtLeast(7, 0, 0))
R_ABORT_UNLESS(hiddbgAttachHdlsWorkBuffer()); R_ABORT_UNLESS(hiddbgAttachHdlsWorkBuffer());
R_ABORT_UNLESS(usbHsInitialize()); R_ABORT_UNLESS(usbHsInitialize());
R_ABORT_UNLESS(pscmInitialize()); R_ABORT_UNLESS(pscmInitialize());

View File

@ -21,7 +21,8 @@ namespace syscon::psc
void PscThreadFunc(void *arg) void PscThreadFunc(void *arg)
{ {
do { do
{
if (R_SUCCEEDED(waitSingle(pscModuleWaiter, UINT64_MAX))) if (R_SUCCEEDED(waitSingle(pscModuleWaiter, UINT64_MAX)))
{ {
PscPmState pscState; PscPmState pscState;
@ -46,7 +47,7 @@ namespace syscon::psc
} }
} while (is_psc_thread_running); } while (is_psc_thread_running);
} }
} } // namespace
Result Initialize() Result Initialize()
{ {
R_TRY(pscmGetPmModule(&pscModule, PscPmModuleId(126), dependencies, sizeof(dependencies) / sizeof(uint16_t), true)); R_TRY(pscmGetPmModule(&pscModule, PscPmModuleId(126), dependencies, sizeof(dependencies) / sizeof(uint16_t), true));
@ -66,4 +67,4 @@ namespace syscon::psc
g_psc_thread.CancelSynchronization(); g_psc_thread.CancelSynchronization();
g_psc_thread.Join(); g_psc_thread.Join();
} }
}; }; // namespace syscon::psc

View File

@ -17,7 +17,6 @@ namespace syscon::usb
constexpr u8 CatchAllEventIndex = 2; constexpr u8 CatchAllEventIndex = 2;
constexpr u8 SonyEventIndex = 0; constexpr u8 SonyEventIndex = 0;
constexpr size_t MaxUsbHsInterfacesSize = 16; constexpr size_t MaxUsbHsInterfacesSize = 16;
ams::os::Mutex usbMutex; ams::os::Mutex usbMutex;
@ -42,7 +41,8 @@ namespace syscon::usb
void UsbEventThreadFunc(void *arg) void UsbEventThreadFunc(void *arg)
{ {
do { do
{
if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX))) if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
{ {
WriteToLog("Catch-all event went off"); WriteToLog("Catch-all event went off");
@ -70,7 +70,8 @@ namespace syscon::usb
void UsbSonyEventThreadFunc(void *arg) void UsbSonyEventThreadFunc(void *arg)
{ {
do { do
{
if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX))) if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX)))
{ {
WriteToLog("Sony event went off"); WriteToLog("Sony event went off");
@ -79,12 +80,10 @@ namespace syscon::usb
if (!controllers::IsAtControllerLimit()) if (!controllers::IsAtControllerLimit())
{ {
s32 total_entries; s32 total_entries;
if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
&& (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
WriteToLog("Initializing Dualshock 3 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock3Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries)))); WriteToLog("Initializing Dualshock 3 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock3Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
else if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_1X) != 0 || QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_2X) != 0) else if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_1X) != 0 || QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_2X) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
&& (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
WriteToLog("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries)))); WriteToLog("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
} }
} }
@ -93,7 +92,8 @@ namespace syscon::usb
void UsbInterfaceChangeThreadFunc(void *arg) void UsbInterfaceChangeThreadFunc(void *arg)
{ {
do { do
{
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX))) if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
{ {
s32 total_entries; s32 total_entries;
@ -138,7 +138,7 @@ namespace syscon::usb
s32 QueryInterfaces(u8 iclass, u8 isubclass, u8 iprotocol) s32 QueryInterfaces(u8 iclass, u8 isubclass, u8 iprotocol)
{ {
UsbHsInterfaceFilter filter { UsbHsInterfaceFilter filter{
.Flags = UsbHsInterfaceFilterFlags_bInterfaceClass | UsbHsInterfaceFilterFlags_bInterfaceSubClass | UsbHsInterfaceFilterFlags_bInterfaceProtocol, .Flags = UsbHsInterfaceFilterFlags_bInterfaceClass | UsbHsInterfaceFilterFlags_bInterfaceSubClass | UsbHsInterfaceFilterFlags_bInterfaceProtocol,
.bInterfaceClass = iclass, .bInterfaceClass = iclass,
.bInterfaceSubClass = isubclass, .bInterfaceSubClass = isubclass,
@ -152,7 +152,7 @@ namespace syscon::usb
s32 QueryVendorProduct(uint16_t vendor_id, uint16_t product_id) s32 QueryVendorProduct(uint16_t vendor_id, uint16_t product_id)
{ {
UsbHsInterfaceFilter filter { UsbHsInterfaceFilter filter{
.Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct, .Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct,
.idVendor = vendor_id, .idVendor = vendor_id,
.idProduct = product_id, .idProduct = product_id,
@ -164,7 +164,7 @@ namespace syscon::usb
inline Result CreateCatchAllAvailableEvent() inline Result CreateCatchAllAvailableEvent()
{ {
constexpr UsbHsInterfaceFilter filter { constexpr UsbHsInterfaceFilter filter{
.Flags = UsbHsInterfaceFilterFlags_bcdDevice_Min, .Flags = UsbHsInterfaceFilterFlags_bcdDevice_Min,
.bcdDevice_Min = 0, .bcdDevice_Min = 0,
}; };
@ -173,14 +173,13 @@ namespace syscon::usb
inline Result CreateSonyAvailableEvent() inline Result CreateSonyAvailableEvent()
{ {
constexpr UsbHsInterfaceFilter filter { constexpr UsbHsInterfaceFilter filter{
.Flags = UsbHsInterfaceFilterFlags_idVendor, .Flags = UsbHsInterfaceFilterFlags_idVendor,
.idVendor = VENDOR_SONY, .idVendor = VENDOR_SONY,
}; };
return usbHsCreateInterfaceAvailableEvent(&g_usbSonyEvent, true, SonyEventIndex, &filter); return usbHsCreateInterfaceAvailableEvent(&g_usbSonyEvent, true, SonyEventIndex, &filter);
} }
} } // namespace
void Initialize() void Initialize()
{ {
@ -236,4 +235,4 @@ namespace syscon::usb
usbHsDestroyInterfaceAvailableEvent(&g_usbCatchAllEvent, CatchAllEventIndex); usbHsDestroyInterfaceAvailableEvent(&g_usbCatchAllEvent, CatchAllEventIndex);
usbHsDestroyInterfaceAvailableEvent(&g_usbSonyEvent, SonyEventIndex); usbHsDestroyInterfaceAvailableEvent(&g_usbSonyEvent, SonyEventIndex);
} }
} } // namespace syscon::usb

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
namespace syscon::usb { namespace syscon::usb
{
void Initialize(); void Initialize();
void Exit(); void Exit();
@ -10,4 +10,4 @@ namespace syscon::usb {
Result CreateUsbEvents(); Result CreateUsbEvents();
void DestroyUsbEvents(); void DestroyUsbEvents();
} } // namespace syscon::usb