Format the files

This commit is contained in:
Maschell 2018-06-19 17:46:37 +02:00
parent a1ae51e073
commit c2e273f46f
17 changed files with 1551 additions and 1315 deletions

View File

@ -80,8 +80,7 @@ typedef int CONTROLLER_PATCHER_RESULT_OR_ERROR;
/**
* @brief The enumeration of Controller sticks defines
*/
enum Controller_Stick_Defines
{
enum Controller_Stick_Defines {
STICK_CONF_MAGIC_VERSION, /**< Version of the stick configuration. Changes with every format*/
STICK_CONF_BYTE, /**< Byte where the stick-axis data is stored*/
STICK_CONF_DEFAULT, /**< Default value*/
@ -95,8 +94,7 @@ enum Controller_Stick_Defines
#define STICK_CONF_MAGIC_VALUE 0xF0 // When you change the enum above, Dont forget to change the magic version!!!!
//! most data has the format: byte,value (byte starting at 0)
enum Controller_Patcher_Settings
{
enum Controller_Patcher_Settings {
CONTRPS_VID, //! pid: 0x451d would be 0x45,0x1d
CONTRPS_PID, //! vid: 0x488d would be 0x48,0x8d
CONTRPS_BUF_SIZE, //! To set: CONTROLLER_PATCHER_VALUE_SET, BUF_SIZE (default is 64)
@ -203,8 +201,7 @@ enum Controller_Patcher_Settings
/**
* @brief The enumeration of different DPAD-Modes
*/
enum Controller_Patcher_DPAD_MODE
{
enum Controller_Patcher_DPAD_MODE {
CONTRPDM_Normal, /**< Normal mode */
CONTRPDM_Hat, /**< Hat mode */
CONTRPDM_Absolute_2Values, /**< DPAD Value stored in 2 values (one for each axis), acting like a stick */
@ -212,8 +209,7 @@ enum Controller_Patcher_DPAD_MODE
/**
* @brief The enumeration of DPAD Settings. Needed for saving both in the PADConst.
*/
enum Controller_Patcher_DPAD_Settings
{
enum Controller_Patcher_DPAD_Settings {
CONTRDPAD_MODE = 0, /**< Byte where the DPAD Mode is stored */
CONTRDPAD_MASK = 1, /**< Byte where the DPAD Mask is stored */
};
@ -256,8 +252,7 @@ typedef struct _HID_Mouse_Data {
/**
* @brief The enumeration of device types
*/
enum DEVICE_TYPE
{
enum DEVICE_TYPE {
DEVICE_TYPE_CONTROLLER = 0, /**< Normal Controller */
DEVICE_TYPE_MOUSE = 1, /**< Mouse */
};

View File

@ -44,7 +44,9 @@ bool ConfigReader::ReadConfigs(std::string path){
}
if(fileList.size() > 0) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Found %d config files\n",fileList.size()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found %d config files\n",fileList.size());
}
processFileList(fileList);
}
return true;
@ -52,7 +54,9 @@ bool ConfigReader::ReadConfigs(std::string path){
ConfigReader::~ConfigReader() {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("~ConfigReader\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("~ConfigReader\n");
}
}
std::vector<std::string> ConfigReader::ScanFolder(std::string path) {
@ -69,13 +73,17 @@ std::vector<std::string> ConfigReader::ScanFolder(std::string path){
bool isDir = dirent->d_type & DT_DIR;
const char *filename = dirent->d_name;
if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0){ continue; }
if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0) {
continue;
}
std::string newPath = path + "/" + std::string(filename);
if(!isDir && StringTools::EndsWith(std::string(filename),".ini")) {
config_files.push_back(newPath);
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Found ini: %s \n",newPath.c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found ini: %s \n",newPath.c_str());
}
}
}

View File

@ -37,9 +37,13 @@ static u32 last_button_hold[4] = {0,0,0,0};
static VPADStatus myVPADBuffer[4];
void ControllerPatcher::InitButtonMapping() {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Init called \n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Init called \n");
}
if(!gButtonRemappingConfigDone) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Remapping is running! \n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Remapping is running! \n");
}
gButtonRemappingConfigDone = 1;
memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything
@ -102,12 +106,16 @@ void ControllerPatcher::ResetConfig(){
gHIDRegisteredDevices = 0;
ControllerPatcherUtils::getNextSlotData(&slotdata);
gGamePadSlot = slotdata.deviceslot;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
gMouseSlot = slotdata.deviceslot;
gHID_LIST_MOUSE = slotdata.hidmask;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
u32 keyboard_slot = slotdata.deviceslot;
@ -115,31 +123,41 @@ void ControllerPatcher::ResetConfig(){
gHID_LIST_KEYBOARD = keyboard_hid;
gHID_SLOT_KEYBOARD = keyboard_slot;
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); }
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);
}
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){ DEBUG_FUNCTION_LINE("Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); }
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);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
u32 ds3_slot = slotdata.deviceslot;
u32 ds3_hid = slotdata.hidmask;
gHID_LIST_DS3 = ds3_hid;
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); }
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);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
u32 ds4_slot = slotdata.deviceslot;
u32 ds4_hid = slotdata.hidmask;
gHID_LIST_DS4 = ds4_hid;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(ds4_hid),ds4_slot); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(ds4_hid),ds4_slot);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
u32 xinput_slot = slotdata.deviceslot;
u32 xinput_hid = slotdata.hidmask;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(xinput_hid),xinput_slot); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d\n",StringTools::byte_to_binary(xinput_hid),xinput_slot);
}
ControllerPatcherUtils::getNextSlotData(&slotdata);
u32 switch_pro_slot = slotdata.deviceslot;
@ -484,17 +502,24 @@ bool ControllerPatcher::Init(const char * pathToConfig) {
}
DEBUG_FUNCTION_LINE("Found the gSamplingCallback at %08X \n",gSamplingCallback);
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Init called! \n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Init called! \n");
}
if(gConfig_done == HID_INIT_NOT_DONE) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("First time calling the Init\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("First time calling the Init\n");
}
gConfig_done = HID_INIT_DONE;
ControllerPatcher::ResetConfig();
} else {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Config already done!\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Config already done!\n");
}
}
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\n");
ConfigReader* reader = ConfigReader::getInstance();
@ -530,7 +555,9 @@ void ControllerPatcher::stopNetworkServer(){
}
void ControllerPatcher::DeInit() {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("called! \n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("called! \n");
}
if(gHIDAttached) HIDDelClient(&gHIDClient);
@ -588,17 +615,21 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableControllerMapping()
}
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting() {
s32 res;
uint32_t res;
if(IMIsDimEnabled(&res) == 0) {
if(res == 1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Dim was orignally enabled!\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Dim was orignally enabled!\n");
}
gOriginalDimState = 1;
}
}
if(IMIsAPDEnabled(&res) == 0) {
if(res == 1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Auto power down was orignally enabled!\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Auto power down was orignally enabled!\n");
}
gOriginalAPDState = 1;
}
}
@ -626,7 +657,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::restoreWiiUEnergySetting()
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::resetControllerMapping(UController_Type type) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type);
if(cm_map_pad == NULL){return CONTROLLER_PATCHER_ERROR_NULL_POINTER;}
if(cm_map_pad == NULL) {
return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
}
memset(cm_map_pad,0,sizeof(*cm_map_pad));
return CONTROLLER_PATCHER_ERROR_NONE;
@ -661,7 +694,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::addControllerMapping(UCont
s32 ControllerPatcher::getActiveMappingSlot(UController_Type type) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type);
if(cm_map_pad == NULL){return -1;}
if(cm_map_pad == NULL) {
return -1;
}
s32 connected = -1;
for(s32 i =0; i<HID_MAX_DEVICES_PER_SLOT; i++) {
@ -708,9 +743,13 @@ bool ControllerPatcher::isControllerConnectedAndActive(UController_Type type,s32
ControllerMappingPADInfo * ControllerPatcher::getControllerMappingInfo(UController_Type type,s32 mapping_slot) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type);
if(cm_map_pad == NULL){return NULL;}
if(cm_map_pad == NULL) {
return NULL;
}
if(mapping_slot < 0 || mapping_slot > HID_MAX_DEVICES_PER_SLOT-1){ return NULL;}
if(mapping_slot < 0 || mapping_slot > HID_MAX_DEVICES_PER_SLOT-1) {
return NULL;
}
return &(cm_map_pad->pad_infos[mapping_slot]);
}
@ -742,7 +781,9 @@ HID_Mouse_Data * ControllerPatcher::getMouseData(){
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumble(UController_Type type,u32 status) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type);
if(cm_map_pad == NULL){return -1;}
if(cm_map_pad == NULL) {
return -1;
}
cm_map_pad->rumble = !!status; //to make sure it's only 0 or 1.
return CONTROLLER_PATCHER_ERROR_NONE;
}
@ -987,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_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->lstick.x,buffer->lstick.y,buffer->rstick.x,buffer->rstick.y);
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);
}
return CONTROLLER_PATCHER_ERROR_NONE;
}
@ -1104,20 +1145,26 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::resetCallbackData(){
}
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADConnectedCallback(s32 chan, wpad_connect_callback_t callback){
if(chan >= 4){ return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; }
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADConnectedCallback(s32 chan, WPADConnectCallback callback) {
if(chan >= 4) {
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
}
gKPADConnectCallback[chan] = callback;
return CONTROLLER_PATCHER_ERROR_NONE;
}
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(s32 chan, wpad_connect_callback_t callback){
if(chan >= 4){ return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; }
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(s32 chan, WPADConnectCallback callback) {
if(chan >= 4) {
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
}
gExtensionCallback[chan] = callback;
return CONTROLLER_PATCHER_ERROR_NONE;
}
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setWPADConnectCallback(s32 chan, wpad_connect_callback_t callback){
if(chan >= 4){ return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; }
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setWPADConnectCallback(s32 chan, WPADConnectCallback callback) {
if(chan >= 4) {
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
}
gWPADConnectCallback[chan] = callback;
return CONTROLLER_PATCHER_ERROR_NONE;
}
@ -1131,26 +1178,17 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(bool bu
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): gKPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gKPADConnectCallback[0],gKPADConnectCallback[1],gKPADConnectCallback[2],gKPADConnectCallback[3]); }*/
for(s32 i = 0;i<4;i++){
bool doCall = false;
if(i == 0){ doCall = ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro1); }
if(i == 1){ doCall = ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro2); }
if(i == 2){ doCall = ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro3); }
if(i == 3){ doCall = ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro4); }
if(doCall){
if(gWPADConnectCallback[i] != NULL){
log_printf("my_VPADRead(line %d): Called WPAD connect callback for pro controller in slot %d!\n",__LINE__,(i+1));
gWPADConnectCallback[i](i,0);
if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro1)) {
ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_0);
}
if(gKPADConnectCallback[i] != NULL){
log_printf("my_VPADRead(line %d): Called KPAD connect callback for pro controller in slot %d!\n",__LINE__,(i+1));
gKPADConnectCallback[i](i,0);
}
if(gExtensionCallback[i] != NULL){
log_printf("my_VPADRead(line %d): Called extension callback for pro controller in slot %d!\n",__LINE__,(i+1));
gExtensionCallback[i](i,WPAD_EXT_PRO_CONTROLLER);
if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro2)) {
ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_1);
}
if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro3)) {
ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_2);
}
if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro4)) {
ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_3);
}
}
if(gCallbackCooldown > 0) {
@ -1160,3 +1198,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(bool bu
return CONTROLLER_PATCHER_ERROR_NONE;
}
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackDataInternal(WPADChan chan) {
if(gWPADConnectCallback[chan] != NULL) {
log_printf("Called WPAD connect callback for pro controller in slot %d!\n",chan + 1);
gWPADConnectCallback[chan](chan,0);
}
if(gKPADConnectCallback[chan] != NULL) {
log_printf("Called KPAD connect callback for pro controller in slot %d!\n",chan + 1);
gKPADConnectCallback[chan](chan,0);
}
if(gExtensionCallback[chan] != NULL) {
log_printf("Called extension callback for pro controller in slot %d!\n",chan + 1);
gExtensionCallback[chan](chan,WPAD_EXT_PRO_CONTROLLER);
}
return CONTROLLER_PATCHER_ERROR_NONE;
}

View File

@ -122,19 +122,30 @@ bool ConfigParser::Init(){
}
void ConfigParser::parseSingleLine(std::string line) {
if(line.empty()){DEBUG_FUNCTION_LINE("Can't parse line. it's empty\n"); return;}
if(line.empty()) {
DEBUG_FUNCTION_LINE("Can't parse line. it's empty\n");
return;
}
std::vector<std::string> cur_values = StringTools::stringSplit(line,"=");
if(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()); }
if(HID_DEBUG || cur_values.size() > 2) {
DEBUG_FUNCTION_LINE("Not a valid key=pair line %s\n",line.c_str());
}
return;
} else {
u16 hid_slot = getSlot();
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("leftpart = \"%s\" \n",cur_values[0].c_str()); }
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("rightpart = \"%s\" \n",cur_values[1].c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("leftpart = \"%s\" \n",cur_values[0].c_str());
}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("rightpart = \"%s\" \n",cur_values[1].c_str());
}
s32 keyslot = -1;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Checking single value\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Checking single value\n");
}
if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD) {
keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]);
} else if(getType() == PARSE_MOUSE) {
@ -143,14 +154,18 @@ void ConfigParser::parseSingleLine(std::string line){
keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]);
}
if(keyslot != -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Its a single value\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a single value\n");
}
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){ DEBUG_FUNCTION_LINE("Settings preset DPAD MODE and Mask\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Settings preset DPAD MODE and Mask\n");
}
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) {
@ -164,9 +179,13 @@ void ConfigParser::parseSingleLine(std::string line){
if(!valueSet) {
if(getType() == PARSE_KEYBOARD) {
if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Used pre-defined Keyboard! \"%s\" is %d\n",cur_values[1].c_str(),rightValue);}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined Keyboard! \"%s\" is %d\n",cur_values[1].c_str(),rightValue);
}
} else {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str());
}
char * ptr;
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
}
@ -175,30 +194,42 @@ void ConfigParser::parseSingleLine(std::string line){
if(getType() == PARSE_MOUSE) { //No parsing for the mouse
if(rightValue == -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Invalid mouse value, lets skip it %s\n",cur_values[1].c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Invalid mouse value, lets skip it %s\n",cur_values[1].c_str());
}
return;
}
} else {
if(rightValue == -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("I need to parse %s\n",cur_values[1].c_str());
}
char * ptr;
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
}
}
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Setting value to %d\n",rightValue); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Setting value to %d\n",rightValue);
}
config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET;
config_controller[hid_slot][keyslot][1] = rightValue;
}
} else {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Check pair value\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Check pair value\n");
}
keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]);
if(keyslot != -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Its a pair value\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a pair value\n");
}
if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("And its no preset\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("And its no preset\n");
}
std::vector<std::string> rightvalues = StringTools::stringSplit(cur_values[1],",");
if(rightvalues.size() != 2) {
@ -212,9 +243,13 @@ void ConfigParser::parseSingleLine(std::string line){
config_controller[hid_slot][keyslot][0] = firstValue;
config_controller[hid_slot][keyslot][1] = secondValue;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Set %02X,%02X\n",firstValue,secondValue); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Set %02X,%02X\n",firstValue,secondValue);
}
} else {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Found preset value!!\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found preset value!!\n");
}
}
} else {
DEBUG_FUNCTION_LINE("The setting \"%s\" is unknown!\n",cur_values[0].c_str());
@ -234,7 +269,9 @@ bool ConfigParser::resetConfig(){
}
s32 ConfigParser::getSlotController(std::string identify) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Getting Controller Slot\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Getting Controller Slot\n");
}
std::vector<std::string> values = StringTools::stringSplit(identify,",");
@ -263,7 +300,9 @@ s32 ConfigParser::getSlotController(std::string identify){
s32 slot = deviceinfo.slotdata.deviceslot;
s32 hid = 0;
if(result < 0) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Its a new controller, lets save it\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Its a new controller, lets save it\n");
}
HIDSlotData slotdata;
ControllerPatcherUtils::getNextSlotData(&slotdata);
@ -275,7 +314,9 @@ s32 ConfigParser::getSlotController(std::string identify){
DEBUG_FUNCTION_LINE("We don't a space for a new controller, please delete .inis\n");
return HID_INVALID_SLOT;
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Got new slot! slot: %d hid %s .. Lets registrate it!\n",slot,StringTools::byte_to_binary(hid)); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Got new slot! slot: %d hid %s .. Lets registrate it!\n",slot,StringTools::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;
@ -284,15 +325,20 @@ s32 ConfigParser::getSlotController(std::string identify){
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Saved vid: %04X pid: %04X\n",
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;
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Saved the hid\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Saved the hid\n");
}
} else {
if(slot < gHIDMaxDevices) {
hid = config_controller_hidmask[slot];
if(HID_DEBUG){ DEBUG_FUNCTION_LINE(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",slot,StringTools::byte_to_binary(hid)); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",slot,StringTools::byte_to_binary(hid));
}
DEBUG_FUNCTION_LINE("We already have data of this controller, lets modify it\n");
} else {
DEBUG_FUNCTION_LINE("Something really odd happend to the slots. %d is bigger then max (%d)\n",slot,gHIDMaxDevices);
@ -311,7 +357,9 @@ bool ConfigParser::parseIni(){
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Parsing content, type %d\n",getType()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Parsing content, type %d\n",getType());
}
s32 start = 1;
if(contentLines.size() <= 1) {
@ -325,18 +373,24 @@ bool ConfigParser::parseIni(){
}
for(u32 i = start; i < contentLines.size(); i++) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("line %d: \"%s\" \n",(i+1),contentLines[i].c_str()); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("line %d: \"%s\" \n",(i+1),contentLines[i].c_str());
}
parseSingleLine(contentLines[i]);
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Parsing of the file is done.\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Parsing of the file is done.\n");
}
return true;
}
s32 ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter) {
std::vector<std::string> string_value = StringTools::stringSplit(value_pair,delimiter);
if(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()); }
if(HID_DEBUG || string_value.size() > 2) {
DEBUG_FUNCTION_LINE("Not a valid key=pair line %s\n",value_pair.c_str());
}
return -1;
}
if(string_value[0].compare(expectedKey) != 0) {

View File

@ -28,7 +28,9 @@ ConfigValues::ConfigValues(){
}
ConfigValues::~ConfigValues() {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("\n");}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("\n");
}
}
const u8 * ConfigValues::getValuesForPreset(std::map<std::string,const u8*> values,std::string possibleValue) {
@ -59,9 +61,13 @@ bool ConfigValues::setIfValueIsPreset(std::map<std::string,const u8*> 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){ DEBUG_FUNCTION_LINE("This may be a predefined stick %s\n",possibleValue.c_str());}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("This may be a predefined stick %s\n",possibleValue.c_str());
}
if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Found predefined stick!\n");}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Found predefined stick!\n");
}
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 +104,13 @@ s32 ConfigValues::getValueFromMap(std::map<std::string,int> values,std::string n
s32 ConfigValues::getPresetValueEx(std::string possibleString) {
s32 rightValue = -1;
if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d\n",possibleString.c_str(),rightValue); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d\n",possibleString.c_str(),rightValue);
}
} else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1) {
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d\n",possibleString.c_str(),rightValue); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d\n",possibleString.c_str(),rightValue);
}
}
return rightValue;
}

