Remove newlines at the end of logs

This commit is contained in:
GaryOderNichts 2020-12-16 02:04:31 +01:00
parent d667f8e364
commit b5f7997c2a
13 changed files with 178 additions and 178 deletions

View File

@ -45,7 +45,7 @@ BOOL ConfigReader::ReadConfigs(std::string path) {
if(fileList.size() > 0) { if(fileList.size() > 0) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found %d config files\n",fileList.size()); DEBUG_FUNCTION_LINE("Found %d config files",fileList.size());
} }
processFileList(fileList); processFileList(fileList);
} }
@ -55,7 +55,7 @@ BOOL ConfigReader::ReadConfigs(std::string path) {
ConfigReader::~ConfigReader() { ConfigReader::~ConfigReader() {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("~ConfigReader\n"); DEBUG_FUNCTION_LINE("~ConfigReader");
} }
} }
@ -65,7 +65,7 @@ std::vector<std::string> ConfigReader::ScanFolder(std::string path) {
struct dirent *dirent = NULL; struct dirent *dirent = NULL;
DIR *dirHandle = opendir(path.c_str()); DIR *dirHandle = opendir(path.c_str());
if (dirHandle == NULL) { if (dirHandle == NULL) {
DEBUG_FUNCTION_LINE("Failed to open dir %s\n",path.c_str()); DEBUG_FUNCTION_LINE("Failed to open dir %s",path.c_str());
config_files.push_back("ERROR"); //TODO: Find a proper solution config_files.push_back("ERROR"); //TODO: Find a proper solution
return config_files; return config_files;
} }
@ -82,7 +82,7 @@ std::vector<std::string> ConfigReader::ScanFolder(std::string path) {
if(!isDir && StringTools::EndsWith(std::string(filename),".ini")) { if(!isDir && StringTools::EndsWith(std::string(filename),".ini")) {
config_files.push_back(newPath); config_files.push_back(newPath);
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found ini: %s \n",newPath.c_str()); DEBUG_FUNCTION_LINE("Found ini: %s ",newPath.c_str());
} }
} }
} }
@ -92,7 +92,7 @@ std::vector<std::string> ConfigReader::ScanFolder(std::string path) {
void ConfigReader::processFileList(std::vector<std::string> path) { void ConfigReader::processFileList(std::vector<std::string> path) {
for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); ++it) { for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); ++it) {
DEBUG_FUNCTION_LINE("Reading %s\n",it->c_str()); DEBUG_FUNCTION_LINE("Reading %s",it->c_str());
std::string result = loadFileToString(*it); std::string result = loadFileToString(*it);
ConfigParser parser(result); ConfigParser parser(result);

View File

@ -38,11 +38,11 @@ static VPADStatus myVPADBuffer[4];
void ControllerPatcher::InitButtonMapping() { void ControllerPatcher::InitButtonMapping() {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Init called \n"); DEBUG_FUNCTION_LINE("Init called ");
} }
if(!gButtonRemappingConfigDone) { if(!gButtonRemappingConfigDone) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Remapping is running! \n"); DEBUG_FUNCTION_LINE("Remapping is running! ");
} }
gButtonRemappingConfigDone = 1; gButtonRemappingConfigDone = 1;
memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything
@ -107,14 +107,14 @@ void ControllerPatcher::ResetConfig() {
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
gGamePadSlot = slotdata.deviceslot; gGamePadSlot = slotdata.deviceslot;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
gMouseSlot = slotdata.deviceslot; gMouseSlot = slotdata.deviceslot;
gHID_LIST_MOUSE = slotdata.hidmask; gHID_LIST_MOUSE = slotdata.hidmask;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
@ -124,7 +124,7 @@ void ControllerPatcher::ResetConfig() {
gHID_SLOT_KEYBOARD = keyboard_slot; gHID_SLOT_KEYBOARD = keyboard_slot;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register Keyboard-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD); DEBUG_FUNCTION_LINE("Register Keyboard-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
@ -133,7 +133,7 @@ void ControllerPatcher::ResetConfig() {
gHID_LIST_GC = gc_hid; gHID_LIST_GC = gc_hid;
gHID_SLOT_GC = gc_slot; gHID_SLOT_GC = gc_slot;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); DEBUG_FUNCTION_LINE("Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
@ -141,7 +141,7 @@ void ControllerPatcher::ResetConfig() {
uint32_t ds3_hid = slotdata.hidmask; uint32_t ds3_hid = slotdata.hidmask;
gHID_LIST_DS3 = ds3_hid; gHID_LIST_DS3 = ds3_hid;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register DS3-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); DEBUG_FUNCTION_LINE("Register DS3-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
@ -149,20 +149,20 @@ void ControllerPatcher::ResetConfig() {
uint32_t ds4_hid = slotdata.hidmask; uint32_t ds4_hid = slotdata.hidmask;
gHID_LIST_DS4 = ds4_hid; gHID_LIST_DS4 = ds4_hid;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(ds4_hid),ds4_slot); DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(ds4_hid),ds4_slot);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
uint32_t xinput_slot = slotdata.deviceslot; uint32_t xinput_slot = slotdata.deviceslot;
uint32_t xinput_hid = slotdata.hidmask; uint32_t xinput_hid = slotdata.hidmask;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(xinput_hid),xinput_slot); DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(xinput_hid),xinput_slot);
} }
ControllerPatcherUtils::getNextSlotData(&slotdata); ControllerPatcherUtils::getNextSlotData(&slotdata);
uint32_t switch_pro_slot = slotdata.deviceslot; uint32_t switch_pro_slot = slotdata.deviceslot;
gHID_LIST_SWITCH_PRO = slotdata.hidmask; gHID_LIST_SWITCH_PRO = slotdata.hidmask;
DEBUG_FUNCTION_LINE("Register Switch-Pro-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_SWITCH_PRO),switch_pro_slot); DEBUG_FUNCTION_LINE("Register Switch-Pro-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_SWITCH_PRO),switch_pro_slot);
config_controller_hidmask[gc_slot] = gHID_LIST_GC; config_controller_hidmask[gc_slot] = gHID_LIST_GC;
@ -500,37 +500,37 @@ BOOL ControllerPatcher::Init(const char * pathToConfig) {
gSamplingCallback = NULL; gSamplingCallback = NULL;
} }
} }
DEBUG_FUNCTION_LINE("Found the gSamplingCallback at %08X \n",gSamplingCallback); DEBUG_FUNCTION_LINE("Found the gSamplingCallback at %08X ",gSamplingCallback);
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Init called! \n"); DEBUG_FUNCTION_LINE("Init called! ");
} }
if(gConfig_done == HID_INIT_NOT_DONE) { if(gConfig_done == HID_INIT_NOT_DONE) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("First time calling the Init\n"); DEBUG_FUNCTION_LINE("First time calling the Init");
} }
gConfig_done = HID_INIT_DONE; gConfig_done = HID_INIT_DONE;
ControllerPatcher::ResetConfig(); ControllerPatcher::ResetConfig();
} else { } else {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Config already done!\n"); DEBUG_FUNCTION_LINE("Config already done!");
} }
} }
if(pathToConfig != NULL && gConfig_done != HID_SDCARD_READ) { if(pathToConfig != NULL && gConfig_done != HID_SDCARD_READ) {
DEBUG_FUNCTION_LINE("Reading config files from SD Card\n"); DEBUG_FUNCTION_LINE("Reading config files from SD Card");
DEBUG_FUNCTION_LINE("Reading config files from SD Card\n"); DEBUG_FUNCTION_LINE("Reading config files from SD Card");
ConfigReader* reader = ConfigReader::getInstance(); ConfigReader* reader = ConfigReader::getInstance();
if(reader->ReadConfigs(pathToConfig)) { if(reader->ReadConfigs(pathToConfig)) {
DEBUG_FUNCTION_LINE("Done with reading config files from SD Card\n"); DEBUG_FUNCTION_LINE("Done with reading config files from SD Card");
gConfig_done = HID_SDCARD_READ; gConfig_done = HID_SDCARD_READ;
} }
} }
DEBUG_FUNCTION_LINE("Initializing the data for button remapping\n"); DEBUG_FUNCTION_LINE("Initializing the data for button remapping");
InitButtonMapping(); InitButtonMapping();
if(!gHIDAttached) { if(!gHIDAttached) {
@ -542,13 +542,13 @@ BOOL ControllerPatcher::Init(const char * pathToConfig) {
void ControllerPatcher::startNetworkServer() { void ControllerPatcher::startNetworkServer() {
if(!gNetworkControllerActivated) return; if(!gNetworkControllerActivated) return;
DEBUG_FUNCTION_LINE("statedNetworkServer! \n"); DEBUG_FUNCTION_LINE("statedNetworkServer! ");
UDPServer::getInstance(); UDPServer::getInstance();
CPTCPServer::getInstance(); CPTCPServer::getInstance();
} }
void ControllerPatcher::stopNetworkServer() { void ControllerPatcher::stopNetworkServer() {
DEBUG_FUNCTION_LINE("called! \n"); DEBUG_FUNCTION_LINE("called! ");
UDPServer::destroyInstance(); UDPServer::destroyInstance();
UDPClient::destroyInstance(); UDPClient::destroyInstance();
CPTCPServer::destroyInstance(); CPTCPServer::destroyInstance();
@ -556,7 +556,7 @@ void ControllerPatcher::stopNetworkServer() {
void ControllerPatcher::DeInit() { void ControllerPatcher::DeInit() {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("called! \n"); DEBUG_FUNCTION_LINE("called! ");
} }
if(gHIDAttached) HIDDelClient(&gHIDClient); if(gHIDAttached) HIDDelClient(&gHIDClient);
@ -619,7 +619,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting()
if(IMIsDimEnabled(&res) == 0) { if(IMIsDimEnabled(&res) == 0) {
if(res == 1) { if(res == 1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Dim was orignally enabled!\n"); DEBUG_FUNCTION_LINE("Dim was orignally enabled!");
} }
gOriginalDimState = 1; gOriginalDimState = 1;
} }
@ -628,7 +628,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting()
if(IMIsAPDEnabled(&res) == 0) { if(IMIsAPDEnabled(&res) == 0) {
if(res == 1) { if(res == 1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Auto power down was orignally enabled!\n"); DEBUG_FUNCTION_LINE("Auto power down was orignally enabled!");
} }
gOriginalAPDState = 1; gOriginalAPDState = 1;
} }
@ -636,7 +636,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting()
IMDisableDim(); IMDisableDim();
IMDisableAPD(); IMDisableAPD();
DEBUG_FUNCTION_LINE("Disable Energy savers\n"); DEBUG_FUNCTION_LINE("Disable Energy savers");
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;
} }
@ -644,11 +644,11 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::restoreWiiUEnergySetting()
//Check if we need to enable Auto Power down again on exiting //Check if we need to enable Auto Power down again on exiting
if(gOriginalAPDState == 1) { if(gOriginalAPDState == 1) {
DEBUG_FUNCTION_LINE("Auto shutdown was on before using HID to VPAD. Setting it to on again.\n"); DEBUG_FUNCTION_LINE("Auto shutdown was on before using HID to VPAD. Setting it to on again.");
IMEnableAPD(); IMEnableAPD();
} }
if(gOriginalDimState == 1) { if(gOriginalDimState == 1) {
DEBUG_FUNCTION_LINE("Burn-in reduction was on before using HID to VPAD. Setting it to on again.\n"); DEBUG_FUNCTION_LINE("Burn-in reduction was on before using HID to VPAD. Setting it to on again.");
IMEnableDim(); IMEnableDim();
} }
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;
@ -900,7 +900,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
int32_t res; int32_t res;
if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) {
DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) = %d\n",res); DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) = %d",res);
continue; continue;
} }
@ -910,7 +910,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
HID_Data * data_cur; HID_Data * data_cur;
if((res = ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) < 0) { if((res = ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) < 0) {
//DEBUG_FUNCTION_LINE("ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) = %d\n",res); //DEBUG_FUNCTION_LINE("ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) = %d",res);
continue; continue;
} }
data_list.push_back(data_cur); data_list.push_back(data_cur);
@ -1028,7 +1028,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::printVPADButtons(VPADStatu
if((buffer->trigger & VPAD_STICK_L_EMULATION_UP) == VPAD_STICK_L_EMULATION_UP) strcat(output,"LE_Up "); if((buffer->trigger & VPAD_STICK_L_EMULATION_UP) == VPAD_STICK_L_EMULATION_UP) strcat(output,"LE_Up ");
if((buffer->trigger & VPAD_STICK_L_EMULATION_DOWN) == VPAD_STICK_L_EMULATION_DOWN) strcat(output,"LE_Down "); if((buffer->trigger & VPAD_STICK_L_EMULATION_DOWN) == VPAD_STICK_L_EMULATION_DOWN) strcat(output,"LE_Down ");
DEBUG_FUNCTION_LINE("%spressed Sticks: LX %f LY %f RX %f RY %f\n",output,buffer->leftStick.x,buffer->leftStick.y,buffer->rightStick.x,buffer->rightStick.y); DEBUG_FUNCTION_LINE("%spressed Sticks: LX %f LY %f RX %f RY %f",output,buffer->leftStick.x,buffer->leftStick.y,buffer->rightStick.x,buffer->rightStick.y);
} }
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;
} }
@ -1173,10 +1173,10 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(BOOL bu
if(button_pressed && gCallbackCooldown == 0) { if(button_pressed && gCallbackCooldown == 0) {
gCallbackCooldown = 0xFF; gCallbackCooldown = 0xFF;
/*if(HID_DEBUG){ log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!\n",__LINE__); } /*if(HID_DEBUG){ log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!",__LINE__); }
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gExtensionCallback = %08X %08X %08X %08X\n",__LINE__,gExtensionCallback[0],gExtensionCallback[1],gExtensionCallback[2],gExtensionCallback[3]); } if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gExtensionCallback = %08X %08X %08X %08X",__LINE__,gExtensionCallback[0],gExtensionCallback[1],gExtensionCallback[2],gExtensionCallback[3]); }
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gWPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gWPADConnectCallback[0],gWPADConnectCallback[1],gWPADConnectCallback[2],gWPADConnectCallback[3]); } if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gWPADConnectCallback = %08X %08X %08X %08X",__LINE__,gWPADConnectCallback[0],gWPADConnectCallback[1],gWPADConnectCallback[2],gWPADConnectCallback[3]); }
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gKPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gKPADConnectCallback[0],gKPADConnectCallback[1],gKPADConnectCallback[2],gKPADConnectCallback[3]); }*/ if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gKPADConnectCallback = %08X %08X %08X %08X",__LINE__,gKPADConnectCallback[0],gKPADConnectCallback[1],gKPADConnectCallback[2],gKPADConnectCallback[3]); }*/
if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro1)) { if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro1)) {
ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_0); ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_0);
@ -1200,15 +1200,15 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(BOOL bu
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackDataInternal(WPADChan chan) { CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackDataInternal(WPADChan chan) {
if(gWPADConnectCallback[chan] != NULL) { if(gWPADConnectCallback[chan] != NULL) {
log_printf("Called WPAD connect callback for pro controller in slot %d!\n",chan + 1); log_printf("Called WPAD connect callback for pro controller in slot %d!",chan + 1);
gWPADConnectCallback[chan](chan,0); gWPADConnectCallback[chan](chan,0);
} }
if(gKPADConnectCallback[chan] != NULL) { if(gKPADConnectCallback[chan] != NULL) {
log_printf("Called KPAD connect callback for pro controller in slot %d!\n",chan + 1); log_printf("Called KPAD connect callback for pro controller in slot %d!",chan + 1);
gKPADConnectCallback[chan](chan,0); gKPADConnectCallback[chan](chan,0);
} }
if(gExtensionCallback[chan] != NULL) { if(gExtensionCallback[chan] != NULL) {
log_printf("Called extension callback for pro controller in slot %d!\n",chan + 1); log_printf("Called extension callback for pro controller in slot %d!",chan + 1);
gExtensionCallback[chan](chan,WPAD_EXT_PRO_CONTROLLER); gExtensionCallback[chan](chan,WPAD_EXT_PRO_CONTROLLER);
} }
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;

View File

@ -23,7 +23,7 @@
ConfigParser::ConfigParser(std::string configData) { ConfigParser::ConfigParser(std::string configData) {
this->content = configData; this->content = configData;
this->contentLines = StringTools::stringSplit(content, "\n"); this->contentLines = StringTools::stringSplit(content, "");
if(contentLines.empty()) { if(contentLines.empty()) {
return; return;
@ -72,13 +72,13 @@ void ConfigParser::setSlot(uint16_t newSlot) {
BOOL ConfigParser::Init() { BOOL ConfigParser::Init() {
if(contentLines.size() == 0) { if(contentLines.size() == 0) {
DEBUG_FUNCTION_LINE("File seems to be empty. Make sure to have a proper header\n"); DEBUG_FUNCTION_LINE("File seems to be empty. Make sure to have a proper header");
return false; return false;
} }
const char * line = contentLines[0].c_str(); const char * line = contentLines[0].c_str();
int32_t len = strlen(line); int32_t len = strlen(line);
if(len <= 4) { if(len <= 4) {
DEBUG_FUNCTION_LINE("Header is too short.\n"); DEBUG_FUNCTION_LINE("Header is too short.");
return false; return false;
} }
std::string identify; std::string identify;
@ -86,28 +86,28 @@ BOOL ConfigParser::Init() {
if(line[0] == '[' && line[len-1] == ']') { if(line[0] == '[' && line[len-1] == ']') {
identify = contentLines[0].substr(1,len-2); identify = contentLines[0].substr(1,len-2);
} else { } else {
DEBUG_FUNCTION_LINE("Not a proper config file!\n"); DEBUG_FUNCTION_LINE("Not a proper config file!");
return false; return false;
} }
if(identify.compare("GAMEPAD") == 0) { if(identify.compare("GAMEPAD") == 0) {
DEBUG_FUNCTION_LINE("Its a gamepad config file!\n"); DEBUG_FUNCTION_LINE("Its a gamepad config file!");
setSlot(gGamePadSlot); setSlot(gGamePadSlot);
setType(PARSE_GAMEPAD); setType(PARSE_GAMEPAD);
} else if(identify.compare("MOUSE") == 0) { } else if(identify.compare("MOUSE") == 0) {
DEBUG_FUNCTION_LINE("Its a mouse config file!\n"); DEBUG_FUNCTION_LINE("Its a mouse config file!");
setSlot(gMouseSlot); setSlot(gMouseSlot);
setType(PARSE_MOUSE); setType(PARSE_MOUSE);
this->vid = HID_MOUSE_VID; this->vid = HID_MOUSE_VID;
this->pid = HID_MOUSE_PID; this->pid = HID_MOUSE_PID;
} else if(identify.compare("KEYBOARD") == 0) { } else if(identify.compare("KEYBOARD") == 0) {
DEBUG_FUNCTION_LINE("Its a keyboard config file!\n"); DEBUG_FUNCTION_LINE("Its a keyboard config file!");
setSlot(gHID_SLOT_KEYBOARD); setSlot(gHID_SLOT_KEYBOARD);
setType(PARSE_KEYBOARD); setType(PARSE_KEYBOARD);
this->vid = HID_KEYBOARD_VID; this->vid = HID_KEYBOARD_VID;
this->pid = HID_KEYBOARD_PID; this->pid = HID_KEYBOARD_PID;
} else { } else {
DEBUG_FUNCTION_LINE("Its a controller config file!\n"); DEBUG_FUNCTION_LINE("Its a controller config file!");
setSlot(getSlotController(identify)); setSlot(getSlotController(identify));
setType(PARSE_CONTROLLER); setType(PARSE_CONTROLLER);
} }
@ -123,28 +123,28 @@ BOOL ConfigParser::Init() {
void ConfigParser::parseSingleLine(std::string line) { void ConfigParser::parseSingleLine(std::string line) {
if(line.empty()) { if(line.empty()) {
DEBUG_FUNCTION_LINE("Can't parse line. it's empty\n"); DEBUG_FUNCTION_LINE("Can't parse line. it's empty");
return; return;
} }
std::vector<std::string> cur_values = StringTools::stringSplit(line,"="); std::vector<std::string> cur_values = StringTools::stringSplit(line,"=");
if(cur_values.size() != 2) { if(cur_values.size() != 2) {
if(HID_DEBUG || cur_values.size() > 2) { if(HID_DEBUG || cur_values.size() > 2) {
DEBUG_FUNCTION_LINE("Not a valid key=pair line %s\n",line.c_str()); DEBUG_FUNCTION_LINE("Not a valid key=pair line %s",line.c_str());
} }
return; return;
} else { } else {
uint16_t hid_slot = getSlot(); uint16_t hid_slot = getSlot();
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("leftpart = \"%s\" \n",cur_values[0].c_str()); DEBUG_FUNCTION_LINE("leftpart = \"%s\" ",cur_values[0].c_str());
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("rightpart = \"%s\" \n",cur_values[1].c_str()); DEBUG_FUNCTION_LINE("rightpart = \"%s\" ",cur_values[1].c_str());
} }
int32_t keyslot = -1; int32_t keyslot = -1;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Checking single value\n"); DEBUG_FUNCTION_LINE("Checking single value");
} }
if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD) { if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD) {
keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]); keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]);
@ -155,7 +155,7 @@ void ConfigParser::parseSingleLine(std::string line) {
} }
if(keyslot != -1) { if(keyslot != -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a single value\n"); DEBUG_FUNCTION_LINE("Its a single value");
} }
long rightValue = -1; long rightValue = -1;
BOOL valueSet = false; BOOL valueSet = false;
@ -164,7 +164,7 @@ void ConfigParser::parseSingleLine(std::string line) {
if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL) { if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL) {
if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE) if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE)
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Settings preset DPAD MODE and Mask\n"); DEBUG_FUNCTION_LINE("Settings preset DPAD MODE and Mask");
} }
config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET;
config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE]; config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE];
@ -180,11 +180,11 @@ void ConfigParser::parseSingleLine(std::string line) {
if(getType() == PARSE_KEYBOARD) { if(getType() == PARSE_KEYBOARD) {
if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1) { if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined Keyboard! \"%s\" is %d\n",cur_values[1].c_str(),rightValue); DEBUG_FUNCTION_LINE("Used pre-defined Keyboard! \"%s\" is %d",cur_values[1].c_str(),rightValue);
} }
} else { } else {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str()); DEBUG_FUNCTION_LINE("I need to parse %s",cur_values[1].c_str());
} }
char * ptr; char * ptr;
rightValue = strtol(cur_values[1].c_str(),&ptr,16); rightValue = strtol(cur_values[1].c_str(),&ptr,16);
@ -195,14 +195,14 @@ void ConfigParser::parseSingleLine(std::string line) {
if(getType() == PARSE_MOUSE) { //No parsing for the mouse if(getType() == PARSE_MOUSE) { //No parsing for the mouse
if(rightValue == -1) { if(rightValue == -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Invalid mouse value, lets skip it %s\n",cur_values[1].c_str()); DEBUG_FUNCTION_LINE("Invalid mouse value, lets skip it %s",cur_values[1].c_str());
} }
return; return;
} }
} else { } else {
if(rightValue == -1) { if(rightValue == -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str()); DEBUG_FUNCTION_LINE("I need to parse %s",cur_values[1].c_str());
} }
char * ptr; char * ptr;
rightValue = strtol(cur_values[1].c_str(),&ptr,16); rightValue = strtol(cur_values[1].c_str(),&ptr,16);
@ -210,7 +210,7 @@ void ConfigParser::parseSingleLine(std::string line) {
} }
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Setting value to %d\n",rightValue); DEBUG_FUNCTION_LINE("Setting value to %d",rightValue);
} }
config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET;
@ -218,22 +218,22 @@ void ConfigParser::parseSingleLine(std::string line) {
} }
} else { } else {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Check pair value\n"); DEBUG_FUNCTION_LINE("Check pair value");
} }
keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]); keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]);
if(keyslot != -1) { if(keyslot != -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a pair value\n"); DEBUG_FUNCTION_LINE("Its a pair value");
} }
if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)) { if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("And its no preset\n"); DEBUG_FUNCTION_LINE("And its no preset");
} }
std::vector<std::string> rightvalues = StringTools::stringSplit(cur_values[1],","); std::vector<std::string> rightvalues = StringTools::stringSplit(cur_values[1],",");
if(rightvalues.size() != 2) { if(rightvalues.size() != 2) {
DEBUG_FUNCTION_LINE("%d instead of 2 key=values pairs in line\n",rightvalues.size()); DEBUG_FUNCTION_LINE("%d instead of 2 key=values pairs in line",rightvalues.size());
return; return;
} }
@ -244,15 +244,15 @@ void ConfigParser::parseSingleLine(std::string line) {
config_controller[hid_slot][keyslot][1] = secondValue; config_controller[hid_slot][keyslot][1] = secondValue;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Set %02X,%02X\n",firstValue,secondValue); DEBUG_FUNCTION_LINE("Set %02X,%02X",firstValue,secondValue);
} }
} else { } else {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found preset value!!\n"); DEBUG_FUNCTION_LINE("Found preset value!!");
} }
} }
} else { } else {
DEBUG_FUNCTION_LINE("The setting \"%s\" is unknown!\n",cur_values[0].c_str()); DEBUG_FUNCTION_LINE("The setting \"%s\" is unknown!",cur_values[0].c_str());
} }
} }
} }
@ -270,13 +270,13 @@ BOOL ConfigParser::resetConfig() {
int32_t ConfigParser::getSlotController(std::string identify) { int32_t ConfigParser::getSlotController(std::string identify) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Getting Controller Slot\n"); DEBUG_FUNCTION_LINE("Getting Controller Slot");
} }
std::vector<std::string> values = StringTools::stringSplit(identify,","); std::vector<std::string> values = StringTools::stringSplit(identify,",");
if(values.size() != 2) { if(values.size() != 2) {
DEBUG_FUNCTION_LINE("You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)\n",identify.c_str()); DEBUG_FUNCTION_LINE("You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)",identify.c_str());
return HID_INVALID_SLOT; return HID_INVALID_SLOT;
} }
@ -288,7 +288,7 @@ int32_t ConfigParser::getSlotController(std::string identify) {
if(pid < 0) { if(pid < 0) {
return HID_INVALID_SLOT; return HID_INVALID_SLOT;
} }
DEBUG_FUNCTION_LINE("VID: %04x PID: %04x\n",vid,pid); DEBUG_FUNCTION_LINE("VID: %04x PID: %04x",vid,pid);
this->vid = vid; this->vid = vid;
this->pid = pid; this->pid = pid;
@ -301,7 +301,7 @@ int32_t ConfigParser::getSlotController(std::string identify) {
int32_t hid = 0; int32_t hid = 0;
if(result < 0) { if(result < 0) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a new controller, lets save it\n"); DEBUG_FUNCTION_LINE("Its a new controller, lets save it");
} }
HIDSlotData slotdata; HIDSlotData slotdata;
@ -311,11 +311,11 @@ int32_t ConfigParser::getSlotController(std::string identify) {
hid = slotdata.hidmask; hid = slotdata.hidmask;
if(slot >= gHIDMaxDevices) { if(slot >= gHIDMaxDevices) {
DEBUG_FUNCTION_LINE("We don't a space for a new controller, please delete .inis\n"); DEBUG_FUNCTION_LINE("We don't a space for a new controller, please delete .inis");
return HID_INVALID_SLOT; return HID_INVALID_SLOT;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Got new slot! slot: %d hid %s .. Lets registrate it!\n",slot,StringTools::byte_to_binary(hid)); DEBUG_FUNCTION_LINE("Got new slot! slot: %d hid %s .. Lets registrate it!",slot,StringTools::byte_to_binary(hid));
} }
config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8; config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8;
config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF); config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF);
@ -323,64 +323,64 @@ int32_t ConfigParser::getSlotController(std::string identify) {
config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF); config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF);
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Saved vid: %04X pid: %04X\n", DEBUG_FUNCTION_LINE("Saved vid: %04X pid: %04X",
config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1], config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1],
config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]); config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]);
} }
config_controller_hidmask[slot] = hid; config_controller_hidmask[slot] = hid;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Saved the hid\n"); DEBUG_FUNCTION_LINE("Saved the hid");
} }
} else { } else {
if(slot < gHIDMaxDevices) { if(slot < gHIDMaxDevices) {
hid = config_controller_hidmask[slot]; hid = config_controller_hidmask[slot];
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",slot,StringTools::byte_to_binary(hid)); DEBUG_FUNCTION_LINE(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<",slot,StringTools::byte_to_binary(hid));
} }
DEBUG_FUNCTION_LINE("We already have data of this controller, lets modify it\n"); DEBUG_FUNCTION_LINE("We already have data of this controller, lets modify it");
} else { } else {
DEBUG_FUNCTION_LINE("Something really odd happend to the slots. %d is bigger then max (%d)\n",slot,gHIDMaxDevices); DEBUG_FUNCTION_LINE("Something really odd happend to the slots. %d is bigger then max (%d)",slot,gHIDMaxDevices);
return HID_INVALID_SLOT; return HID_INVALID_SLOT;
} }
} }
DEBUG_FUNCTION_LINE("using slot: %d hid %08X\n",slot,hid); DEBUG_FUNCTION_LINE("using slot: %d hid %08X",slot,hid);
return slot; return slot;
} }
BOOL ConfigParser::parseIni() { BOOL ConfigParser::parseIni() {
if(getSlot() == HID_INVALID_SLOT) { if(getSlot() == HID_INVALID_SLOT) {
DEBUG_FUNCTION_LINE("Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices\n",getType(),gHIDMaxDevices); DEBUG_FUNCTION_LINE("Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices",getType(),gHIDMaxDevices);
return false; return false;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Parsing content, type %d\n",getType()); DEBUG_FUNCTION_LINE("Parsing content, type %d",getType());
} }
int32_t start = 1; int32_t start = 1;
if(contentLines.size() <= 1) { if(contentLines.size() <= 1) {
DEBUG_FUNCTION_LINE("File only contains a header.\n"); DEBUG_FUNCTION_LINE("File only contains a header.");
return false; return false;
} }
if(contentLines[1].compare("[IGNOREDEFAULT]") == 0) { if(contentLines[1].compare("[IGNOREDEFAULT]") == 0) {
resetConfig(); resetConfig();
DEBUG_FUNCTION_LINE("Ignoring existing settings of this device\n"); DEBUG_FUNCTION_LINE("Ignoring existing settings of this device");
start++; start++;
} }
for(uint32_t i = start; i < contentLines.size(); i++) { for(uint32_t i = start; i < contentLines.size(); i++) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("line %d: \"%s\" \n",(i+1),contentLines[i].c_str()); DEBUG_FUNCTION_LINE("line %d: \"%s\" ",(i+1),contentLines[i].c_str());
} }
parseSingleLine(contentLines[i]); parseSingleLine(contentLines[i]);
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Parsing of the file is done.\n"); DEBUG_FUNCTION_LINE("Parsing of the file is done.");
} }
return true; return true;
} }
@ -389,7 +389,7 @@ int32_t ConfigParser::getValueFromKeyValue(std::string value_pair,std::string ex
std::vector<std::string> string_value = StringTools::stringSplit(value_pair,delimiter); std::vector<std::string> string_value = StringTools::stringSplit(value_pair,delimiter);
if(string_value.size() != 2) { if(string_value.size() != 2) {
if(HID_DEBUG || string_value.size() > 2) { if(HID_DEBUG || string_value.size() > 2) {
DEBUG_FUNCTION_LINE("Not a valid key=pair line %s\n",value_pair.c_str()); DEBUG_FUNCTION_LINE("Not a valid key=pair line %s",value_pair.c_str());
} }
return -1; return -1;
} }

View File

@ -62,11 +62,11 @@ BOOL ConfigValues::setIfValueIsPreset(std::map<std::string,const uint8_t*> value
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X || keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X ||
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y) { keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("This may be a predefined stick %s\n",possibleValue.c_str()); DEBUG_FUNCTION_LINE("This may be a predefined stick %s",possibleValue.c_str());
} }
if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL) { if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found predefined stick!\n"); DEBUG_FUNCTION_LINE("Found predefined stick!");
} }
config_controller[slot][keyslot][0] = values_[STICK_CONF_BYTE]; //CONTRPS_VPAD_BUTTON_L_STICK_X config_controller[slot][keyslot][0] = values_[STICK_CONF_BYTE]; //CONTRPS_VPAD_BUTTON_L_STICK_X
config_controller[slot][keyslot][1] = values_[STICK_CONF_DEFAULT]; config_controller[slot][keyslot][1] = values_[STICK_CONF_DEFAULT];
@ -105,11 +105,11 @@ int32_t ConfigValues::getPresetValueEx(std::string possibleString) {
int32_t rightValue = -1; int32_t rightValue = -1;
if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1) { if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d\n",possibleString.c_str(),rightValue); DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d",possibleString.c_str(),rightValue);
} }
} else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1) { } else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d\n",possibleString.c_str(),rightValue); DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d",possibleString.c_str(),rightValue);
} }
} }
return rightValue; return rightValue;

