diff --git a/ConfigReader.cpp b/ConfigReader.cpp index cba65ff..1ce167f 100644 --- a/ConfigReader.cpp +++ b/ConfigReader.cpp @@ -34,14 +34,14 @@ ConfigReader::ConfigReader(){ void ConfigReader::ReadAllConfigs(){ std::vector fileList = ScanFolder(); if(fileList.size() > 0){ - if(HID_DEBUG) log_printf("ConfigReader::ConfigReader(line %d): Found %d config files\n",__LINE__,fileList.size()); + if(HID_DEBUG){ log_printf("ConfigReader::ConfigReader(line %d): Found %d config files\n",__LINE__,fileList.size()); } processFileList(fileList); } } ConfigReader::~ConfigReader(){ - if(HID_DEBUG) log_printf("ConfigReader::~ConfigReader(line %d): ~ConfigReader\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigReader::~ConfigReader(line %d): ~ConfigReader\n",__LINE__); } freeFSHandles(); } @@ -59,7 +59,7 @@ void ConfigReader::freeFSHandles(){ // Mounting the sdcard without any external lib to be portable s32 ConfigReader::InitSDCard(){ - if(HID_DEBUG) log_printf("ConfigReader::InitSDCard(line %d): InitSDCard\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigReader::InitSDCard(line %d): InitSDCard\n",__LINE__); } char mountSrc[FS_MOUNT_SOURCE_SIZE]; char mountPath[FS_MAX_MOUNTPATH_SIZE]; @@ -102,7 +102,7 @@ s32 ConfigReader::InitSDCard(){ std::vector ConfigReader::ScanFolder(){ std::string path = CONTROLLER_PATCHER_PATH; s32 dirhandle = 0; - if(HID_DEBUG) log_printf("ConfigReader::ScanFolder(line %d): Opening %s\n",__LINE__,path.c_str()); + if(HID_DEBUG){ log_printf("ConfigReader::ScanFolder(line %d): Opening %s\n",__LINE__,path.c_str()); } std::vector config_files; if (this->pClient && this->pCmd){ s32 status = 0; @@ -113,7 +113,7 @@ std::vector ConfigReader::ScanFolder(){ if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) != FS_STAT_FLAG_IS_DIRECTORY){ if(CPStringTools::EndsWith(std::string(dir_entry.name),".ini")){ config_files.push_back(full_path); - if(HID_DEBUG) log_printf("ConfigReader::ScanFolder(line %d): %s \n",__LINE__,full_path.c_str()); + if(HID_DEBUG){ log_printf("ConfigReader::ScanFolder(line %d): %s \n",__LINE__,full_path.c_str()); } } } } diff --git a/ControllerPatcher.cpp b/ControllerPatcher.cpp index 291e35c..3ee6b2a 100644 --- a/ControllerPatcher.cpp +++ b/ControllerPatcher.cpp @@ -33,9 +33,9 @@ static u32 last_button_hold[4] = {0,0,0,0}; static VPADData myVPADBuffer[4]; void ControllerPatcher::InitButtonMapping(){ - if(HID_DEBUG) log_printf("ControllerPatcher::InitButtonMapping(line %d): Init called \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::InitButtonMapping(line %d): Init called \n",__LINE__); } if(!gButtonRemappingConfigDone){ - if(HID_DEBUG) log_printf("ControllerPatcher::InitButtonMapping(line %d): Remapping is running! \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::InitButtonMapping(line %d): Remapping is running! \n",__LINE__); } gButtonRemappingConfigDone = 1; memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything @@ -98,13 +98,12 @@ void ControllerPatcher::ResetConfig(){ gHIDRegisteredDevices = 0; ControllerPatcherUtils::getNextSlotData(&slotdata); gGamePadSlot = slotdata.deviceslot; - u32 gGamePadHid = slotdata.hidmask; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gGamePadHid),gGamePadSlot); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); } ControllerPatcherUtils::getNextSlotData(&slotdata); gMouseSlot = slotdata.deviceslot; gHID_LIST_MOUSE = slotdata.hidmask; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 keyboard_slot = slotdata.deviceslot; @@ -112,31 +111,31 @@ void ControllerPatcher::ResetConfig(){ gHID_LIST_KEYBOARD = keyboard_hid; gHID_SLOT_KEYBOARD = keyboard_slot; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register Keyboard-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Keyboard-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 gc_slot = slotdata.deviceslot; u32 gc_hid = slotdata.hidmask; gHID_LIST_GC = gc_hid; gHID_SLOT_GC = gc_slot; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 ds3_slot = slotdata.deviceslot; u32 ds3_hid = slotdata.hidmask; gHID_LIST_DS3 = ds3_hid; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register DS3-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register DS3-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 ds4_slot = slotdata.deviceslot; u32 ds4_hid = slotdata.hidmask; gHID_LIST_DS4 = ds4_hid; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register DS4-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(ds4_hid),ds4_slot); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register DS4-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(ds4_hid),ds4_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 xinput_slot = slotdata.deviceslot; u32 xinput_hid = slotdata.hidmask; - if(HID_DEBUG) log_printf("ControllerPatcher::ResetConfig(line %d): Register XInput-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(xinput_hid),xinput_slot); + if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register XInput-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(xinput_hid),xinput_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); u32 switch_pro_slot = slotdata.deviceslot; @@ -482,7 +481,7 @@ bool ControllerPatcher::Init(){ } log_printf("ControllerPatcher::Init(line %d): Found the gSamplingCallback at %08X \n",__LINE__,gSamplingCallback); - if(HID_DEBUG) log_printf("ControllerPatcher::Init(line %d): Init called! \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): Init called! \n",__LINE__); } if(syshid_handle == 0){ log_printf("ControllerPatcher::Init(line %d): Failed to load the HID API \n",__LINE__); @@ -490,11 +489,11 @@ bool ControllerPatcher::Init(){ } if(gConfig_done == HID_INIT_NOT_DONE){ - if(HID_DEBUG) log_printf("ControllerPatcher::Init(line %d): First time calling the Init\n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): First time calling the Init\n",__LINE__); } gConfig_done = HID_INIT_DONE; ControllerPatcher::ResetConfig(); }else{ - if(HID_DEBUG) log_printf("ControllerPatcher::Init(line %d): ControllerPatcher::Init(): Config already done!\n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): ControllerPatcher::Init(): Config already done!\n",__LINE__); } } if(gConfig_done != HID_SDCARD_READ){ @@ -502,7 +501,7 @@ bool ControllerPatcher::Init(){ ConfigReader* reader = ConfigReader::getInstance(); s32 status = 0; if((status = reader->InitSDCard()) == 0){ - if(HID_DEBUG) log_printf("ControllerPatcher::Init(line %d): SD Card mounted for controller config!\n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): SD Card mounted for controller config!\n",__LINE__); } reader->ReadAllConfigs(); log_printf("ControllerPatcher::Init(line %d): Done with reading config files from SD Card\n",__LINE__); gConfig_done = HID_SDCARD_READ; @@ -534,7 +533,7 @@ void ControllerPatcher::stopNetworkServer(){ } void ControllerPatcher::DeInit(){ - if(HID_DEBUG) log_printf("ControllerPatcher::DeInit(line %d) called! \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcher::DeInit(line %d) called! \n",__LINE__); } if(gHIDAttached) HIDDelClient(&gHIDClient); @@ -595,14 +594,14 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting() s32 res; if(IMIsDimEnabled(&res) == 0){ if(res == 1){ - if(HID_DEBUG) log_print("ControllerPatcher::disableWiiUEnergySetting(): Dim was orignally enabled!\n"); + if(HID_DEBUG){ log_print("ControllerPatcher::disableWiiUEnergySetting(): Dim was orignally enabled!\n"); } gOriginalDimState = 1; } } if(IMIsAPDEnabled(&res) == 0){ if(res == 1){ - if(HID_DEBUG) log_print("ControllerPatcher::disableWiiUEnergySetting(): Auto power down was orignally enabled!\n"); + if(HID_DEBUG){ log_print("ControllerPatcher::disableWiiUEnergySetting(): Auto power down was orignally enabled!\n"); } gOriginalAPDState = 1; } } diff --git a/config/ConfigParser.cpp b/config/ConfigParser.cpp index caf6f80..caf9747 100644 --- a/config/ConfigParser.cpp +++ b/config/ConfigParser.cpp @@ -122,16 +122,16 @@ bool ConfigParser::Init(){ void ConfigParser::parseSingleLine(std::string line){ std::vector cur_values = CPStringTools::StringSplit(line,"="); if(cur_values.size() != 2){ - if(HID_DEBUG || cur_values.size() > 2) log_printf("ConfigParser::parseSingleLine(line %d): Not a valid key=pair line %s\n",__LINE__,line.c_str()); + if(HID_DEBUG || cur_values.size() > 2){ log_printf("ConfigParser::parseSingleLine(line %d): Not a valid key=pair line %s\n",__LINE__,line.c_str()); } return; }else{ u16 hid_slot = getSlot(); - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): leftpart = \"%s\" \n",__LINE__,cur_values[0].c_str()); - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): rightpart = \"%s\" \n",__LINE__,cur_values[1].c_str()); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): leftpart = \"%s\" \n",__LINE__,cur_values[0].c_str()); } + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): rightpart = \"%s\" \n",__LINE__,cur_values[1].c_str()); } s32 keyslot = -1; - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Checking single value\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Checking single value\n",__LINE__); } if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD){ keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]); }else if(getType() == PARSE_MOUSE){ @@ -140,14 +140,14 @@ void ConfigParser::parseSingleLine(std::string line){ keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]); } if(keyslot != -1){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Its a single value\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Its a single value\n",__LINE__); } long rightValue = -1; bool valueSet = false; if(cur_values[0].compare("DPAD_MODE") == 0){ const u8 * values_ = NULL; if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL){ if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE) - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Settings preset DPAD MODE and Mask\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Settings preset DPAD MODE and Mask\n",__LINE__); } config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE]; if(values_[CONTRDPAD_MASK] != 0x00){ @@ -161,9 +161,9 @@ void ConfigParser::parseSingleLine(std::string line){ if(!valueSet){ if(getType() == PARSE_KEYBOARD){ if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Used pre-defined Keyboard! \"%s\" is %d\n",__LINE__,cur_values[1].c_str(),rightValue); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Used pre-defined Keyboard! \"%s\" is %d\n",__LINE__,cur_values[1].c_str(),rightValue);} }else{ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); } char * ptr; rightValue = strtol(cur_values[1].c_str(),&ptr,16); } @@ -172,30 +172,30 @@ void ConfigParser::parseSingleLine(std::string line){ if(getType() == PARSE_MOUSE){ //No parsing for the mouse if(rightValue == -1){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Invalid mouse value, lets skip it %s\n",__LINE__,cur_values[1].c_str()); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Invalid mouse value, lets skip it %s\n",__LINE__,cur_values[1].c_str()); } return; } }else{ if(rightValue == -1){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); } char * ptr; rightValue = strtol(cur_values[1].c_str(),&ptr,16); } } } - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Setting value to %d\n",__LINE__,rightValue); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Setting value to %d\n",__LINE__,rightValue); } config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][keyslot][1] = rightValue; } }else{ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Check pair value\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Check pair value\n",__LINE__); } keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]); if(keyslot != -1){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Its a pair value\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Its a pair value\n",__LINE__); } if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)){ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): And its no preset\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): And its no preset\n",__LINE__); } std::vector rightvalues = CPStringTools::StringSplit(cur_values[1],","); if(rightvalues.size() != 2){ @@ -209,9 +209,9 @@ void ConfigParser::parseSingleLine(std::string line){ config_controller[hid_slot][keyslot][0] = firstValue; config_controller[hid_slot][keyslot][1] = secondValue; - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Set %02X,%02X\n",__LINE__,firstValue,secondValue); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Set %02X,%02X\n",__LINE__,firstValue,secondValue); } }else{ - if(HID_DEBUG) log_printf("ConfigParser::parseSingleLine(line %d): Found preset value!!\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Found preset value!!\n",__LINE__); } } }else{ log_printf("ConfigParser::parseSingleLine(line %d): The setting \"%s\" is unknown!\n",__LINE__,cur_values[0].c_str()); @@ -231,7 +231,7 @@ bool ConfigParser::resetConfig(){ } s32 ConfigParser::getSlotController(std::string identify){ - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): Getting Controller Slot\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Getting Controller Slot\n",__LINE__); } std::vector values = CPStringTools::StringSplit(identify,","); @@ -260,7 +260,7 @@ s32 ConfigParser::getSlotController(std::string identify){ s32 slot = deviceinfo.slotdata.deviceslot; s32 hid = 0; if(result < 0){ - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): Its a new controller, lets save it\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Its a new controller, lets save it\n",__LINE__); } HIDSlotData slotdata; ControllerPatcherUtils::getNextSlotData(&slotdata); @@ -272,24 +272,24 @@ s32 ConfigParser::getSlotController(std::string identify){ log_printf("ConfigParser::getSlotController(line %d): ConfigParser::getSlotController: We don't a space for a new controller, please delete .inis\n",__LINE__); return HID_INVALID_SLOT; } - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): Got new slot! slot: %d hid %s .. Lets registrate it!\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); + if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Got new slot! slot: %d hid %s .. Lets registrate it!\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); } config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8; config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF); config_controller[slot][CONTRPS_PID][0] = (pid & 0xFF00) >> 8; config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF); - u16 used_vid = config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1]; - u16 used_pid = config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]; - - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): Saved vid: %04X pid: %04X\n",__LINE__,used_vid,used_pid); + if(HID_DEBUG){ + log_printf("ConfigParser::getSlotController(line %d): Saved vid: %04X pid: %04X\n",__LINE__, + 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_hidmask[slot] = hid; - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): Saved the hid\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Saved the hid\n",__LINE__); } }else{ if(slot < gHIDMaxDevices){ hid = config_controller_hidmask[slot]; - if(HID_DEBUG) log_printf("ConfigParser::getSlotController(line %d): >>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); + if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): >>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); } log_printf("ConfigParser::getSlotController(line %d): We already have data of this controller, lets modify it\n",__LINE__); }else{ log_printf("ConfigParser::getSlotController(line %d): Something really odd happend to the slots. %d is bigger then max (%d)\n",__LINE__,slot,gHIDMaxDevices); @@ -306,7 +306,7 @@ bool ConfigParser::parseIni(){ log_printf("ConfigParser::parseIni(line %d): Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices\n",__LINE__,getType(),gHIDMaxDevices); } - if(HID_DEBUG) log_printf("ConfigParser::parseIni(line %d): Parsing content, type %d\n",__LINE__,getType()); + if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): Parsing content, type %d\n",__LINE__,getType()); } s32 start = 1; if(contentLines[1].compare("[IGNOREDEFAULT]") == 0){ @@ -316,18 +316,18 @@ bool ConfigParser::parseIni(){ } for(u32 i = start; i < contentLines.size(); i++){ - if(HID_DEBUG) log_printf("ConfigParser::parseIni(line %d): line %d: \"%s\" \n",__LINE__,(i+1),contentLines[i].c_str()); + if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): line %d: \"%s\" \n",__LINE__,(i+1),contentLines[i].c_str()); } parseSingleLine(contentLines[i]); } - if(HID_DEBUG) log_printf("ConfigParser::parseIni(line %d): Parsing of the file is done.\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): Parsing of the file is done.\n",__LINE__); } return true; } s32 ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter){ std::vector string_value = CPStringTools::StringSplit(value_pair,delimiter); if(string_value.size() != 2){ - if(HID_DEBUG || string_value.size() > 2) log_printf("ConfigParser::getValueFromKeyValue(line %d): Not a valid key=pair line %s\n",__LINE__,value_pair.c_str()); + if(HID_DEBUG || string_value.size() > 2){ log_printf("ConfigParser::getValueFromKeyValue(line %d): Not a valid key=pair line %s\n",__LINE__,value_pair.c_str()); } return -1; } if(string_value[0].compare(expectedKey) != 0){ diff --git a/config/ConfigValues.cpp b/config/ConfigValues.cpp index 5d5183f..b41fead 100644 --- a/config/ConfigValues.cpp +++ b/config/ConfigValues.cpp @@ -28,7 +28,7 @@ ConfigValues::ConfigValues(){ } ConfigValues::~ConfigValues(){ - if(HID_DEBUG) log_printf("ConfigValues::~ConfigValues(line %d){\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigValues::~ConfigValues(line %d){\n",__LINE__);} } const u8 * ConfigValues::getValuesForPreset(std::map values,std::string possibleValue){ @@ -59,9 +59,9 @@ bool ConfigValues::setIfValueIsPreset(std::map values,std keyslot == CONTRPS_VPAD_BUTTON_L_STICK_Y || keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X || keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y){ - if(HID_DEBUG) log_printf("ConfigValues::setIfValueIsPreset(line %d): This may be a predefined stick %s\n",__LINE__,possibleValue.c_str()); + if(HID_DEBUG){ log_printf("ConfigValues::setIfValueIsPreset(line %d): This may be a predefined stick %s\n",__LINE__,possibleValue.c_str());} if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL){ - if(HID_DEBUG) log_printf("ConfigValues::setIfValueIsPreset(line %d): Found predefined stick!\n",__LINE__); + if(HID_DEBUG){ log_printf("ConfigValues::setIfValueIsPreset(line %d): Found predefined stick!\n",__LINE__);} 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+DEF_STICK_OFFSET_INVERT][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT @@ -98,9 +98,9 @@ s32 ConfigValues::getValueFromMap(std::map values,std::string n s32 ConfigValues::getPresetValueEx(std::string possibleString){ s32 rightValue = -1; if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1){ - if(HID_DEBUG) log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined VPAD_VALUE! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); + if(HID_DEBUG){ log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined VPAD_VALUE! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); } }else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1){ - if(HID_DEBUG) log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined value! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); + if(HID_DEBUG){ log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined value! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); } } return rightValue; } diff --git a/network/TCPServer.cpp b/network/TCPServer.cpp index 07f65af..8f88c8b 100644 --- a/network/TCPServer.cpp +++ b/network/TCPServer.cpp @@ -39,14 +39,14 @@ TCPServer::TCPServer(s32 port){ TCPServer::~TCPServer(){ CloseSockets(); - if(HID_DEBUG) log_printf("TCPServer::~TCPServer(line %d): Thread will be closed\n",__LINE__); + if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Thread will be closed\n",__LINE__); } TCPServer::AttachDetach(DETACH); exitThread = 1; if(TCPServer::pThread != NULL){ - if(HID_DEBUG) log_printf("TCPServer::~TCPServer(line %d): Deleting it!\n",__LINE__); + if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Deleting it!\n",__LINE__); } delete TCPServer::pThread; } - if(HID_DEBUG) log_printf("TCPServer::~TCPServer(line %d): Thread done\n",__LINE__); + if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Thread done\n",__LINE__); } TCPServer::pThread = NULL; } @@ -136,7 +136,7 @@ s32 TCPServer::RunTCP(){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait handle\n",__LINE__,WIIU_CP_TCP_ATTACH); return ret; } - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): got handle %d\n",handle); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got handle %d\n",handle); } u16 vid = 0; u16 pid = 0; ret = ControllerPatcherNet::recvwait(clientfd, &vid, 2); @@ -144,14 +144,14 @@ s32 TCPServer::RunTCP(){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait vid\n",__LINE__,WIIU_CP_TCP_ATTACH); return ret; } - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): got vid %04X\n",vid); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got vid %04X\n",vid); } ret = ControllerPatcherNet::recvwait(clientfd, &pid, 2); if(ret < 0){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait pid\n",__LINE__,WIIU_CP_TCP_ATTACH); return ret; } - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): got pid %04X\n",pid); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got pid %04X\n",pid); } HIDDevice device; memset(&device,0,sizeof(device)); device.handle = handle; @@ -200,14 +200,14 @@ s32 TCPServer::RunTCP(){ break; } - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): attachted to device slot: %d , pad slot is: %d\n",__LINE__,user->slotdata.deviceslot,user->pad_slot); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): attachted to device slot: %d , pad slot is: %d\n",__LINE__,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_PID] = device.pid; gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_ACTIVE] = 1; gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_HANDLE] = handle; - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d\n",__LINE__,handle,vid,pid,user->slotdata.deviceslot,user->pad_slot); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d\n",__LINE__,handle,vid,pid,user->slotdata.deviceslot,user->pad_slot); } break; } break; @@ -222,7 +222,7 @@ s32 TCPServer::RunTCP(){ break; } - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): got detach for handle: %d\n",__LINE__,handle); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got detach for handle: %d\n",__LINE__,handle); } my_cb_user * user = NULL; if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: getDataByHandle(%d,%08X).\n",__LINE__,WIIU_CP_TCP_DETACH,handle,&user); @@ -235,7 +235,7 @@ s32 TCPServer::RunTCP(){ break; } s32 deviceslot = user->slotdata.deviceslot; - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): device slot is: %d , pad slot is: %d\n",__LINE__,deviceslot,user->pad_slot); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): device slot is: %d , pad slot is: %d\n",__LINE__,deviceslot,user->pad_slot); } DeviceVIDPIDInfo vidpid; s32 result; @@ -255,14 +255,14 @@ s32 TCPServer::RunTCP(){ ControllerPatcherHID::externAttachDetachCallback(&device,DETACH); memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot])); - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): handle %d disconnected!\n",__LINE__,handle); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): handle %d disconnected!\n",__LINE__,handle); } break; } break; } case WIIU_CP_TCP_PING: { /*ping*/ if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1){ - if(HID_DEBUG) log_printf("TCPServer::RunTCP(line %d): Got Ping, sending now a Pong\n",__LINE__); + if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): Got Ping, sending now a Pong\n",__LINE__); } s32 ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_PONG); if(ret < 0){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: sendbyte PONG\n",__LINE__); return -1;} @@ -305,7 +305,7 @@ void TCPServer::DoTCPThreadInternal(){ if(ret < 0){ ErrorHandling(); continue;} do{ - if(HID_DEBUG) log_printf("TCPServer::DoTCPThreadInternal(line %d): Waiting for a connection\n",__LINE__); + if(HID_DEBUG){ log_printf("TCPServer::DoTCPThreadInternal(line %d): Waiting for a connection\n",__LINE__); } if(exitThread) break; len = 16; diff --git a/network/UDPClient.cpp b/network/UDPClient.cpp index e9d2009..21ac4d3 100644 --- a/network/UDPClient.cpp +++ b/network/UDPClient.cpp @@ -44,7 +44,7 @@ UDPClient::~UDPClient(){ if (this->sockfd != -1){ socketclose(sockfd); } - if(HID_DEBUG) log_printf("UDPClient::~UDPClient(line %d): Thread has been closed\n",__LINE__); + if(HID_DEBUG){ log_printf("UDPClient::~UDPClient(line %d): Thread has been closed\n",__LINE__); } } bool UDPClient::sendData(char * data,s32 length){ diff --git a/network/UDPServer.cpp b/network/UDPServer.cpp index 59e5c4b..94ee3bb 100644 --- a/network/UDPServer.cpp +++ b/network/UDPServer.cpp @@ -56,7 +56,7 @@ UDPServer::~UDPServer(){ this->sockfd = -1; } } - if(HID_DEBUG) log_printf("UDPServer::~UDPServer(line %d): Thread has been closed\n",__LINE__); + if(HID_DEBUG){ log_printf("UDPServer::~UDPServer(line %d): Thread has been closed\n",__LINE__); } } @@ -162,5 +162,5 @@ void UDPServer::DoUDPThreadInternal(){ } } } - if(HID_DEBUG) log_printf("UDPServer::DoUDPThreadInternal(line %d): UDPServer Thread ended\n",__LINE__); + if(HID_DEBUG){ log_printf("UDPServer::DoUDPThreadInternal(line %d): UDPServer Thread ended\n",__LINE__); } } diff --git a/patcher/ControllerPatcherHID.cpp b/patcher/ControllerPatcherHID.cpp index 909276c..92cfa6e 100644 --- a/patcher/ControllerPatcherHID.cpp +++ b/patcher/ControllerPatcherHID.cpp @@ -114,11 +114,11 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, u32 attach){ if(attach){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x connected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid)); - if(HID_DEBUG) log_printf("interface index %02x\n", p_device->interface_index); - if(HID_DEBUG) log_printf("sub class %02x\n", p_device->sub_class); - if(HID_DEBUG) log_printf("protocol %02x\n", p_device->protocol); - if(HID_DEBUG) log_printf("max packet in %02x\n", p_device->max_packet_size_rx); - if(HID_DEBUG) log_printf("max packet out %02x\n", p_device->max_packet_size_tx); + if(HID_DEBUG){ log_printf("interface index %02x\n", p_device->interface_index); + log_printf("sub class %02x\n", p_device->sub_class); + log_printf("protocol %02x\n", p_device->protocol); + log_printf("max packet in %02x\n", p_device->max_packet_size_rx); + log_printf("max packet out %02x\n", p_device->max_packet_size_tx); } } if(!attach){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x disconnected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid)); @@ -222,7 +222,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data)); } - if(HID_DEBUG) log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully attached\n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully attached\n",__LINE__); } if(slotdata->hidmask == gHID_LIST_GC){ // GC PAD //The GC Adapter has all ports in one device. Set them all. @@ -311,7 +311,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p free(user_data); user_data = NULL; }else{ - if(founddata) log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): user_data null. You may have a memory leak.\n",__LINE__); + if(founddata){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): user_data null. You may have a memory leak.\n",__LINE__); } return HID_DEVICE_DETACH; } if(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0){ @@ -327,9 +327,9 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; } }else{ - if(HID_DEBUG)log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): We still have pad for deviceslot %d connected.\n",__LINE__,slotdata->deviceslot); + if(HID_DEBUG){log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): We still have pad for deviceslot %d connected.\n",__LINE__,slotdata->deviceslot); } } - if(HID_DEBUG)log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully detached\n",__LINE__); + if(HID_DEBUG){log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully detached\n",__LINE__); } } }else{ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): HID-Device currently not supported! You can add support through config files\n",__LINE__); diff --git a/patcher/ControllerPatcherUtils.cpp b/patcher/ControllerPatcherUtils.cpp index 3891681..a3370ee 100644 --- a/patcher/ControllerPatcherUtils.cpp +++ b/patcher/ControllerPatcherUtils.cpp @@ -617,9 +617,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode( if((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) && ((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) != (isInKeyboardData(last_data,HID_KEYBOARD_BUTTON_F1) > 0))){ if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){ gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH; - if(HID_DEBUG) log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); } }else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){ - if(HID_DEBUG) log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); + if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); } gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; } }