diff --git a/.vscode/settings.json b/.vscode/settings.json index c9a7570..22f1b93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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": { "array": "cpp", "*.tcc": "cpp", @@ -56,5 +60,4 @@ "mutex": "cpp", "shared_mutex": "cpp" }, - "C_Cpp.dimInactiveRegions": true } \ No newline at end of file diff --git a/source/Sysmodule/source/config_handler.cpp b/source/Sysmodule/source/config_handler.cpp index f5575cd..3b66d6b 100644 --- a/source/Sysmodule/source/config_handler.cpp +++ b/source/Sysmodule/source/config_handler.cpp @@ -172,11 +172,11 @@ namespace syscon::config return ini_parse(path, ParseConfigLine, NULL); } - void ConfigChangedCheckThreadFunc(void *arg) { WriteToLog("Starting config check thread!"); - do { + do + { if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX))) { if (config::CheckForFileChanges()) @@ -187,7 +187,7 @@ namespace syscon::config } } while (is_config_changed_check_thread_running); } - } + } // namespace void LoadGlobalConfig(const GlobalConfig &config) { @@ -327,4 +327,4 @@ namespace syscon::config g_config_changed_check_thread.CancelSynchronization(); g_config_changed_check_thread.Join(); } -} \ No newline at end of file +} // namespace syscon::config \ No newline at end of file diff --git a/source/Sysmodule/source/config_handler.h b/source/Sysmodule/source/config_handler.h index de4c3f8..883664f 100644 --- a/source/Sysmodule/source/config_handler.h +++ b/source/Sysmodule/source/config_handler.h @@ -3,10 +3,10 @@ #define CONFIG_PATH "/config/sys-con/" -#define GLOBALCONFIG CONFIG_PATH "config_global.ini" -#define XBOXCONFIG CONFIG_PATH "config_xboxorig.ini" -#define XBOX360CONFIG CONFIG_PATH "config_xbox360.ini" -#define XBOXONECONFIG CONFIG_PATH "config_xboxone.ini" +#define GLOBALCONFIG CONFIG_PATH "config_global.ini" +#define XBOXCONFIG CONFIG_PATH "config_xboxorig.ini" +#define XBOX360CONFIG CONFIG_PATH "config_xbox360.ini" +#define XBOXONECONFIG CONFIG_PATH "config_xboxone.ini" #define DUALSHOCK3CONFIG CONFIG_PATH "config_dualshock3.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 LoadAllConfigs(); @@ -29,4 +27,4 @@ namespace syscon::config Result Enable(); void Disable(); -}; \ No newline at end of file +}; // namespace syscon::config \ No newline at end of file diff --git a/source/Sysmodule/source/controller_handler.cpp b/source/Sysmodule/source/controller_handler.cpp index 6564e47..b377e89 100644 --- a/source/Sysmodule/source/controller_handler.cpp +++ b/source/Sysmodule/source/controller_handler.cpp @@ -9,13 +9,13 @@ namespace syscon::controllers { - namespace + namespace { constexpr size_t MaxControllerHandlersSize = 10; std::vector> controllerHandlers; bool UseAbstractedPad; ams::os::Mutex controllerMutex; - } + } // namespace bool IsAtControllerLimit() { @@ -46,12 +46,12 @@ namespace syscon::controllers return rc; } - std::vector>& Get() + std::vector> &Get() { return controllerHandlers; } - ams::os::Mutex& GetScopedLock() + ams::os::Mutex &GetScopedLock() { return controllerMutex; } @@ -78,4 +78,4 @@ namespace syscon::controllers { Reset(); } -} \ No newline at end of file +} // namespace syscon::controllers \ No newline at end of file diff --git a/source/Sysmodule/source/controller_handler.h b/source/Sysmodule/source/controller_handler.h index 584c0f6..626188b 100644 --- a/source/Sysmodule/source/controller_handler.h +++ b/source/Sysmodule/source/controller_handler.h @@ -9,12 +9,12 @@ namespace syscon::controllers bool IsAtControllerLimit(); Result Insert(std::unique_ptr &&controllerPtr); - std::vector>& Get(); - ams::os::Mutex& GetScopedLock(); + std::vector> &Get(); + ams::os::Mutex &GetScopedLock(); //void Remove(void Remove(bool (*func)(std::unique_ptr a)));; void Initialize(); void Reset(); void Exit(); -} \ No newline at end of file +} // namespace syscon::controllers \ No newline at end of file diff --git a/source/Sysmodule/source/main.cpp b/source/Sysmodule/source/main.cpp index c2c9b52..f5d5534 100644 --- a/source/Sysmodule/source/main.cpp +++ b/source/Sysmodule/source/main.cpp @@ -14,7 +14,7 @@ extern "C" { 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; char nx_inner_heap[INNER_HEAP_SIZE]; @@ -38,17 +38,18 @@ extern "C" } // libstratosphere variables -namespace ams +namespace ams { ncm::ProgramId CurrentProgramId = {0x690000000000000D}; - namespace result { bool CallFatalOnResultAssertion = true; } -} - + namespace result + { + bool CallFatalOnResultAssertion = true; + } +} // namespace ams extern "C" void __appInit(void) { - ams::sm::DoWithSession([] - { + ams::sm::DoWithSession([] { //Initialize system firmware version R_ABORT_UNLESS(setsysInitialize()); SetSysFirmwareVersion fw; @@ -58,7 +59,7 @@ extern "C" void __appInit(void) R_ABORT_UNLESS(timeInitialize()); R_ABORT_UNLESS(hiddbgInitialize()); - if (hosversionAtLeast(7,0,0)) + if (hosversionAtLeast(7, 0, 0)) R_ABORT_UNLESS(hiddbgAttachHdlsWorkBuffer()); R_ABORT_UNLESS(usbHsInitialize()); R_ABORT_UNLESS(pscmInitialize()); diff --git a/source/Sysmodule/source/psc_module.cpp b/source/Sysmodule/source/psc_module.cpp index 7737b0f..7b176f7 100644 --- a/source/Sysmodule/source/psc_module.cpp +++ b/source/Sysmodule/source/psc_module.cpp @@ -21,7 +21,8 @@ namespace syscon::psc void PscThreadFunc(void *arg) { - do { + do + { if (R_SUCCEEDED(waitSingle(pscModuleWaiter, UINT64_MAX))) { PscPmState pscState; @@ -46,7 +47,7 @@ namespace syscon::psc } } while (is_psc_thread_running); } - } + } // namespace Result Initialize() { 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.Join(); } -}; \ No newline at end of file +}; // namespace syscon::psc \ No newline at end of file diff --git a/source/Sysmodule/source/usb_module.cpp b/source/Sysmodule/source/usb_module.cpp index 931212f..0a89fda 100644 --- a/source/Sysmodule/source/usb_module.cpp +++ b/source/Sysmodule/source/usb_module.cpp @@ -17,7 +17,6 @@ namespace syscon::usb constexpr u8 CatchAllEventIndex = 2; constexpr u8 SonyEventIndex = 0; - constexpr size_t MaxUsbHsInterfacesSize = 16; ams::os::Mutex usbMutex; @@ -42,7 +41,8 @@ namespace syscon::usb void UsbEventThreadFunc(void *arg) { - do { + do + { if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX))) { WriteToLog("Catch-all event went off"); @@ -70,7 +70,8 @@ namespace syscon::usb void UsbSonyEventThreadFunc(void *arg) { - do { + do + { if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX))) { WriteToLog("Sony event went off"); @@ -79,12 +80,10 @@ namespace syscon::usb if (!controllers::IsAtControllerLimit()) { s32 total_entries; - if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) - && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0) + if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0) WriteToLog("Initializing Dualshock 3 controller: 0x%x", controllers::Insert(std::make_unique(std::make_unique(interfaces, total_entries)))); - 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) + 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) WriteToLog("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique(std::make_unique(interfaces, total_entries)))); } } @@ -93,7 +92,8 @@ namespace syscon::usb void UsbInterfaceChangeThreadFunc(void *arg) { - do { + do + { if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX))) { s32 total_entries; @@ -138,7 +138,7 @@ namespace syscon::usb s32 QueryInterfaces(u8 iclass, u8 isubclass, u8 iprotocol) { - UsbHsInterfaceFilter filter { + UsbHsInterfaceFilter filter{ .Flags = UsbHsInterfaceFilterFlags_bInterfaceClass | UsbHsInterfaceFilterFlags_bInterfaceSubClass | UsbHsInterfaceFilterFlags_bInterfaceProtocol, .bInterfaceClass = iclass, .bInterfaceSubClass = isubclass, @@ -152,7 +152,7 @@ namespace syscon::usb s32 QueryVendorProduct(uint16_t vendor_id, uint16_t product_id) { - UsbHsInterfaceFilter filter { + UsbHsInterfaceFilter filter{ .Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct, .idVendor = vendor_id, .idProduct = product_id, @@ -164,7 +164,7 @@ namespace syscon::usb inline Result CreateCatchAllAvailableEvent() { - constexpr UsbHsInterfaceFilter filter { + constexpr UsbHsInterfaceFilter filter{ .Flags = UsbHsInterfaceFilterFlags_bcdDevice_Min, .bcdDevice_Min = 0, }; @@ -173,14 +173,13 @@ namespace syscon::usb inline Result CreateSonyAvailableEvent() { - constexpr UsbHsInterfaceFilter filter { + constexpr UsbHsInterfaceFilter filter{ .Flags = UsbHsInterfaceFilterFlags_idVendor, .idVendor = VENDOR_SONY, }; return usbHsCreateInterfaceAvailableEvent(&g_usbSonyEvent, true, SonyEventIndex, &filter); } - } - + } // namespace void Initialize() { @@ -236,4 +235,4 @@ namespace syscon::usb usbHsDestroyInterfaceAvailableEvent(&g_usbCatchAllEvent, CatchAllEventIndex); usbHsDestroyInterfaceAvailableEvent(&g_usbSonyEvent, SonyEventIndex); } -} \ No newline at end of file +} // namespace syscon::usb \ No newline at end of file diff --git a/source/Sysmodule/source/usb_module.h b/source/Sysmodule/source/usb_module.h index dc0e73a..f6c5ad7 100644 --- a/source/Sysmodule/source/usb_module.h +++ b/source/Sysmodule/source/usb_module.h @@ -1,7 +1,7 @@ #pragma once -namespace syscon::usb { - +namespace syscon::usb +{ void Initialize(); void Exit(); @@ -10,4 +10,4 @@ namespace syscon::usb { Result CreateUsbEvents(); void DestroyUsbEvents(); -} \ No newline at end of file +} // namespace syscon::usb \ No newline at end of file