View File

@ -170,7 +170,7 @@ private:
int32_t getPresetValueEx(std::string possibleString); int32_t getPresetValueEx(std::string possibleString);
void InitValues(){ void InitValues(){
DEBUG_FUNCTION_LINE("Init values for the configuration\n"); DEBUG_FUNCTION_LINE("Init values for the configuration");
CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A;
CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B; CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B;
CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X; CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X;

View File

@ -34,16 +34,16 @@ CPTCPServer::~CPTCPServer() {
void CPTCPServer::AttachDetach(HIDAttachEvent attach) { void CPTCPServer::AttachDetach(HIDAttachEvent attach) {
if(HID_DEBUG) { if(HID_DEBUG) {
if(attach) { if(attach) {
DEBUG_FUNCTION_LINE("Network Attach\n"); DEBUG_FUNCTION_LINE("Network Attach");
} else { } else {
DEBUG_FUNCTION_LINE("Network Detach\n"); DEBUG_FUNCTION_LINE("Network Detach");
} }
} }
for(int32_t i= 0; i< gHIDMaxDevices; i++) { for(int32_t i= 0; i< gHIDMaxDevices; i++) {
for(int32_t j= 0; j< HID_MAX_PADS_COUNT; j++) { for(int32_t j= 0; j< HID_MAX_PADS_COUNT; j++) {
if(gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0) { if(gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0) {
DEBUG_FUNCTION_LINE("Found a registered pad in deviceslot %d and padslot %d! Lets detach it.\n",i,j); DEBUG_FUNCTION_LINE("Found a registered pad in deviceslot %d and padslot %d! Lets detach it.",i,j);
HIDDevice device; HIDDevice device;
memset(&device,0,sizeof(device)); memset(&device,0,sizeof(device));
@ -60,9 +60,9 @@ void CPTCPServer::AttachDetach(HIDAttachEvent attach) {
if(HID_DEBUG) { if(HID_DEBUG) {
if(attach) { if(attach) {
DEBUG_FUNCTION_LINE("Network Attach DONE!\n"); DEBUG_FUNCTION_LINE("Network Attach DONE!");
} else { } else {
DEBUG_FUNCTION_LINE("Network Detach DONE!\n"); DEBUG_FUNCTION_LINE("Network Detach DONE!");
} }
} }
} }
@ -87,37 +87,37 @@ BOOL CPTCPServer::whileLoop() {
OSSleepTicks(OSMicrosecondsToTicks(1000)); OSSleepTicks(OSMicrosecondsToTicks(1000));
continue; continue;
} }
//DEBUG_FUNCTION_LINE("got byte from tcp! %01X\n",ret); //DEBUG_FUNCTION_LINE("got byte from tcp! %01X",ret);
switch (ret) { switch (ret) {
case WIIU_CP_TCP_ATTACH: { /*attach */ case WIIU_CP_TCP_ATTACH: { /*attach */
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) {
int32_t handle; int32_t handle;
ret = recvwait(clientfd, &handle, 4); ret = recvwait(clientfd, &handle, 4);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle\n",WIIU_CP_TCP_ATTACH); DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle",WIIU_CP_TCP_ATTACH);
return false; return false;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("got handle %d\n",handle); DEBUG_FUNCTION_LINE("got handle %d",handle);
} }
uint16_t vid = 0; uint16_t vid = 0;
uint16_t pid = 0; uint16_t pid = 0;
ret = recvwait(clientfd, &vid, 2); ret = recvwait(clientfd, &vid, 2);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: recvwait vid\n",WIIU_CP_TCP_ATTACH); DEBUG_FUNCTION_LINE("Error in %02X: recvwait vid",WIIU_CP_TCP_ATTACH);
return false; return false;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("got vid %04X\n",vid); DEBUG_FUNCTION_LINE("got vid %04X",vid);
} }
ret = recvwait(clientfd, &pid, 2); ret = recvwait(clientfd, &pid, 2);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: recvwait pid\n",WIIU_CP_TCP_ATTACH); DEBUG_FUNCTION_LINE("Error in %02X: recvwait pid",WIIU_CP_TCP_ATTACH);
return false; return false;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("got pid %04X\n",pid); DEBUG_FUNCTION_LINE("got pid %04X",pid);
} }
HIDDevice device; HIDDevice device;
memset(&device,0,sizeof(device)); memset(&device,0,sizeof(device));
@ -130,37 +130,37 @@ BOOL CPTCPServer::whileLoop() {
my_cb_user * user = NULL; my_cb_user * user = NULL;
ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_ATTACH); ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_ATTACH);
if((ret = ControllerPatcherUtils::getDataByHandle(handle,&user)) < 0) { if((ret = ControllerPatcherUtils::getDataByHandle(handle,&user)) < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).\n",WIIU_CP_TCP_ATTACH,handle,&user); DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).",WIIU_CP_TCP_ATTACH,handle,&user);
DEBUG_FUNCTION_LINE("Error in %02X: Config for the controller is missing.\n",WIIU_CP_TCP_ATTACH); DEBUG_FUNCTION_LINE("Error in %02X: Config for the controller is missing.",WIIU_CP_TCP_ATTACH);
if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND) < 0)) { if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND) < 0)) {
DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND byte failed. Error: %d.\n",WIIU_CP_TCP_ATTACH,ret); DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND byte failed. Error: %d.",WIIU_CP_TCP_ATTACH,ret);
} }
return false; return false;
} }
if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_FOUND) < 0)) { if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_FOUND) < 0)) {
DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_FOUND byte failed. Error: %d.\n",WIIU_CP_TCP_ATTACH,ret); DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_FOUND byte failed. Error: %d.",WIIU_CP_TCP_ATTACH,ret);
return false; return false;
} }
if(user != NULL) { if(user != NULL) {
if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_OKAY) < 0)) { if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_OKAY) < 0)) {
DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_OKAY byte failed. Error: %d.\n",WIIU_CP_TCP_ATTACH,ret); DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_OKAY byte failed. Error: %d.",WIIU_CP_TCP_ATTACH,ret);
return false; return false;
} }
ret = sendwait(clientfd,&user->slotdata.deviceslot,2); ret = sendwait(clientfd,&user->slotdata.deviceslot,2);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: sendwait slotdata: %04X\n",WIIU_CP_TCP_ATTACH,user->slotdata.deviceslot); DEBUG_FUNCTION_LINE("Error in %02X: sendwait slotdata: %04X",WIIU_CP_TCP_ATTACH,user->slotdata.deviceslot);
return false; return false;
} }
ret = sendwait(clientfd,&user->pad_slot,1); ret = sendwait(clientfd,&user->pad_slot,1);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: sendwait pad_slot: %04X\n",WIIU_CP_TCP_ATTACH,user->pad_slot); DEBUG_FUNCTION_LINE("Error in %02X: sendwait pad_slot: %04X",WIIU_CP_TCP_ATTACH,user->pad_slot);
return false; return false;
} }
} else { } else {
DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.\n",WIIU_CP_TCP_ATTACH); DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.",WIIU_CP_TCP_ATTACH);
if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_BAD) < 0)) { if((ret = sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_BAD) < 0)) {
DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_BAD byte failed. Error: %d.\n",WIIU_CP_TCP_ATTACH,ret); DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_BAD byte failed. Error: %d.",WIIU_CP_TCP_ATTACH,ret);
return false; return false;
} }
return false; return false;
@ -168,7 +168,7 @@ BOOL CPTCPServer::whileLoop() {
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("attachted to device slot: %d , pad slot is: %d\n",user->slotdata.deviceslot,user->pad_slot); DEBUG_FUNCTION_LINE("attachted to device slot: %d , pad slot is: %d",user->slotdata.deviceslot,user->pad_slot);
} }
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_VID] = device.vid; gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_VID] = device.vid;
@ -177,7 +177,7 @@ BOOL CPTCPServer::whileLoop() {
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_HANDLE] = handle; gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_HANDLE] = handle;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d\n",handle,vid,pid,user->slotdata.deviceslot,user->pad_slot); DEBUG_FUNCTION_LINE("handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d",handle,vid,pid,user->slotdata.deviceslot,user->pad_slot);
} }
break; break;
} }
@ -188,34 +188,34 @@ BOOL CPTCPServer::whileLoop() {
int32_t handle; int32_t handle;
ret = recvwait(clientfd, &handle, 4); ret = recvwait(clientfd, &handle, 4);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle\n",WIIU_CP_TCP_DETACH); DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle",WIIU_CP_TCP_DETACH);
return false; return false;
break; break;
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("got detach for handle: %d\n",handle); DEBUG_FUNCTION_LINE("got detach for handle: %d",handle);
} }
my_cb_user * user = NULL; my_cb_user * user = NULL;
if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0) { if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).\n",WIIU_CP_TCP_DETACH,handle,&user); DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).",WIIU_CP_TCP_DETACH,handle,&user);
return false; return false;
break; break;
} }
if(user == NULL) { if(user == NULL) {
DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.\n",WIIU_CP_TCP_DETACH); DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.",WIIU_CP_TCP_DETACH);
return false; return false;
break; break;
} }
int32_t deviceslot = user->slotdata.deviceslot; int32_t deviceslot = user->slotdata.deviceslot;
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("device slot is: %d , pad slot is: %d\n",deviceslot,user->pad_slot); DEBUG_FUNCTION_LINE("device slot is: %d , pad slot is: %d",deviceslot,user->pad_slot);
} }
DeviceVIDPIDInfo vidpid; DeviceVIDPIDInfo vidpid;
int32_t result; int32_t result;
if((result = ControllerPatcherUtils::getVIDPIDbyDeviceSlot(deviceslot,&vidpid)) < 0) { if((result = ControllerPatcherUtils::getVIDPIDbyDeviceSlot(deviceslot,&vidpid)) < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: Couldn't find a valid VID/PID for device slot %d. Error: %d\n",WIIU_CP_TCP_DETACH,deviceslot,ret); DEBUG_FUNCTION_LINE("Error in %02X: Couldn't find a valid VID/PID for device slot %d. Error: %d",WIIU_CP_TCP_DETACH,deviceslot,ret);
return false; return false;
break; break;
} }
@ -231,7 +231,7 @@ BOOL CPTCPServer::whileLoop() {
ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_DETACH); ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_DETACH);
memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot])); memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot]));
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("handle %d disconnected!\n",handle); DEBUG_FUNCTION_LINE("handle %d disconnected!",handle);
} }
break; break;
} }
@ -240,11 +240,11 @@ BOOL CPTCPServer::whileLoop() {
case WIIU_CP_TCP_PING: { /*ping*/ case WIIU_CP_TCP_PING: { /*ping*/
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Got Ping, sending now a Pong\n"); DEBUG_FUNCTION_LINE("Got Ping, sending now a Pong");
} }
int32_t ret = sendbyte(clientfd, WIIU_CP_TCP_PONG); int32_t ret = sendbyte(clientfd, WIIU_CP_TCP_PONG);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error in %02X: sendbyte PONG\n"); DEBUG_FUNCTION_LINE("Error in %02X: sendbyte PONG");
return false; return false;
} }
@ -262,7 +262,7 @@ BOOL CPTCPServer::whileLoop() {
BOOL CPTCPServer::acceptConnection() { BOOL CPTCPServer::acceptConnection() {
int32_t clientfd = getClientFD(); int32_t clientfd = getClientFD();
DEBUG_FUNCTION_LINE("TCP Connection accepted! Sending my protocol version: %d (0x%02X)\n", (WIIU_CP_TCP_HANDSHAKE - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,WIIU_CP_TCP_HANDSHAKE); DEBUG_FUNCTION_LINE("TCP Connection accepted! Sending my protocol version: %d (0x%02X)", (WIIU_CP_TCP_HANDSHAKE - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,WIIU_CP_TCP_HANDSHAKE);
gUDPClientip = getSockAddr().sin_addr.s_addr; gUDPClientip = getSockAddr().sin_addr.s_addr;
UDPClient::createInstance(); UDPClient::createInstance();
@ -270,38 +270,38 @@ BOOL CPTCPServer::acceptConnection() {
int32_t ret; int32_t ret;
ret = sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE); //Hey I'm a WiiU console! ret = sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE); //Hey I'm a WiiU console!
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error sendbyte: %02X\n",WIIU_CP_TCP_HANDSHAKE); DEBUG_FUNCTION_LINE("Error sendbyte: %02X",WIIU_CP_TCP_HANDSHAKE);
return false; return false;
} }
uint8_t clientProtocolVersion = recvbyte(clientfd); uint8_t clientProtocolVersion = recvbyte(clientfd);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error recvbyte: %02X\n",WIIU_CP_TCP_HANDSHAKE); DEBUG_FUNCTION_LINE("Error recvbyte: %02X",WIIU_CP_TCP_HANDSHAKE);
return false; return false;
} }
if(clientProtocolVersion == WIIU_CP_TCP_HANDSHAKE_ABORT) { if(clientProtocolVersion == WIIU_CP_TCP_HANDSHAKE_ABORT) {
DEBUG_FUNCTION_LINE("The network client wants to abort.\n"); DEBUG_FUNCTION_LINE("The network client wants to abort.");
return false; return false;
} }
DEBUG_FUNCTION_LINE("received protocol version: %d (0x%02X)\n",(clientProtocolVersion - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,clientProtocolVersion); DEBUG_FUNCTION_LINE("received protocol version: %d (0x%02X)",(clientProtocolVersion - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,clientProtocolVersion);
if(clientProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_MIN && clientProtocolVersion <= WIIU_CP_TCP_HANDSHAKE_VERSION_MAX) { if(clientProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_MIN && clientProtocolVersion <= WIIU_CP_TCP_HANDSHAKE_VERSION_MAX) {
DEBUG_FUNCTION_LINE("We support this protocol version. Let's confirm it to the network client.\n"); DEBUG_FUNCTION_LINE("We support this protocol version. Let's confirm it to the network client.");
gUsedProtocolVersion = clientProtocolVersion; gUsedProtocolVersion = clientProtocolVersion;
ret = sendbyte(clientfd, clientProtocolVersion); ret = sendbyte(clientfd, clientProtocolVersion);
if(ret < 0) { if(ret < 0) {
DEBUG_FUNCTION_LINE("Error sendbyte: %02X\n",clientProtocolVersion); DEBUG_FUNCTION_LINE("Error sendbyte: %02X",clientProtocolVersion);
return false; return false;
} }
} else { } else {
DEBUG_FUNCTION_LINE("We don't support this protocol version. We need to abort =(.\n"); DEBUG_FUNCTION_LINE("We don't support this protocol version. We need to abort =(.");
ret = sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE_ABORT); ret = sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE_ABORT);
return false; return false;
} }
DEBUG_FUNCTION_LINE("Handshake done! Success!\n"); DEBUG_FUNCTION_LINE("Handshake done! Success!");
return true; return true;
} }