View File

@ -35,8 +35,7 @@ UDPClient::UDPClient(u32 ip, s32 port){
connect_addr.sin_port = port;
connect_addr.sin_addr.s_addr = ip;
if(connect(sockfd, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
{
if(connect(sockfd, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) {
socketclose(sockfd);
sockfd = -1;
}
@ -46,7 +45,9 @@ 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) {

View File

@ -57,7 +57,9 @@ UDPServer::~UDPServer(){
this->sockfd = -1;
}
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Thread has been closed\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Thread has been closed\n");
}
}
@ -163,5 +165,7 @@ void UDPServer::DoUDPThreadInternal(){
}
}
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("UDPServer Thread ended\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("UDPServer Thread ended\n");
}
}

View File

@ -112,11 +112,13 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha
s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach) {
if(attach) {
DEBUG_FUNCTION_LINE("vid %04x pid %04x connected\n", SWAP16(p_device->vid),SWAP16(p_device->pid));
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("interface index %02x\n", p_device->interfaceIndex);
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("interface index %02x\n", p_device->interfaceIndex);
DEBUG_FUNCTION_LINE("sub class %02x\n", p_device->subClass);
DEBUG_FUNCTION_LINE("protocol %02x\n", p_device->protocol);
DEBUG_FUNCTION_LINE("max packet in %02x\n", p_device->maxPacketSizeRx);
DEBUG_FUNCTION_LINE("max packet out %02x\n", p_device->maxPacketSizeRx); }
DEBUG_FUNCTION_LINE("max packet out %02x\n", p_device->maxPacketSizeRx);
}
}
if(!attach) {
DEBUG_FUNCTION_LINE("vid %04x pid %04x disconnected\n", SWAP16(p_device->vid),SWAP16(p_device->pid));
@ -220,7 +222,9 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data));
}
if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Device successfully attached\n"); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Device successfully attached\n");
}
if(slotdata->hidmask == gHID_LIST_GC) { // GC PAD
//The GC Adapter has all ports in one device. Set them all.
@ -273,7 +277,10 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
} else if (slotdata->hidmask == gHID_LIST_DS3) {
HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0);
HIDDS3Rumble(p_device->handle,usr,0);
buf[0] = 0x42; buf[1] = 0x0c; buf[2] = 0x00; buf[3] = 0x00;
buf[0] = 0x42;
buf[1] = 0x0c;
buf[2] = 0x00;
buf[3] = 0x00;
HIDSetReport(p_device->handle, HID_REPORT_FEATURE, PS3_F4_REPORT_ID, buf, PS3_F4_REPORT_LEN, NULL, NULL);
HIDRead(p_device->handle, usr->buf, p_device->maxPacketSizeRx, myHIDReadCallback, usr);
} else {
@ -309,7 +316,9 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
free(user_data);
user_data = NULL;
} else {
if(founddata){ DEBUG_FUNCTION_LINE("user_data null. You may have a memory leak.\n"); }
if(founddata) {
DEBUG_FUNCTION_LINE("user_data null. You may have a memory leak.\n");
}
return HID_DEVICE_DETACH;
}
if(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0) {
@ -325,9 +334,13 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
}
} else {
if(HID_DEBUG){DEBUG_FUNCTION_LINE("We still have pad for deviceslot %d connected.\n",slotdata->deviceslot); }
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("We still have pad for deviceslot %d connected.\n",slotdata->deviceslot);
}
}
if(HID_DEBUG) {
DEBUG_FUNCTION_LINE("Device successfully detached\n");
}
if(HID_DEBUG){DEBUG_FUNCTION_LINE("Device successfully detached\n"); }
}
} else {
DEBUG_FUNCTION_LINE("HID-Device currently not supported! You can add support through config files\n");
@ -662,8 +675,7 @@ void ControllerPatcherHID::HIDRumble(u32 handle,my_cb_user *usr,u32 pad){
}
}
static u8 ds3_rumble_Report[48] =
{
static u8 ds3_rumble_Report[48] = {
0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x27, 0x10, 0x00, 0x32,

View File

@ -50,26 +50,30 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_
if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) {
if(VPADButton == VPAD_BUTTON_TOUCH) {
if(ms_data->left_click & 0x01) {
result = 1; break;
result = 1;
break;
}
}
} else if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM) {
if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_LEFT][0] == CONTROLLER_PATCHER_VALUE_SET) {
if(VPADButton == (int)gGamePadValues[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_LEFT][1]]) {
if(ms_data->left_click & 0x01) {
result = 1; break;
result = 1;
break;
}
}
}
if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_RIGHT][0] == CONTROLLER_PATCHER_VALUE_SET) {
if(VPADButton == (int)gGamePadValues[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_RIGHT][1]]) {
if(ms_data->right_click & 0x01) {
result = 1; break;
result = 1;
break;
}
}
}
}
result = 0; break;
result = 0;
break;
}
u8 * cur_data = &data->data_union.controller.cur_hid_data[0];
if(cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
@ -151,7 +155,10 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_
}
if(direction && (((cur_data[dir1_0] & mask) == dir1_1) ||
((cur_data[dir2_0] & mask) == dir2_1) ||
((cur_data[dir3_0] & mask) == dir3_1))) {result = 1; break;}
((cur_data[dir3_0] & mask) == dir3_1))) {
result = 1;
break;
}
}
} else if(config_controller[deviceslot][CONTRPS_DPAD_MODE][1] == CONTRPDM_Absolute_2Values) {
@ -191,23 +198,54 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_
if(result && config_controller[deviceslot][CONTRPS_DOUBLE_USE][0] == CONTROLLER_PATCHER_VALUE_SET) {
if(config_controller[deviceslot][CONTRPS_DOUBLE_USE][1] == CONTROLLER_PATCHER_GC_DOUBLE_USE) {
if(cur_data[config_controller[deviceslot][CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR][0]] & config_controller[deviceslot][CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR][1]) {
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED,cur_config)) {
result = 0;
break;
}
} else {
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED,cur_config)){result = 0; break;}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED,cur_config)) {
result = 0;
break;
}
if(checkValueinConfigController(deviceslot,CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED,cur_config)) {
result = 0;
break;
}
}
}
}
if(isValueSet(data,cur_config) == 1) {
result = 1; break;
result = 1;
break;
} else {
//log_printf("Invalid data! deviceslot(slot): %d config: %d\n",deviceslot,cur_config);
}
@ -336,10 +374,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::normalizeStickValues(
stick->y *= mul_val;
}
if(stick->x > 1.0f){ stick->x = 1.0f; }
if(stick->y > 1.0f){ stick->y = 1.0f; }
if(stick->x < -1.0f){ stick->x = -1.0f; }
if(stick->y < -1.0f){ stick->y = -1.0f; }
if(stick->x > 1.0f) {
stick->x = 1.0f;
}
if(stick->y > 1.0f) {
stick->y = 1.0f;
}
if(stick->x < -1.0f) {
stick->x = -1.0f;
}
if(stick->y < -1.0f) {
stick->y = -1.0f;
}
return CONTROLLER_PATCHER_ERROR_NONE;
}
@ -498,10 +544,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
u8 stick_values = 0;
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_UP)){ stick_values |= STICK_VALUE_UP; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_DOWN)){ stick_values |= STICK_VALUE_DOWN; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_LEFT)){ stick_values |= STICK_VALUE_LEFT; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_UP)) {
stick_values |= STICK_VALUE_UP;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_DOWN)) {
stick_values |= STICK_VALUE_DOWN;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_LEFT)) {
stick_values |= STICK_VALUE_LEFT;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)) {
stick_values |= STICK_VALUE_RIGHT;
}
if(stick_values > 0 ) {
VPADVec2D stick = getAnalogValueByButtons(stick_values);
@ -510,10 +564,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
}
stick_values = 0;
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_UP)){ stick_values |= STICK_VALUE_UP; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_DOWN)){ stick_values |= STICK_VALUE_DOWN; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_LEFT)){ stick_values |= STICK_VALUE_LEFT; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_UP)) {
stick_values |= STICK_VALUE_UP;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_DOWN)) {
stick_values |= STICK_VALUE_DOWN;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_LEFT)) {
stick_values |= STICK_VALUE_LEFT;
}
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)) {
stick_values |= STICK_VALUE_RIGHT;
}
if(stick_values > 0 ) {
VPADVec2D stick = getAnalogValueByButtons(stick_values);
@ -525,10 +587,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
if(config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] == 1) {
u8 stick_values = 0;
if(buffer->hold & VPAD_BUTTON_UP){ stick_values |= STICK_VALUE_UP; }
if(buffer->hold & VPAD_BUTTON_DOWN){ stick_values |= STICK_VALUE_DOWN; }
if(buffer->hold & VPAD_BUTTON_LEFT){ stick_values |= STICK_VALUE_LEFT; }
if(buffer->hold & VPAD_BUTTON_RIGHT){ stick_values |= STICK_VALUE_RIGHT; }
if(buffer->hold & VPAD_BUTTON_UP) {
stick_values |= STICK_VALUE_UP;
}
if(buffer->hold & VPAD_BUTTON_DOWN) {
stick_values |= STICK_VALUE_DOWN;
}
if(buffer->hold & VPAD_BUTTON_LEFT) {
stick_values |= STICK_VALUE_LEFT;
}
if(buffer->hold & VPAD_BUTTON_RIGHT) {
stick_values |= STICK_VALUE_RIGHT;
}
if(stick_values > 0 ) {
VPADVec2D stick = getAnalogValueByButtons(stick_values);
@ -541,10 +611,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
if(config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] == 1) {
u8 stick_values = 0;
if(buffer->hold & VPAD_BUTTON_UP){ stick_values |= STICK_VALUE_UP; }
if(buffer->hold & VPAD_BUTTON_DOWN){ stick_values |= STICK_VALUE_DOWN; }
if(buffer->hold & VPAD_BUTTON_LEFT){ stick_values |= STICK_VALUE_LEFT; }
if(buffer->hold & VPAD_BUTTON_RIGHT){ stick_values |= STICK_VALUE_RIGHT; }
if(buffer->hold & VPAD_BUTTON_UP) {
stick_values |= STICK_VALUE_UP;
}
if(buffer->hold & VPAD_BUTTON_DOWN) {
stick_values |= STICK_VALUE_DOWN;
}
if(buffer->hold & VPAD_BUTTON_LEFT) {
stick_values |= STICK_VALUE_LEFT;
}
if(buffer->hold & VPAD_BUTTON_RIGHT) {
stick_values |= STICK_VALUE_RIGHT;
}
if(stick_values > 0 ) {
VPADVec2D stick = getAnalogValueByButtons(stick_values);

View File

@ -72,4 +72,5 @@ u32 gUDPClientip __attribute__((section(".data"))) = 0;
ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0],
&gControllerMapping.proController[1].pad_infos[0],
&gControllerMapping.proController[2].pad_infos[0],
&gControllerMapping.proController[3].pad_infos[0]} ;
&gControllerMapping.proController[3].pad_infos[0]
} ;

