1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-12-28 18:17:13 +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": {
"array": "cpp",
"*.tcc": "cpp",
@ -56,5 +60,4 @@
"mutex": "cpp",
"shared_mutex": "cpp"
},
"C_Cpp.dimInactiveRegions": true
}

View File

@ -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();
}
}
} // namespace syscon::config

View File

@ -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();
};
}; // namespace syscon::config

View File

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

View File

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

View File

@ -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());

View File

@ -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();
}
};
}; // namespace syscon::psc

View File

@ -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<Dualshock3Controller>(std::make_unique<SwitchUSBDevice>(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<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(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);
}
}
} // namespace syscon::usb

View File

@ -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();
}
} // namespace syscon::usb