View File

@ -73,7 +73,7 @@ private:
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA
priority = 10; priority = 10;
DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d\n",priority); DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d",priority);
} }
return priority; return priority;
} }

View File

@ -46,7 +46,7 @@ UDPClient::~UDPClient() {
socketclose(sockfd); socketclose(sockfd);
} }
if(HID_DEBUG) { if(HID_DEBUG) {
log_printf("UDPClient::~UDPClient(line %d): Thread has been closed\n",__LINE__); log_printf("UDPClient::~UDPClient(line %d): Thread has been closed",__LINE__);
} }
} }

View File

@ -58,7 +58,7 @@ UDPServer::~UDPServer() {
} }
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Thread has been closed\n"); DEBUG_FUNCTION_LINE("Thread has been closed");
} }
@ -72,7 +72,7 @@ void UDPServer::StartUDPThread(UDPServer * server) {
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA
priority = 10; priority = 10;
DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d\n",priority); DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d",priority);
} }
UDPServer::pThread = CThread::create(UDPServer::DoUDPThread, (void*)server, CThread::eAttributeAffCore2,priority); UDPServer::pThread = CThread::create(UDPServer::DoUDPThread, (void*)server, CThread::eAttributeAffCore2,priority);
UDPServer::pThread->resumeThread(); UDPServer::pThread->resumeThread();
@ -80,7 +80,7 @@ void UDPServer::StartUDPThread(UDPServer * server) {
BOOL UDPServer::cpyIncrementBufferOffset(void * target, void * source, int32_t * offset, int32_t typesize, int32_t maximum) { BOOL UDPServer::cpyIncrementBufferOffset(void * target, void * source, int32_t * offset, int32_t typesize, int32_t maximum) {
if(((int)*offset + typesize) > maximum) { if(((int)*offset + typesize) > maximum) {
DEBUG_FUNCTION_LINE("Transfer error. Excepted %04X bytes, but only got %04X\n",(*offset + typesize),maximum); DEBUG_FUNCTION_LINE("Transfer error. Excepted %04X bytes, but only got %04X",(*offset + typesize),maximum);
return false; return false;
} }
memcpy(target,(void*)((uint32_t)source+(*offset)),typesize); memcpy(target,(void*)((uint32_t)source+(*offset)),typesize);
@ -135,7 +135,7 @@ void UDPServer::DoUDPThreadInternal() {
if(!cpyIncrementBufferOffset((void *)&datasize, (void *)buffer,&bufferoffset,sizeof(datasize), n))continue; if(!cpyIncrementBufferOffset((void *)&datasize, (void *)buffer,&bufferoffset,sizeof(datasize), n))continue;
uint8_t * databuffer = (uint8_t*) malloc(datasize * sizeof(uint8_t)); uint8_t * databuffer = (uint8_t*) malloc(datasize * sizeof(uint8_t));
if(!databuffer) { if(!databuffer) {
DEBUG_FUNCTION_LINE("Allocating memory failed\n"); DEBUG_FUNCTION_LINE("Allocating memory failed");
continue; continue;
} }
@ -166,6 +166,6 @@ void UDPServer::DoUDPThreadInternal() {
} }
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("UDPServer Thread ended\n"); DEBUG_FUNCTION_LINE("UDPServer Thread ended");
} }
} }