View File

@ -63,7 +63,8 @@ const uint8_t HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x1A, //STICK_CONF_MIN,
0xE4};//STICK_CONF_MAX,
0xE4
};//STICK_CONF_MAX,
const uint8_t HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x04, //STICK_CONF_BYTE,
@ -71,7 +72,8 @@ const uint8_t HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x11, //STICK_CONF_MIN,
0xE1};//STICK_CONF_MAX,
0xE1
};//STICK_CONF_MAX,
const uint8_t HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x05, //STICK_CONF_BYTE,
@ -79,7 +81,8 @@ const uint8_t HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x2B, //STICK_CONF_MIN,
0xE2};//STICK_CONF_MAX,
0xE2
};//STICK_CONF_MAX,
const uint8_t HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x06, //STICK_CONF_BYTE,
@ -87,7 +90,8 @@ const uint8_t HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x1D, //STICK_CONF_MIN,
0xDB};//STICK_CONF_MAX,
0xDB
};//STICK_CONF_MAX,
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! DS3
@ -122,7 +126,8 @@ const uint8_t HID_DS3_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x06, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS3_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x07, //STICK_CONF_BYTE,
@ -130,7 +135,8 @@ const uint8_t HID_DS3_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x06, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS3_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x08, //STICK_CONF_BYTE,
@ -138,7 +144,8 @@ const uint8_t HID_DS3_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x06, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS3_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x09, //STICK_CONF_BYTE,
@ -146,7 +153,8 @@ const uint8_t HID_DS3_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x06, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! DS4
@ -189,7 +197,8 @@ const uint8_t HID_DS4_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x06, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS4_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x02, //STICK_CONF_BYTE,
@ -197,7 +206,8 @@ const uint8_t HID_DS4_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x05, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS4_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x03, //STICK_CONF_BYTE,
@ -205,7 +215,8 @@ const uint8_t HID_DS4_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x07, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_DS4_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x04, //STICK_CONF_BYTE,
@ -213,7 +224,8 @@ const uint8_t HID_DS4_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGI
0x09, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! XInput
@ -248,7 +260,8 @@ const uint8_t HID_XINPUT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_M
0x10, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_XINPUT_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x01, //STICK_CONF_BYTE,
@ -256,7 +269,8 @@ const uint8_t HID_XINPUT_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_M
0x10, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_XINPUT_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x02, //STICK_CONF_BYTE,
@ -264,7 +278,8 @@ const uint8_t HID_XINPUT_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_M
0x10, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
const uint8_t HID_XINPUT_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x03, //STICK_CONF_BYTE,
@ -272,7 +287,8 @@ const uint8_t HID_XINPUT_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_M
0x10, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x00, //STICK_CONF_MIN,
0xFF};//STICK_CONF_MAX,
0xFF
};//STICK_CONF_MAX,
@ -315,7 +331,8 @@ const uint8_t HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK
0x01, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x28, //STICK_CONF_MIN,
0xDF};//STICK_CONF_MAX,
0xDF
};//STICK_CONF_MAX,
const uint8_t HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x06, //STICK_CONF_BYTE,
@ -323,7 +340,8 @@ const uint8_t HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK
0x06, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x16, //STICK_CONF_MIN,
0xD7};//STICK_CONF_MAX,
0xD7
};//STICK_CONF_MAX,
const uint8_t HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x08, //STICK_CONF_BYTE,
@ -331,7 +349,8 @@ const uint8_t HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK
0x04, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT,
0x29, //STICK_CONF_MIN,
0xE2};//STICK_CONF_MAX,
0xE2
};//STICK_CONF_MAX,
const uint8_t HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x0A, //STICK_CONF_BYTE,
@ -339,4 +358,5 @@ const uint8_t HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK
0x08, //STICK_CONF_DEADZONE,
0x01, //STICK_CONF_INVERT,
0x22, //STICK_CONF_MIN,
0xE4};//STICK_CONF_MAX,
0xE4
};//STICK_CONF_MAX,