Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSI GC20 SUPPORT #299

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add LOG macro
cathery committed Dec 7, 2020
commit f8b472fda9180b3f812835e582bc37de0a91251a
16 changes: 8 additions & 8 deletions source/Sysmodule/source/config_handler.cpp
Original file line number Diff line number Diff line change
@@ -176,14 +176,14 @@ namespace syscon::config

void ConfigChangedCheckThreadFunc(void *arg)
{
WriteToLog("Starting config check thread!");
LOG("Starting config check thread!");
do
{
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX)))
{
if (config::CheckForFileChanges())
{
WriteToLog("File check succeeded! Loading configs...");
LOG("File check succeeded! Loading configs...");
config::LoadAllConfigs();
}
}
@@ -203,37 +203,37 @@ namespace syscon::config
LoadGlobalConfig(tempGlobalConfig);
}
else
WriteToLog("Failed to read from global config!");
LOG("Failed to read from global config!");

if (R_SUCCEEDED(ReadFromConfig(XBOXCONFIG)))
{
XboxController::LoadConfig(&tempConfig);
}
else
WriteToLog("Failed to read from xbox orig config!");
LOG("Failed to read from xbox orig config!");

if (R_SUCCEEDED(ReadFromConfig(XBOXONECONFIG)))
XboxOneController::LoadConfig(&tempConfig);
else
WriteToLog("Failed to read from xbox one config!");
LOG("Failed to read from xbox one config!");

if (R_SUCCEEDED(ReadFromConfig(XBOX360CONFIG)))
{
Xbox360Controller::LoadConfig(&tempConfig);
Xbox360WirelessController::LoadConfig(&tempConfig);
}
else
WriteToLog("Failed to read from xbox 360 config!");
LOG("Failed to read from xbox 360 config!");

if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK3CONFIG)))
Dualshock3Controller::LoadConfig(&tempConfig);
else
WriteToLog("Failed to read from dualshock 3 config!");
LOG("Failed to read from dualshock 3 config!");

if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK4CONFIG)))
Dualshock4Controller::LoadConfig(&tempConfig, tempColor);
else
WriteToLog("Failed to read from dualshock 4 config!");
LOG("Failed to read from dualshock 4 config!");
}

bool CheckForFileChanges()
4 changes: 2 additions & 2 deletions source/Sysmodule/source/controller_handler.cpp
Original file line number Diff line number Diff line change
@@ -28,12 +28,12 @@ namespace syscon::controllers
if (UseAbstractedPad)
{
switchHandler = std::make_unique<SwitchAbstractedPadHandler>(std::move(controllerPtr));
WriteToLog("Inserting controller as abstracted pad");
LOG("Inserting controller as abstracted pad");
}
else
{
switchHandler = std::make_unique<SwitchHDLHandler>(std::move(controllerPtr));
WriteToLog("Inserting controller as HDLs");
LOG("Inserting controller as HDLs");
}

Result rc = switchHandler->Initialize();
3 changes: 1 addition & 2 deletions source/Sysmodule/source/log.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ void DiscardOldLogs()
if (fileSize >= 0x20'000)
{
fsFsDeleteFile(fs, LOG_PATH);
WriteToLog("Deleted previous log file");
LOG("Deleted previous log file");
}
}

@@ -46,7 +46,6 @@ void WriteToLog(const char *fmt, ...)
vfprintf(fp, fmt, va);
va_end(va);

fprintf(fp, "\n");
fclose(fp);
}

2 changes: 2 additions & 0 deletions source/Sysmodule/source/log.h
Original file line number Diff line number Diff line change
@@ -15,3 +15,5 @@ extern "C"
#ifdef __cplusplus
}
#endif

#define LOG(fmt, ...) WriteToLog(fmt "\n", ##__VA_ARGS__)
2 changes: 1 addition & 1 deletion source/Sysmodule/source/main.cpp
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ using namespace syscon;

int main(int argc, char *argv[])
{
WriteToLog("\n\nNew sysmodule session started on version " APP_VERSION);
LOG("\n\nNew sysmodule session started on version " APP_VERSION);
config::Initialize();
controllers::Initialize();
usb::Initialize();
22 changes: 11 additions & 11 deletions source/Sysmodule/source/usb_module.cpp
Original file line number Diff line number Diff line change
@@ -52,24 +52,24 @@ namespace syscon::usb
{
if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
{
WriteToLog("Catch-all event went off");
LOG("Catch-all event went off");

std::scoped_lock usbLock(usbMutex);
if (!controllers::IsAtControllerLimit())
{
s32 total_entries;
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 1)) != 0)
WriteToLog("Initializing Xbox 360 controller: 0x%x", controllers::Insert(std::make_unique<Xbox360Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox 360 controller: 0x%x", controllers::Insert(std::make_unique<Xbox360Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));

if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 129)) != 0)
for (int i = 0; i != total_entries; ++i)
WriteToLog("Initializing Xbox 360 wireless controller: 0x%x", controllers::Insert(std::make_unique<Xbox360WirelessController>(std::make_unique<SwitchUSBDevice>(interfaces + i, 1))));
LOG("Initializing Xbox 360 wireless controller: 0x%x", controllers::Insert(std::make_unique<Xbox360WirelessController>(std::make_unique<SwitchUSBDevice>(interfaces + i, 1))));

if ((total_entries = QueryInterfaces(0x58, 0x42, 0x00)) != 0)
WriteToLog("Initializing Xbox Original controller: 0x%x", controllers::Insert(std::make_unique<XboxController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox Original controller: 0x%x", controllers::Insert(std::make_unique<XboxController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));

if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 71, 208)) != 0)
WriteToLog("Initializing Xbox One controller: 0x%x", controllers::Insert(std::make_unique<XboxOneController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox One controller: 0x%x", controllers::Insert(std::make_unique<XboxOneController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
}
}
} while (is_usb_event_thread_running);
@@ -81,17 +81,17 @@ namespace syscon::usb
{
if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX)))
{
WriteToLog("Sony event went off");
LOG("Sony event went off");

std::scoped_lock usbLock(usbMutex);
if (!controllers::IsAtControllerLimit())
{
s32 total_entries;
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))));
LOG("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)
WriteToLog("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
}
}
} while (is_usb_event_thread_running);
@@ -104,7 +104,7 @@ namespace syscon::usb
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
{
s32 total_entries;
WriteToLog("Interface state was changed");
LOG("Interface state was changed");

std::scoped_lock usbLock(usbMutex);
std::scoped_lock controllersLock(controllers::GetScopedLock());
@@ -133,9 +133,9 @@ namespace syscon::usb

if (!found_flag)
{
WriteToLog("Erasing controller");
LOG("Erasing controller");
controllers::Get().erase(it--);
WriteToLog("Controller erased!");
LOG("Controller erased!");
}
}
}