View File

@ -111,17 +111,17 @@ void ControllerPatcherHID::myHIDReadCallback(uint32_t handle, int32_t error, uns
int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach) { int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach) {
if(attach) { if(attach) {
DEBUG_FUNCTION_LINE("vid %04x pid %04x connected\n", SWAP16(p_device->vid),SWAP16(p_device->pid)); DEBUG_FUNCTION_LINE("vid %04x pid %04x connected", SWAP16(p_device->vid),SWAP16(p_device->pid));
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("interface index %02x\n", p_device->interfaceIndex); DEBUG_FUNCTION_LINE("interface index %02x", p_device->interfaceIndex);
DEBUG_FUNCTION_LINE("sub class %02x\n", p_device->subClass); DEBUG_FUNCTION_LINE("sub class %02x", p_device->subClass);
DEBUG_FUNCTION_LINE("protocol %02x\n", p_device->protocol); DEBUG_FUNCTION_LINE("protocol %02x", p_device->protocol);
DEBUG_FUNCTION_LINE("max packet in %02x\n", p_device->maxPacketSizeRx); DEBUG_FUNCTION_LINE("max packet in %02x", p_device->maxPacketSizeRx);
DEBUG_FUNCTION_LINE("max packet out %02x\n", p_device->maxPacketSizeRx); DEBUG_FUNCTION_LINE("max packet out %02x", p_device->maxPacketSizeRx);
} }
} }
if(!attach) { if(!attach) {
DEBUG_FUNCTION_LINE("vid %04x pid %04x disconnected\n", SWAP16(p_device->vid),SWAP16(p_device->pid)); DEBUG_FUNCTION_LINE("vid %04x pid %04x disconnected", SWAP16(p_device->vid),SWAP16(p_device->pid));
} }
DeviceInfo device_info; DeviceInfo device_info;
memset(&device_info,0,sizeof(DeviceInfo)); memset(&device_info,0,sizeof(DeviceInfo));
@ -134,18 +134,18 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
if ((p_device->subClass == 1) && (p_device->protocol == 1)) { //Keyboard if ((p_device->subClass == 1) && (p_device->protocol == 1)) { //Keyboard
slotdata->hidmask = gHID_LIST_KEYBOARD; slotdata->hidmask = gHID_LIST_KEYBOARD;
slotdata->deviceslot = gHID_SLOT_KEYBOARD; slotdata->deviceslot = gHID_SLOT_KEYBOARD;
//DEBUG_FUNCTION_LINE("Found Keyboard: device: %s slot: %d\n",byte_to_binary(device_info.slotdata.hidmask),device_info.slotdata.deviceslot); //DEBUG_FUNCTION_LINE("Found Keyboard: device: %s slot: %d",byte_to_binary(device_info.slotdata.hidmask),device_info.slotdata.deviceslot);
} else if ((p_device->subClass == 1) && (p_device->protocol == 2)) { // MOUSE } else if ((p_device->subClass == 1) && (p_device->protocol == 2)) { // MOUSE
slotdata->hidmask = gHID_LIST_MOUSE; slotdata->hidmask = gHID_LIST_MOUSE;
slotdata->deviceslot = gMouseSlot; slotdata->deviceslot = gMouseSlot;
//DEBUG_FUNCTION_LINE("Found Mouse: device: %s slot: %d\n",byte_to_binary(device_info.hid),device_info.slot); //DEBUG_FUNCTION_LINE("Found Mouse: device: %s slot: %d",byte_to_binary(device_info.hid),device_info.slot);
} else { } else {
int32_t ret; int32_t ret;
if((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { if((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) {
DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d \n",ret); DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d ",ret);
return HID_DEVICE_DETACH; return HID_DEVICE_DETACH;
} else { } else {
//DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) success %d \n",ret); //DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) success %d ",ret);
} }
} }
@ -189,7 +189,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
} }
if(failed) { if(failed) {
DEBUG_FUNCTION_LINE("error: I can only handle %d devices of the same type. Sorry \n",HID_MAX_PADS_COUNT); DEBUG_FUNCTION_LINE("error: I can only handle %d devices of the same type. Sorry ",HID_MAX_PADS_COUNT);
if(buf) { if(buf) {
free(buf); free(buf);
buf = NULL; buf = NULL;
@ -213,7 +213,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
memset(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],0,sizeof(HID_Data)); memset(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],0,sizeof(HID_Data));
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].handle = p_device->handle; gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].handle = p_device->handle;
//DEBUG_FUNCTION_LINE("saved handle %d to slot %d and pad %d\n",p_device->handle,slotdata->deviceslot,pad_slot); //DEBUG_FUNCTION_LINE("saved handle %d to slot %d and pad %d",p_device->handle,slotdata->deviceslot,pad_slot);
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].user_data = usr; gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].user_data = usr;
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].slotdata = device_info.slotdata; gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].slotdata = device_info.slotdata;
@ -223,7 +223,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Device successfully attached\n"); DEBUG_FUNCTION_LINE("Device successfully attached");
} }
if(slotdata->hidmask == gHID_LIST_GC) { // GC PAD if(slotdata->hidmask == gHID_LIST_GC) { // GC PAD
@ -246,7 +246,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
int32_t read_result = HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL); int32_t read_result = HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
if(read_result == 64) { if(read_result == 64) {
if(usr->buf[01] == 0x01) { //We need to do the handshake if(usr->buf[01] == 0x01) { //We need to do the handshake
DEBUG_FUNCTION_LINE("Switch Pro Controller handshake needed\n"); DEBUG_FUNCTION_LINE("Switch Pro Controller handshake needed");
/** /**
Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering) Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering)
**/ **/
@ -266,7 +266,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
HIDWrite(p_device->handle, usr->buf, 2, NULL,NULL); HIDWrite(p_device->handle, usr->buf, 2, NULL,NULL);
HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL); HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
} else { } else {
DEBUG_FUNCTION_LINE("Switch Pro Controller handshake already done\n"); DEBUG_FUNCTION_LINE("Switch Pro Controller handshake already done");
} }
HIDRead(p_device->handle, usr->buf, usr->transfersize, myHIDReadCallback, usr); HIDRead(p_device->handle, usr->buf, usr->transfersize, myHIDReadCallback, usr);
} }
@ -317,7 +317,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
user_data = NULL; user_data = NULL;
} else { } else {
if(founddata) { if(founddata) {
DEBUG_FUNCTION_LINE("user_data null. You may have a memory leak.\n"); DEBUG_FUNCTION_LINE("user_data null. You may have a memory leak.");
} }
return HID_DEVICE_DETACH; return HID_DEVICE_DETACH;
} }
@ -335,15 +335,15 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
} }
} else { } else {
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("We still have pad for deviceslot %d connected.\n",slotdata->deviceslot); DEBUG_FUNCTION_LINE("We still have pad for deviceslot %d connected.",slotdata->deviceslot);
} }
} }
if(HID_DEBUG) { if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Device successfully detached\n"); DEBUG_FUNCTION_LINE("Device successfully detached");
} }
} }
} else { } else {
DEBUG_FUNCTION_LINE("HID-Device currently not supported! You can add support through config files\n"); DEBUG_FUNCTION_LINE("HID-Device currently not supported! You can add support through config files");
} }
return HID_DEVICE_DETACH; return HID_DEVICE_DETACH;
} }
@ -351,7 +351,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user * usr) { void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user * usr) {
ControllerPatcherUtils::doSampling(usr->slotdata.deviceslot,usr->pad_slot,false); ControllerPatcherUtils::doSampling(usr->slotdata.deviceslot,usr->pad_slot,false);
//DEBUG_FUNCTION_LINE("my_read_cbInternal: %d %08X %d\n",bytes_transfered,usr->slotdata.hidmask,usr->slotdata.deviceslot); //DEBUG_FUNCTION_LINE("my_read_cbInternal: %d %08X %d",bytes_transfered,usr->slotdata.hidmask,usr->slotdata.deviceslot);
if(usr->slotdata.hidmask == gHID_LIST_GC) { if(usr->slotdata.hidmask == gHID_LIST_GC) {
HID_Data * data_ptr = NULL; HID_Data * data_ptr = NULL;
@ -648,7 +648,7 @@ void ControllerPatcherHID::HIDRumble(uint32_t handle,my_cb_user *usr,uint32_t pa
} }
usr->forceRumbleInTicks[pad]--; usr->forceRumbleInTicks[pad]--;
if(rumblechanged || usr->forceRumbleInTicks[pad] <= 0) { if(rumblechanged || usr->forceRumbleInTicks[pad] <= 0) {
//DEBUG_FUNCTION_LINE("Rumble: %d %d\n",usr->rumblestatus[pad],usr->rumbleForce[pad]); //DEBUG_FUNCTION_LINE("Rumble: %d %d",usr->rumblestatus[pad],usr->rumbleForce[pad]);
//Seding to the network client! //Seding to the network client!
char bytes[6]; char bytes[6];

View File

@ -23,7 +23,7 @@
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDataByHandle(int32_t handle, my_cb_user ** data) { CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDataByHandle(int32_t handle, my_cb_user ** data) {
for(int32_t i = 0; i< gHIDMaxDevices; i++) { for(int32_t i = 0; i< gHIDMaxDevices; i++) {
for(int32_t j = 0; j<4; j++) { for(int32_t j = 0; j<4; j++) {
//log_printf("%d %d %d %d\n",i,j,gHID_Devices[i].pad_data[j].handle,(uint32_t)handle); //log_printf("%d %d %d %d",i,j,gHID_Devices[i].pad_data[j].handle,(uint32_t)handle);
if(gHID_Devices[i].pad_data[j].handle == (uint32_t)handle) { if(gHID_Devices[i].pad_data[j].handle == (uint32_t)handle) {
*data = gHID_Devices[i].pad_data[j].user_data; *data = gHID_Devices[i].pad_data[j].user_data;
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;
@ -247,7 +247,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_
result = 1; result = 1;
break; break;
} else { } else {
//log_printf("Invalid data! deviceslot(slot): %d config: %d\n",deviceslot,cur_config); //log_printf("Invalid data! deviceslot(slot): %d config: %d",deviceslot,cur_config);
} }
} while(0); //The break will become handy ;) } while(0); //The break will become handy ;)
@ -632,7 +632,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
} }
} }
/*log_printf("LX %f(%02X) LY %f(%02X) RX %f(%02X) RY %f(%02X)\n",buffer->leftStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]], /*log_printf("LX %f(%02X) LY %f(%02X) RX %f(%02X) RY %f(%02X)",buffer->leftStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]],
buffer->leftStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]], buffer->leftStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]],
buffer->rightStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]], buffer->rightStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],
buffer->rightStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]]);*/ buffer->rightStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]]);*/
@ -727,9 +727,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(
gMouseModeCoolDown = 60; gMouseModeCoolDown = 60;
if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM) { if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM) {
gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH; gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH;
//log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); //log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch ",__LINE__);
} else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { } else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) {
//log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); //log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim ",__LINE__);
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
} }
} }
@ -944,7 +944,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidP
for(int32_t i = 0; i< gHIDMaxDevices; i++) { for(int32_t i = 0; i< gHIDMaxDevices; i++) {
uint16_t my_vid = config_controller[i][CONTRPS_VID][0] * 0x100 + config_controller[i][CONTRPS_VID][1]; uint16_t my_vid = config_controller[i][CONTRPS_VID][0] * 0x100 + config_controller[i][CONTRPS_VID][1];
uint16_t my_pid = config_controller[i][CONTRPS_PID][0] * 0x100 + config_controller[i][CONTRPS_PID][1]; uint16_t my_pid = config_controller[i][CONTRPS_PID][0] * 0x100 + config_controller[i][CONTRPS_PID][1];
//log_printf("info->vidpid.vid (%04X) == my_vid (%04X) && info->vidpid.pid (%04X) == my_pid (%04X)\n",info->vidpid.vid,my_vid,info->vidpid.pid,my_pid); //log_printf("info->vidpid.vid (%04X) == my_vid (%04X) && info->vidpid.pid (%04X) == my_pid (%04X)",info->vidpid.vid,my_vid,info->vidpid.pid,my_pid);
if(info->vidpid.vid == my_vid && info->vidpid.pid == my_pid) { if(info->vidpid.vid == my_vid && info->vidpid.pid == my_pid) {
info->slotdata.hidmask = config_controller_hidmask[i]; info->slotdata.hidmask = config_controller_hidmask[i];
info->slotdata.deviceslot = i; info->slotdata.deviceslot = i;
@ -957,7 +957,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidP
} }
return CONTROLLER_PATCHER_ERROR_NONE; return CONTROLLER_PATCHER_ERROR_NONE;
//log_printf("Found device: device: %s slot: %d\n",byte_to_binary(device),deviceSlot); //log_printf("Found device: device: %s slot: %d",byte_to_binary(device),deviceSlot);
break; break;
} }
} }

