diff --git a/ConfigReader.cpp b/ConfigReader.cpp index b9bc2a9..9deae94 100644 --- a/ConfigReader.cpp +++ b/ConfigReader.cpp @@ -90,8 +90,11 @@ s32 ConfigReader::InitSDCard(){ if (this->pClient && this->pCmd){ FSInit(); + if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): FSInit done\n",__LINE__); } FSInitCmdBlock((FSCmdBlock*)pCmd); - FSAddClientEx((FSClient*)pClient,0, -1); + if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): Init CMD Block done\n",__LINE__); } + status = FSAddClientEx((FSClient*)pClient,0, -1); + if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): Added Client, result: %d\n",__LINE__,status); } if ((status = FSGetMountSource((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd, FS_MOUNT_SOURCE_SD, (FSMountSource *)mountSrc, 0)) == FS_STATUS_OK) { if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); } diff --git a/ControllerPatcher.cpp b/ControllerPatcher.cpp index aaa36c7..6d62fdf 100644 --- a/ControllerPatcher.cpp +++ b/ControllerPatcher.cpp @@ -755,6 +755,92 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumble(UController_Type return CONTROLLER_PATCHER_ERROR_NONE; } +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevicesEx(InputDataEx * output,s32 array_size){ + s32 hid = gHIDCurrentDevice; + HID_Data * data_cur; + VPADStatus pad_buffer; + VPADStatus * buffer = &pad_buffer; + s32 result = CONTROLLER_PATCHER_ERROR_NONE; + for(s32 i = 0;i< gHIDMaxDevices;i++){ + if(result > array_size){ + break; + } + if((hid & (1 << i)) != 0){ + memset(buffer,0,sizeof(*buffer)); + + s32 newhid = (1 << i); + + s32 buttons_hold = 0; + + for(s32 pad = 0;padhold = 0; + buttondata->trigger = 0; + buttondata->release = 0; + + result++; + if(result > array_size){ + break; + } + + s32 res; + if((res = ControllerPatcherHID::getHIDData(newhid,pad,&data_cur)) < 0){ + *status = 0; + continue; + } + *status = 1; + + res = ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_A); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_B); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_X); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_Y); + + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_LEFT); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_RIGHT); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_DOWN); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_UP); + + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_MINUS); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_L); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_R); + + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_PLUS); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_ZL); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_ZR); + + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_HOME); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_L); + ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_R); + + buttondata->hold |= buttons_hold; + buttondata->trigger |= (buttons_hold & (~(data_cur->last_buttons))); + buttondata->release |= ((data_cur->last_buttons) & (~buttons_hold)); + + buffer->leftStick.x = 0.0f; + buffer->leftStick.y = 0.0f; + buffer->rightStick.x = 0.0f; + buffer->rightStick.y = 0.0f; + + ControllerPatcherUtils::convertAnalogSticks(data_cur,buffer); + ControllerPatcherUtils::normalizeStickValues(&(buffer->leftStick)); + ControllerPatcherUtils::normalizeStickValues(&(buffer->rightStick)); + + stickdata->leftStickX = buffer->leftStick.x; + stickdata->leftStickY = buffer->leftStick.y; + stickdata->rightStickX = buffer->rightStick.x; + stickdata->rightStickY = buffer->rightStick.y; + + data_cur->last_buttons = buttons_hold; + } + } + } + + return array_size; +} + CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(InputData * output,s32 array_size){ s32 hid = gHIDCurrentDevice; HID_Data * data_cur; diff --git a/ControllerPatcher.hpp b/ControllerPatcher.hpp index 58aaa65..ecc7bd7 100644 --- a/ControllerPatcher.hpp +++ b/ControllerPatcher.hpp @@ -217,6 +217,7 @@ class ControllerPatcher{ @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. If the result is > 0 the number of stored sets in the array is returned. **/ static CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size); + static CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevicesEx(InputDataEx * output,s32 array_size); /** Remaps the buttons in the given \p VPADStatus pointer. InitButtonMapping() needs to be called before calling this. The information about the remapping is stored in the config_controller array. diff --git a/ControllerPatcherWrapper.cpp b/ControllerPatcherWrapper.cpp index 6151924..e0c2fb6 100644 --- a/ControllerPatcherWrapper.cpp +++ b/ControllerPatcherWrapper.cpp @@ -27,8 +27,8 @@ extern "C" CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatu ControllerPatcher::setControllerDataFromHID(data); } -extern "C" CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size){ - ControllerPatcher::gettingInputAllDevices(output,array_size); +extern "C" CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevicesEx(InputDataEx * output,s32 array_size){ + ControllerPatcher::gettingInputAllDevicesEx(output,array_size); } extern "C" void ControllerPatcherDeInit(void){ diff --git a/ControllerPatcherWrapper.h b/ControllerPatcherWrapper.h index 106d2aa..4291b22 100644 --- a/ControllerPatcherWrapper.h +++ b/ControllerPatcherWrapper.h @@ -14,7 +14,7 @@ extern "C" { void ControllerPatcherInit(void); void ControllerPatcherDeInit(void); CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus * data); -CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size); +CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevicesEx(InputDataEx * output,s32 array_size); #ifdef __cplusplus } diff --git a/patcher/ControllerPatcherDefs.h b/patcher/ControllerPatcherDefs.h index 46517f1..a1c0c6e 100644 --- a/patcher/ControllerPatcherDefs.h +++ b/patcher/ControllerPatcherDefs.h @@ -352,6 +352,7 @@ typedef struct _InputButtonData{ u32 trigger; /**< Buttons that started pressing */ u32 release; /**< Buttons that were button released */ }InputButtonData; + /** * @brief Struct where the inputdata of a device for all HID_MAX_PADS_COUNT pads can be stored */ @@ -359,6 +360,20 @@ typedef struct _InputData{ DeviceInfo device_info; /**< Infos about the device where the data is coming from */ InputButtonData button_data[HID_MAX_PADS_COUNT]; }InputData; + +typedef struct _InputStickData{ + f32 leftStickX; + f32 leftStickY; + f32 rightStickX; + f32 rightStickY; +}InputStickData; + +typedef struct _InputDataEx{ + u8 status; + InputButtonData button_data; + InputStickData stick_data; +}InputDataEx; + /** * @brief The enumeration of WiiU Controller types */