View File

@ -20,17 +20,17 @@ TCPServer::TCPServer(int32_t port,int32_t priority) {
TCPServer::~TCPServer() { TCPServer::~TCPServer() {
CloseSockets(); CloseSockets();
//DEBUG_FUNCTION_LINE("Thread will be closed\n"); //DEBUG_FUNCTION_LINE("Thread will be closed");
exitThread = 1; exitThread = 1;
ICInvalidateRange((void*)&exitThread, 4); ICInvalidateRange((void*)&exitThread, 4);
DCFlushRange((void*)&exitThread, 4); DCFlushRange((void*)&exitThread, 4);
if(pThread != NULL) { if(pThread != NULL) {
//DEBUG_FUNCTION_LINE("Deleting it!\n"); //DEBUG_FUNCTION_LINE("Deleting it!");
delete pThread; delete pThread;
} }
//DEBUG_FUNCTION_LINE("Thread done\n"); //DEBUG_FUNCTION_LINE("Thread done");
pThread = NULL; pThread = NULL;
} }
@ -84,7 +84,7 @@ void TCPServer::DoTCPThreadInternal() {
} }
do { do {
DEBUG_FUNCTION_LINE("Waiting for a connection\n"); DEBUG_FUNCTION_LINE("Waiting for a connection");
if(exitThread) { if(exitThread) {
break; break;
} }
@ -103,24 +103,24 @@ void TCPServer::DoTCPThreadInternal() {
connected = true; connected = true;
DEBUG_FUNCTION_LINE("Connection accepted\n"); DEBUG_FUNCTION_LINE("Connection accepted");
whileLoop(); whileLoop();
DEBUG_FUNCTION_LINE("Client disconnected\n"); DEBUG_FUNCTION_LINE("Client disconnected");
if(clientfd != -1) { if(clientfd != -1) {
socketclose(clientfd); socketclose(clientfd);
} }
clientfd = -1; clientfd = -1;
} while(0); } while(0);
DEBUG_FUNCTION_LINE("Closing TCPServer\n"); DEBUG_FUNCTION_LINE("Closing TCPServer");
connected = false; connected = false;
onConnectionClosed(); onConnectionClosed();
CloseSockets(); CloseSockets();
continue; continue;
} }
DEBUG_FUNCTION_LINE("Ending DoTCPThreadInternal\n"); DEBUG_FUNCTION_LINE("Ending DoTCPThreadInternal");
} }
void TCPServer::DoTCPThread(CThread *thread, void *arg) { void TCPServer::DoTCPThread(CThread *thread, void *arg) {

View File

@ -50,7 +50,7 @@ private:
virtual BOOL acceptConnection() = 0; virtual BOOL acceptConnection() = 0;
virtual void onConnectionClosed(){ virtual void onConnectionClosed(){
DEBUG_FUNCTION_LINE("Default onConnectionClosed \n"); DEBUG_FUNCTION_LINE("Default onConnectionClosed ");
} }
/** /**