diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56cc685 --- /dev/null +++ b/.clang-format @@ -0,0 +1,67 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never diff --git a/README.md b/README.md index 444977d..f90e682 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ ControllerPatcher::DeInit(); ControllerPatcher::stopNetworkServer(); ``` +## Format the code via docker +`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include -i` + + # Credits: - Maschell - FIX94 - huge thanks to him and his initally created gc-to-vpad. Was a motivation and base to start all this diff --git a/include/controller_patcher/ControllerPatcher.hpp b/include/controller_patcher/ControllerPatcher.hpp index 55f556e..0bb065c 100644 --- a/include/controller_patcher/ControllerPatcher.hpp +++ b/include/controller_patcher/ControllerPatcher.hpp @@ -29,9 +29,9 @@ #include +#include "ControllerPatcherDefs.h" #include #include -#include "ControllerPatcherDefs.h" class ControllerPatcher { public: @@ -48,7 +48,7 @@ public: devoptabs! If no configuration should be loaded from the SD Card, set this parameter to NULL. **/ - static BOOL Init(const char * pathToConfig); + static BOOL Init(const char *pathToConfig); /** \brief De-Initialises the controller_patcher @@ -84,7 +84,7 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setProControllerDataFromHID(void * data,int32_t chan,int32_t mode = PRO_CONTROLLER_MODE_KPADDATA); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setProControllerDataFromHID(void *data, int32_t chan, int32_t mode = PRO_CONTROLLER_MODE_KPADDATA); /** @@ -96,7 +96,7 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus * buffer); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus *buffer); /*----------------------------------------------------------------------------------------------------------------------------------- * Useful functions @@ -144,7 +144,7 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR addControllerMapping(UController_Type type,ControllerMappingPADInfo config); + static CONTROLLER_PATCHER_RESULT_OR_ERROR addControllerMapping(UController_Type type, ControllerMappingPADInfo config); /** @@ -158,7 +158,7 @@ public: @param mapping_slot: information about the added controller. @return When the functions failed result < 0 is returned. Otherwise a pointer to a ControllerMappingPADInfo is returned. **/ - static ControllerMappingPADInfo * getControllerMappingInfo(UController_Type type,int32_t mapping_slot); + static ControllerMappingPADInfo *getControllerMappingInfo(UController_Type type, int32_t mapping_slot); /** Checks if a emulated controller is connected for the given controller type / mapping slot. @@ -168,13 +168,13 @@ public: @return **/ - static BOOL isControllerConnectedAndActive(UController_Type type,int32_t mapping_slot = 0); + static BOOL isControllerConnectedAndActive(UController_Type type, int32_t mapping_slot = 0); /** Search for a connected mouse and returns a pointer to it's data. @return A pointer to the first connected mouse that is found. NULL if no mouse is connected. **/ - static HID_Mouse_Data * getMouseData(); + static HID_Mouse_Data *getMouseData(); /** Sets a rumble status for a controller. @@ -184,7 +184,7 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setRumble(UController_Type type,uint32_t status); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setRumble(UController_Type type, uint32_t status); /** Reads the input of all connected HID devices. Each attached controller will write his date into given array until it's full. @@ -194,7 +194,7 @@ public: @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,int32_t array_size); + static CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData *output, int32_t 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. @@ -204,7 +204,7 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR buttonRemapping(VPADStatus * buffer, int32_t buffer_count); + static CONTROLLER_PATCHER_RESULT_OR_ERROR buttonRemapping(VPADStatus *buffer, int32_t buffer_count); /** Prints the current pressed down buttons of the given \p VPADStatus pointer. Uses the utils/logger.c UDP logger.. @@ -213,9 +213,9 @@ public: @return When the functions failed result < 0 is returned. If the result is == 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR printVPADButtons(VPADStatus * buffer); + static CONTROLLER_PATCHER_RESULT_OR_ERROR printVPADButtons(VPADStatus *buffer); - static std::string getIdentifierByVIDPID(uint16_t vid,uint16_t pid); + static std::string getIdentifierByVIDPID(uint16_t vid, uint16_t pid); static void destroyConfigHelper(); diff --git a/include/controller_patcher/ControllerPatcherDefs.h b/include/controller_patcher/ControllerPatcherDefs.h index 5b82f09..d3eed1d 100644 --- a/include/controller_patcher/ControllerPatcherDefs.h +++ b/include/controller_patcher/ControllerPatcherDefs.h @@ -31,79 +31,79 @@ #define FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK 0x9421FFB8 -#define HID_INIT_NOT_DONE 0 -#define HID_INIT_DONE 1 -#define HID_SDCARD_READ 2 +#define HID_INIT_NOT_DONE 0 +#define HID_INIT_DONE 1 +#define HID_SDCARD_READ 2 -#define gHIDMaxDevices 32 -#define HID_MAX_DATA_LENGTH_PER_PAD 16 -#define HID_MAX_PADS_COUNT 5 -#define HID_MAX_DEVICES_PER_SLOT 2 +#define gHIDMaxDevices 32 +#define HID_MAX_DATA_LENGTH_PER_PAD 16 +#define HID_MAX_PADS_COUNT 5 +#define HID_MAX_DEVICES_PER_SLOT 2 -#define NETWORK_CONTROLLER_VID 0 -#define NETWORK_CONTROLLER_PID 1 -#define NETWORK_CONTROLLER_ACTIVE 2 -#define NETWORK_CONTROLLER_HANDLE 3 +#define NETWORK_CONTROLLER_VID 0 +#define NETWORK_CONTROLLER_PID 1 +#define NETWORK_CONTROLLER_ACTIVE 2 +#define NETWORK_CONTROLLER_HANDLE 3 -#define CONTROLLER_PATCHER_VALUE_SET 0x01 -#define CONTROLLER_PATCHER_GC_DOUBLE_USE 0x01 -#define CONTROLLER_PATCHER_INVALIDVALUE 0xFF +#define CONTROLLER_PATCHER_VALUE_SET 0x01 +#define CONTROLLER_PATCHER_GC_DOUBLE_USE 0x01 +#define CONTROLLER_PATCHER_INVALIDVALUE 0xFF -#define HID_INVALID_SLOT 0xFFFF -#define HID_INVALID_HIDMASK 0xFFFFFFFF +#define HID_INVALID_SLOT 0xFFFF +#define HID_INVALID_HIDMASK 0xFFFFFFFF typedef int CONTROLLER_PATCHER_RESULT_OR_ERROR; -#define CONTROLLER_PATCHER_ERROR_NONE 0 -#define CONTROLLER_PATCHER_ERROR_INVALID_CHAN -1 -#define CONTROLLER_PATCHER_ERROR_UNKNOWN_VID_PID -2 -#define CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA -3 -#define CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED -4 -#define CONTROLLER_PATCHER_ERROR_INVALID_BUFFER -5 -#define CONTROLLER_PATCHER_ERROR_HID_NOT_CONNECTED -6 -#define CONTROLLER_PATCHER_ERROR_NO_PAD_CONNECTED -7 -#define CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND -8 -#define CONTROLLER_PATCHER_ERROR_NULL_POINTER -9 -#define CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE -10 -#define CONTROLLER_PATCHER_ERROR_NO_FREE_SLOT -11 -#define CONTROLLER_PATCHER_ERROR_UNKNOWN -50 +#define CONTROLLER_PATCHER_ERROR_NONE 0 +#define CONTROLLER_PATCHER_ERROR_INVALID_CHAN -1 +#define CONTROLLER_PATCHER_ERROR_UNKNOWN_VID_PID -2 +#define CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA -3 +#define CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED -4 +#define CONTROLLER_PATCHER_ERROR_INVALID_BUFFER -5 +#define CONTROLLER_PATCHER_ERROR_HID_NOT_CONNECTED -6 +#define CONTROLLER_PATCHER_ERROR_NO_PAD_CONNECTED -7 +#define CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND -8 +#define CONTROLLER_PATCHER_ERROR_NULL_POINTER -9 +#define CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE -10 +#define CONTROLLER_PATCHER_ERROR_NO_FREE_SLOT -11 +#define CONTROLLER_PATCHER_ERROR_UNKNOWN -50 -#define PRO_CONTROLLER_MODE_KPADDATA 0 -#define PRO_CONTROLLER_MODE_WPADReadData 1 +#define PRO_CONTROLLER_MODE_KPADDATA 0 +#define PRO_CONTROLLER_MODE_WPADReadData 1 -#define STICK_VALUE_UP 1 << 1 -#define STICK_VALUE_DOWN 1 << 2 -#define STICK_VALUE_LEFT 1 << 3 -#define STICK_VALUE_RIGHT 1 << 4 +#define STICK_VALUE_UP 1 << 1 +#define STICK_VALUE_DOWN 1 << 2 +#define STICK_VALUE_LEFT 1 << 3 +#define STICK_VALUE_RIGHT 1 << 4 /** * @brief The enumeration of Controller sticks 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*/ - STICK_CONF_DEADZONE, /**< Size of the deadzone */ - STICK_CONF_INVERT, /**< Is 1 when the axis is inverted */ - STICK_CONF_MIN, /**< Value that represent the minimum value (-1.0f)*/ - STICK_CONF_MAX, /**< Value that represent the maximum value (1.0f) */ - STICK_CONF_ENUM_MAXVALUE /**< Maxmimum enum value for iteration*/ + 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*/ + STICK_CONF_DEADZONE, /**< Size of the deadzone */ + STICK_CONF_INVERT, /**< Is 1 when the axis is inverted */ + STICK_CONF_MIN, /**< Value that represent the minimum value (-1.0f)*/ + STICK_CONF_MAX, /**< Value that represent the maximum value (1.0f) */ + STICK_CONF_ENUM_MAXVALUE /**< Maxmimum enum value for iteration*/ }; #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 { - 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) + 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) CONTRPS_VPAD_BUTTON_A, CONTRPS_VPAD_BUTTON_B, CONTRPS_VPAD_BUTTON_X, CONTRPS_VPAD_BUTTON_Y, - CONTRPS_DPAD_MODE, //! To set mode: CONTROLLER_PATCHER_VALUE_SET, Controller_Patcher_DPAD_MODE (default is normal mode) - CONTRPS_DPAD_MASK, //! Mask needed for hat mode: CONTROLLER_PATCHER_VALUE_SET, mask + CONTRPS_DPAD_MODE, //! To set mode: CONTROLLER_PATCHER_VALUE_SET, Controller_Patcher_DPAD_MODE (default is normal mode) + CONTRPS_DPAD_MASK, //! Mask needed for hat mode: CONTROLLER_PATCHER_VALUE_SET, mask /* Normal DPAD */ CONTRPS_VPAD_BUTTON_LEFT, CONTRPS_VPAD_BUTTON_RIGHT, @@ -175,7 +175,7 @@ enum Controller_Patcher_Settings { CONTRPS_VPAD_STICK_R_COPY_DPAD, CONTRPS_VPAD_BUTTON_TV, - CONTRPS_DOUBLE_USE, //!When used: e.g. CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE + CONTRPS_DOUBLE_USE, //!When used: e.g. CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR, CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED, CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED, @@ -187,14 +187,14 @@ enum Controller_Patcher_Settings { CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED, CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED, CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED, - CONTRPS_PAD_COUNT, //! - CONTRPS_CONNECTED_PADS, //! - CONTRPS_INPUT_FILTER, //! - CONTRPS_PAD1_FILTER, //! - CONTRPS_PAD2_FILTER, //! - CONTRPS_PAD3_FILTER, //! - CONTRPS_PAD4_FILTER, //! - CONTRPS_PAD5_FILTER, //! + CONTRPS_PAD_COUNT, //! + CONTRPS_CONNECTED_PADS, //! + CONTRPS_INPUT_FILTER, //! + CONTRPS_PAD1_FILTER, //! + CONTRPS_PAD2_FILTER, //! + CONTRPS_PAD3_FILTER, //! + CONTRPS_PAD4_FILTER, //! + CONTRPS_PAD5_FILTER, //! CONTRPS_MOUSE_STICK, CONTRPS_MAX_VALUE }; @@ -202,9 +202,9 @@ enum Controller_Patcher_Settings { * @brief The enumeration of different DPAD-Modes */ 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 */ + 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 */ }; /** * @brief The enumeration of DPAD Settings. Needed for saving both in the PADConst. @@ -218,20 +218,20 @@ enum Controller_Patcher_DPAD_Settings { * @brief Stores data if the Slot the device is using in gHID_Devices */ typedef struct _HIDSlotData { - uint16_t deviceslot; /**< deviceslot number */ - uint32_t hidmask; /**< Used HID-Mask */ + uint16_t deviceslot; /**< deviceslot number */ + uint32_t hidmask; /**< Used HID-Mask */ } HIDSlotData; /** * @brief Struct where the data for the callback funtion is stored */ typedef struct _my_cb_user { - uint8_t *buf; /**< pointer the buffer that is used */ - uint32_t transfersize; /**< number of transfered data */ - uint32_t handle; /**< HID handle */ - HIDSlotData slotdata; /**< Information about the deviceslot and hidmask */ - uint32_t pads_per_device; /**< Number of maximum pads of this device */ - uint8_t pad_slot; /**< number of the pad that will be used */ + uint8_t *buf; /**< pointer the buffer that is used */ + uint32_t transfersize; /**< number of transfered data */ + uint32_t handle; /**< HID handle */ + HIDSlotData slotdata; /**< Information about the deviceslot and hidmask */ + uint32_t pads_per_device; /**< Number of maximum pads of this device */ + uint8_t pad_slot; /**< number of the pad that will be used */ uint8_t rumblestatus[HID_MAX_PADS_COUNT]; /**< Current status of the device rumble */ uint8_t forceRumbleInTicks[HID_MAX_PADS_COUNT]; } my_cb_user; @@ -240,12 +240,12 @@ typedef struct _my_cb_user { * @brief Stores data for the mouse */ typedef struct _HID_Mouse_Data { - uint8_t left_click; /**< Is 1 when the left mouse button is pressed */ - uint8_t right_click; /**< Is 1 when the right mouse button is pressed */ - int16_t X; /**< X position of the cursor */ - int16_t Y; /**< Y position of the cursor */ - int16_t deltaX; /**< difference of the X value since the last call */ - int16_t deltaY; /**< difference of the Y value since the last call */ + uint8_t left_click; /**< Is 1 when the left mouse button is pressed */ + uint8_t right_click; /**< Is 1 when the right mouse button is pressed */ + int16_t X; /**< X position of the cursor */ + int16_t Y; /**< Y position of the cursor */ + int16_t deltaX; /**< difference of the X value since the last call */ + int16_t deltaY; /**< difference of the Y value since the last call */ uint8_t valuedChanged; /**< Is 1 when the value has changed */ } HID_Mouse_Data; @@ -253,30 +253,30 @@ typedef struct _HID_Mouse_Data { * @brief The enumeration of device types */ enum DEVICE_TYPE { - DEVICE_TYPE_CONTROLLER = 0, /**< Normal Controller */ - DEVICE_TYPE_MOUSE = 1, /**< Mouse */ + DEVICE_TYPE_CONTROLLER = 0, /**< Normal Controller */ + DEVICE_TYPE_MOUSE = 1, /**< Mouse */ }; /** * @brief Stores all data of the HID Device for accessing */ typedef struct _HID_Data { - uint32_t handle; /**< The HID-handle this device is using */ - uint8_t rumbleActive; /**< 1 when rumble is active */ - uint32_t last_buttons; /**< The last pressed buttons, based on VPAD_BUTTON_XXX data */ + uint32_t handle; /**< The HID-handle this device is using */ + uint8_t rumbleActive; /**< 1 when rumble is active */ + uint32_t last_buttons; /**< The last pressed buttons, based on VPAD_BUTTON_XXX data */ union { struct { - uint8_t cur_hid_data[HID_MAX_DATA_LENGTH_PER_PAD]; /**< Array where the current controller data is stored */ - uint8_t last_hid_data[HID_MAX_DATA_LENGTH_PER_PAD]; /**< Array where the last controller data is stored */ - } controller; /**< Used when the device in a controller. Using uint8_t array where the raw data of the controller is placed. */ + uint8_t cur_hid_data[HID_MAX_DATA_LENGTH_PER_PAD]; /**< Array where the current controller data is stored */ + uint8_t last_hid_data[HID_MAX_DATA_LENGTH_PER_PAD]; /**< Array where the last controller data is stored */ + } controller; /**< Used when the device in a controller. Using uint8_t array where the raw data of the controller is placed. */ struct { HID_Mouse_Data cur_mouse_data; /**< Struct where the current mouse data is stored */ HID_Mouse_Data last_mouse_data; /**< Struct where the last mouse data is stored */ - } mouse; /**< Used when the device in a mouse. Using a new struct to store the data. */ - } data_union; /**< The data union where the current and last data is stored.*/ - DEVICE_TYPE type; /**< The device type*/ - HIDSlotData slotdata; /**< Information about the deviceslot and his mask*/ - my_cb_user * user_data; /**< Pointer to the user data the read callback is using*/ + } mouse; /**< Used when the device in a mouse. Using a new struct to store the data. */ + } data_union; /**< The data union where the current and last data is stored.*/ + DEVICE_TYPE type; /**< The device type*/ + HIDSlotData slotdata; /**< Information about the deviceslot and his mask*/ + my_cb_user *user_data; /**< Pointer to the user data the read callback is using*/ } HID_Data; @@ -300,29 +300,29 @@ typedef struct _DeviceVIDPIDInfo { * @brief Infos of the device */ typedef struct _DeviceInfo { - HIDSlotData slotdata; /**< The slot used by this device */ + HIDSlotData slotdata; /**< The slot used by this device */ DeviceVIDPIDInfo vidpid; /**< The VID/PID of the device */ - uint8_t pad_count; /**< Number of maximum pads this device can have*/ + uint8_t pad_count; /**< Number of maximum pads this device can have*/ } DeviceInfo; /** * @brief The enumeration of Controller-Mapping types */ enum ControllerMapping_Type_Defines { - CM_Type_Controller = 0, /**< Device with single input */ + CM_Type_Controller = 0, /**< Device with single input */ CM_Type_RealController = 1, /**< Real Pro Controller */ - CM_Type_Mouse = 2, /**< Mouse */ - CM_Type_Keyboard = 3, /**< Keyboard */ + CM_Type_Mouse = 2, /**< Mouse */ + CM_Type_Keyboard = 3, /**< Keyboard */ }; /** * @brief Infos of a mapped controller */ typedef struct _ControllerMappingPADInfo { - uint8_t active; /**< Set to one if mapped */ + uint8_t active; /**< Set to one if mapped */ ControllerMapping_Type_Defines type; /**< Type of the controller mapping */ - DeviceVIDPIDInfo vidpid; /**< The VID/PID of the device */ - uint8_t pad; /**< Stores which pad it mapped */ + DeviceVIDPIDInfo vidpid; /**< The VID/PID of the device */ + uint8_t pad; /**< Stores which pad it mapped */ } ControllerMappingPADInfo; /** @@ -338,7 +338,7 @@ typedef struct _ControllerMappingPAD { * @brief Stores informations about all mapped controller */ typedef struct _ControllerMapping { - ControllerMappingPAD gamepad; /**< Information about the gamepad mapping */ + ControllerMappingPAD gamepad; /**< Information about the gamepad mapping */ ControllerMappingPAD proController[4]; /**< Information about the Pro Controller mapping */ } ControllerMapping; @@ -372,160 +372,160 @@ enum UController_Type { }; -#define CONTROLLER_PATCHER_PATH "sd:/wiiu/controller" +#define CONTROLLER_PATCHER_PATH "sd:/wiiu/controller" -#define UController_Type_Gamepad_Name gettext("GamePad") -#define UController_Type_Pro1_Name gettext("Pro Controller 1") -#define UController_Type_Pro2_Name gettext("Pro Controller 2") -#define UController_Type_Pro3_Name gettext("Pro Controller 3") -#define UController_Type_Pro4_Name gettext("Pro Controller 4") +#define UController_Type_Gamepad_Name gettext("GamePad") +#define UController_Type_Pro1_Name gettext("Pro Controller 1") +#define UController_Type_Pro2_Name gettext("Pro Controller 2") +#define UController_Type_Pro3_Name gettext("Pro Controller 3") +#define UController_Type_Pro4_Name gettext("Pro Controller 4") /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * VID/PID values *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_GC_VID 0x057e -#define HID_GC_PID 0x0337 +#define HID_GC_VID 0x057e +#define HID_GC_PID 0x0337 -#define HID_KEYBOARD_VID 0xAFFE -#define HID_KEYBOARD_PID 0XAAAC +#define HID_KEYBOARD_VID 0xAFFE +#define HID_KEYBOARD_PID 0XAAAC -#define HID_MOUSE_VID 0xAFFE -#define HID_MOUSE_PID 0XAAAB +#define HID_MOUSE_VID 0xAFFE +#define HID_MOUSE_PID 0XAAAB -#define HID_DS3_VID 0x054c -#define HID_DS3_PID 0x0268 +#define HID_DS3_VID 0x054c +#define HID_DS3_PID 0x0268 -#define HID_DS4_VID 0x054c -#define HID_DS4_PID 0x05c4 +#define HID_DS4_VID 0x054c +#define HID_DS4_PID 0x05c4 -#define HID_NEW_DS4_VID 0x054c -#define HID_NEW_DS4_PID 0x09CC +#define HID_NEW_DS4_VID 0x054c +#define HID_NEW_DS4_PID 0x09CC -#define HID_XINPUT_VID 0x7331 -#define HID_XINPUT_PID 0x1337 +#define HID_XINPUT_VID 0x7331 +#define HID_XINPUT_PID 0x1337 -#define HID_SWITCH_PRO_VID 0x057e -#define HID_SWITCH_PRO_PID 0x2009 +#define HID_SWITCH_PRO_VID 0x057e +#define HID_SWITCH_PRO_PID 0x2009 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * GC Adapter *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_GC_BUTTON_A_VALUE 0x01 -#define HID_GC_BUTTON_B_VALUE 0x02 -#define HID_GC_BUTTON_X_VALUE 0x04 -#define HID_GC_BUTTON_Y_VALUE 0x08 -#define HID_GC_BUTTON_LEFT_VALUE 0x10 -#define HID_GC_BUTTON_RIGHT_VALUE 0x20 -#define HID_GC_BUTTON_DOWN_VALUE 0x40 -#define HID_GC_BUTTON_UP_VALUE 0x80 +#define HID_GC_BUTTON_A_VALUE 0x01 +#define HID_GC_BUTTON_B_VALUE 0x02 +#define HID_GC_BUTTON_X_VALUE 0x04 +#define HID_GC_BUTTON_Y_VALUE 0x08 +#define HID_GC_BUTTON_LEFT_VALUE 0x10 +#define HID_GC_BUTTON_RIGHT_VALUE 0x20 +#define HID_GC_BUTTON_DOWN_VALUE 0x40 +#define HID_GC_BUTTON_UP_VALUE 0x80 -#define HID_GC_BUTTON_START_VALUE 0x01 -#define HID_GC_BUTTON_L_VALUE 0x80 -#define HID_GC_BUTTON_R_VALUE 0x80 -#define HID_GC_BUTTON_Z_VALUE 0x02 +#define HID_GC_BUTTON_START_VALUE 0x01 +#define HID_GC_BUTTON_L_VALUE 0x80 +#define HID_GC_BUTTON_R_VALUE 0x80 +#define HID_GC_BUTTON_Z_VALUE 0x02 -#define HID_GC_PAD_COUNT 4 +#define HID_GC_PAD_COUNT 4 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * DS3 *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define PS3_F4_REPORT_LEN 4 -#define PS3_F5_REPORT_LEN 8 -#define PS3_01_REPORT_LEN 48 -#define HID_REPORT_FEATURE 3 -#define HID_REPORT_OUTPUT 2 -#define PS3_F4_REPORT_ID 0xF4 -#define PS3_01_REPORT_ID 0x01 -#define PS3_F5_REPORT_ID 0xF5 +#define PS3_F4_REPORT_LEN 4 +#define PS3_F5_REPORT_LEN 8 +#define PS3_01_REPORT_LEN 48 +#define HID_REPORT_FEATURE 3 +#define HID_REPORT_OUTPUT 2 +#define PS3_F4_REPORT_ID 0xF4 +#define PS3_01_REPORT_ID 0x01 +#define PS3_F5_REPORT_ID 0xF5 -#define HID_DS3_BUTTON_CROSS_VALUE 0x40 // 3 -#define HID_DS3_BUTTON_CIRCLE_VALUE 0x20 // 3 -#define HID_DS3_BUTTON_SQUARE_VALUE 0x80 // 3 -#define HID_DS3_BUTTON_TRIANGLE_VALUE 0x10 // 3 -#define HID_DS3_BUTTON_L1_VALUE 0x04 // 3 -#define HID_DS3_BUTTON_L2_VALUE 0x01 // 3 -#define HID_DS3_BUTTON_R1_VALUE 0x08 // 3 -#define HID_DS3_BUTTON_R2_VALUE 0x02 // 3 +#define HID_DS3_BUTTON_CROSS_VALUE 0x40 // 3 +#define HID_DS3_BUTTON_CIRCLE_VALUE 0x20 // 3 +#define HID_DS3_BUTTON_SQUARE_VALUE 0x80 // 3 +#define HID_DS3_BUTTON_TRIANGLE_VALUE 0x10 // 3 +#define HID_DS3_BUTTON_L1_VALUE 0x04 // 3 +#define HID_DS3_BUTTON_L2_VALUE 0x01 // 3 +#define HID_DS3_BUTTON_R1_VALUE 0x08 // 3 +#define HID_DS3_BUTTON_R2_VALUE 0x02 // 3 -#define HID_DS3_BUTTON_L3_VALUE 0x02 // 2 -#define HID_DS3_BUTTON_R3_VALUE 0x04 // 2 -#define HID_DS3_BUTTON_SELECT_VALUE 0x01 // 2 -#define HID_DS3_BUTTON_START_VALUE 0x08 // 2 -#define HID_DS3_BUTTON_LEFT_VALUE 0x80 // 2 -#define HID_DS3_BUTTON_RIGHT_VALUE 0x20 // 2 -#define HID_DS3_BUTTON_UP_VALUE 0x10 // 2 -#define HID_DS3_BUTTON_DOWN_VALUE 0x40 // 2 -#define HID_DS3_BUTTON_GUIDE_VALUE 0x01 // 4 +#define HID_DS3_BUTTON_L3_VALUE 0x02 // 2 +#define HID_DS3_BUTTON_R3_VALUE 0x04 // 2 +#define HID_DS3_BUTTON_SELECT_VALUE 0x01 // 2 +#define HID_DS3_BUTTON_START_VALUE 0x08 // 2 +#define HID_DS3_BUTTON_LEFT_VALUE 0x80 // 2 +#define HID_DS3_BUTTON_RIGHT_VALUE 0x20 // 2 +#define HID_DS3_BUTTON_UP_VALUE 0x10 // 2 +#define HID_DS3_BUTTON_DOWN_VALUE 0x40 // 2 +#define HID_DS3_BUTTON_GUIDE_VALUE 0x01 // 4 -#define HID_DS3_PAD_COUNT 1 +#define HID_DS3_PAD_COUNT 1 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * DS4 *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_DS4_BUTTON_CROSS_VALUE 0x20 // 5 -#define HID_DS4_BUTTON_SQUARE_VALUE 0x10 // 5 -#define HID_DS4_BUTTON_CIRCLE_VALUE 0x40 // 5 -#define HID_DS4_BUTTON_TRIANGLE_VALUE 0x80 // 5 -#define HID_DS4_BUTTON_L1_VALUE 0x01 // 6 -#define HID_DS4_BUTTON_L2_VALUE 0x04 // 6 -#define HID_DS4_BUTTON_L3_VALUE 0x40 // 6 -#define HID_DS4_BUTTON_R1_VALUE 0x02 // 6 -#define HID_DS4_BUTTON_R2_VALUE 0x08 // 6 -#define HID_DS4_BUTTON_R3_VALUE 0x80 // 6 -#define HID_DS4_BUTTON_SHARE_VALUE 0x10 // 6 -#define HID_DS4_BUTTON_OPTIONS_VALUE 0x20 // 6 +#define HID_DS4_BUTTON_CROSS_VALUE 0x20 // 5 +#define HID_DS4_BUTTON_SQUARE_VALUE 0x10 // 5 +#define HID_DS4_BUTTON_CIRCLE_VALUE 0x40 // 5 +#define HID_DS4_BUTTON_TRIANGLE_VALUE 0x80 // 5 +#define HID_DS4_BUTTON_L1_VALUE 0x01 // 6 +#define HID_DS4_BUTTON_L2_VALUE 0x04 // 6 +#define HID_DS4_BUTTON_L3_VALUE 0x40 // 6 +#define HID_DS4_BUTTON_R1_VALUE 0x02 // 6 +#define HID_DS4_BUTTON_R2_VALUE 0x08 // 6 +#define HID_DS4_BUTTON_R3_VALUE 0x80 // 6 +#define HID_DS4_BUTTON_SHARE_VALUE 0x10 // 6 +#define HID_DS4_BUTTON_OPTIONS_VALUE 0x20 // 6 -#define HID_DS4_BUTTON_DPAD_MASK_VALUE 0x0F +#define HID_DS4_BUTTON_DPAD_MASK_VALUE 0x0F -#define HID_DS4_BUTTON_DPAD_N_VALUE 0x00 // 5 -#define HID_DS4_BUTTON_DPAD_NE_VALUE 0x01 // 5 -#define HID_DS4_BUTTON_DPAD_E_VALUE 0x02 // 5 -#define HID_DS4_BUTTON_DPAD_SE_VALUE 0x03 // 5 -#define HID_DS4_BUTTON_DPAD_S_VALUE 0x04 // 5 -#define HID_DS4_BUTTON_DPAD_SW_VALUE 0x05 // 5 -#define HID_DS4_BUTTON_DPAD_W_VALUE 0x06 // 5 -#define HID_DS4_BUTTON_DPAD_NW_VALUE 0x07 // 5 -#define HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE 0x08 // 5 +#define HID_DS4_BUTTON_DPAD_N_VALUE 0x00 // 5 +#define HID_DS4_BUTTON_DPAD_NE_VALUE 0x01 // 5 +#define HID_DS4_BUTTON_DPAD_E_VALUE 0x02 // 5 +#define HID_DS4_BUTTON_DPAD_SE_VALUE 0x03 // 5 +#define HID_DS4_BUTTON_DPAD_S_VALUE 0x04 // 5 +#define HID_DS4_BUTTON_DPAD_SW_VALUE 0x05 // 5 +#define HID_DS4_BUTTON_DPAD_W_VALUE 0x06 // 5 +#define HID_DS4_BUTTON_DPAD_NW_VALUE 0x07 // 5 +#define HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE 0x08 // 5 -#define HID_DS4_BUTTON_GUIDE_VALUE 0x01 // 7 -#define HID_DS4_BUTTON_T_PAD_CLICK_VALUE 0x02 // 7 +#define HID_DS4_BUTTON_GUIDE_VALUE 0x01 // 7 +#define HID_DS4_BUTTON_T_PAD_CLICK_VALUE 0x02 // 7 -#define HID_DS4_PAD_COUNT 1 +#define HID_DS4_PAD_COUNT 1 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * XInput *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_XINPUT_BUTTON_A_VALUE 0x01 // 7 -#define HID_XINPUT_BUTTON_B_VALUE 0x02 // 7 -#define HID_XINPUT_BUTTON_X_VALUE 0x04 // 7 -#define HID_XINPUT_BUTTON_Y_VALUE 0x08 // 7 +#define HID_XINPUT_BUTTON_A_VALUE 0x01 // 7 +#define HID_XINPUT_BUTTON_B_VALUE 0x02 // 7 +#define HID_XINPUT_BUTTON_X_VALUE 0x04 // 7 +#define HID_XINPUT_BUTTON_Y_VALUE 0x08 // 7 -#define HID_XINPUT_BUTTON_START_VALUE 0x02 // 6 -#define HID_XINPUT_BUTTON_BACK_VALUE 0x01 // 6 -#define HID_XINPUT_BUTTON_GUIDE_VALUE 0x80 // 6 +#define HID_XINPUT_BUTTON_START_VALUE 0x02 // 6 +#define HID_XINPUT_BUTTON_BACK_VALUE 0x01 // 6 +#define HID_XINPUT_BUTTON_GUIDE_VALUE 0x80 // 6 -#define HID_XINPUT_BUTTON_LB_VALUE 0x04 // 6 -#define HID_XINPUT_BUTTON_RB_VALUE 0x08 // 6 +#define HID_XINPUT_BUTTON_LB_VALUE 0x04 // 6 +#define HID_XINPUT_BUTTON_RB_VALUE 0x08 // 6 -#define HID_XINPUT_BUTTON_L3_VALUE 0x10 // 6 -#define HID_XINPUT_BUTTON_R3_VALUE 0x20 // 6 +#define HID_XINPUT_BUTTON_L3_VALUE 0x10 // 6 +#define HID_XINPUT_BUTTON_R3_VALUE 0x20 // 6 -#define HID_XINPUT_BUTTON_LT_VALUE 0x80 // 4 -#define HID_XINPUT_BUTTON_RT_VALUE 0x80 // 5 +#define HID_XINPUT_BUTTON_LT_VALUE 0x80 // 4 +#define HID_XINPUT_BUTTON_RT_VALUE 0x80 // 5 -#define HID_XINPUT_BUTTON_DPAD_MASK_VALUE 0xF0 -#define HID_XINPUT_BUTTON_LEFT_VALUE 0x10 // 7 -#define HID_XINPUT_BUTTON_RIGHT_VALUE 0x40 // 7 -#define HID_XINPUT_BUTTON_DOWN_VALUE 0x80 // 7 -#define HID_XINPUT_BUTTON_UP_VALUE 0x20 // 7 +#define HID_XINPUT_BUTTON_DPAD_MASK_VALUE 0xF0 +#define HID_XINPUT_BUTTON_LEFT_VALUE 0x10 // 7 +#define HID_XINPUT_BUTTON_RIGHT_VALUE 0x40 // 7 +#define HID_XINPUT_BUTTON_DOWN_VALUE 0x80 // 7 +#define HID_XINPUT_BUTTON_UP_VALUE 0x20 // 7 -#define HID_XINPUT_PAD_COUNT 1 +#define HID_XINPUT_PAD_COUNT 1 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Switch Pro Controller @@ -587,110 +587,110 @@ enum UController_Type { * Keyboard (Full list is on: http://www.freebsddiary.org/APC/usb_hid_usages.php) *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_KEYBOARD_BUTTON_SHIFT 0x02 +#define HID_KEYBOARD_BUTTON_SHIFT 0x02 -#define HID_KEYBOARD_BUTTON_A 0x04 -#define HID_KEYBOARD_BUTTON_B 0x05 -#define HID_KEYBOARD_BUTTON_C 0x06 -#define HID_KEYBOARD_BUTTON_D 0x07 -#define HID_KEYBOARD_BUTTON_E 0x08 -#define HID_KEYBOARD_BUTTON_F 0x09 -#define HID_KEYBOARD_BUTTON_G 0x0A -#define HID_KEYBOARD_BUTTON_H 0x0B -#define HID_KEYBOARD_BUTTON_I 0x0C -#define HID_KEYBOARD_BUTTON_J 0x0D -#define HID_KEYBOARD_BUTTON_K 0x0E -#define HID_KEYBOARD_BUTTON_L 0x0F -#define HID_KEYBOARD_BUTTON_M 0x10 -#define HID_KEYBOARD_BUTTON_N 0x11 -#define HID_KEYBOARD_BUTTON_O 0x12 -#define HID_KEYBOARD_BUTTON_P 0x13 -#define HID_KEYBOARD_BUTTON_Q 0x14 -#define HID_KEYBOARD_BUTTON_R 0x15 -#define HID_KEYBOARD_BUTTON_S 0x16 -#define HID_KEYBOARD_BUTTON_T 0x17 -#define HID_KEYBOARD_BUTTON_U 0x18 -#define HID_KEYBOARD_BUTTON_V 0x19 -#define HID_KEYBOARD_BUTTON_W 0x1A -#define HID_KEYBOARD_BUTTON_X 0x1B -#define HID_KEYBOARD_BUTTON_Y 0x1C -#define HID_KEYBOARD_BUTTON_Z 0x1D -#define HID_KEYBOARD_BUTTON_F1 0x3A -#define HID_KEYBOARD_BUTTON_F2 0x3B -#define HID_KEYBOARD_BUTTON_F3 0x3C -#define HID_KEYBOARD_BUTTON_F4 0x3D -#define HID_KEYBOARD_BUTTON_F5 0x3E -#define HID_KEYBOARD_BUTTON_F6 0x3F -#define HID_KEYBOARD_BUTTON_F7 0x40 -#define HID_KEYBOARD_BUTTON_F8 0x41 -#define HID_KEYBOARD_BUTTON_F9 0x42 -#define HID_KEYBOARD_BUTTON_F10 0x43 -#define HID_KEYBOARD_BUTTON_F11 0x44 -#define HID_KEYBOARD_BUTTON_F12 0x45 -#define HID_KEYBOARD_BUTTON_1 0x1E -#define HID_KEYBOARD_BUTTON_2 0x1F -#define HID_KEYBOARD_BUTTON_3 0x20 -#define HID_KEYBOARD_BUTTON_4 0x21 -#define HID_KEYBOARD_BUTTON_5 0x22 -#define HID_KEYBOARD_BUTTON_6 0x23 -#define HID_KEYBOARD_BUTTON_7 0x24 -#define HID_KEYBOARD_BUTTON_8 0x25 -#define HID_KEYBOARD_BUTTON_9 0x26 -#define HID_KEYBOARD_BUTTON_0 0x27 +#define HID_KEYBOARD_BUTTON_A 0x04 +#define HID_KEYBOARD_BUTTON_B 0x05 +#define HID_KEYBOARD_BUTTON_C 0x06 +#define HID_KEYBOARD_BUTTON_D 0x07 +#define HID_KEYBOARD_BUTTON_E 0x08 +#define HID_KEYBOARD_BUTTON_F 0x09 +#define HID_KEYBOARD_BUTTON_G 0x0A +#define HID_KEYBOARD_BUTTON_H 0x0B +#define HID_KEYBOARD_BUTTON_I 0x0C +#define HID_KEYBOARD_BUTTON_J 0x0D +#define HID_KEYBOARD_BUTTON_K 0x0E +#define HID_KEYBOARD_BUTTON_L 0x0F +#define HID_KEYBOARD_BUTTON_M 0x10 +#define HID_KEYBOARD_BUTTON_N 0x11 +#define HID_KEYBOARD_BUTTON_O 0x12 +#define HID_KEYBOARD_BUTTON_P 0x13 +#define HID_KEYBOARD_BUTTON_Q 0x14 +#define HID_KEYBOARD_BUTTON_R 0x15 +#define HID_KEYBOARD_BUTTON_S 0x16 +#define HID_KEYBOARD_BUTTON_T 0x17 +#define HID_KEYBOARD_BUTTON_U 0x18 +#define HID_KEYBOARD_BUTTON_V 0x19 +#define HID_KEYBOARD_BUTTON_W 0x1A +#define HID_KEYBOARD_BUTTON_X 0x1B +#define HID_KEYBOARD_BUTTON_Y 0x1C +#define HID_KEYBOARD_BUTTON_Z 0x1D +#define HID_KEYBOARD_BUTTON_F1 0x3A +#define HID_KEYBOARD_BUTTON_F2 0x3B +#define HID_KEYBOARD_BUTTON_F3 0x3C +#define HID_KEYBOARD_BUTTON_F4 0x3D +#define HID_KEYBOARD_BUTTON_F5 0x3E +#define HID_KEYBOARD_BUTTON_F6 0x3F +#define HID_KEYBOARD_BUTTON_F7 0x40 +#define HID_KEYBOARD_BUTTON_F8 0x41 +#define HID_KEYBOARD_BUTTON_F9 0x42 +#define HID_KEYBOARD_BUTTON_F10 0x43 +#define HID_KEYBOARD_BUTTON_F11 0x44 +#define HID_KEYBOARD_BUTTON_F12 0x45 +#define HID_KEYBOARD_BUTTON_1 0x1E +#define HID_KEYBOARD_BUTTON_2 0x1F +#define HID_KEYBOARD_BUTTON_3 0x20 +#define HID_KEYBOARD_BUTTON_4 0x21 +#define HID_KEYBOARD_BUTTON_5 0x22 +#define HID_KEYBOARD_BUTTON_6 0x23 +#define HID_KEYBOARD_BUTTON_7 0x24 +#define HID_KEYBOARD_BUTTON_8 0x25 +#define HID_KEYBOARD_BUTTON_9 0x26 +#define HID_KEYBOARD_BUTTON_0 0x27 -#define HID_KEYBOARD_BUTTON_RETURN 0x28 -#define HID_KEYBOARD_BUTTON_ESCAPE 0x29 -#define HID_KEYBOARD_BUTTON_DELETE 0x2A -#define HID_KEYBOARD_BUTTON_TAB 0x2B -#define HID_KEYBOARD_BUTTON_SPACEBAR 0x2C -#define HID_KEYBOARD_BUTTON_CAPSLOCK 0x39 -#define HID_KEYBOARD_BUTTON_PRINTSCREEN 0x46 -#define HID_KEYBOARD_BUTTON_SCROLLLOCK 0x47 -#define HID_KEYBOARD_BUTTON_PAUSE 0x48 -#define HID_KEYBOARD_BUTTON_INSERT 0x49 -#define HID_KEYBOARD_BUTTON_HOME 0x4A -#define HID_KEYBOARD_BUTTON_PAGEUP 0x4B -#define HID_KEYBOARD_BUTTON_PAGEDOWN 0x4E -#define HID_KEYBOARD_BUTTON_DELETEFORWARD 0x4C -#define HID_KEYBOARD_BUTTON_END 0x4D -#define HID_KEYBOARD_BUTTON_LEFT_CONTROL 0xE0 -#define HID_KEYBOARD_BUTTON_LEFT_ALT 0xE2 -#define HID_KEYBOARD_BUTTON_RIGHT_CONTROL 0xE4 -#define HID_KEYBOARD_BUTTON_RIGHT_SHIFT 0xE5 -#define HID_KEYBOARD_BUTTON_RIGHT_ALT 0xE6 +#define HID_KEYBOARD_BUTTON_RETURN 0x28 +#define HID_KEYBOARD_BUTTON_ESCAPE 0x29 +#define HID_KEYBOARD_BUTTON_DELETE 0x2A +#define HID_KEYBOARD_BUTTON_TAB 0x2B +#define HID_KEYBOARD_BUTTON_SPACEBAR 0x2C +#define HID_KEYBOARD_BUTTON_CAPSLOCK 0x39 +#define HID_KEYBOARD_BUTTON_PRINTSCREEN 0x46 +#define HID_KEYBOARD_BUTTON_SCROLLLOCK 0x47 +#define HID_KEYBOARD_BUTTON_PAUSE 0x48 +#define HID_KEYBOARD_BUTTON_INSERT 0x49 +#define HID_KEYBOARD_BUTTON_HOME 0x4A +#define HID_KEYBOARD_BUTTON_PAGEUP 0x4B +#define HID_KEYBOARD_BUTTON_PAGEDOWN 0x4E +#define HID_KEYBOARD_BUTTON_DELETEFORWARD 0x4C +#define HID_KEYBOARD_BUTTON_END 0x4D +#define HID_KEYBOARD_BUTTON_LEFT_CONTROL 0xE0 +#define HID_KEYBOARD_BUTTON_LEFT_ALT 0xE2 +#define HID_KEYBOARD_BUTTON_RIGHT_CONTROL 0xE4 +#define HID_KEYBOARD_BUTTON_RIGHT_SHIFT 0xE5 +#define HID_KEYBOARD_BUTTON_RIGHT_ALT 0xE6 -#define HID_KEYBOARD_BUTTON_LEFT 0x50 -#define HID_KEYBOARD_BUTTON_RIGHT 0x4f -#define HID_KEYBOARD_BUTTON_DOWN 0x51 -#define HID_KEYBOARD_BUTTON_UP 0x52 +#define HID_KEYBOARD_BUTTON_LEFT 0x50 +#define HID_KEYBOARD_BUTTON_RIGHT 0x4f +#define HID_KEYBOARD_BUTTON_DOWN 0x51 +#define HID_KEYBOARD_BUTTON_UP 0x52 -#define HID_KEYBOARD_KEYPAD_BUTTON_1 0x59 -#define HID_KEYBOARD_KEYPAD_BUTTON_2 0x5A -#define HID_KEYBOARD_KEYPAD_BUTTON_3 0x5B -#define HID_KEYBOARD_KEYPAD_BUTTON_4 0x5C -#define HID_KEYBOARD_KEYPAD_BUTTON_5 0x5D -#define HID_KEYBOARD_KEYPAD_BUTTON_6 0x5E -#define HID_KEYBOARD_KEYPAD_BUTTON_7 0x5F -#define HID_KEYBOARD_KEYPAD_BUTTON_8 0x60 -#define HID_KEYBOARD_KEYPAD_BUTTON_9 0x61 -#define HID_KEYBOARD_KEYPAD_BUTTON_0 0x62 -#define HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK 0x53 -#define HID_KEYBOARD_KEYPAD_BUTTON_MINUS 0x56 -#define HID_KEYBOARD_KEYPAD_BUTTON_PLUS 0x57 +#define HID_KEYBOARD_KEYPAD_BUTTON_1 0x59 +#define HID_KEYBOARD_KEYPAD_BUTTON_2 0x5A +#define HID_KEYBOARD_KEYPAD_BUTTON_3 0x5B +#define HID_KEYBOARD_KEYPAD_BUTTON_4 0x5C +#define HID_KEYBOARD_KEYPAD_BUTTON_5 0x5D +#define HID_KEYBOARD_KEYPAD_BUTTON_6 0x5E +#define HID_KEYBOARD_KEYPAD_BUTTON_7 0x5F +#define HID_KEYBOARD_KEYPAD_BUTTON_8 0x60 +#define HID_KEYBOARD_KEYPAD_BUTTON_9 0x61 +#define HID_KEYBOARD_KEYPAD_BUTTON_0 0x62 +#define HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK 0x53 +#define HID_KEYBOARD_KEYPAD_BUTTON_MINUS 0x56 +#define HID_KEYBOARD_KEYPAD_BUTTON_PLUS 0x57 -#define HID_KEYBOARD_PAD_COUNT 1 -#define HID_KEYBOARD_DATA_LENGTH 8 +#define HID_KEYBOARD_PAD_COUNT 1 +#define HID_KEYBOARD_DATA_LENGTH 8 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Mouse *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define HID_MOUSE_BUTTON_LEFTCLICK 0x04 -#define HID_MOUSE_BUTTON_RIGHTCLICK 0x05 +#define HID_MOUSE_BUTTON_LEFTCLICK 0x04 +#define HID_MOUSE_BUTTON_RIGHTCLICK 0x05 -#define HID_MOUSE_PAD_COUNT 1 +#define HID_MOUSE_PAD_COUNT 1 -#define HID_MOUSE_MODE_AIM 0x01 -#define HID_MOUSE_MODE_TOUCH 0x02 +#define HID_MOUSE_MODE_AIM 0x01 +#define HID_MOUSE_MODE_TOUCH 0x02 #endif /* _CONTROLLER_PATCHER_DEFS_H_ */ diff --git a/source/ConfigReader.cpp b/source/ConfigReader.cpp index a57db76..31188da 100644 --- a/source/ConfigReader.cpp +++ b/source/ConfigReader.cpp @@ -17,13 +17,12 @@ #include "./ConfigReader.hpp" #include +#include +#include #include #include #include -#include -#include #include -#include #include #include @@ -32,20 +31,20 @@ #include int32_t ConfigReader::numberValidFiles = 0; -ConfigReader *ConfigReader::instance = NULL; +ConfigReader *ConfigReader::instance = NULL; ConfigReader::ConfigReader() { } BOOL ConfigReader::ReadConfigs(std::string path) { std::vector fileList = ScanFolder(path); - if(fileList.size() == 1 && fileList[0].compare("ERROR") == 0) { + if (fileList.size() == 1 && fileList[0].compare("ERROR") == 0) { return false; } - if(fileList.size() > 0) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Found %d config files",fileList.size()); + if (fileList.size() > 0) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Found %d config files", fileList.size()); } processFileList(fileList); } @@ -54,7 +53,7 @@ BOOL ConfigReader::ReadConfigs(std::string path) { ConfigReader::~ConfigReader() { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("~ConfigReader"); } } @@ -63,26 +62,26 @@ std::vector ConfigReader::ScanFolder(std::string path) { std::vector config_files; struct dirent *dirent = NULL; - DIR *dirHandle = opendir(path.c_str()); + DIR *dirHandle = opendir(path.c_str()); if (dirHandle == NULL) { - DEBUG_FUNCTION_LINE("Failed to open dir %s",path.c_str()); + DEBUG_FUNCTION_LINE("Failed to open dir %s", path.c_str()); config_files.push_back("ERROR"); //TODO: Find a proper solution return config_files; } while ((dirent = readdir(dirHandle)) != 0) { - BOOL isDir = dirent->d_type & DT_DIR; + BOOL isDir = dirent->d_type & DT_DIR; const char *filename = dirent->d_name; - if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0) { + if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) { continue; } std::string newPath = path + "/" + std::string(filename); - if(!isDir && StringTools::EndsWith(std::string(filename),".ini")) { + if (!isDir && StringTools::EndsWith(std::string(filename), ".ini")) { config_files.push_back(newPath); - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Found ini: %s ",newPath.c_str()); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Found ini: %s ", newPath.c_str()); } } } @@ -91,8 +90,8 @@ std::vector ConfigReader::ScanFolder(std::string path) { } void ConfigReader::processFileList(std::vector path) { - for(std::vector::iterator it = path.begin(); it != path.end(); ++it) { - DEBUG_FUNCTION_LINE("Reading %s",it->c_str()); + for (std::vector::iterator it = path.begin(); it != path.end(); ++it) { + DEBUG_FUNCTION_LINE("Reading %s", it->c_str()); std::string result = loadFileToString(*it); ConfigParser parser(result); @@ -102,12 +101,12 @@ void ConfigReader::processFileList(std::vector path) { std::string ConfigReader::loadFileToString(std::string path) { std::string strBuffer = ""; - uint8_t * buffer = NULL; - if(FSUtils::LoadFileToMem(path.c_str(),&buffer,NULL) > 0) { - strBuffer = std::string((char *)buffer); - strBuffer = StringTools::removeCharFromString(strBuffer,'\r'); - strBuffer = StringTools::removeCharFromString(strBuffer,' '); - strBuffer = StringTools::removeCharFromString(strBuffer,'\t'); + uint8_t *buffer = NULL; + if (FSUtils::LoadFileToMem(path.c_str(), &buffer, NULL) > 0) { + strBuffer = std::string((char *) buffer); + strBuffer = StringTools::removeCharFromString(strBuffer, '\r'); + strBuffer = StringTools::removeCharFromString(strBuffer, ' '); + strBuffer = StringTools::removeCharFromString(strBuffer, '\t'); } return strBuffer; } diff --git a/source/ConfigReader.hpp b/source/ConfigReader.hpp index 7204ead..01090ca 100644 --- a/source/ConfigReader.hpp +++ b/source/ConfigReader.hpp @@ -22,46 +22,47 @@ #include "ControllerPatcherIncludes.hpp" -class ConfigReader{ +class ConfigReader { friend class ControllerPatcher; friend class ConfigParser; - private: - static ConfigReader *getInstance() { - if(!instance){ - instance = new ConfigReader(); - } - return instance; + +private: + static ConfigReader *getInstance() { + if (!instance) { + instance = new ConfigReader(); } + return instance; + } - static void destroyInstance() { - if(instance){ - delete instance; - instance = NULL; - } + static void destroyInstance() { + if (instance) { + delete instance; + instance = NULL; } + } - static int32_t getNumberOfLoadedFiles(){ - return ConfigReader::numberValidFiles; - } + static int32_t getNumberOfLoadedFiles() { + return ConfigReader::numberValidFiles; + } - static void increaseNumberOfLoadedFiles(){ - ConfigReader::numberValidFiles++; - } - BOOL ReadConfigs(std::string path); - static int32_t numberValidFiles; + static void increaseNumberOfLoadedFiles() { + ConfigReader::numberValidFiles++; + } + BOOL ReadConfigs(std::string path); + static int32_t numberValidFiles; - //!Constructor - ConfigReader(); - //!Destructor - ~ConfigReader(); + //!Constructor + ConfigReader(); + //!Destructor + ~ConfigReader(); - int32_t InitSDCard(); + int32_t InitSDCard(); - static ConfigReader *instance; + static ConfigReader *instance; - std::string loadFileToString(std::string path); - void processFileList(std::vector path); + std::string loadFileToString(std::string path); + void processFileList(std::vector path); - std::vector ScanFolder(std::string path); + std::vector ScanFolder(std::string path); }; #endif diff --git a/source/ControllerPatcher.cpp b/source/ControllerPatcher.cpp index 85a4b53..6c666ce 100644 --- a/source/ControllerPatcher.cpp +++ b/source/ControllerPatcher.cpp @@ -18,11 +18,11 @@ #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include @@ -32,508 +32,507 @@ static uint32_t buttonRemapping_lastButtonsHold = 0; /* To set the controls of an Pro Controler, we first get the result for an Gamepad and convert them later. This way both can share the same functions.*/ // This arrays stores the last hold buttons of the Pro Controllers. One uint32_t for each channel of the controllers -static uint32_t last_button_hold[4] = {0,0,0,0}; +static uint32_t last_button_hold[4] = {0, 0, 0, 0}; // This arrays stores the VPADStatus that will be used to get the HID Data for the Pro Controllers. One for each channel. static VPADStatus myVPADBuffer[4]; void ControllerPatcher::InitButtonMapping() { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Init called "); } - if(!gButtonRemappingConfigDone) { - if(HID_DEBUG) { + if (!gButtonRemappingConfigDone) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Remapping is running! "); } gButtonRemappingConfigDone = 1; - memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything + memset(gGamePadValues, 0, sizeof(gGamePadValues)); // Init / Invalid everything - gGamePadValues[CONTRPS_VPAD_BUTTON_A] = VPAD_BUTTON_A; - gGamePadValues[CONTRPS_VPAD_BUTTON_B] = VPAD_BUTTON_B; - gGamePadValues[CONTRPS_VPAD_BUTTON_X] = VPAD_BUTTON_X; - gGamePadValues[CONTRPS_VPAD_BUTTON_Y] = VPAD_BUTTON_Y; - gGamePadValues[CONTRPS_VPAD_BUTTON_LEFT] = VPAD_BUTTON_LEFT; - gGamePadValues[CONTRPS_VPAD_BUTTON_RIGHT] = VPAD_BUTTON_RIGHT; - gGamePadValues[CONTRPS_VPAD_BUTTON_UP] = VPAD_BUTTON_UP; - gGamePadValues[CONTRPS_VPAD_BUTTON_DOWN] = VPAD_BUTTON_DOWN; - gGamePadValues[CONTRPS_VPAD_BUTTON_ZL] = VPAD_BUTTON_ZL; - gGamePadValues[CONTRPS_VPAD_BUTTON_ZR] = VPAD_BUTTON_ZR; - gGamePadValues[CONTRPS_VPAD_BUTTON_L] = VPAD_BUTTON_L; - gGamePadValues[CONTRPS_VPAD_BUTTON_R] = VPAD_BUTTON_R; - gGamePadValues[CONTRPS_VPAD_BUTTON_PLUS] = VPAD_BUTTON_PLUS; - gGamePadValues[CONTRPS_VPAD_BUTTON_MINUS] = VPAD_BUTTON_MINUS; - gGamePadValues[CONTRPS_VPAD_BUTTON_HOME] = VPAD_BUTTON_HOME; - gGamePadValues[CONTRPS_VPAD_BUTTON_SYNC] = VPAD_BUTTON_SYNC; - gGamePadValues[CONTRPS_VPAD_BUTTON_STICK_R] = VPAD_BUTTON_STICK_R; - gGamePadValues[CONTRPS_VPAD_BUTTON_STICK_L] = VPAD_BUTTON_STICK_L; - gGamePadValues[CONTRPS_VPAD_BUTTON_TV] = VPAD_BUTTON_TV; + gGamePadValues[CONTRPS_VPAD_BUTTON_A] = VPAD_BUTTON_A; + gGamePadValues[CONTRPS_VPAD_BUTTON_B] = VPAD_BUTTON_B; + gGamePadValues[CONTRPS_VPAD_BUTTON_X] = VPAD_BUTTON_X; + gGamePadValues[CONTRPS_VPAD_BUTTON_Y] = VPAD_BUTTON_Y; + gGamePadValues[CONTRPS_VPAD_BUTTON_LEFT] = VPAD_BUTTON_LEFT; + gGamePadValues[CONTRPS_VPAD_BUTTON_RIGHT] = VPAD_BUTTON_RIGHT; + gGamePadValues[CONTRPS_VPAD_BUTTON_UP] = VPAD_BUTTON_UP; + gGamePadValues[CONTRPS_VPAD_BUTTON_DOWN] = VPAD_BUTTON_DOWN; + gGamePadValues[CONTRPS_VPAD_BUTTON_ZL] = VPAD_BUTTON_ZL; + gGamePadValues[CONTRPS_VPAD_BUTTON_ZR] = VPAD_BUTTON_ZR; + gGamePadValues[CONTRPS_VPAD_BUTTON_L] = VPAD_BUTTON_L; + gGamePadValues[CONTRPS_VPAD_BUTTON_R] = VPAD_BUTTON_R; + gGamePadValues[CONTRPS_VPAD_BUTTON_PLUS] = VPAD_BUTTON_PLUS; + gGamePadValues[CONTRPS_VPAD_BUTTON_MINUS] = VPAD_BUTTON_MINUS; + gGamePadValues[CONTRPS_VPAD_BUTTON_HOME] = VPAD_BUTTON_HOME; + gGamePadValues[CONTRPS_VPAD_BUTTON_SYNC] = VPAD_BUTTON_SYNC; + gGamePadValues[CONTRPS_VPAD_BUTTON_STICK_R] = VPAD_BUTTON_STICK_R; + gGamePadValues[CONTRPS_VPAD_BUTTON_STICK_L] = VPAD_BUTTON_STICK_L; + gGamePadValues[CONTRPS_VPAD_BUTTON_TV] = VPAD_BUTTON_TV; - gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_LEFT] = VPAD_STICK_R_EMULATION_LEFT; - gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_RIGHT] = VPAD_STICK_R_EMULATION_RIGHT; - gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_UP] = VPAD_STICK_R_EMULATION_UP; - gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_DOWN] = VPAD_STICK_R_EMULATION_DOWN; - gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_LEFT] = VPAD_STICK_L_EMULATION_LEFT; - gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_RIGHT] = VPAD_STICK_L_EMULATION_RIGHT; - gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_UP] = VPAD_STICK_L_EMULATION_UP; - gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_DOWN] = VPAD_STICK_L_EMULATION_DOWN; + gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_LEFT] = VPAD_STICK_R_EMULATION_LEFT; + gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_RIGHT] = VPAD_STICK_R_EMULATION_RIGHT; + gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_UP] = VPAD_STICK_R_EMULATION_UP; + gGamePadValues[CONTRPS_VPAD_STICK_R_EMULATION_DOWN] = VPAD_STICK_R_EMULATION_DOWN; + gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_LEFT] = VPAD_STICK_L_EMULATION_LEFT; + gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_RIGHT] = VPAD_STICK_L_EMULATION_RIGHT; + gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_UP] = VPAD_STICK_L_EMULATION_UP; + gGamePadValues[CONTRPS_VPAD_STICK_L_EMULATION_DOWN] = VPAD_STICK_L_EMULATION_DOWN; } } void ControllerPatcher::ResetConfig() { - memset(&gControllerMapping,0,sizeof(gControllerMapping)); + memset(&gControllerMapping, 0, sizeof(gControllerMapping)); disableControllerMapping(); - memset(config_controller,CONTROLLER_PATCHER_INVALIDVALUE,sizeof(config_controller)); // Init / Invalid everything - memset(config_controller_hidmask,0,sizeof(config_controller_hidmask)); // Init / Invalid everything - memset(gNetworkController,0,sizeof(gNetworkController)); // Init / Invalid everything - memset(gHID_Devices,0,sizeof(gHID_Devices)); // Init / Invalid everything + memset(config_controller, CONTROLLER_PATCHER_INVALIDVALUE, sizeof(config_controller)); // Init / Invalid everything + memset(config_controller_hidmask, 0, sizeof(config_controller_hidmask)); // Init / Invalid everything + memset(gNetworkController, 0, sizeof(gNetworkController)); // Init / Invalid everything + memset(gHID_Devices, 0, sizeof(gHID_Devices)); // Init / Invalid everything - memset(gWPADConnectCallback,0,sizeof(gWPADConnectCallback)); - memset(gKPADConnectCallback,0,sizeof(gKPADConnectCallback)); - memset(gExtensionCallback,0,sizeof(gExtensionCallback)); + memset(gWPADConnectCallback, 0, sizeof(gWPADConnectCallback)); + memset(gKPADConnectCallback, 0, sizeof(gKPADConnectCallback)); + memset(gExtensionCallback, 0, sizeof(gExtensionCallback)); gCallbackCooldown = 0; - gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; - gHID_LIST_GC = 0; - gHID_LIST_DS3 = 0; - gHID_LIST_DS4 = 0; + gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; + gHID_LIST_GC = 0; + gHID_LIST_DS3 = 0; + gHID_LIST_DS4 = 0; gHID_LIST_KEYBOARD = 0; - gHID_LIST_MOUSE = 0; - gGamePadSlot = 0; - gHID_SLOT_GC = 0; + gHID_LIST_MOUSE = 0; + gGamePadSlot = 0; + gHID_SLOT_GC = 0; gHID_SLOT_KEYBOARD = 0; - gMouseSlot = 0; + gMouseSlot = 0; HIDSlotData slotdata; gHIDRegisteredDevices = 0; ControllerPatcherUtils::getNextSlotData(&slotdata); gGamePadSlot = slotdata.deviceslot; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Register Gamepad-Config. HID-Mask %s Device-Slot: %d", StringTools::byte_to_binary(slotdata.hidmask), gGamePadSlot); } ControllerPatcherUtils::getNextSlotData(&slotdata); - gMouseSlot = slotdata.deviceslot; + gMouseSlot = slotdata.deviceslot; gHID_LIST_MOUSE = slotdata.hidmask; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Register Mouse-Config. HID-Mask %s Device-Slot: %d", StringTools::byte_to_binary(gHID_LIST_MOUSE), gMouseSlot); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t keyboard_slot = slotdata.deviceslot; - uint32_t keyboard_hid = slotdata.hidmask; - gHID_LIST_KEYBOARD = keyboard_hid; - gHID_SLOT_KEYBOARD = keyboard_slot; + uint32_t keyboard_hid = slotdata.hidmask; + 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",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", StringTools::byte_to_binary(gHID_LIST_KEYBOARD), gHID_SLOT_KEYBOARD); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t gc_slot = slotdata.deviceslot; - uint32_t 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",StringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); + uint32_t 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", StringTools::byte_to_binary(gHID_LIST_GC), gHID_SLOT_GC); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t ds3_slot = slotdata.deviceslot; - uint32_t ds3_hid = slotdata.hidmask; - gHID_LIST_DS3 = ds3_hid; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Register DS3-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); + uint32_t ds3_hid = slotdata.hidmask; + gHID_LIST_DS3 = ds3_hid; + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Register DS3-Config. HID-Mask %s Device-Slot: %d", StringTools::byte_to_binary(gHID_LIST_DS3), ds3_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t ds4_slot = slotdata.deviceslot; - uint32_t ds4_hid = slotdata.hidmask; - gHID_LIST_DS4 = ds4_hid; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(ds4_hid),ds4_slot); + uint32_t ds4_hid = slotdata.hidmask; + gHID_LIST_DS4 = ds4_hid; + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Register DS4-Config. HID-Mask %s Device-Slot: %d", StringTools::byte_to_binary(ds4_hid), ds4_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t xinput_slot = slotdata.deviceslot; - uint32_t xinput_hid = slotdata.hidmask; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(xinput_hid),xinput_slot); + uint32_t xinput_hid = slotdata.hidmask; + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Register XInput-Config. HID-Mask %s Device-Slot: %d", StringTools::byte_to_binary(xinput_hid), xinput_slot); } ControllerPatcherUtils::getNextSlotData(&slotdata); uint32_t switch_pro_slot = slotdata.deviceslot; - gHID_LIST_SWITCH_PRO = slotdata.hidmask; - DEBUG_FUNCTION_LINE("Register Switch-Pro-Config. HID-Mask %s Device-Slot: %d",StringTools::byte_to_binary(gHID_LIST_SWITCH_PRO),switch_pro_slot); + gHID_LIST_SWITCH_PRO = slotdata.hidmask; + 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[ds3_slot] = gHID_LIST_DS3; - config_controller_hidmask[keyboard_slot] = gHID_LIST_KEYBOARD; - config_controller_hidmask[gMouseSlot] = gHID_LIST_MOUSE; - config_controller_hidmask[ds4_slot] = gHID_LIST_DS4; - config_controller_hidmask[xinput_slot] = xinput_hid; - config_controller_hidmask[switch_pro_slot] = gHID_LIST_SWITCH_PRO; + config_controller_hidmask[gc_slot] = gHID_LIST_GC; + config_controller_hidmask[ds3_slot] = gHID_LIST_DS3; + config_controller_hidmask[keyboard_slot] = gHID_LIST_KEYBOARD; + config_controller_hidmask[gMouseSlot] = gHID_LIST_MOUSE; + config_controller_hidmask[ds4_slot] = gHID_LIST_DS4; + config_controller_hidmask[xinput_slot] = xinput_hid; + config_controller_hidmask[switch_pro_slot] = gHID_LIST_SWITCH_PRO; /* We need to give the GamePad, Mouse and Keyboard a unique VID/PID to find the right slots.*/ //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! GamePad //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gGamePadSlot][CONTRPS_VID], 0xAF,0xFE); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gGamePadSlot][CONTRPS_PID], 0xAA,0xAA); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gGamePadSlot][CONTRPS_VID], 0xAF, 0xFE); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gGamePadSlot][CONTRPS_PID], 0xAA, 0xAA); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Switch Pro Controller //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VID], (HID_SWITCH_PRO_VID>>8)&0xFF, HID_SWITCH_PRO_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_PID], (HID_SWITCH_PRO_PID>>8)&0xFF, HID_SWITCH_PRO_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_A], HID_SWITCH_PRO_BT_BUTTON_A[0], HID_SWITCH_PRO_BT_BUTTON_A[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_B], HID_SWITCH_PRO_BT_BUTTON_B[0], HID_SWITCH_PRO_BT_BUTTON_B[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_X], HID_SWITCH_PRO_BT_BUTTON_X[0], HID_SWITCH_PRO_BT_BUTTON_X[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_Y], HID_SWITCH_PRO_BT_BUTTON_Y[0], HID_SWITCH_PRO_BT_BUTTON_Y[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_N], HID_SWITCH_PRO_BT_BUTTON_DPAD_N[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_N[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NE], HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_E], HID_SWITCH_PRO_BT_BUTTON_DPAD_E[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_E[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_SE], HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_S], HID_SWITCH_PRO_BT_BUTTON_DPAD_S[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_S[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_SW], HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_W], HID_SWITCH_PRO_BT_BUTTON_DPAD_W[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_W[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NW], HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL], HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_SWITCH_PRO_BT_BUTTON_PLUS[0], HID_SWITCH_PRO_BT_BUTTON_PLUS[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_SWITCH_PRO_BT_BUTTON_MINUS[0], HID_SWITCH_PRO_BT_BUTTON_MINUS[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L], HID_SWITCH_PRO_BT_BUTTON_L[0], HID_SWITCH_PRO_BT_BUTTON_L[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R], HID_SWITCH_PRO_BT_BUTTON_R[0], HID_SWITCH_PRO_BT_BUTTON_R[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_ZL], HID_SWITCH_PRO_BT_BUTTON_ZL[0], HID_SWITCH_PRO_BT_BUTTON_ZL[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_ZR], HID_SWITCH_PRO_BT_BUTTON_ZR[0], HID_SWITCH_PRO_BT_BUTTON_ZR[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_SWITCH_PRO_BT_BUTTON_STICK_L[0], HID_SWITCH_PRO_BT_BUTTON_STICK_L[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_SWITCH_PRO_BT_BUTTON_STICK_R[0], HID_SWITCH_PRO_BT_BUTTON_STICK_R[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_HOME], HID_SWITCH_PRO_BT_BUTTON_HOME[0], HID_SWITCH_PRO_BT_BUTTON_HOME[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VID], (HID_SWITCH_PRO_VID >> 8) & 0xFF, HID_SWITCH_PRO_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_PID], (HID_SWITCH_PRO_PID >> 8) & 0xFF, HID_SWITCH_PRO_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_A], HID_SWITCH_PRO_BT_BUTTON_A[0], HID_SWITCH_PRO_BT_BUTTON_A[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_B], HID_SWITCH_PRO_BT_BUTTON_B[0], HID_SWITCH_PRO_BT_BUTTON_B[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_X], HID_SWITCH_PRO_BT_BUTTON_X[0], HID_SWITCH_PRO_BT_BUTTON_X[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_Y], HID_SWITCH_PRO_BT_BUTTON_Y[0], HID_SWITCH_PRO_BT_BUTTON_Y[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_N], HID_SWITCH_PRO_BT_BUTTON_DPAD_N[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_N[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NE], HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_E], HID_SWITCH_PRO_BT_BUTTON_DPAD_E[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_E[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_SE], HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_S], HID_SWITCH_PRO_BT_BUTTON_DPAD_S[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_S[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_SW], HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_W], HID_SWITCH_PRO_BT_BUTTON_DPAD_W[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_W[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NW], HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL], HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[0], HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_SWITCH_PRO_BT_BUTTON_PLUS[0], HID_SWITCH_PRO_BT_BUTTON_PLUS[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_SWITCH_PRO_BT_BUTTON_MINUS[0], HID_SWITCH_PRO_BT_BUTTON_MINUS[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L], HID_SWITCH_PRO_BT_BUTTON_L[0], HID_SWITCH_PRO_BT_BUTTON_L[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R], HID_SWITCH_PRO_BT_BUTTON_R[0], HID_SWITCH_PRO_BT_BUTTON_R[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_ZL], HID_SWITCH_PRO_BT_BUTTON_ZL[0], HID_SWITCH_PRO_BT_BUTTON_ZL[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_ZR], HID_SWITCH_PRO_BT_BUTTON_ZR[0], HID_SWITCH_PRO_BT_BUTTON_ZR[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_SWITCH_PRO_BT_BUTTON_STICK_L[0], HID_SWITCH_PRO_BT_BUTTON_STICK_L[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_SWITCH_PRO_BT_BUTTON_STICK_R[0], HID_SWITCH_PRO_BT_BUTTON_STICK_R[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_HOME], HID_SWITCH_PRO_BT_BUTTON_HOME[0], HID_SWITCH_PRO_BT_BUTTON_HOME[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_PAD_COUNT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_L_Y[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_BYTE], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_MIN], HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[switch_pro_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_SWITCH_PRO_BT_STICK_R_Y[STICK_CONF_INVERT]); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Mouse //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gMouseSlot][CONTRPS_VID], (HID_MOUSE_VID>>8)&0xFF, HID_MOUSE_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gMouseSlot][CONTRPS_PID], (HID_MOUSE_PID>>8)&0xFF, HID_MOUSE_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gMouseSlot][CONTRPS_VPAD_BUTTON_LEFT], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZR); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gMouseSlot][CONTRPS_VPAD_BUTTON_RIGHT], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_R); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gMouseSlot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_MOUSE_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gMouseSlot][CONTRPS_VID], (HID_MOUSE_VID >> 8) & 0xFF, HID_MOUSE_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gMouseSlot][CONTRPS_PID], (HID_MOUSE_PID >> 8) & 0xFF, HID_MOUSE_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gMouseSlot][CONTRPS_VPAD_BUTTON_LEFT], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZR); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gMouseSlot][CONTRPS_VPAD_BUTTON_RIGHT], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_R); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gMouseSlot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_MOUSE_PAD_COUNT); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Keyboard //!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VID], (HID_KEYBOARD_VID>>8)&0xFF, HID_KEYBOARD_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_PID], (HID_KEYBOARD_PID>>8)&0xFF, HID_KEYBOARD_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_A], 0x00, HID_KEYBOARD_BUTTON_E); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_B], 0x00, HID_KEYBOARD_BUTTON_Q); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_X], 0x00, HID_KEYBOARD_BUTTON_SPACEBAR); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_Y], 0x00, HID_KEYBOARD_BUTTON_R); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET,CONTRPDM_Normal); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_LEFT], 0x00, HID_KEYBOARD_BUTTON_LEFT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_RIGHT], 0x00, HID_KEYBOARD_BUTTON_RIGHT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_DOWN], 0x00, HID_KEYBOARD_BUTTON_DOWN); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_UP], 0x00, HID_KEYBOARD_BUTTON_UP); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_PLUS], 0x00, HID_KEYBOARD_BUTTON_RETURN); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_MINUS], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_MINUS); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L], 0x00, HID_KEYBOARD_BUTTON_V); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R], 0x00, HID_KEYBOARD_BUTTON_B); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_ZL], 0x00, HID_KEYBOARD_BUTTON_SHIFT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_ZR], 0x00, HID_KEYBOARD_BUTTON_N); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_STICK_L], 0x00, HID_KEYBOARD_BUTTON_F); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_STICK_R], 0x00, HID_KEYBOARD_BUTTON_TAB); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VID], (HID_KEYBOARD_VID >> 8) & 0xFF, HID_KEYBOARD_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_PID], (HID_KEYBOARD_PID >> 8) & 0xFF, HID_KEYBOARD_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_A], 0x00, HID_KEYBOARD_BUTTON_E); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_B], 0x00, HID_KEYBOARD_BUTTON_Q); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_X], 0x00, HID_KEYBOARD_BUTTON_SPACEBAR); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_Y], 0x00, HID_KEYBOARD_BUTTON_R); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, CONTRPDM_Normal); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_LEFT], 0x00, HID_KEYBOARD_BUTTON_LEFT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_RIGHT], 0x00, HID_KEYBOARD_BUTTON_RIGHT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_DOWN], 0x00, HID_KEYBOARD_BUTTON_DOWN); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_UP], 0x00, HID_KEYBOARD_BUTTON_UP); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_PLUS], 0x00, HID_KEYBOARD_BUTTON_RETURN); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_MINUS], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_MINUS); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L], 0x00, HID_KEYBOARD_BUTTON_V); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R], 0x00, HID_KEYBOARD_BUTTON_B); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_ZL], 0x00, HID_KEYBOARD_BUTTON_SHIFT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_ZR], 0x00, HID_KEYBOARD_BUTTON_N); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_STICK_L], 0x00, HID_KEYBOARD_BUTTON_F); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_STICK_R], 0x00, HID_KEYBOARD_BUTTON_TAB); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_UP], 0x00, HID_KEYBOARD_BUTTON_W); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_DOWN], 0x00, HID_KEYBOARD_BUTTON_S); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_LEFT], 0x00, HID_KEYBOARD_BUTTON_A); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_RIGHT], 0x00, HID_KEYBOARD_BUTTON_D); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_UP], 0x00, HID_KEYBOARD_BUTTON_W); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_DOWN], 0x00, HID_KEYBOARD_BUTTON_S); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_LEFT], 0x00, HID_KEYBOARD_BUTTON_A); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_L_STICK_RIGHT], 0x00, HID_KEYBOARD_BUTTON_D); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_UP], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_8); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_DOWN], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_2); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_LEFT], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_4); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_RIGHT], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_6); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_UP], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_8); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_DOWN], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_2); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_LEFT], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_4); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_VPAD_BUTTON_R_STICK_RIGHT], 0x00, HID_KEYBOARD_KEYPAD_BUTTON_6); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_KEYBOARD][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET,HID_KEYBOARD_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_KEYBOARD][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_KEYBOARD_PAD_COUNT); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! GC-Adapter //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VID], (HID_GC_VID>>8)&0xFF, HID_GC_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_PID], (HID_GC_PID>>8)&0xFF, HID_GC_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_A], HID_GC_BUTTON_A[0], HID_GC_BUTTON_A[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_B], HID_GC_BUTTON_B[0], HID_GC_BUTTON_B[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_X], HID_GC_BUTTON_X[0], HID_GC_BUTTON_X[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_Y], HID_GC_BUTTON_Y[0], HID_GC_BUTTON_Y[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_GC_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_LEFT], HID_GC_BUTTON_LEFT[0], HID_GC_BUTTON_LEFT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_RIGHT], HID_GC_BUTTON_RIGHT[0], HID_GC_BUTTON_RIGHT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_DOWN], HID_GC_BUTTON_DOWN[0], HID_GC_BUTTON_DOWN[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_UP], HID_GC_BUTTON_UP[0], HID_GC_BUTTON_UP[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_MINUS], HID_GC_BUTTON_START[0], HID_GC_BUTTON_START[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L], HID_GC_BUTTON_L[0], HID_GC_BUTTON_L[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R], HID_GC_BUTTON_R[0], HID_GC_BUTTON_R[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_PLUS], HID_GC_BUTTON_START[0], HID_GC_BUTTON_START[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_ZL], HID_GC_BUTTON_L[0], HID_GC_BUTTON_L[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_ZR], HID_GC_BUTTON_R[0], HID_GC_BUTTON_R[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_STICK_L], HID_GC_BUTTON_A[0], HID_GC_BUTTON_A[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_STICK_R], HID_GC_BUTTON_B[0], HID_GC_BUTTON_B[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE], CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR], HID_GC_BUTTON_Z[0], HID_GC_BUTTON_Z[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VID], (HID_GC_VID >> 8) & 0xFF, HID_GC_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_PID], (HID_GC_PID >> 8) & 0xFF, HID_GC_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_A], HID_GC_BUTTON_A[0], HID_GC_BUTTON_A[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_B], HID_GC_BUTTON_B[0], HID_GC_BUTTON_B[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_X], HID_GC_BUTTON_X[0], HID_GC_BUTTON_X[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_Y], HID_GC_BUTTON_Y[0], HID_GC_BUTTON_Y[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_GC_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_LEFT], HID_GC_BUTTON_LEFT[0], HID_GC_BUTTON_LEFT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_RIGHT], HID_GC_BUTTON_RIGHT[0], HID_GC_BUTTON_RIGHT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_DOWN], HID_GC_BUTTON_DOWN[0], HID_GC_BUTTON_DOWN[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_UP], HID_GC_BUTTON_UP[0], HID_GC_BUTTON_UP[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_MINUS], HID_GC_BUTTON_START[0], HID_GC_BUTTON_START[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L], HID_GC_BUTTON_L[0], HID_GC_BUTTON_L[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R], HID_GC_BUTTON_R[0], HID_GC_BUTTON_R[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_PLUS], HID_GC_BUTTON_START[0], HID_GC_BUTTON_START[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_ZL], HID_GC_BUTTON_L[0], HID_GC_BUTTON_L[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_ZR], HID_GC_BUTTON_R[0], HID_GC_BUTTON_R[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_STICK_L], HID_GC_BUTTON_A[0], HID_GC_BUTTON_A[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_STICK_R], HID_GC_BUTTON_B[0], HID_GC_BUTTON_B[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE], CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR], HID_GC_BUTTON_Z[0], HID_GC_BUTTON_Z[1]); //Buttons that will be ignored when the CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR is pressed - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_MINUS); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_L); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_R); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_STICK_L); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_STICK_R); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_MINUS); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_L); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_R); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_STICK_L); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_STICK_R); //Buttons that will be ignored when the CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR is released - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_PLUS); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZL); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZR); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_A); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_B); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_PLUS); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZL); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_ZR); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_A); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED], CONTROLLER_PATCHER_VALUE_SET, CONTRPS_VPAD_BUTTON_B); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_PAD_COUNT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_GC_STICK_L_X[STICK_CONF_BYTE],HID_GC_STICK_L_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_GC_STICK_L_X[STICK_CONF_MIN], HID_GC_STICK_L_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_GC_STICK_L_X[STICK_CONF_BYTE], HID_GC_STICK_L_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_GC_STICK_L_X[STICK_CONF_MIN], HID_GC_STICK_L_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_GC_STICK_L_Y[STICK_CONF_BYTE],HID_GC_STICK_L_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_GC_STICK_L_Y[STICK_CONF_MIN], HID_GC_STICK_L_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_GC_STICK_L_Y[STICK_CONF_BYTE], HID_GC_STICK_L_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_GC_STICK_L_Y[STICK_CONF_MIN], HID_GC_STICK_L_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_L_Y[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_GC_STICK_R_X[STICK_CONF_BYTE],HID_GC_STICK_R_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_GC_STICK_R_X[STICK_CONF_MIN], HID_GC_STICK_R_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_GC_STICK_R_X[STICK_CONF_BYTE], HID_GC_STICK_R_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_GC_STICK_R_X[STICK_CONF_MIN], HID_GC_STICK_R_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_GC_STICK_R_Y[STICK_CONF_BYTE],HID_GC_STICK_R_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_GC_STICK_R_Y[STICK_CONF_MIN], HID_GC_STICK_R_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_GC_STICK_R_Y[STICK_CONF_BYTE], HID_GC_STICK_R_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_GC_STICK_R_Y[STICK_CONF_MIN], HID_GC_STICK_R_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[gHID_SLOT_GC][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_GC_STICK_R_Y[STICK_CONF_INVERT]); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! DS3 //!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VID], (HID_DS3_VID>>8)&0xFF, HID_DS3_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_PID], (HID_DS3_PID>>8)&0xFF, HID_DS3_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_A], HID_DS3_BUTTON_CIRCLE[0], HID_DS3_BUTTON_CIRCLE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_B], HID_DS3_BUTTON_CROSS[0], HID_DS3_BUTTON_CROSS[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_X], HID_DS3_BUTTON_TRIANGLE[0], HID_DS3_BUTTON_TRIANGLE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_Y], HID_DS3_BUTTON_SQUARE[0], HID_DS3_BUTTON_SQUARE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_LEFT], HID_DS3_BUTTON_LEFT[0], HID_DS3_BUTTON_LEFT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_RIGHT], HID_DS3_BUTTON_RIGHT[0], HID_DS3_BUTTON_RIGHT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_DOWN], HID_DS3_BUTTON_DOWN[0], HID_DS3_BUTTON_DOWN[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_UP], HID_DS3_BUTTON_UP[0], HID_DS3_BUTTON_UP[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_DS3_BUTTON_START[0], HID_DS3_BUTTON_START[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_DS3_BUTTON_SELECT[0], HID_DS3_BUTTON_SELECT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L], HID_DS3_BUTTON_L1[0], HID_DS3_BUTTON_L1[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R], HID_DS3_BUTTON_R1[0], HID_DS3_BUTTON_R1[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_ZL], HID_DS3_BUTTON_L2[0], HID_DS3_BUTTON_L2[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_ZR], HID_DS3_BUTTON_R2[0], HID_DS3_BUTTON_R2[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_DS3_BUTTON_L3[0], HID_DS3_BUTTON_L3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_DS3_BUTTON_R3[0], HID_DS3_BUTTON_R3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_HOME], HID_DS3_BUTTON_GUIDE[0], HID_DS3_BUTTON_GUIDE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VID], (HID_DS3_VID >> 8) & 0xFF, HID_DS3_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_PID], (HID_DS3_PID >> 8) & 0xFF, HID_DS3_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_A], HID_DS3_BUTTON_CIRCLE[0], HID_DS3_BUTTON_CIRCLE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_B], HID_DS3_BUTTON_CROSS[0], HID_DS3_BUTTON_CROSS[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_X], HID_DS3_BUTTON_TRIANGLE[0], HID_DS3_BUTTON_TRIANGLE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_Y], HID_DS3_BUTTON_SQUARE[0], HID_DS3_BUTTON_SQUARE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_LEFT], HID_DS3_BUTTON_LEFT[0], HID_DS3_BUTTON_LEFT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_RIGHT], HID_DS3_BUTTON_RIGHT[0], HID_DS3_BUTTON_RIGHT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_DOWN], HID_DS3_BUTTON_DOWN[0], HID_DS3_BUTTON_DOWN[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_UP], HID_DS3_BUTTON_UP[0], HID_DS3_BUTTON_UP[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_DS3_BUTTON_START[0], HID_DS3_BUTTON_START[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_DS3_BUTTON_SELECT[0], HID_DS3_BUTTON_SELECT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L], HID_DS3_BUTTON_L1[0], HID_DS3_BUTTON_L1[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R], HID_DS3_BUTTON_R1[0], HID_DS3_BUTTON_R1[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_ZL], HID_DS3_BUTTON_L2[0], HID_DS3_BUTTON_L2[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_ZR], HID_DS3_BUTTON_R2[0], HID_DS3_BUTTON_R2[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_DS3_BUTTON_L3[0], HID_DS3_BUTTON_L3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_DS3_BUTTON_R3[0], HID_DS3_BUTTON_R3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_HOME], HID_DS3_BUTTON_GUIDE[0], HID_DS3_BUTTON_GUIDE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_PAD_COUNT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_DS3_STICK_L_X[STICK_CONF_BYTE], HID_DS3_STICK_L_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_DS3_STICK_L_X[STICK_CONF_MIN], HID_DS3_STICK_L_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_DS3_STICK_L_X[STICK_CONF_BYTE], HID_DS3_STICK_L_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_DS3_STICK_L_X[STICK_CONF_MIN], HID_DS3_STICK_L_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_DS3_STICK_L_Y[STICK_CONF_BYTE], HID_DS3_STICK_L_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_DS3_STICK_L_Y[STICK_CONF_MIN], HID_DS3_STICK_L_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_DS3_STICK_L_Y[STICK_CONF_BYTE], HID_DS3_STICK_L_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_DS3_STICK_L_Y[STICK_CONF_MIN], HID_DS3_STICK_L_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_L_Y[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_DS3_STICK_R_X[STICK_CONF_BYTE], HID_DS3_STICK_R_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_DS3_STICK_R_X[STICK_CONF_MIN], HID_DS3_STICK_R_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_DS3_STICK_R_X[STICK_CONF_BYTE], HID_DS3_STICK_R_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_DS3_STICK_R_X[STICK_CONF_MIN], HID_DS3_STICK_R_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_DS3_STICK_R_Y[STICK_CONF_BYTE], HID_DS3_STICK_R_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_DS3_STICK_R_Y[STICK_CONF_MIN], HID_DS3_STICK_R_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_DS3_STICK_R_Y[STICK_CONF_BYTE], HID_DS3_STICK_R_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_DS3_STICK_R_Y[STICK_CONF_MIN], HID_DS3_STICK_R_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds3_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS3_STICK_R_Y[STICK_CONF_INVERT]); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! DS4 //!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VID], (HID_DS4_VID>>8)&0xFF, HID_DS4_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_PID], (HID_DS4_PID>>8)&0xFF, HID_DS4_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_A], HID_DS4_BUTTON_CIRCLE[0], HID_DS4_BUTTON_CIRCLE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_B], HID_DS4_BUTTON_CROSS[0], HID_DS4_BUTTON_CROSS[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_X], HID_DS4_BUTTON_TRIANGLE[0], HID_DS4_BUTTON_TRIANGLE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_Y], HID_DS4_BUTTON_SQUARE[0], HID_DS4_BUTTON_SQUARE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_N], HID_DS4_BUTTON_DPAD_N[0], HID_DS4_BUTTON_DPAD_N[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NE], HID_DS4_BUTTON_DPAD_NE[0], HID_DS4_BUTTON_DPAD_NE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_E], HID_DS4_BUTTON_DPAD_E[0], HID_DS4_BUTTON_DPAD_E[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_SE], HID_DS4_BUTTON_DPAD_SE[0], HID_DS4_BUTTON_DPAD_SE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_S], HID_DS4_BUTTON_DPAD_S[0], HID_DS4_BUTTON_DPAD_S[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_SW], HID_DS4_BUTTON_DPAD_SW[0], HID_DS4_BUTTON_DPAD_SW[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_W], HID_DS4_BUTTON_DPAD_W[0], HID_DS4_BUTTON_DPAD_W[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NW], HID_DS4_BUTTON_DPAD_NW[0], HID_DS4_BUTTON_DPAD_NW[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL], HID_DS4_BUTTON_DPAD_NEUTRAL[0], HID_DS4_BUTTON_DPAD_NEUTRAL[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_DS4_BUTTON_OPTIONS[0], HID_DS4_BUTTON_OPTIONS[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_DS4_BUTTON_SHARE[0], HID_DS4_BUTTON_SHARE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L], HID_DS4_BUTTON_L1[0], HID_DS4_BUTTON_L1[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R], HID_DS4_BUTTON_R1[0], HID_DS4_BUTTON_R1[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_ZL], HID_DS4_BUTTON_L2[0], HID_DS4_BUTTON_L2[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_ZR], HID_DS4_BUTTON_R2[0], HID_DS4_BUTTON_R2[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_DS4_BUTTON_L3[0], HID_DS4_BUTTON_L3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_DS4_BUTTON_R3[0], HID_DS4_BUTTON_R3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_HOME], HID_DS4_BUTTON_GUIDE[0], HID_DS4_BUTTON_GUIDE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VID], (HID_DS4_VID >> 8) & 0xFF, HID_DS4_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_PID], (HID_DS4_PID >> 8) & 0xFF, HID_DS4_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_A], HID_DS4_BUTTON_CIRCLE[0], HID_DS4_BUTTON_CIRCLE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_B], HID_DS4_BUTTON_CROSS[0], HID_DS4_BUTTON_CROSS[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_X], HID_DS4_BUTTON_TRIANGLE[0], HID_DS4_BUTTON_TRIANGLE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_Y], HID_DS4_BUTTON_SQUARE[0], HID_DS4_BUTTON_SQUARE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_N], HID_DS4_BUTTON_DPAD_N[0], HID_DS4_BUTTON_DPAD_N[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NE], HID_DS4_BUTTON_DPAD_NE[0], HID_DS4_BUTTON_DPAD_NE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_E], HID_DS4_BUTTON_DPAD_E[0], HID_DS4_BUTTON_DPAD_E[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_SE], HID_DS4_BUTTON_DPAD_SE[0], HID_DS4_BUTTON_DPAD_SE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_S], HID_DS4_BUTTON_DPAD_S[0], HID_DS4_BUTTON_DPAD_S[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_SW], HID_DS4_BUTTON_DPAD_SW[0], HID_DS4_BUTTON_DPAD_SW[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_W], HID_DS4_BUTTON_DPAD_W[0], HID_DS4_BUTTON_DPAD_W[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NW], HID_DS4_BUTTON_DPAD_NW[0], HID_DS4_BUTTON_DPAD_NW[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL], HID_DS4_BUTTON_DPAD_NEUTRAL[0], HID_DS4_BUTTON_DPAD_NEUTRAL[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_DS4_BUTTON_OPTIONS[0], HID_DS4_BUTTON_OPTIONS[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_DS4_BUTTON_SHARE[0], HID_DS4_BUTTON_SHARE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L], HID_DS4_BUTTON_L1[0], HID_DS4_BUTTON_L1[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R], HID_DS4_BUTTON_R1[0], HID_DS4_BUTTON_R1[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_ZL], HID_DS4_BUTTON_L2[0], HID_DS4_BUTTON_L2[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_ZR], HID_DS4_BUTTON_R2[0], HID_DS4_BUTTON_R2[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_DS4_BUTTON_L3[0], HID_DS4_BUTTON_L3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_DS4_BUTTON_R3[0], HID_DS4_BUTTON_R3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_HOME], HID_DS4_BUTTON_GUIDE[0], HID_DS4_BUTTON_GUIDE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_PAD_COUNT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_DS4_STICK_L_X[STICK_CONF_BYTE], HID_DS4_STICK_L_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_DS4_STICK_L_X[STICK_CONF_MIN], HID_DS4_STICK_L_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_DS4_STICK_L_X[STICK_CONF_BYTE], HID_DS4_STICK_L_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_DS4_STICK_L_X[STICK_CONF_MIN], HID_DS4_STICK_L_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_DS4_STICK_L_Y[STICK_CONF_BYTE], HID_DS4_STICK_L_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_DS4_STICK_L_Y[STICK_CONF_MIN], HID_DS4_STICK_L_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_DS4_STICK_L_Y[STICK_CONF_BYTE], HID_DS4_STICK_L_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_DS4_STICK_L_Y[STICK_CONF_MIN], HID_DS4_STICK_L_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_L_Y[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_DS4_STICK_R_X[STICK_CONF_BYTE], HID_DS4_STICK_R_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_DS4_STICK_R_X[STICK_CONF_MIN], HID_DS4_STICK_R_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_DS4_STICK_R_X[STICK_CONF_BYTE], HID_DS4_STICK_R_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_DS4_STICK_R_X[STICK_CONF_MIN], HID_DS4_STICK_R_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_DS4_STICK_R_Y[STICK_CONF_BYTE], HID_DS4_STICK_R_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_DS4_STICK_R_Y[STICK_CONF_MIN], HID_DS4_STICK_R_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_DS4_STICK_R_Y[STICK_CONF_BYTE], HID_DS4_STICK_R_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_DS4_STICK_R_Y[STICK_CONF_MIN], HID_DS4_STICK_R_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[ds4_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_DS4_STICK_R_Y[STICK_CONF_INVERT]); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! XInput //!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VID], (HID_XINPUT_VID>>8)&0xFF, HID_XINPUT_VID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_PID], (HID_XINPUT_PID>>8)&0xFF, HID_XINPUT_PID&0xFF); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_A], HID_XINPUT_BUTTON_B[0], HID_XINPUT_BUTTON_B[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_B], HID_XINPUT_BUTTON_A[0], HID_XINPUT_BUTTON_A[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_X], HID_XINPUT_BUTTON_Y[0], HID_XINPUT_BUTTON_Y[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_Y], HID_XINPUT_BUTTON_X[0], HID_XINPUT_BUTTON_X[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_UP], HID_XINPUT_BUTTON_UP[0], HID_XINPUT_BUTTON_UP[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_DOWN], HID_XINPUT_BUTTON_DOWN[0], HID_XINPUT_BUTTON_DOWN[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_LEFT], HID_XINPUT_BUTTON_LEFT[0], HID_XINPUT_BUTTON_LEFT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_RIGHT], HID_XINPUT_BUTTON_RIGHT[0], HID_XINPUT_BUTTON_RIGHT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_XINPUT_BUTTON_START[0], HID_XINPUT_BUTTON_START[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_XINPUT_BUTTON_BACK[0], HID_XINPUT_BUTTON_BACK[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L], HID_XINPUT_BUTTON_LB[0], HID_XINPUT_BUTTON_LB[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R], HID_XINPUT_BUTTON_RB[0], HID_XINPUT_BUTTON_RB[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_ZL], HID_XINPUT_BUTTON_LT[0], HID_XINPUT_BUTTON_LT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_ZR], HID_XINPUT_BUTTON_RT[0], HID_XINPUT_BUTTON_RT[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_XINPUT_BUTTON_L3[0], HID_XINPUT_BUTTON_L3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_XINPUT_BUTTON_R3[0], HID_XINPUT_BUTTON_R3[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_HOME], HID_XINPUT_BUTTON_GUIDE[0], HID_XINPUT_BUTTON_GUIDE[1]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_PAD_COUNT); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VID], (HID_XINPUT_VID >> 8) & 0xFF, HID_XINPUT_VID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_PID], (HID_XINPUT_PID >> 8) & 0xFF, HID_XINPUT_PID & 0xFF); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_A], HID_XINPUT_BUTTON_B[0], HID_XINPUT_BUTTON_B[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_B], HID_XINPUT_BUTTON_A[0], HID_XINPUT_BUTTON_A[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_X], HID_XINPUT_BUTTON_Y[0], HID_XINPUT_BUTTON_Y[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_Y], HID_XINPUT_BUTTON_X[0], HID_XINPUT_BUTTON_X[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_DPAD_MODE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_BUTTON_DPAD_TYPE[CONTRDPAD_MODE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_DPAD_MASK], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_BUTTON_DPAD_TYPE[CONTRDPAD_MASK]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_UP], HID_XINPUT_BUTTON_UP[0], HID_XINPUT_BUTTON_UP[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_DOWN], HID_XINPUT_BUTTON_DOWN[0], HID_XINPUT_BUTTON_DOWN[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_LEFT], HID_XINPUT_BUTTON_LEFT[0], HID_XINPUT_BUTTON_LEFT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_RIGHT], HID_XINPUT_BUTTON_RIGHT[0], HID_XINPUT_BUTTON_RIGHT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_PLUS], HID_XINPUT_BUTTON_START[0], HID_XINPUT_BUTTON_START[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_MINUS], HID_XINPUT_BUTTON_BACK[0], HID_XINPUT_BUTTON_BACK[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L], HID_XINPUT_BUTTON_LB[0], HID_XINPUT_BUTTON_LB[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R], HID_XINPUT_BUTTON_RB[0], HID_XINPUT_BUTTON_RB[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_ZL], HID_XINPUT_BUTTON_LT[0], HID_XINPUT_BUTTON_LT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_ZR], HID_XINPUT_BUTTON_RT[0], HID_XINPUT_BUTTON_RT[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_STICK_L], HID_XINPUT_BUTTON_L3[0], HID_XINPUT_BUTTON_L3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_STICK_R], HID_XINPUT_BUTTON_R3[0], HID_XINPUT_BUTTON_R3[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_HOME], HID_XINPUT_BUTTON_GUIDE[0], HID_XINPUT_BUTTON_GUIDE[1]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_PAD_COUNT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_PAD_COUNT); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_XINPUT_STICK_L_X[STICK_CONF_BYTE], HID_XINPUT_STICK_L_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_XINPUT_STICK_L_X[STICK_CONF_MIN], HID_XINPUT_STICK_L_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X], HID_XINPUT_STICK_L_X[STICK_CONF_BYTE], HID_XINPUT_STICK_L_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX], HID_XINPUT_STICK_L_X[STICK_CONF_MIN], HID_XINPUT_STICK_L_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_XINPUT_STICK_L_Y[STICK_CONF_BYTE], HID_XINPUT_STICK_L_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_XINPUT_STICK_L_Y[STICK_CONF_MIN], HID_XINPUT_STICK_L_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y], HID_XINPUT_STICK_L_Y[STICK_CONF_BYTE], HID_XINPUT_STICK_L_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX], HID_XINPUT_STICK_L_Y[STICK_CONF_MIN], HID_XINPUT_STICK_L_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_L_Y[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_XINPUT_STICK_R_X[STICK_CONF_BYTE], HID_XINPUT_STICK_R_X[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_X[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_XINPUT_STICK_R_X[STICK_CONF_MIN], HID_XINPUT_STICK_R_X[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_X[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X], HID_XINPUT_STICK_R_X[STICK_CONF_BYTE], HID_XINPUT_STICK_R_X[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_X[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX], HID_XINPUT_STICK_R_X[STICK_CONF_MIN], HID_XINPUT_STICK_R_X[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_X[STICK_CONF_INVERT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_XINPUT_STICK_R_Y[STICK_CONF_BYTE], HID_XINPUT_STICK_R_Y[STICK_CONF_DEFAULT]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_Y[STICK_CONF_DEADZONE]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_XINPUT_STICK_R_Y[STICK_CONF_MIN], HID_XINPUT_STICK_R_Y[STICK_CONF_MAX]); - ControllerPatcherUtils::setConfigValue((uint8_t*)&config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_Y[STICK_CONF_INVERT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y], HID_XINPUT_STICK_R_Y[STICK_CONF_BYTE], HID_XINPUT_STICK_R_Y[STICK_CONF_DEFAULT]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_Y[STICK_CONF_DEADZONE]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX], HID_XINPUT_STICK_R_Y[STICK_CONF_MIN], HID_XINPUT_STICK_R_Y[STICK_CONF_MAX]); + ControllerPatcherUtils::setConfigValue((uint8_t *) &config_controller[xinput_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT], CONTROLLER_PATCHER_VALUE_SET, HID_XINPUT_STICK_R_Y[STICK_CONF_INVERT]); } -BOOL ControllerPatcher::Init(const char * pathToConfig) { +BOOL ControllerPatcher::Init(const char *pathToConfig) { OSDynLoad_Module handle; - void* kpad_ptr; - OSDynLoad_Acquire("padscore",&handle); - OSDynLoad_FindExport(handle, OS_DYNLOAD_EXPORT_FUNC ,"KPADRead",&kpad_ptr); + void *kpad_ptr; + OSDynLoad_Acquire("padscore", &handle); + OSDynLoad_FindExport(handle, OS_DYNLOAD_EXPORT_FUNC, "KPADRead", &kpad_ptr); - gSamplingCallback = (WPADSamplingCallback)((uint32_t)kpad_ptr + 0x1F0); - if(*(uint32_t*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { + gSamplingCallback = (WPADSamplingCallback) ((uint32_t) kpad_ptr + 0x1F0); + if (*(uint32_t *) gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { //In Firmware <= 5.1.2 the offset changes - gSamplingCallback = (WPADSamplingCallback)((uint32_t)kpad_ptr + 0x1F8); - if(*(uint32_t*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { + gSamplingCallback = (WPADSamplingCallback) ((uint32_t) kpad_ptr + 0x1F8); + if (*(uint32_t *) gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { //Should never happen. I looked into the padscore.rpl of ALL firmwares. gSamplingCallback = NULL; } } - DEBUG_FUNCTION_LINE("Found the gSamplingCallback at %08X ",gSamplingCallback); + DEBUG_FUNCTION_LINE("Found the gSamplingCallback at %08X ", gSamplingCallback); - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Init called! "); } - if(gConfig_done == HID_INIT_NOT_DONE) { - if(HID_DEBUG) { + if (gConfig_done == HID_INIT_NOT_DONE) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("First time calling the Init"); } gConfig_done = HID_INIT_DONE; ControllerPatcher::ResetConfig(); } else { - if(HID_DEBUG) { + if (HID_DEBUG) { 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"); 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"); gConfig_done = HID_SDCARD_READ; } - } DEBUG_FUNCTION_LINE("Initializing the data for button remapping"); InitButtonMapping(); - if(!gHIDAttached) { + if (!gHIDAttached) { HIDAddClient(&gHIDClient, ControllerPatcherHID::myAttachDetachCallback); } @@ -541,7 +540,7 @@ BOOL ControllerPatcher::Init(const char * pathToConfig) { } void ControllerPatcher::startNetworkServer() { - if(!gNetworkControllerActivated) return; + if (!gNetworkControllerActivated) return; DEBUG_FUNCTION_LINE("statedNetworkServer! "); UDPServer::getInstance(); CPTCPServer::getInstance(); @@ -555,46 +554,46 @@ void ControllerPatcher::stopNetworkServer() { } void ControllerPatcher::DeInit() { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("called! "); } - if(gHIDAttached) HIDDelClient(&gHIDClient); + if (gHIDAttached) HIDDelClient(&gHIDClient); //Resetting the state of the last pressed data. buttonRemapping_lastButtonsHold = 0; - memset(last_button_hold,0,sizeof(last_button_hold)); - memset(myVPADBuffer,0,sizeof(myVPADBuffer)); - memset(&gControllerMapping,0,sizeof(gControllerMapping)); - memset(&gHIDClient,0,sizeof(gHIDClient)); - memset(gHID_Devices,0,sizeof(gHID_Devices)); - memset(gGamePadValues,0,sizeof(gGamePadValues)); - memset(config_controller,0,sizeof(config_controller)); - memset(config_controller_hidmask,0,sizeof(config_controller_hidmask)); - memset(gNetworkController,0,sizeof(gNetworkController)); + memset(last_button_hold, 0, sizeof(last_button_hold)); + memset(myVPADBuffer, 0, sizeof(myVPADBuffer)); + memset(&gControllerMapping, 0, sizeof(gControllerMapping)); + memset(&gHIDClient, 0, sizeof(gHIDClient)); + memset(gHID_Devices, 0, sizeof(gHID_Devices)); + memset(gGamePadValues, 0, sizeof(gGamePadValues)); + memset(config_controller, 0, sizeof(config_controller)); + memset(config_controller_hidmask, 0, sizeof(config_controller_hidmask)); + memset(gNetworkController, 0, sizeof(gNetworkController)); - memset(gWPADConnectCallback,0,sizeof(gWPADConnectCallback)); - memset(gKPADConnectCallback,0,sizeof(gKPADConnectCallback)); - memset(gExtensionCallback,0,sizeof(gExtensionCallback)); + memset(gWPADConnectCallback, 0, sizeof(gWPADConnectCallback)); + memset(gKPADConnectCallback, 0, sizeof(gKPADConnectCallback)); + memset(gExtensionCallback, 0, sizeof(gExtensionCallback)); gCallbackCooldown = 0; - gConfig_done = HID_INIT_NOT_DONE; + gConfig_done = HID_INIT_NOT_DONE; gButtonRemappingConfigDone = 0; - gHIDAttached = 0; - gHIDCurrentDevice = 0; - gHIDRegisteredDevices = 0; - gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH; - gHID_LIST_GC = 0; - gHID_LIST_DS3 = 0; - gHID_LIST_DS4 = 0; - gHID_LIST_KEYBOARD = 0; - gHID_LIST_MOUSE = 0; - gHID_LIST_SWITCH_PRO = 0; + gHIDAttached = 0; + gHIDCurrentDevice = 0; + gHIDRegisteredDevices = 0; + gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH; + gHID_LIST_GC = 0; + gHID_LIST_DS3 = 0; + gHID_LIST_DS4 = 0; + gHID_LIST_KEYBOARD = 0; + gHID_LIST_MOUSE = 0; + gHID_LIST_SWITCH_PRO = 0; - gGamePadSlot = 0; - gHID_SLOT_GC = 0; + gGamePadSlot = 0; + gHID_SLOT_GC = 0; gHID_SLOT_KEYBOARD = 0; - gMouseSlot = 0; + gMouseSlot = 0; gOriginalDimState = 0; gOriginalAPDState = 0; @@ -616,18 +615,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableControllerMapping() CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting() { uint32_t res; - if(IMIsDimEnabled(&res) == 0) { - if(res == 1) { - if(HID_DEBUG) { + if (IMIsDimEnabled(&res) == 0) { + if (res == 1) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Dim was orignally enabled!"); } gOriginalDimState = 1; } } - if(IMIsAPDEnabled(&res) == 0) { - if(res == 1) { - if(HID_DEBUG) { + if (IMIsAPDEnabled(&res) == 0) { + if (res == 1) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Auto power down was orignally enabled!"); } gOriginalAPDState = 1; @@ -643,11 +642,11 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting() CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::restoreWiiUEnergySetting() { //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."); 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."); IMEnableDim(); } @@ -655,35 +654,35 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::restoreWiiUEnergySetting() } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::resetControllerMapping(UController_Type type) { - ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); + ControllerMappingPAD *cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); - if(cm_map_pad == NULL) { + if (cm_map_pad == NULL) { return CONTROLLER_PATCHER_ERROR_NULL_POINTER; } - memset(cm_map_pad,0,sizeof(*cm_map_pad)); + memset(cm_map_pad, 0, sizeof(*cm_map_pad)); return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::addControllerMapping(UController_Type type,ControllerMappingPADInfo config) { - ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::addControllerMapping(UController_Type type, ControllerMappingPADInfo config) { + ControllerMappingPAD *cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); int32_t result = 0; - for(int32_t i=0; ipad_infos[i]); - if(info != NULL && !info->active) { - info->active = 1; - info->pad = config.pad; - info->type = config.type; - info->vidpid.vid = config.vidpid.vid; - info->vidpid.pid = config.vidpid.pid; + for (int32_t i = 0; i < HID_MAX_DEVICES_PER_SLOT; i++) { + ControllerMappingPADInfo *info = &(cm_map_pad->pad_infos[i]); + if (info != NULL && !info->active) { + info->active = 1; + info->pad = config.pad; + info->type = config.type; + info->vidpid.vid = config.vidpid.vid; + info->vidpid.pid = config.vidpid.pid; result = 1; break; } } - if(result == 0) { + if (result == 0) { //No free slot. return -1; } @@ -692,15 +691,15 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::addControllerMapping(UCont } int32_t ControllerPatcher::getActiveMappingSlot(UController_Type type) { - ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); + ControllerMappingPAD *cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); - if(cm_map_pad == NULL) { + if (cm_map_pad == NULL) { return -1; } int32_t connected = -1; - for(int32_t i =0; ipad_infos[i].active || cm_map_pad->pad_infos[i].type == CM_Type_RealController) { + for (int32_t i = 0; i < HID_MAX_DEVICES_PER_SLOT; i++) { + if (cm_map_pad->pad_infos[i].active || cm_map_pad->pad_infos[i].type == CM_Type_RealController) { connected = i; break; } @@ -709,29 +708,29 @@ int32_t ControllerPatcher::getActiveMappingSlot(UController_Type type) { return connected; } -BOOL ControllerPatcher::isControllerConnectedAndActive(UController_Type type,int32_t mapping_slot) { - ControllerMappingPADInfo * padinfo = getControllerMappingInfo(type,mapping_slot); - if(!padinfo) { +BOOL ControllerPatcher::isControllerConnectedAndActive(UController_Type type, int32_t mapping_slot) { + ControllerMappingPADInfo *padinfo = getControllerMappingInfo(type, mapping_slot); + if (!padinfo) { return false; } - if(padinfo->active) { + if (padinfo->active) { DeviceInfo device_info; - memset(&device_info,0,sizeof(device_info)); + memset(&device_info, 0, sizeof(device_info)); device_info.vidpid = padinfo->vidpid; int32_t res; - if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { + if ((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { return false; } uint32_t hidmask = device_info.slotdata.hidmask; - uint32_t pad = padinfo->pad; + uint32_t pad = padinfo->pad; - 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) { return false; } @@ -740,79 +739,79 @@ BOOL ControllerPatcher::isControllerConnectedAndActive(UController_Type type,int return false; } -ControllerMappingPADInfo * ControllerPatcher::getControllerMappingInfo(UController_Type type,int32_t mapping_slot) { - ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); +ControllerMappingPADInfo *ControllerPatcher::getControllerMappingInfo(UController_Type type, int32_t mapping_slot) { + ControllerMappingPAD *cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); - if(cm_map_pad == NULL) { + if (cm_map_pad == NULL) { return NULL; } - if(mapping_slot < 0 || mapping_slot > HID_MAX_DEVICES_PER_SLOT-1) { + if (mapping_slot < 0 || mapping_slot > HID_MAX_DEVICES_PER_SLOT - 1) { return NULL; } return &(cm_map_pad->pad_infos[mapping_slot]); } -HID_Mouse_Data * ControllerPatcher::getMouseData() { - if(gHID_Mouse_Mode != HID_MOUSE_MODE_TOUCH) return NULL; - ControllerMappingPAD * CMPAD = ControllerPatcherUtils::getControllerMappingByType(UController_Type_Gamepad); +HID_Mouse_Data *ControllerPatcher::getMouseData() { + if (gHID_Mouse_Mode != HID_MOUSE_MODE_TOUCH) return NULL; + ControllerMappingPAD *CMPAD = ControllerPatcherUtils::getControllerMappingByType(UController_Type_Gamepad); - if(CMPAD == NULL) { + if (CMPAD == NULL) { return NULL; } - HID_Mouse_Data * result = NULL; + HID_Mouse_Data *result = NULL; - for(int32_t i = 0; ipad_infos[i]); - if(!padinfo->active) { + for (int32_t i = 0; i < HID_MAX_DEVICES_PER_SLOT; i++) { + ControllerMappingPADInfo *padinfo = &(CMPAD->pad_infos[i]); + if (!padinfo->active) { break; } - if(padinfo->type == CM_Type_Mouse) { + if (padinfo->type == CM_Type_Mouse) { result = &(gHID_Devices[gMouseSlot].pad_data[padinfo->pad].data_union.mouse.cur_mouse_data); - DCFlushRange(&result,sizeof(result)); - DCInvalidateRange(&result,sizeof(result)); + DCFlushRange(&result, sizeof(result)); + DCInvalidateRange(&result, sizeof(result)); break; } } return result; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumble(UController_Type type,uint32_t status) { - ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); - if(cm_map_pad == NULL) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumble(UController_Type type, uint32_t status) { + ControllerMappingPAD *cm_map_pad = ControllerPatcherUtils::getControllerMappingByType(type); + 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; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(InputData * output,int32_t array_size) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(InputData *output, int32_t array_size) { int32_t hid = gHIDCurrentDevice; - HID_Data * data_cur; + HID_Data *data_cur; VPADStatus pad_buffer; - VPADStatus * buffer = &pad_buffer; - int32_t result = CONTROLLER_PATCHER_ERROR_NONE; - for(int32_t i = 0; i< gHIDMaxDevices; i++) { - if((hid & (1 << i)) != 0) { - memset(buffer,0,sizeof(*buffer)); + VPADStatus *buffer = &pad_buffer; + int32_t result = CONTROLLER_PATCHER_ERROR_NONE; + for (int32_t i = 0; i < gHIDMaxDevices; i++) { + if ((hid & (1 << i)) != 0) { + memset(buffer, 0, sizeof(*buffer)); - uint32_t newhid = (1 << i); + uint32_t newhid = (1 << i); int32_t deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid); - if(deviceslot < 0) continue; + if (deviceslot < 0) continue; output[result].type = CM_Type_Controller; - DeviceInfo * deviceinfo = &(output[result].device_info); - InputButtonData * buttondata = output[result].button_data; + DeviceInfo *deviceinfo = &(output[result].device_info); + InputButtonData *buttondata = output[result].button_data; deviceinfo->slotdata.deviceslot = deviceslot; - deviceinfo->slotdata.hidmask = newhid; + deviceinfo->slotdata.hidmask = newhid; - if(newhid == gHID_LIST_MOUSE) { + if (newhid == gHID_LIST_MOUSE) { output[result].type = CM_Type_Mouse; - } else if(newhid == gHID_LIST_KEYBOARD) { + } else if (newhid == gHID_LIST_KEYBOARD) { output[result].type = CM_Type_Keyboard; } @@ -828,38 +827,38 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp int32_t buttons_hold = 0; - for(int32_t pad = 0; padslotdata.hidmask,pad,&data_cur)) < 0) { + if ((res = ControllerPatcherHID::getHIDData(deviceinfo->slotdata.hidmask, pad, &data_cur)) < 0) { continue; } - 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); + 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_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_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_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); + 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[pad].btn_h |= buttons_hold; buttondata[pad].btn_d |= (buttons_hold & (~(data_cur->last_buttons))); @@ -869,7 +868,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp } result++; - if(result >= array_size) { + if (result >= array_size) { break; } } @@ -878,74 +877,74 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp return result; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHID(void * data,int32_t chan, int32_t mode) { - if(data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(chan < 0 || chan > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHID(void *data, int32_t chan, int32_t mode) { + if (data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (chan < 0 || chan > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; //if(gControllerMapping.proController[chan].enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED; - VPADStatus * vpad_buffer = &myVPADBuffer[chan]; - memset(vpad_buffer,0,sizeof(*vpad_buffer)); + VPADStatus *vpad_buffer = &myVPADBuffer[chan]; + memset(vpad_buffer, 0, sizeof(*vpad_buffer)); std::vector data_list; - for(int32_t i = 0; i::iterator it = data_list.begin(); it != data_list.end(); ++it) { - HID_Data * cur_ptr = *it; + for (std::vector::iterator it = data_list.begin(); it != data_list.end(); ++it) { + HID_Data *cur_ptr = *it; cur_ptr->rumbleActive = !!gControllerMapping.proController[chan].rumble; } return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(VPADStatus * buffer) { - if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(VPADStatus *buffer) { + if (buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; //if(gControllerMapping.gamepad.enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED; int32_t hidmask = 0; - int32_t pad = 0; + int32_t pad = 0; ControllerMappingPAD cm_map_pad = gControllerMapping.gamepad; std::vector data_list; @@ -953,143 +952,143 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(V if (cm_map_pad.useAll == 1) { data_list = ControllerPatcherHID::getHIDDataAll(); } else { - for(int32_t i = 0; irumbleActive = !!gControllerMapping.gamepad.rumble; } return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::printVPADButtons(VPADStatus * buffer) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::printVPADButtons(VPADStatus *buffer) { return CONTROLLER_PATCHER_ERROR_NONE; /* BROKEN on transitions.*/ - if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(buffer->trigger != 0x00000000) { + if (buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (buffer->trigger != 0x00000000) { char output[250]; output[0] = 0; //null terminate it. just in case. - if((buffer->trigger & VPAD_BUTTON_A) == VPAD_BUTTON_A) strcat(output,"A "); - if((buffer->trigger & VPAD_BUTTON_B) == VPAD_BUTTON_B) strcat(output,"B "); - if((buffer->trigger & VPAD_BUTTON_X) == VPAD_BUTTON_X) strcat(output,"X "); - if((buffer->trigger & VPAD_BUTTON_Y) == VPAD_BUTTON_Y) strcat(output,"Y "); - if((buffer->trigger & VPAD_BUTTON_L) == VPAD_BUTTON_L) strcat(output,"L "); - if((buffer->trigger & VPAD_BUTTON_R) == VPAD_BUTTON_R) strcat(output,"R "); - if((buffer->trigger & VPAD_BUTTON_ZR) == VPAD_BUTTON_ZR) strcat(output,"ZR "); - if((buffer->trigger & VPAD_BUTTON_ZL) == VPAD_BUTTON_ZL) strcat(output,"ZL "); - if((buffer->trigger & VPAD_BUTTON_LEFT) == VPAD_BUTTON_LEFT) strcat(output,"Left "); - if((buffer->trigger & VPAD_BUTTON_RIGHT) == VPAD_BUTTON_RIGHT) strcat(output,"Right "); - if((buffer->trigger & VPAD_BUTTON_UP) == VPAD_BUTTON_UP) strcat(output,"Up "); - if((buffer->trigger & VPAD_BUTTON_DOWN) == VPAD_BUTTON_DOWN) strcat(output,"Down "); - if((buffer->trigger & VPAD_BUTTON_PLUS) == VPAD_BUTTON_PLUS) strcat(output,"+ "); - if((buffer->trigger & VPAD_BUTTON_MINUS) == VPAD_BUTTON_MINUS) strcat(output,"- "); - if((buffer->trigger & VPAD_BUTTON_TV) == VPAD_BUTTON_TV) strcat(output,"TV "); - if((buffer->trigger & VPAD_BUTTON_HOME) == VPAD_BUTTON_HOME) strcat(output,"HOME "); - if((buffer->trigger & VPAD_BUTTON_STICK_L) == VPAD_BUTTON_STICK_L) strcat(output,"SL "); - if((buffer->trigger & VPAD_BUTTON_STICK_R) == VPAD_BUTTON_STICK_R) strcat(output,"SR "); - if((buffer->trigger & VPAD_STICK_R_EMULATION_LEFT) == VPAD_STICK_R_EMULATION_LEFT) strcat(output,"RE_Left "); - if((buffer->trigger & VPAD_STICK_R_EMULATION_RIGHT) == VPAD_STICK_R_EMULATION_RIGHT) strcat(output,"RE_Right "); - if((buffer->trigger & VPAD_STICK_R_EMULATION_UP) == VPAD_STICK_R_EMULATION_UP) strcat(output,"RE_Up "); - if((buffer->trigger & VPAD_STICK_R_EMULATION_DOWN) == VPAD_STICK_R_EMULATION_DOWN) strcat(output,"RE_Down "); - if((buffer->trigger & VPAD_STICK_L_EMULATION_LEFT) == VPAD_STICK_L_EMULATION_LEFT) strcat(output,"LE_Left "); - if((buffer->trigger & VPAD_STICK_L_EMULATION_RIGHT) == VPAD_STICK_L_EMULATION_RIGHT) strcat(output,"LE_Right "); - 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_BUTTON_A) == VPAD_BUTTON_A) strcat(output, "A "); + if ((buffer->trigger & VPAD_BUTTON_B) == VPAD_BUTTON_B) strcat(output, "B "); + if ((buffer->trigger & VPAD_BUTTON_X) == VPAD_BUTTON_X) strcat(output, "X "); + if ((buffer->trigger & VPAD_BUTTON_Y) == VPAD_BUTTON_Y) strcat(output, "Y "); + if ((buffer->trigger & VPAD_BUTTON_L) == VPAD_BUTTON_L) strcat(output, "L "); + if ((buffer->trigger & VPAD_BUTTON_R) == VPAD_BUTTON_R) strcat(output, "R "); + if ((buffer->trigger & VPAD_BUTTON_ZR) == VPAD_BUTTON_ZR) strcat(output, "ZR "); + if ((buffer->trigger & VPAD_BUTTON_ZL) == VPAD_BUTTON_ZL) strcat(output, "ZL "); + if ((buffer->trigger & VPAD_BUTTON_LEFT) == VPAD_BUTTON_LEFT) strcat(output, "Left "); + if ((buffer->trigger & VPAD_BUTTON_RIGHT) == VPAD_BUTTON_RIGHT) strcat(output, "Right "); + if ((buffer->trigger & VPAD_BUTTON_UP) == VPAD_BUTTON_UP) strcat(output, "Up "); + if ((buffer->trigger & VPAD_BUTTON_DOWN) == VPAD_BUTTON_DOWN) strcat(output, "Down "); + if ((buffer->trigger & VPAD_BUTTON_PLUS) == VPAD_BUTTON_PLUS) strcat(output, "+ "); + if ((buffer->trigger & VPAD_BUTTON_MINUS) == VPAD_BUTTON_MINUS) strcat(output, "- "); + if ((buffer->trigger & VPAD_BUTTON_TV) == VPAD_BUTTON_TV) strcat(output, "TV "); + if ((buffer->trigger & VPAD_BUTTON_HOME) == VPAD_BUTTON_HOME) strcat(output, "HOME "); + if ((buffer->trigger & VPAD_BUTTON_STICK_L) == VPAD_BUTTON_STICK_L) strcat(output, "SL "); + if ((buffer->trigger & VPAD_BUTTON_STICK_R) == VPAD_BUTTON_STICK_R) strcat(output, "SR "); + if ((buffer->trigger & VPAD_STICK_R_EMULATION_LEFT) == VPAD_STICK_R_EMULATION_LEFT) strcat(output, "RE_Left "); + if ((buffer->trigger & VPAD_STICK_R_EMULATION_RIGHT) == VPAD_STICK_R_EMULATION_RIGHT) strcat(output, "RE_Right "); + if ((buffer->trigger & VPAD_STICK_R_EMULATION_UP) == VPAD_STICK_R_EMULATION_UP) strcat(output, "RE_Up "); + if ((buffer->trigger & VPAD_STICK_R_EMULATION_DOWN) == VPAD_STICK_R_EMULATION_DOWN) strcat(output, "RE_Down "); + if ((buffer->trigger & VPAD_STICK_L_EMULATION_LEFT) == VPAD_STICK_L_EMULATION_LEFT) strcat(output, "LE_Left "); + if ((buffer->trigger & VPAD_STICK_L_EMULATION_RIGHT) == VPAD_STICK_L_EMULATION_RIGHT) strcat(output, "LE_Right "); + 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",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; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::buttonRemapping(VPADStatus * buffer,int32_t buffer_count) { - if(!gButtonRemappingConfigDone) return CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE; - if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - for(int32_t i = 0; i < buffer_count; i++) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::buttonRemapping(VPADStatus *buffer, int32_t buffer_count) { + if (!gButtonRemappingConfigDone) return CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE; + if (buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + for (int32_t i = 0; i < buffer_count; i++) { VPADStatus new_data; - memset(&new_data,0,sizeof(new_data)); + memset(&new_data, 0, sizeof(new_data)); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_A, CONTRPS_VPAD_BUTTON_A); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_B, CONTRPS_VPAD_BUTTON_B); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_X, CONTRPS_VPAD_BUTTON_X); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_Y, CONTRPS_VPAD_BUTTON_Y); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_LEFT, CONTRPS_VPAD_BUTTON_LEFT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_RIGHT, CONTRPS_VPAD_BUTTON_RIGHT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_UP, CONTRPS_VPAD_BUTTON_UP); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_DOWN, CONTRPS_VPAD_BUTTON_DOWN); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_ZL, CONTRPS_VPAD_BUTTON_ZL); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_ZR, CONTRPS_VPAD_BUTTON_ZR); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_L, CONTRPS_VPAD_BUTTON_L); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_R, CONTRPS_VPAD_BUTTON_R); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_PLUS, CONTRPS_VPAD_BUTTON_PLUS); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_MINUS, CONTRPS_VPAD_BUTTON_MINUS); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_HOME, CONTRPS_VPAD_BUTTON_HOME); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_SYNC, CONTRPS_VPAD_BUTTON_SYNC); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_STICK_R, CONTRPS_VPAD_BUTTON_STICK_R); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_STICK_L, CONTRPS_VPAD_BUTTON_STICK_L); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_TV, CONTRPS_VPAD_BUTTON_TV); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_A, CONTRPS_VPAD_BUTTON_A); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_B, CONTRPS_VPAD_BUTTON_B); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_X, CONTRPS_VPAD_BUTTON_X); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_Y, CONTRPS_VPAD_BUTTON_Y); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_LEFT, CONTRPS_VPAD_BUTTON_LEFT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_RIGHT, CONTRPS_VPAD_BUTTON_RIGHT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_UP, CONTRPS_VPAD_BUTTON_UP); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_DOWN, CONTRPS_VPAD_BUTTON_DOWN); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_ZL, CONTRPS_VPAD_BUTTON_ZL); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_ZR, CONTRPS_VPAD_BUTTON_ZR); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_L, CONTRPS_VPAD_BUTTON_L); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_R, CONTRPS_VPAD_BUTTON_R); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_PLUS, CONTRPS_VPAD_BUTTON_PLUS); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_MINUS, CONTRPS_VPAD_BUTTON_MINUS); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_HOME, CONTRPS_VPAD_BUTTON_HOME); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_SYNC, CONTRPS_VPAD_BUTTON_SYNC); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_STICK_R, CONTRPS_VPAD_BUTTON_STICK_R); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_STICK_L, CONTRPS_VPAD_BUTTON_STICK_L); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_BUTTON_TV, CONTRPS_VPAD_BUTTON_TV); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_LEFT, CONTRPS_VPAD_STICK_R_EMULATION_LEFT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_RIGHT, CONTRPS_VPAD_STICK_R_EMULATION_RIGHT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_UP, CONTRPS_VPAD_STICK_R_EMULATION_UP); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_DOWN, CONTRPS_VPAD_STICK_R_EMULATION_DOWN); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_LEFT, CONTRPS_VPAD_STICK_R_EMULATION_LEFT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_RIGHT, CONTRPS_VPAD_STICK_R_EMULATION_RIGHT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_UP, CONTRPS_VPAD_STICK_R_EMULATION_UP); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_DOWN, CONTRPS_VPAD_STICK_R_EMULATION_DOWN); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_LEFT, CONTRPS_VPAD_STICK_L_EMULATION_LEFT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_RIGHT, CONTRPS_VPAD_STICK_L_EMULATION_RIGHT); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_UP, CONTRPS_VPAD_STICK_L_EMULATION_UP); - ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_DOWN, CONTRPS_VPAD_STICK_L_EMULATION_DOWN); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_LEFT, CONTRPS_VPAD_STICK_L_EMULATION_LEFT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_RIGHT, CONTRPS_VPAD_STICK_L_EMULATION_RIGHT); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_UP, CONTRPS_VPAD_STICK_L_EMULATION_UP); + ControllerPatcherUtils::setButtonRemappingData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_DOWN, CONTRPS_VPAD_STICK_L_EMULATION_DOWN); //Even when you remap any Stick Emulation to a button, we still want to keep the emulated stick data. Some games like New Super Mario Bros. only work with the emulated stick data. - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_LEFT, VPAD_STICK_L_EMULATION_LEFT); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_RIGHT, VPAD_STICK_L_EMULATION_RIGHT); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_UP, VPAD_STICK_L_EMULATION_UP); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_L_EMULATION_DOWN, VPAD_STICK_L_EMULATION_DOWN); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_LEFT, VPAD_STICK_L_EMULATION_LEFT); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_RIGHT, VPAD_STICK_L_EMULATION_RIGHT); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_UP, VPAD_STICK_L_EMULATION_UP); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_L_EMULATION_DOWN, VPAD_STICK_L_EMULATION_DOWN); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_LEFT, VPAD_STICK_R_EMULATION_LEFT); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_RIGHT, VPAD_STICK_R_EMULATION_RIGHT); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_UP, VPAD_STICK_R_EMULATION_UP); - ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_DOWN, VPAD_STICK_R_EMULATION_DOWN); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_LEFT, VPAD_STICK_R_EMULATION_LEFT); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_RIGHT, VPAD_STICK_R_EMULATION_RIGHT); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_UP, VPAD_STICK_R_EMULATION_UP); + ControllerPatcherUtils::setButtonData(&buffer[i], &new_data, VPAD_STICK_R_EMULATION_DOWN, VPAD_STICK_R_EMULATION_DOWN); - buffer[i].hold = new_data.hold; + buffer[i].hold = new_data.hold; buffer[i].trigger = new_data.trigger; buffer[i].release = new_data.release; } return CONTROLLER_PATCHER_ERROR_NONE; } -std::string ControllerPatcher::getIdentifierByVIDPID(uint16_t vid,uint16_t pid) { - return ConfigValues::getStringByVIDPID(vid,pid); +std::string ControllerPatcher::getIdentifierByVIDPID(uint16_t vid, uint16_t pid) { + return ConfigValues::getStringByVIDPID(vid, pid); } void ControllerPatcher::destroyConfigHelper() { @@ -1098,7 +1097,7 @@ void ControllerPatcher::destroyConfigHelper() { } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::doSamplingForDeviceSlot(uint16_t device_slot) { - return ControllerPatcherUtils::doSampling(device_slot,0,true); + return ControllerPatcherUtils::doSampling(device_slot, 0, true); } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumbleActivated(BOOL value) { @@ -1129,16 +1128,16 @@ BOOL ControllerPatcher::areControllersConnected() { } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::sampleKeyboardData() { - if(ControllerPatcher::isKeyboardConnected()) { + if (ControllerPatcher::isKeyboardConnected()) { ControllerPatcher::doSamplingForDeviceSlot(gHID_SLOT_KEYBOARD); } return CONTROLLER_PATCHER_ERROR_NONE; } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::resetCallbackData() { - memset(gWPADConnectCallback,0,sizeof(gWPADConnectCallback)); - memset(gKPADConnectCallback,0,sizeof(gKPADConnectCallback)); - memset(gExtensionCallback,0,sizeof(gExtensionCallback)); + memset(gWPADConnectCallback, 0, sizeof(gWPADConnectCallback)); + memset(gKPADConnectCallback, 0, sizeof(gKPADConnectCallback)); + memset(gExtensionCallback, 0, sizeof(gExtensionCallback)); gSamplingCallback = 0; gCallbackCooldown = 0; return CONTROLLER_PATCHER_ERROR_NONE; @@ -1146,7 +1145,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::resetCallbackData() { CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADConnectedCallback(int32_t chan, WPADConnectCallback callback) { - if(chan >= 4) { + if (chan >= 4) { return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; } gKPADConnectCallback[chan] = callback; @@ -1154,7 +1153,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADConnectedCallback(i } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(int32_t chan, WPADConnectCallback callback) { - if(chan >= 4) { + if (chan >= 4) { return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; } gExtensionCallback[chan] = callback; @@ -1162,7 +1161,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(i } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setWPADConnectCallback(int32_t chan, WPADConnectCallback callback) { - if(chan >= 4) { + if (chan >= 4) { return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; } gWPADConnectCallback[chan] = callback; @@ -1170,7 +1169,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setWPADConnectCallback(int } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(BOOL button_pressed) { - if(button_pressed && gCallbackCooldown == 0) { + if (button_pressed && gCallbackCooldown == 0) { gCallbackCooldown = 0xFF; /*if(HID_DEBUG){ log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!",__LINE__); } @@ -1178,20 +1177,20 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(BOOL bu 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",__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); } - if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro2)) { + if (ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro2)) { ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_1); } - if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro3)) { + if (ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro3)) { ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_2); } - if(ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro4)) { + if (ControllerPatcher::isControllerConnectedAndActive(UController_Type_Pro4)) { ControllerPatcher::handleCallbackDataInternal(WPAD_CHAN_3); } } - if(gCallbackCooldown > 0) { + if (gCallbackCooldown > 0) { gCallbackCooldown--; } @@ -1199,17 +1198,17 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::handleCallbackData(BOOL bu } 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!",chan + 1); - gWPADConnectCallback[chan](chan,0); + if (gWPADConnectCallback[chan] != NULL) { + log_printf("Called WPAD connect callback for pro controller in slot %d!", chan + 1); + gWPADConnectCallback[chan](chan, 0); } - if(gKPADConnectCallback[chan] != NULL) { - log_printf("Called KPAD connect callback for pro controller in slot %d!",chan + 1); - gKPADConnectCallback[chan](chan,0); + if (gKPADConnectCallback[chan] != NULL) { + log_printf("Called KPAD connect callback for pro controller in slot %d!", chan + 1); + gKPADConnectCallback[chan](chan, 0); } - if(gExtensionCallback[chan] != NULL) { - log_printf("Called extension callback for pro controller in slot %d!",chan + 1); - gExtensionCallback[chan](chan,WPAD_EXT_PRO_CONTROLLER); + if (gExtensionCallback[chan] != NULL) { + log_printf("Called extension callback for pro controller in slot %d!", chan + 1); + gExtensionCallback[chan](chan, WPAD_EXT_PRO_CONTROLLER); } return CONTROLLER_PATCHER_ERROR_NONE; } diff --git a/source/ControllerPatcherIncludes.hpp b/source/ControllerPatcherIncludes.hpp index af34710..c3d2348 100644 --- a/source/ControllerPatcherIncludes.hpp +++ b/source/ControllerPatcherIncludes.hpp @@ -22,29 +22,29 @@ #include +#include #include #include -#include -#include #include +#include #include "./ConfigReader.hpp" #include -#include #include "./utils/CPRetainVars.hpp" #include "./utils/PadConst.hpp" +#include #include #include "./patcher/ControllerPatcherHID.hpp" #include "./patcher/ControllerPatcherUtils.hpp" -#include "./config/ConfigValues.hpp" #include "./config/ConfigParser.hpp" +#include "./config/ConfigValues.hpp" #include "./network/CPTCPServer.hpp" -#include "./network/UDPServer.hpp" #include "./network/UDPClient.hpp" +#include "./network/UDPServer.hpp" #endif /* _CONTROLLER_PATCHER_INCLUDES_H_ */ diff --git a/source/config/ConfigParser.cpp b/source/config/ConfigParser.cpp index 173a553..8e63f04 100644 --- a/source/config/ConfigParser.cpp +++ b/source/config/ConfigParser.cpp @@ -15,34 +15,34 @@ * along with this program. If not, see . ****************************************************************************/ #include "./ConfigParser.hpp" -#include #include #include #include #include +#include ConfigParser::ConfigParser(std::string configData) { - this->content = configData; + this->content = configData; this->contentLines = StringTools::stringSplit(content, ""); - if(contentLines.empty()) { + if (contentLines.empty()) { return; } //remove the comments and make everything uppercase - for(uint32_t i = 0; i < contentLines.size(); i++) { + for (uint32_t i = 0; i < contentLines.size(); i++) { std::vector comments = StringTools::stringSplit(contentLines[i], "//"); - if(!comments.empty()) { + if (!comments.empty()) { contentLines[i] = comments[0]; } //we want everything uppercase - std::transform(contentLines[i].begin(), contentLines[i].end(),contentLines[i].begin(), ::toupper); + std::transform(contentLines[i].begin(), contentLines[i].end(), contentLines[i].begin(), ::toupper); } //remove empty lines std::vector contentline2; - for(uint32_t i = 0; i < contentLines.size(); i++) { - if(strlen(contentLines[i].c_str()) > 0) { + for (uint32_t i = 0; i < contentLines.size(); i++) { + if (strlen(contentLines[i].c_str()) > 0) { contentline2.push_back(contentLines[i]); } } @@ -51,7 +51,6 @@ ConfigParser::ConfigParser(std::string configData) { } ConfigParser::~ConfigParser() { - } PARSE_TYPE ConfigParser::getType() { @@ -71,36 +70,36 @@ void ConfigParser::setSlot(uint16_t newSlot) { } 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"); return false; } - const char * line = contentLines[0].c_str(); - int32_t len = strlen(line); - if(len <= 4) { + const char *line = contentLines[0].c_str(); + int32_t len = strlen(line); + if (len <= 4) { DEBUG_FUNCTION_LINE("Header is too short."); return false; } std::string identify; - if(line[0] == '[' && line[len-1] == ']') { - identify = contentLines[0].substr(1,len-2); + if (line[0] == '[' && line[len - 1] == ']') { + identify = contentLines[0].substr(1, len - 2); } else { DEBUG_FUNCTION_LINE("Not a proper config file!"); return false; } - if(identify.compare("GAMEPAD") == 0) { + if (identify.compare("GAMEPAD") == 0) { DEBUG_FUNCTION_LINE("Its a gamepad config file!"); setSlot(gGamePadSlot); setType(PARSE_GAMEPAD); - } else if(identify.compare("MOUSE") == 0) { + } else if (identify.compare("MOUSE") == 0) { DEBUG_FUNCTION_LINE("Its a mouse config file!"); setSlot(gMouseSlot); setType(PARSE_MOUSE); this->vid = HID_MOUSE_VID; 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!"); setSlot(gHID_SLOT_KEYBOARD); setType(PARSE_KEYBOARD); @@ -112,7 +111,7 @@ BOOL ConfigParser::Init() { setType(PARSE_CONTROLLER); } - if(getSlot() == HID_INVALID_SLOT) { + if (getSlot() == HID_INVALID_SLOT) { return false; } @@ -122,53 +121,53 @@ BOOL ConfigParser::Init() { } void ConfigParser::parseSingleLine(std::string line) { - if(line.empty()) { + if (line.empty()) { DEBUG_FUNCTION_LINE("Can't parse line. it's empty"); return; } - std::vector 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",line.c_str()); + std::vector 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", line.c_str()); } return; } else { uint16_t hid_slot = getSlot(); - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("leftpart = \"%s\" ",cur_values[0].c_str()); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("leftpart = \"%s\" ", cur_values[0].c_str()); } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("rightpart = \"%s\" ",cur_values[1].c_str()); + if (HID_DEBUG) { + 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"); } - if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD) { + if (getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD) { keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]); - } else if(getType() == PARSE_MOUSE) { + } else if (getType() == PARSE_MOUSE) { keyslot = ConfigValues::getKeySlotMouse(cur_values[0]); } else { keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]); } - if(keyslot != -1) { - if(HID_DEBUG) { + if (keyslot != -1) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Its a single value"); } long rightValue = -1; - BOOL valueSet = false; - if(cur_values[0].compare("DPAD_MODE") == 0) { - const uint8_t * values_ = NULL; - if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL) { - if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE) - if(HID_DEBUG) { + BOOL valueSet = false; + if (cur_values[0].compare("DPAD_MODE") == 0) { + const uint8_t *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"); } 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) { + if (values_[CONTRDPAD_MASK] != 0x00) { config_controller[hid_slot][CONTRPS_DPAD_MASK][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][CONTRPS_DPAD_MASK][1] = values_[CONTRDPAD_MASK]; } @@ -176,83 +175,83 @@ 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",cur_values[1].c_str(),rightValue); + 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", cur_values[1].c_str(), rightValue); } } else { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("I need to parse %s",cur_values[1].c_str()); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("I need to parse %s", cur_values[1].c_str()); } - char * ptr; - rightValue = strtol(cur_values[1].c_str(),&ptr,16); + char *ptr; + rightValue = strtol(cur_values[1].c_str(), &ptr, 16); } } else { rightValue = ConfigValues::getPresetValue(cur_values[1]); - 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",cur_values[1].c_str()); + 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", cur_values[1].c_str()); } return; } } else { - if(rightValue == -1) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("I need to parse %s",cur_values[1].c_str()); + if (rightValue == -1) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("I need to parse %s", cur_values[1].c_str()); } - char * ptr; - rightValue = strtol(cur_values[1].c_str(),&ptr,16); + char *ptr; + rightValue = strtol(cur_values[1].c_str(), &ptr, 16); } } } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Setting value to %d",rightValue); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Setting value to %d", rightValue); } config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET; config_controller[hid_slot][keyslot][1] = rightValue; } } else { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Check pair value"); } keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]); - if(keyslot != -1) { - if(HID_DEBUG) { + if (keyslot != -1) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Its a pair value"); } - if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)) { - if(HID_DEBUG) { + if (!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1], getSlot(), keyslot)) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("And its no preset"); } - std::vector rightvalues = StringTools::stringSplit(cur_values[1],","); + std::vector rightvalues = StringTools::stringSplit(cur_values[1], ","); - if(rightvalues.size() != 2) { - DEBUG_FUNCTION_LINE("%d instead of 2 key=values pairs in line",rightvalues.size()); + if (rightvalues.size() != 2) { + DEBUG_FUNCTION_LINE("%d instead of 2 key=values pairs in line", rightvalues.size()); return; } - char * ptr; - long firstValue = strtol(rightvalues[0].c_str(),&ptr,16); - long secondValue = strtol(rightvalues[1].c_str(),&ptr,16); + char *ptr; + long firstValue = strtol(rightvalues[0].c_str(), &ptr, 16); + long secondValue = strtol(rightvalues[1].c_str(), &ptr, 16); config_controller[hid_slot][keyslot][0] = firstValue; config_controller[hid_slot][keyslot][1] = secondValue; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Set %02X,%02X",firstValue,secondValue); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Set %02X,%02X", firstValue, secondValue); } } else { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Found preset value!!"); } } } else { - DEBUG_FUNCTION_LINE("The setting \"%s\" is unknown!",cur_values[0].c_str()); + DEBUG_FUNCTION_LINE("The setting \"%s\" is unknown!", cur_values[0].c_str()); } } } @@ -260,47 +259,47 @@ void ConfigParser::parseSingleLine(std::string line) { BOOL ConfigParser::resetConfig() { int32_t slot = getSlot(); - if((slot == HID_INVALID_SLOT) || (slot >= gHIDMaxDevices)) return false; - for(int32_t j = (CONTRPS_PID+1); j< CONTRPS_MAX_VALUE; j++) { + if ((slot == HID_INVALID_SLOT) || (slot >= gHIDMaxDevices)) return false; + for (int32_t j = (CONTRPS_PID + 1); j < CONTRPS_MAX_VALUE; j++) { config_controller[slot][j][0] = CONTROLLER_PATCHER_INVALIDVALUE; config_controller[slot][j][1] = CONTROLLER_PATCHER_INVALIDVALUE; } return true; } -int32_t ConfigParser::getSlotController(std::string identify) { - if(HID_DEBUG) { +int32_t ConfigParser::getSlotController(std::string identify) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Getting Controller Slot"); } - std::vector values = StringTools::stringSplit(identify,","); + std::vector values = StringTools::stringSplit(identify, ","); - if(values.size() != 2) { - DEBUG_FUNCTION_LINE("You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)",identify.c_str()); + if (values.size() != 2) { + 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; } - int32_t vid = getValueFromKeyValue(values[0],"VID","="); - if(vid < 0) { + int32_t vid = getValueFromKeyValue(values[0], "VID", "="); + if (vid < 0) { return HID_INVALID_SLOT; } - int32_t pid = getValueFromKeyValue(values[1],"PID","="); - if(pid < 0) { + int32_t pid = getValueFromKeyValue(values[1], "PID", "="); + if (pid < 0) { return HID_INVALID_SLOT; } - DEBUG_FUNCTION_LINE("VID: %04x PID: %04x",vid,pid); + DEBUG_FUNCTION_LINE("VID: %04x PID: %04x", vid, pid); this->vid = vid; this->pid = pid; DeviceInfo deviceinfo; - memset(&deviceinfo,0,sizeof(deviceinfo)); + memset(&deviceinfo, 0, sizeof(deviceinfo)); deviceinfo.vidpid.vid = vid; deviceinfo.vidpid.pid = pid; - int32_t result = ControllerPatcherUtils::getDeviceInfoFromVidPid(&deviceinfo); - int32_t slot = deviceinfo.slotdata.deviceslot; - int32_t hid = 0; - if(result < 0) { - if(HID_DEBUG) { + int32_t result = ControllerPatcherUtils::getDeviceInfoFromVidPid(&deviceinfo); + int32_t slot = deviceinfo.slotdata.deviceslot; + int32_t hid = 0; + if (result < 0) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Its a new controller, lets save it"); } @@ -308,97 +307,97 @@ int32_t ConfigParser::getSlotController(std::string identify) { ControllerPatcherUtils::getNextSlotData(&slotdata); slot = slotdata.deviceslot; - 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"); return HID_INVALID_SLOT; } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Got new slot! slot: %d hid %s .. Lets registrate it!",slot,StringTools::byte_to_binary(hid)); + if (HID_DEBUG) { + 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][1] = (vid & 0x00FF); config_controller[slot][CONTRPS_PID][0] = (pid & 0xFF00) >> 8; config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF); - if(HID_DEBUG) { + if (HID_DEBUG) { 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_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]); } - config_controller_hidmask[slot] = hid; - if(HID_DEBUG) { + config_controller_hidmask[slot] = hid; + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Saved the hid"); } } else { - if(slot < gHIDMaxDevices) { + if (slot < gHIDMaxDevices) { hid = config_controller_hidmask[slot]; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<",slot,StringTools::byte_to_binary(hid)); + if (HID_DEBUG) { + 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"); } else { - DEBUG_FUNCTION_LINE("Something really odd happend to the slots. %d is bigger then max (%d)",slot,gHIDMaxDevices); + DEBUG_FUNCTION_LINE("Something really odd happend to the slots. %d is bigger then max (%d)", slot, gHIDMaxDevices); return HID_INVALID_SLOT; } } - DEBUG_FUNCTION_LINE("using slot: %d hid %08X",slot,hid); + DEBUG_FUNCTION_LINE("using slot: %d hid %08X", slot, hid); return slot; } BOOL ConfigParser::parseIni() { - 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",getType(),gHIDMaxDevices); + 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", getType(), gHIDMaxDevices); return false; } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Parsing content, type %d",getType()); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Parsing content, type %d", getType()); } int32_t start = 1; - if(contentLines.size() <= 1) { + if (contentLines.size() <= 1) { DEBUG_FUNCTION_LINE("File only contains a header."); return false; } - if(contentLines[1].compare("[IGNOREDEFAULT]") == 0) { + if (contentLines[1].compare("[IGNOREDEFAULT]") == 0) { resetConfig(); DEBUG_FUNCTION_LINE("Ignoring existing settings of this device"); start++; } - for(uint32_t i = start; i < contentLines.size(); i++) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("line %d: \"%s\" ",(i+1),contentLines[i].c_str()); + for (uint32_t i = start; i < contentLines.size(); i++) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("line %d: \"%s\" ", (i + 1), contentLines[i].c_str()); } parseSingleLine(contentLines[i]); } - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Parsing of the file is done."); } return true; } -int32_t ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter) { - std::vector 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",value_pair.c_str()); +int32_t ConfigParser::getValueFromKeyValue(std::string value_pair, std::string expectedKey, std::string delimiter) { + std::vector 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", value_pair.c_str()); } return -1; } - if(string_value[0].compare(expectedKey) != 0) { - DEBUG_FUNCTION_LINE("Key part not %s, its %s",expectedKey.c_str(),string_value[0].c_str()); + if (string_value[0].compare(expectedKey) != 0) { + DEBUG_FUNCTION_LINE("Key part not %s, its %s", expectedKey.c_str(), string_value[0].c_str()); return -1; } - char * ptr; - int32_t value = strtol(string_value[1].c_str(),&ptr,16); + char *ptr; + int32_t value = strtol(string_value[1].c_str(), &ptr, 16); return value; } diff --git a/source/config/ConfigParser.hpp b/source/config/ConfigParser.hpp index 4ef4917..538dbf4 100644 --- a/source/config/ConfigParser.hpp +++ b/source/config/ConfigParser.hpp @@ -17,9 +17,9 @@ #ifndef _ConfigParser_H_ #define _ConfigParser_H_ +#include #include #include -#include #include @@ -27,16 +27,17 @@ #include -enum PARSE_TYPE{ +enum PARSE_TYPE { PARSE_CONTROLLER, PARSE_GAMEPAD, PARSE_MOUSE, PARSE_KEYBOARD }; -class ConfigParser{ +class ConfigParser { friend class ConfigReader; friend class ControllerPatcher; + private: //!Constructor ConfigParser(std::string configData); @@ -59,7 +60,7 @@ private: int32_t checkExistingController(int32_t vid, int32_t pid); - int32_t getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter); + int32_t getValueFromKeyValue(std::string value_pair, std::string expectedKey, std::string delimiter); BOOL resetConfig(); diff --git a/source/config/ConfigValues.cpp b/source/config/ConfigValues.cpp index 3fe262a..8479bda 100644 --- a/source/config/ConfigValues.cpp +++ b/source/config/ConfigValues.cpp @@ -28,13 +28,13 @@ ConfigValues::ConfigValues() { } ConfigValues::~ConfigValues() { - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("\n"); } } -const uint8_t * ConfigValues::getValuesForPreset(std::map values,std::string possibleValue) { - std::map::iterator it; +const uint8_t *ConfigValues::getValuesForPreset(std::map values, std::string possibleValue) { + std::map::iterator it; it = values.find(possibleValue); if (it != values.end()) { return it->second; @@ -42,46 +42,46 @@ const uint8_t * ConfigValues::getValuesForPreset(std::map values,std::string possibleValue,int32_t slot,int32_t keyslot) { - if(slot > gHIDMaxDevices || slot < 0 || keyslot < 0 || keyslot >= CONTRPS_MAX_VALUE) { +BOOL ConfigValues::setIfValueIsPreset(std::map values, std::string possibleValue, int32_t slot, int32_t keyslot) { + if (slot > gHIDMaxDevices || slot < 0 || keyslot < 0 || keyslot >= CONTRPS_MAX_VALUE) { return false; } - const uint8_t * values_ = NULL; - if( keyslot == CONTRPS_VPAD_BUTTON_L_STICK_X || - 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",possibleValue.c_str()); + const uint8_t *values_ = NULL; + if (keyslot == CONTRPS_VPAD_BUTTON_L_STICK_X || + 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", possibleValue.c_str()); } - if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL) { - if(HID_DEBUG) { + if ((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL) { + if (HID_DEBUG) { 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][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 - config_controller[slot][keyslot+DEF_STICK_OFFSET_INVERT][1] = values_[STICK_CONF_INVERT]; - config_controller[slot][keyslot+DEF_STICK_OFFSET_DEADZONE][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE - config_controller[slot][keyslot+DEF_STICK_OFFSET_DEADZONE][1] = values_[STICK_CONF_DEADZONE]; - config_controller[slot][keyslot+DEF_STICK_OFFSET_MINMAX][0] = values_[STICK_CONF_MIN]; //CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX - config_controller[slot][keyslot+DEF_STICK_OFFSET_MINMAX][1] = values_[STICK_CONF_MAX]; + 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 + config_controller[slot][keyslot + DEF_STICK_OFFSET_INVERT][1] = values_[STICK_CONF_INVERT]; + config_controller[slot][keyslot + DEF_STICK_OFFSET_DEADZONE][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE + config_controller[slot][keyslot + DEF_STICK_OFFSET_DEADZONE][1] = values_[STICK_CONF_DEADZONE]; + config_controller[slot][keyslot + DEF_STICK_OFFSET_MINMAX][0] = values_[STICK_CONF_MIN]; //CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX + config_controller[slot][keyslot + DEF_STICK_OFFSET_MINMAX][1] = values_[STICK_CONF_MAX]; return true; } } - if((values_ = getValuesForPreset(values,possibleValue)) != NULL) { + if ((values_ = getValuesForPreset(values, possibleValue)) != NULL) { config_controller[slot][keyslot][0] = values_[0]; config_controller[slot][keyslot][1] = values_[1]; return true; @@ -90,8 +90,8 @@ BOOL ConfigValues::setIfValueIsPreset(std::map value } -int32_t ConfigValues::getValueFromMap(std::map values,std::string nameOfString) { - std::map::iterator it; +int32_t ConfigValues::getValueFromMap(std::map values, std::string nameOfString) { + std::map::iterator it; it = values.find(nameOfString); if (it != values.end()) { return it->second; @@ -103,31 +103,31 @@ int32_t ConfigValues::getValueFromMap(std::map values,std::stri int32_t ConfigValues::getPresetValueEx(std::string possibleString) { int32_t rightValue = -1; - if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d",possibleString.c_str(),rightValue); + if ((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString, possibleString)) != -1) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Used pre-defined VPAD_VALUE! \"%s\" is %d", possibleString.c_str(), rightValue); } - } else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d",possibleString.c_str(),rightValue); + } else if ((rightValue = getValueFromMap(presetValues, possibleString)) != -1) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Used pre-defined value! \"%s\" is %d", possibleString.c_str(), rightValue); } } return rightValue; } -void ConfigValues::addDeviceNameEx(uint16_t vid,uint16_t pid,std::string value) { - deviceNames[StringTools::strfmt("%04X%04X",vid,pid).c_str()] = value; +void ConfigValues::addDeviceNameEx(uint16_t vid, uint16_t pid, std::string value) { + deviceNames[StringTools::strfmt("%04X%04X", vid, pid).c_str()] = value; } -std::string ConfigValues::getStringByVIDPIDEx(uint16_t vid,uint16_t pid) { +std::string ConfigValues::getStringByVIDPIDEx(uint16_t vid, uint16_t pid) { std::string result = ""; - std::map::iterator it; + std::map::iterator it; - it = deviceNames.find(StringTools::strfmt("%04X%04X",vid,pid)); + it = deviceNames.find(StringTools::strfmt("%04X%04X", vid, pid)); if (it != deviceNames.end()) { result = it->second; } else { - result = StringTools::strfmt("VID: 0x%04X\nPID: 0x%04X",vid,pid); + result = StringTools::strfmt("VID: 0x%04X\nPID: 0x%04X", vid, pid); } return result; } diff --git a/source/config/ConfigValues.hpp b/source/config/ConfigValues.hpp index f0daa2c..97787f0 100644 --- a/source/config/ConfigValues.hpp +++ b/source/config/ConfigValues.hpp @@ -17,21 +17,21 @@ #ifndef _ConfigValues_H_ #define _ConfigValues_H_ +#include #include #include -#include #include "../ControllerPatcherIncludes.hpp" #include -class ConfigValues -{ -friend class ConfigParser; -friend class ControllerPatcher; +class ConfigValues { + friend class ConfigParser; + friend class ControllerPatcher; + private: static ConfigValues *getInstance() { - if(instance == NULL){ + if (instance == NULL) { DEBUG_FUNCTION_LINE("We need a new instance!!!\n"); instance = new ConfigValues(); } @@ -39,7 +39,7 @@ private: } static void destroyInstance() { - if(instance){ + if (instance) { delete instance; instance = NULL; } @@ -48,96 +48,88 @@ private: /** Returns NULL if not a preset! **/ - static const uint8_t * getValuesStickPreset(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return NULL; - return cur_instance->getValuesForPreset(cur_instance->presetSticks,possibleValue); + static const uint8_t *getValuesStickPreset(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return NULL; + return cur_instance->getValuesForPreset(cur_instance->presetSticks, possibleValue); } /** Returns -1 if not found **/ - static int32_t getKeySlotGamePad(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue,possibleValue); + static int32_t getKeySlotGamePad(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue, possibleValue); } /** Returns -1 if not found **/ - static int32_t getKeySlotMouse(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->getValueFromMap(cur_instance->mouseLeftValues,possibleValue); + static int32_t getKeySlotMouse(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->getValueFromMap(cur_instance->mouseLeftValues, possibleValue); } /** Returns -1 if not found **/ - static int32_t getKeySlotDefaultSingleValue(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValueSingle,possibleValue); + static int32_t getKeySlotDefaultSingleValue(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValueSingle, possibleValue); } /** Returns -1 if not found **/ - static int32_t getKeySlotDefaultPairedValue(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue,possibleValue); + static int32_t getKeySlotDefaultPairedValue(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue, possibleValue); } /** Returns -1 if not found **/ - static int32_t getPresetValuesKeyboard(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->getValueFromMap(cur_instance->presetKeyboardValues,possibleValue); + static int32_t getPresetValuesKeyboard(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->getValueFromMap(cur_instance->presetKeyboardValues, possibleValue); } /** Returns -1 if not found **/ - static int32_t getPresetValue(std::string possibleValue) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; + static int32_t getPresetValue(std::string possibleValue) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; return cur_instance->getPresetValueEx(possibleValue); } /** Returns -1 if not found **/ - static int32_t setIfValueIsAControllerPreset(std::string value,int32_t slot,int32_t keyslot) - { - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return -1; - return cur_instance->setIfValueIsAControllerPresetEx(value,slot,keyslot); + static int32_t setIfValueIsAControllerPreset(std::string value, int32_t slot, int32_t keyslot) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return -1; + return cur_instance->setIfValueIsAControllerPresetEx(value, slot, keyslot); } - static void addDeviceName(uint16_t vid,uint16_t pid,std::string value){ - ConfigValues * cur_instance = getInstance(); - if(cur_instance != NULL){ - cur_instance->addDeviceNameEx(vid,pid,value); + static void addDeviceName(uint16_t vid, uint16_t pid, std::string value) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance != NULL) { + cur_instance->addDeviceNameEx(vid, pid, value); } } /** Returns empty String if not found **/ - static std::string getStringByVIDPID(uint16_t vid,uint16_t pid){ - ConfigValues * cur_instance = getInstance(); - if(cur_instance == NULL) return ""; - return cur_instance->getStringByVIDPIDEx(vid,pid); + static std::string getStringByVIDPID(uint16_t vid, uint16_t pid) { + ConfigValues *cur_instance = getInstance(); + if (cur_instance == NULL) return ""; + return cur_instance->getStringByVIDPIDEx(vid, pid); } //!Constructor @@ -147,428 +139,428 @@ private: static ConfigValues *instance; - std::map mouseLeftValues; - std::map CONTPRStringToValue; - std::map CONTPRStringToValueSingle; - std::map presetValues; - std::map gGamePadValuesToCONTRPSString; - std::map presetKeyboardValues; + std::map mouseLeftValues; + std::map CONTPRStringToValue; + std::map CONTPRStringToValueSingle; + std::map presetValues; + std::map gGamePadValuesToCONTRPSString; + std::map presetKeyboardValues; - std::map deviceNames; + std::map deviceNames; - std::map presetGCValues; - std::map presetDS3Values; - std::map presetDS4Values; - std::map presetXInputValues; - std::map presetSwitchProValues; - std::map presetSticks; + std::map presetGCValues; + std::map presetDS3Values; + std::map presetDS4Values; + std::map presetXInputValues; + std::map presetSwitchProValues; + std::map presetSticks; - int32_t getValueFromMap(std::map values,std::string nameOfString); + int32_t getValueFromMap(std::map values, std::string nameOfString); - BOOL checkIfValueIsAControllerPreset(std::string value,int32_t slot,int32_t keyslot); + BOOL checkIfValueIsAControllerPreset(std::string value, int32_t slot, int32_t keyslot); int32_t getPresetValueEx(std::string possibleString); - void InitValues(){ + void InitValues() { DEBUG_FUNCTION_LINE("Init values for the configuration"); - CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; - CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B; - CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X; - CONTPRStringToValue["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y; + CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; + CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B; + CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X; + CONTPRStringToValue["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y; /* Normal DPAD */ - CONTPRStringToValue["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT; - CONTPRStringToValue["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT; - CONTPRStringToValue["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP; - CONTPRStringToValue["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN; + CONTPRStringToValue["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT; + CONTPRStringToValue["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT; + CONTPRStringToValue["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP; + CONTPRStringToValue["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN; /* DPAD hat mode */ - CONTPRStringToValue["VPAD_BUTTON_DPAD_N"] = CONTRPS_VPAD_BUTTON_DPAD_N; - CONTPRStringToValue["VPAD_BUTTON_DPAD_NE"] = CONTRPS_VPAD_BUTTON_DPAD_NE; - CONTPRStringToValue["VPAD_BUTTON_DPAD_E"] = CONTRPS_VPAD_BUTTON_DPAD_E; - CONTPRStringToValue["VPAD_BUTTON_DPAD_SE"] = CONTRPS_VPAD_BUTTON_DPAD_SE; - CONTPRStringToValue["VPAD_BUTTON_DPAD_S"] = CONTRPS_VPAD_BUTTON_DPAD_S; - CONTPRStringToValue["VPAD_BUTTON_DPAD_SW"] = CONTRPS_VPAD_BUTTON_DPAD_SW; - CONTPRStringToValue["VPAD_BUTTON_DPAD_W"] = CONTRPS_VPAD_BUTTON_DPAD_W; - CONTPRStringToValue["VPAD_BUTTON_DPAD_NW"] = CONTRPS_VPAD_BUTTON_DPAD_NW; - CONTPRStringToValue["VPAD_BUTTON_DPAD_NEUTRAL"] = CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL; + CONTPRStringToValue["VPAD_BUTTON_DPAD_N"] = CONTRPS_VPAD_BUTTON_DPAD_N; + CONTPRStringToValue["VPAD_BUTTON_DPAD_NE"] = CONTRPS_VPAD_BUTTON_DPAD_NE; + CONTPRStringToValue["VPAD_BUTTON_DPAD_E"] = CONTRPS_VPAD_BUTTON_DPAD_E; + CONTPRStringToValue["VPAD_BUTTON_DPAD_SE"] = CONTRPS_VPAD_BUTTON_DPAD_SE; + CONTPRStringToValue["VPAD_BUTTON_DPAD_S"] = CONTRPS_VPAD_BUTTON_DPAD_S; + CONTPRStringToValue["VPAD_BUTTON_DPAD_SW"] = CONTRPS_VPAD_BUTTON_DPAD_SW; + CONTPRStringToValue["VPAD_BUTTON_DPAD_W"] = CONTRPS_VPAD_BUTTON_DPAD_W; + CONTPRStringToValue["VPAD_BUTTON_DPAD_NW"] = CONTRPS_VPAD_BUTTON_DPAD_NW; + CONTPRStringToValue["VPAD_BUTTON_DPAD_NEUTRAL"] = CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL; /* DPAD Absolute mode */ - CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_UP"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_UP; - CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_DOWN"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_DOWN; - CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_LEFT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_LEFT; - CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_RIGHT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_RIGHT; + CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_UP"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_UP; + CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_DOWN"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_DOWN; + CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_LEFT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_LEFT; + CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_RIGHT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_RIGHT; /* */ - CONTPRStringToValue["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL; - CONTPRStringToValue["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR; - CONTPRStringToValue["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L; - CONTPRStringToValue["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R; - CONTPRStringToValue["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS; - CONTPRStringToValue["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS; - CONTPRStringToValue["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME; - CONTPRStringToValue["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC; - CONTPRStringToValue["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R; - CONTPRStringToValue["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L; + CONTPRStringToValue["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL; + CONTPRStringToValue["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR; + CONTPRStringToValue["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L; + CONTPRStringToValue["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R; + CONTPRStringToValue["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS; + CONTPRStringToValue["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS; + CONTPRStringToValue["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME; + CONTPRStringToValue["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC; + CONTPRStringToValue["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R; + CONTPRStringToValue["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L; - CONTPRStringToValue["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT; - CONTPRStringToValue["VPAD_STICK_R_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_R_EMULATION_RIGHT; - CONTPRStringToValue["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP; - CONTPRStringToValue["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN; - CONTPRStringToValue["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT; - CONTPRStringToValue["VPAD_STICK_L_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_L_EMULATION_RIGHT; - CONTPRStringToValue["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP; - CONTPRStringToValue["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN; + CONTPRStringToValue["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT; + CONTPRStringToValue["VPAD_STICK_R_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_R_EMULATION_RIGHT; + CONTPRStringToValue["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP; + CONTPRStringToValue["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN; + CONTPRStringToValue["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT; + CONTPRStringToValue["VPAD_STICK_L_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_L_EMULATION_RIGHT; + CONTPRStringToValue["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP; + CONTPRStringToValue["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN; - CONTPRStringToValue["VPAD_L_STICK_UP"] = CONTRPS_VPAD_BUTTON_L_STICK_UP; - CONTPRStringToValue["VPAD_L_STICK_DOWN"] = CONTRPS_VPAD_BUTTON_L_STICK_DOWN; - CONTPRStringToValue["VPAD_L_STICK_LEFT"] = CONTRPS_VPAD_BUTTON_L_STICK_LEFT; - CONTPRStringToValue["VPAD_L_STICK_RIGHT"] = CONTRPS_VPAD_BUTTON_L_STICK_RIGHT; + CONTPRStringToValue["VPAD_L_STICK_UP"] = CONTRPS_VPAD_BUTTON_L_STICK_UP; + CONTPRStringToValue["VPAD_L_STICK_DOWN"] = CONTRPS_VPAD_BUTTON_L_STICK_DOWN; + CONTPRStringToValue["VPAD_L_STICK_LEFT"] = CONTRPS_VPAD_BUTTON_L_STICK_LEFT; + CONTPRStringToValue["VPAD_L_STICK_RIGHT"] = CONTRPS_VPAD_BUTTON_L_STICK_RIGHT; - CONTPRStringToValue["VPAD_R_STICK_UP"] = CONTRPS_VPAD_BUTTON_R_STICK_UP; - CONTPRStringToValue["VPAD_R_STICK_DOWN"] = CONTRPS_VPAD_BUTTON_R_STICK_DOWN; - CONTPRStringToValue["VPAD_R_STICK_LEFT"] = CONTRPS_VPAD_BUTTON_R_STICK_LEFT; - CONTPRStringToValue["VPAD_R_STICK_RIGHT"] = CONTRPS_VPAD_BUTTON_R_STICK_RIGHT; + CONTPRStringToValue["VPAD_R_STICK_UP"] = CONTRPS_VPAD_BUTTON_R_STICK_UP; + CONTPRStringToValue["VPAD_R_STICK_DOWN"] = CONTRPS_VPAD_BUTTON_R_STICK_DOWN; + CONTPRStringToValue["VPAD_R_STICK_LEFT"] = CONTRPS_VPAD_BUTTON_R_STICK_LEFT; + CONTPRStringToValue["VPAD_R_STICK_RIGHT"] = CONTRPS_VPAD_BUTTON_R_STICK_RIGHT; - CONTPRStringToValue["VPAD_L_STICK_X"] = CONTRPS_VPAD_BUTTON_L_STICK_X; - CONTPRStringToValue["VPAD_L_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX; - CONTPRStringToValue["VPAD_L_STICK_Y"] = CONTRPS_VPAD_BUTTON_L_STICK_Y; - CONTPRStringToValue["VPAD_L_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX; - CONTPRStringToValue["VPAD_R_STICK_X"] = CONTRPS_VPAD_BUTTON_R_STICK_X; - CONTPRStringToValue["VPAD_R_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX; - CONTPRStringToValue["VPAD_R_STICK_Y"] = CONTRPS_VPAD_BUTTON_R_STICK_Y; - CONTPRStringToValue["VPAD_R_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX; - CONTPRStringToValue["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV; + CONTPRStringToValue["VPAD_L_STICK_X"] = CONTRPS_VPAD_BUTTON_L_STICK_X; + CONTPRStringToValue["VPAD_L_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX; + CONTPRStringToValue["VPAD_L_STICK_Y"] = CONTRPS_VPAD_BUTTON_L_STICK_Y; + CONTPRStringToValue["VPAD_L_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX; + CONTPRStringToValue["VPAD_R_STICK_X"] = CONTRPS_VPAD_BUTTON_R_STICK_X; + CONTPRStringToValue["VPAD_R_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX; + CONTPRStringToValue["VPAD_R_STICK_Y"] = CONTRPS_VPAD_BUTTON_R_STICK_Y; + CONTPRStringToValue["VPAD_R_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX; + CONTPRStringToValue["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV; - CONTPRStringToValue["DOUBLE_USE_BUTTON_ACTIVATOR"] = CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR, - CONTPRStringToValue["INPUT_FILTER"] = CONTRPS_INPUT_FILTER; - CONTPRStringToValue["PAD1_FILTER"] = CONTRPS_PAD1_FILTER; - CONTPRStringToValue["PAD2_FILTER"] = CONTRPS_PAD2_FILTER; - CONTPRStringToValue["PAD3_FILTER"] = CONTRPS_PAD3_FILTER; - CONTPRStringToValue["PAD4_FILTER"] = CONTRPS_PAD4_FILTER; - CONTPRStringToValue["PAD5_FILTER"] = CONTRPS_PAD5_FILTER; + CONTPRStringToValue["DOUBLE_USE_BUTTON_ACTIVATOR"] = CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR, + CONTPRStringToValue["INPUT_FILTER"] = CONTRPS_INPUT_FILTER; + CONTPRStringToValue["PAD1_FILTER"] = CONTRPS_PAD1_FILTER; + CONTPRStringToValue["PAD2_FILTER"] = CONTRPS_PAD2_FILTER; + CONTPRStringToValue["PAD3_FILTER"] = CONTRPS_PAD3_FILTER; + CONTPRStringToValue["PAD4_FILTER"] = CONTRPS_PAD4_FILTER; + CONTPRStringToValue["PAD5_FILTER"] = CONTRPS_PAD5_FILTER; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED; - CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED; + CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED; - CONTPRStringToValueSingle["BUF_SIZE"] = CONTRPS_BUF_SIZE; - CONTPRStringToValueSingle["DPAD_MODE"] = CONTRPS_DPAD_MODE; - CONTPRStringToValueSingle["DPAD_MASK"] = CONTRPS_DPAD_MASK; - CONTPRStringToValueSingle["VPAD_L_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE; - CONTPRStringToValueSingle["VPAD_L_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE; - CONTPRStringToValueSingle["VPAD_R_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE; - CONTPRStringToValueSingle["VPAD_R_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE; - CONTPRStringToValueSingle["VPAD_L_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT; - CONTPRStringToValueSingle["VPAD_L_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT; - CONTPRStringToValueSingle["VPAD_R_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT; - CONTPRStringToValueSingle["VPAD_R_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT; + CONTPRStringToValueSingle["BUF_SIZE"] = CONTRPS_BUF_SIZE; + CONTPRStringToValueSingle["DPAD_MODE"] = CONTRPS_DPAD_MODE; + CONTPRStringToValueSingle["DPAD_MASK"] = CONTRPS_DPAD_MASK; + CONTPRStringToValueSingle["VPAD_L_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE; + CONTPRStringToValueSingle["VPAD_L_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE; + CONTPRStringToValueSingle["VPAD_R_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE; + CONTPRStringToValueSingle["VPAD_R_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE; + CONTPRStringToValueSingle["VPAD_L_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT; + CONTPRStringToValueSingle["VPAD_L_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT; + CONTPRStringToValueSingle["VPAD_R_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT; + CONTPRStringToValueSingle["VPAD_R_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT; - CONTPRStringToValueSingle["DOUBLE_USE"] = CONTRPS_DOUBLE_USE; - CONTPRStringToValueSingle["PAD_COUNT"] = CONTRPS_PAD_COUNT; + CONTPRStringToValueSingle["DOUBLE_USE"] = CONTRPS_DOUBLE_USE; + CONTPRStringToValueSingle["PAD_COUNT"] = CONTRPS_PAD_COUNT; - CONTPRStringToValueSingle["VPAD_L_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_L_COPY_DPAD; - CONTPRStringToValueSingle["VPAD_R_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_R_COPY_DPAD; + CONTPRStringToValueSingle["VPAD_L_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_L_COPY_DPAD; + CONTPRStringToValueSingle["VPAD_R_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_R_COPY_DPAD; - mouseLeftValues["LEFT_CLICK"] = CONTRPS_VPAD_BUTTON_LEFT; - mouseLeftValues["RIGHT_CLICK"] = CONTRPS_VPAD_BUTTON_RIGHT; - mouseLeftValues["EMULATED_STICK"] = CONTRPS_MOUSE_STICK; + mouseLeftValues["LEFT_CLICK"] = CONTRPS_VPAD_BUTTON_LEFT; + mouseLeftValues["RIGHT_CLICK"] = CONTRPS_VPAD_BUTTON_RIGHT; + mouseLeftValues["EMULATED_STICK"] = CONTRPS_MOUSE_STICK; - presetGCValues["GC_BUTTON_A"] = HID_GC_BUTTON_A; - presetGCValues["GC_BUTTON_B"] = HID_GC_BUTTON_B; - presetGCValues["GC_BUTTON_X"] = HID_GC_BUTTON_X; - presetGCValues["GC_BUTTON_Y"] = HID_GC_BUTTON_Y; - presetGCValues["GC_BUTTON_LEFT"] = HID_GC_BUTTON_LEFT; - presetGCValues["GC_BUTTON_RIGHT"] = HID_GC_BUTTON_RIGHT; - presetGCValues["GC_BUTTON_DOWN"] = HID_GC_BUTTON_DOWN; - presetGCValues["GC_BUTTON_UP"] = HID_GC_BUTTON_UP; - presetGCValues["GC_BUTTON_START"] = HID_GC_BUTTON_START; - presetGCValues["GC_BUTTON_Z"] = HID_GC_BUTTON_Z; - presetGCValues["GC_BUTTON_L"] = HID_GC_BUTTON_L; - presetGCValues["GC_BUTTON_R"] = HID_GC_BUTTON_R; + presetGCValues["GC_BUTTON_A"] = HID_GC_BUTTON_A; + presetGCValues["GC_BUTTON_B"] = HID_GC_BUTTON_B; + presetGCValues["GC_BUTTON_X"] = HID_GC_BUTTON_X; + presetGCValues["GC_BUTTON_Y"] = HID_GC_BUTTON_Y; + presetGCValues["GC_BUTTON_LEFT"] = HID_GC_BUTTON_LEFT; + presetGCValues["GC_BUTTON_RIGHT"] = HID_GC_BUTTON_RIGHT; + presetGCValues["GC_BUTTON_DOWN"] = HID_GC_BUTTON_DOWN; + presetGCValues["GC_BUTTON_UP"] = HID_GC_BUTTON_UP; + presetGCValues["GC_BUTTON_START"] = HID_GC_BUTTON_START; + presetGCValues["GC_BUTTON_Z"] = HID_GC_BUTTON_Z; + presetGCValues["GC_BUTTON_L"] = HID_GC_BUTTON_L; + presetGCValues["GC_BUTTON_R"] = HID_GC_BUTTON_R; - presetDS3Values["DS3_BUTTON_CROSS"] = HID_DS3_BUTTON_CROSS; - presetDS3Values["DS3_BUTTON_CIRCLE"] = HID_DS3_BUTTON_CIRCLE; - presetDS3Values["DS3_BUTTON_SQUARE"] = HID_DS3_BUTTON_SQUARE; - presetDS3Values["DS3_BUTTON_TRIANGLE"] = HID_DS3_BUTTON_TRIANGLE; + presetDS3Values["DS3_BUTTON_CROSS"] = HID_DS3_BUTTON_CROSS; + presetDS3Values["DS3_BUTTON_CIRCLE"] = HID_DS3_BUTTON_CIRCLE; + presetDS3Values["DS3_BUTTON_SQUARE"] = HID_DS3_BUTTON_SQUARE; + presetDS3Values["DS3_BUTTON_TRIANGLE"] = HID_DS3_BUTTON_TRIANGLE; - presetDS3Values["DS3_BUTTON_L1"] = HID_DS3_BUTTON_L1; - presetDS3Values["DS3_BUTTON_L2"] = HID_DS3_BUTTON_L2; - presetDS3Values["DS3_BUTTON_L3"] = HID_DS3_BUTTON_L3; - presetDS3Values["DS3_BUTTON_R1"] = HID_DS3_BUTTON_R1; - presetDS3Values["DS3_BUTTON_R2"] = HID_DS3_BUTTON_R2; - presetDS3Values["DS3_BUTTON_R3"] = HID_DS3_BUTTON_R3; + presetDS3Values["DS3_BUTTON_L1"] = HID_DS3_BUTTON_L1; + presetDS3Values["DS3_BUTTON_L2"] = HID_DS3_BUTTON_L2; + presetDS3Values["DS3_BUTTON_L3"] = HID_DS3_BUTTON_L3; + presetDS3Values["DS3_BUTTON_R1"] = HID_DS3_BUTTON_R1; + presetDS3Values["DS3_BUTTON_R2"] = HID_DS3_BUTTON_R2; + presetDS3Values["DS3_BUTTON_R3"] = HID_DS3_BUTTON_R3; - presetDS3Values["DS3_BUTTON_SELECT"] = HID_DS3_BUTTON_SELECT; - presetDS3Values["DS3_BUTTON_START"] = HID_DS3_BUTTON_START; - presetDS3Values["DS3_BUTTON_LEFT"] = HID_DS3_BUTTON_LEFT; - presetDS3Values["DS3_BUTTON_RIGHT"] = HID_DS3_BUTTON_RIGHT; - presetDS3Values["DS3_BUTTON_UP"] = HID_DS3_BUTTON_UP; - presetDS3Values["DS3_BUTTON_DOWN"] = HID_DS3_BUTTON_DOWN; - presetDS3Values["DS3_BUTTON_GUIDE"] = HID_DS3_BUTTON_GUIDE; + presetDS3Values["DS3_BUTTON_SELECT"] = HID_DS3_BUTTON_SELECT; + presetDS3Values["DS3_BUTTON_START"] = HID_DS3_BUTTON_START; + presetDS3Values["DS3_BUTTON_LEFT"] = HID_DS3_BUTTON_LEFT; + presetDS3Values["DS3_BUTTON_RIGHT"] = HID_DS3_BUTTON_RIGHT; + presetDS3Values["DS3_BUTTON_UP"] = HID_DS3_BUTTON_UP; + presetDS3Values["DS3_BUTTON_DOWN"] = HID_DS3_BUTTON_DOWN; + presetDS3Values["DS3_BUTTON_GUIDE"] = HID_DS3_BUTTON_GUIDE; - presetDS4Values["DS4_BUTTON_CROSS"] = HID_DS4_BUTTON_CROSS; - presetDS4Values["DS4_BUTTON_CIRCLE"] = HID_DS4_BUTTON_CIRCLE; - presetDS4Values["DS4_BUTTON_SQUARE"] = HID_DS4_BUTTON_SQUARE; - presetDS4Values["DS4_BUTTON_TRIANGLE"] = HID_DS4_BUTTON_TRIANGLE; + presetDS4Values["DS4_BUTTON_CROSS"] = HID_DS4_BUTTON_CROSS; + presetDS4Values["DS4_BUTTON_CIRCLE"] = HID_DS4_BUTTON_CIRCLE; + presetDS4Values["DS4_BUTTON_SQUARE"] = HID_DS4_BUTTON_SQUARE; + presetDS4Values["DS4_BUTTON_TRIANGLE"] = HID_DS4_BUTTON_TRIANGLE; - presetDS4Values["DS4_BUTTON_L1"] = HID_DS4_BUTTON_L1; - presetDS4Values["DS4_BUTTON_L2"] = HID_DS4_BUTTON_L2; - presetDS4Values["DS4_BUTTON_L3"] = HID_DS4_BUTTON_L3; - presetDS4Values["DS4_BUTTON_R1"] = HID_DS4_BUTTON_R1; - presetDS4Values["DS4_BUTTON_R2"] = HID_DS4_BUTTON_R2; - presetDS4Values["DS4_BUTTON_R3"] = HID_DS4_BUTTON_R3; + presetDS4Values["DS4_BUTTON_L1"] = HID_DS4_BUTTON_L1; + presetDS4Values["DS4_BUTTON_L2"] = HID_DS4_BUTTON_L2; + presetDS4Values["DS4_BUTTON_L3"] = HID_DS4_BUTTON_L3; + presetDS4Values["DS4_BUTTON_R1"] = HID_DS4_BUTTON_R1; + presetDS4Values["DS4_BUTTON_R2"] = HID_DS4_BUTTON_R2; + presetDS4Values["DS4_BUTTON_R3"] = HID_DS4_BUTTON_R3; - presetDS4Values["DS4_BUTTON_SHARE"] = HID_DS4_BUTTON_SHARE; - presetDS4Values["DS4_BUTTON_OPTIONS"] = HID_DS4_BUTTON_OPTIONS; - presetDS4Values["DS4_BUTTON_DPAD_TYPE"] = HID_DS4_BUTTON_DPAD_TYPE; + presetDS4Values["DS4_BUTTON_SHARE"] = HID_DS4_BUTTON_SHARE; + presetDS4Values["DS4_BUTTON_OPTIONS"] = HID_DS4_BUTTON_OPTIONS; + presetDS4Values["DS4_BUTTON_DPAD_TYPE"] = HID_DS4_BUTTON_DPAD_TYPE; - presetDS4Values["DS4_BUTTON_DPAD_N"] = HID_DS4_BUTTON_DPAD_N; - presetDS4Values["DS4_BUTTON_DPAD_NE"] = HID_DS4_BUTTON_DPAD_NE; - presetDS4Values["DS4_BUTTON_DPAD_E"] = HID_DS4_BUTTON_DPAD_E; - presetDS4Values["DS4_BUTTON_DPAD_SE"] = HID_DS4_BUTTON_DPAD_SE; - presetDS4Values["DS4_BUTTON_DPAD_S"] = HID_DS4_BUTTON_DPAD_S; - presetDS4Values["DS4_BUTTON_DPAD_SW"] = HID_DS4_BUTTON_DPAD_SW; - presetDS4Values["DS4_BUTTON_DPAD_W"] = HID_DS4_BUTTON_DPAD_W; - presetDS4Values["DS4_BUTTON_DPAD_NW"] = HID_DS4_BUTTON_DPAD_NW; - presetDS4Values["DS4_BUTTON_DPAD_NEUTRAL"] = HID_DS4_BUTTON_DPAD_NEUTRAL; + presetDS4Values["DS4_BUTTON_DPAD_N"] = HID_DS4_BUTTON_DPAD_N; + presetDS4Values["DS4_BUTTON_DPAD_NE"] = HID_DS4_BUTTON_DPAD_NE; + presetDS4Values["DS4_BUTTON_DPAD_E"] = HID_DS4_BUTTON_DPAD_E; + presetDS4Values["DS4_BUTTON_DPAD_SE"] = HID_DS4_BUTTON_DPAD_SE; + presetDS4Values["DS4_BUTTON_DPAD_S"] = HID_DS4_BUTTON_DPAD_S; + presetDS4Values["DS4_BUTTON_DPAD_SW"] = HID_DS4_BUTTON_DPAD_SW; + presetDS4Values["DS4_BUTTON_DPAD_W"] = HID_DS4_BUTTON_DPAD_W; + presetDS4Values["DS4_BUTTON_DPAD_NW"] = HID_DS4_BUTTON_DPAD_NW; + presetDS4Values["DS4_BUTTON_DPAD_NEUTRAL"] = HID_DS4_BUTTON_DPAD_NEUTRAL; - presetDS4Values["DS4_BUTTON_GUIDE"] = HID_DS4_BUTTON_GUIDE; - presetDS4Values["DS4_BUTTON_T_PAD_CLICK"] = HID_DS4_BUTTON_T_PAD_CLICK; + presetDS4Values["DS4_BUTTON_GUIDE"] = HID_DS4_BUTTON_GUIDE; + presetDS4Values["DS4_BUTTON_T_PAD_CLICK"] = HID_DS4_BUTTON_T_PAD_CLICK; - presetXInputValues["XINPUT_BUTTON_A"] = HID_XINPUT_BUTTON_A; - presetXInputValues["XINPUT_BUTTON_B"] = HID_XINPUT_BUTTON_B; - presetXInputValues["XINPUT_BUTTON_X"] = HID_XINPUT_BUTTON_X; - presetXInputValues["XINPUT_BUTTON_Y"] = HID_XINPUT_BUTTON_Y; + presetXInputValues["XINPUT_BUTTON_A"] = HID_XINPUT_BUTTON_A; + presetXInputValues["XINPUT_BUTTON_B"] = HID_XINPUT_BUTTON_B; + presetXInputValues["XINPUT_BUTTON_X"] = HID_XINPUT_BUTTON_X; + presetXInputValues["XINPUT_BUTTON_Y"] = HID_XINPUT_BUTTON_Y; - presetXInputValues["XINPUT_BUTTON_LB"] = HID_XINPUT_BUTTON_LB; - presetXInputValues["XINPUT_BUTTON_LT"] = HID_XINPUT_BUTTON_LT; - presetXInputValues["XINPUT_BUTTON_L3"] = HID_XINPUT_BUTTON_L3; - presetXInputValues["XINPUT_BUTTON_RB"] = HID_XINPUT_BUTTON_RB; - presetXInputValues["XINPUT_BUTTON_RT"] = HID_XINPUT_BUTTON_RT; - presetXInputValues["XINPUT_BUTTON_R3"] = HID_XINPUT_BUTTON_R3; + presetXInputValues["XINPUT_BUTTON_LB"] = HID_XINPUT_BUTTON_LB; + presetXInputValues["XINPUT_BUTTON_LT"] = HID_XINPUT_BUTTON_LT; + presetXInputValues["XINPUT_BUTTON_L3"] = HID_XINPUT_BUTTON_L3; + presetXInputValues["XINPUT_BUTTON_RB"] = HID_XINPUT_BUTTON_RB; + presetXInputValues["XINPUT_BUTTON_RT"] = HID_XINPUT_BUTTON_RT; + presetXInputValues["XINPUT_BUTTON_R3"] = HID_XINPUT_BUTTON_R3; - presetXInputValues["XINPUT_BUTTON_START"] = HID_XINPUT_BUTTON_START; - presetXInputValues["XINPUT_BUTTON_BACK"] = HID_XINPUT_BUTTON_BACK; - presetXInputValues["XINPUT_BUTTON_DPAD_TYPE"] = HID_XINPUT_BUTTON_DPAD_TYPE; + presetXInputValues["XINPUT_BUTTON_START"] = HID_XINPUT_BUTTON_START; + presetXInputValues["XINPUT_BUTTON_BACK"] = HID_XINPUT_BUTTON_BACK; + presetXInputValues["XINPUT_BUTTON_DPAD_TYPE"] = HID_XINPUT_BUTTON_DPAD_TYPE; - presetXInputValues["XINPUT_BUTTON_DPAD_UP"] = HID_XINPUT_BUTTON_UP; - presetXInputValues["XINPUT_BUTTON_DPAD_DOWN"] = HID_XINPUT_BUTTON_DOWN; - presetXInputValues["XINPUT_BUTTON_DPAD_LEFT"] = HID_XINPUT_BUTTON_LEFT; - presetXInputValues["XINPUT_BUTTON_DPAD_RIGHT"] = HID_XINPUT_BUTTON_RIGHT; + presetXInputValues["XINPUT_BUTTON_DPAD_UP"] = HID_XINPUT_BUTTON_UP; + presetXInputValues["XINPUT_BUTTON_DPAD_DOWN"] = HID_XINPUT_BUTTON_DOWN; + presetXInputValues["XINPUT_BUTTON_DPAD_LEFT"] = HID_XINPUT_BUTTON_LEFT; + presetXInputValues["XINPUT_BUTTON_DPAD_RIGHT"] = HID_XINPUT_BUTTON_RIGHT; - presetXInputValues["XINPUT_BUTTON_GUIDE"] = HID_XINPUT_BUTTON_GUIDE; + presetXInputValues["XINPUT_BUTTON_GUIDE"] = HID_XINPUT_BUTTON_GUIDE; - presetSwitchProValues["SWITCH_PRO_BUTTON_A"] = HID_SWITCH_PRO_BT_BUTTON_A; - presetSwitchProValues["SWITCH_PRO_BUTTON_B"] = HID_SWITCH_PRO_BT_BUTTON_B; - presetSwitchProValues["SWITCH_PRO_BUTTON_X"] = HID_SWITCH_PRO_BT_BUTTON_X; - presetSwitchProValues["SWITCH_PRO_BUTTON_Y"] = HID_SWITCH_PRO_BT_BUTTON_Y; + presetSwitchProValues["SWITCH_PRO_BUTTON_A"] = HID_SWITCH_PRO_BT_BUTTON_A; + presetSwitchProValues["SWITCH_PRO_BUTTON_B"] = HID_SWITCH_PRO_BT_BUTTON_B; + presetSwitchProValues["SWITCH_PRO_BUTTON_X"] = HID_SWITCH_PRO_BT_BUTTON_X; + presetSwitchProValues["SWITCH_PRO_BUTTON_Y"] = HID_SWITCH_PRO_BT_BUTTON_Y; - presetSwitchProValues["SWITCH_PRO_BUTTON_PLUS"] = HID_SWITCH_PRO_BT_BUTTON_PLUS; - presetSwitchProValues["SWITCH_PRO_BUTTON_MINUS"] = HID_SWITCH_PRO_BT_BUTTON_MINUS; - presetSwitchProValues["SWITCH_PRO_BUTTON_HOME"] = HID_SWITCH_PRO_BT_BUTTON_HOME; + presetSwitchProValues["SWITCH_PRO_BUTTON_PLUS"] = HID_SWITCH_PRO_BT_BUTTON_PLUS; + presetSwitchProValues["SWITCH_PRO_BUTTON_MINUS"] = HID_SWITCH_PRO_BT_BUTTON_MINUS; + presetSwitchProValues["SWITCH_PRO_BUTTON_HOME"] = HID_SWITCH_PRO_BT_BUTTON_HOME; - presetSwitchProValues["SWITCH_PRO_BUTTON_L"] = HID_SWITCH_PRO_BT_BUTTON_L; - presetSwitchProValues["SWITCH_PRO_BUTTON_R"] = HID_SWITCH_PRO_BT_BUTTON_R; + presetSwitchProValues["SWITCH_PRO_BUTTON_L"] = HID_SWITCH_PRO_BT_BUTTON_L; + presetSwitchProValues["SWITCH_PRO_BUTTON_R"] = HID_SWITCH_PRO_BT_BUTTON_R; - presetSwitchProValues["SWITCH_PRO_BUTTON_ZL"] = HID_SWITCH_PRO_BT_BUTTON_ZL; - presetSwitchProValues["SWITCH_PRO_BUTTON_ZR"] = HID_SWITCH_PRO_BT_BUTTON_ZR; + presetSwitchProValues["SWITCH_PRO_BUTTON_ZL"] = HID_SWITCH_PRO_BT_BUTTON_ZL; + presetSwitchProValues["SWITCH_PRO_BUTTON_ZR"] = HID_SWITCH_PRO_BT_BUTTON_ZR; - presetSwitchProValues["SWITCH_PRO_BUTTON_STICK_L"] = HID_SWITCH_PRO_BT_BUTTON_STICK_L; - presetSwitchProValues["SWITCH_PRO_BUTTON_STICK_R"] = HID_SWITCH_PRO_BT_BUTTON_STICK_R; + presetSwitchProValues["SWITCH_PRO_BUTTON_STICK_L"] = HID_SWITCH_PRO_BT_BUTTON_STICK_L; + presetSwitchProValues["SWITCH_PRO_BUTTON_STICK_R"] = HID_SWITCH_PRO_BT_BUTTON_STICK_R; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_N"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_N; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NE; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_E"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_E; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_SE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_SE; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_S"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_S; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_SW"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_SW; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_W"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_W; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NW"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NW; - presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NEUTRAL"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_N"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_N; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NE; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_E"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_E; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_SE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_SE; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_S"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_S; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_SW"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_SW; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_W"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_W; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NW"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NW; + presetSwitchProValues["SWITCH_PRO_BUTTON_DPAD_NEUTRAL"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL; - presetKeyboardValues["KEYBOARD_SHIFT"] = HID_KEYBOARD_BUTTON_SHIFT; - presetKeyboardValues["KEYBOARD_A"] = HID_KEYBOARD_BUTTON_A; - presetKeyboardValues["KEYBOARD_B"] = HID_KEYBOARD_BUTTON_B; - presetKeyboardValues["KEYBOARD_C"] = HID_KEYBOARD_BUTTON_C; - presetKeyboardValues["KEYBOARD_D"] = HID_KEYBOARD_BUTTON_D; - presetKeyboardValues["KEYBOARD_E"] = HID_KEYBOARD_BUTTON_E; - presetKeyboardValues["KEYBOARD_F"] = HID_KEYBOARD_BUTTON_F; - presetKeyboardValues["KEYBOARD_G"] = HID_KEYBOARD_BUTTON_G; - presetKeyboardValues["KEYBOARD_H"] = HID_KEYBOARD_BUTTON_H; - presetKeyboardValues["KEYBOARD_I"] = HID_KEYBOARD_BUTTON_I; - presetKeyboardValues["KEYBOARD_J"] = HID_KEYBOARD_BUTTON_J; - presetKeyboardValues["KEYBOARD_K"] = HID_KEYBOARD_BUTTON_K; - presetKeyboardValues["KEYBOARD_L"] = HID_KEYBOARD_BUTTON_L; - presetKeyboardValues["KEYBOARD_M"] = HID_KEYBOARD_BUTTON_M; - presetKeyboardValues["KEYBOARD_N"] = HID_KEYBOARD_BUTTON_N; - presetKeyboardValues["KEYBOARD_O"] = HID_KEYBOARD_BUTTON_O; - presetKeyboardValues["KEYBOARD_P"] = HID_KEYBOARD_BUTTON_P; - presetKeyboardValues["KEYBOARD_Q"] = HID_KEYBOARD_BUTTON_Q; - presetKeyboardValues["KEYBOARD_R"] = HID_KEYBOARD_BUTTON_R; - presetKeyboardValues["KEYBOARD_S"] = HID_KEYBOARD_BUTTON_S; - presetKeyboardValues["KEYBOARD_T"] = HID_KEYBOARD_BUTTON_T; - presetKeyboardValues["KEYBOARD_U"] = HID_KEYBOARD_BUTTON_U; - presetKeyboardValues["KEYBOARD_V"] = HID_KEYBOARD_BUTTON_V; - presetKeyboardValues["KEYBOARD_W"] = HID_KEYBOARD_BUTTON_W; - presetKeyboardValues["KEYBOARD_X"] = HID_KEYBOARD_BUTTON_X; - presetKeyboardValues["KEYBOARD_Y"] = HID_KEYBOARD_BUTTON_Y; - presetKeyboardValues["KEYBOARD_Z"] = HID_KEYBOARD_BUTTON_Z; - presetKeyboardValues["KEYBOARD_F1"] = HID_KEYBOARD_BUTTON_F1; - presetKeyboardValues["KEYBOARD_F2"] = HID_KEYBOARD_BUTTON_F2; - presetKeyboardValues["KEYBOARD_F3"] = HID_KEYBOARD_BUTTON_F3; - presetKeyboardValues["KEYBOARD_F4"] = HID_KEYBOARD_BUTTON_F4; - presetKeyboardValues["KEYBOARD_F5"] = HID_KEYBOARD_BUTTON_F5; - presetKeyboardValues["KEYBOARD_F6"] = HID_KEYBOARD_BUTTON_F6; - presetKeyboardValues["KEYBOARD_F7"] = HID_KEYBOARD_BUTTON_F7; - presetKeyboardValues["KEYBOARD_F8"] = HID_KEYBOARD_BUTTON_F8; - presetKeyboardValues["KEYBOARD_F9"] = HID_KEYBOARD_BUTTON_F9; - presetKeyboardValues["KEYBOARD_F10"] = HID_KEYBOARD_BUTTON_F10; - presetKeyboardValues["KEYBOARD_F11"] = HID_KEYBOARD_BUTTON_F11; - presetKeyboardValues["KEYBOARD_F12"] = HID_KEYBOARD_BUTTON_F12; - presetKeyboardValues["KEYBOARD_1"] = HID_KEYBOARD_BUTTON_1; - presetKeyboardValues["KEYBOARD_2"] = HID_KEYBOARD_BUTTON_2; - presetKeyboardValues["KEYBOARD_3"] = HID_KEYBOARD_BUTTON_3; - presetKeyboardValues["KEYBOARD_4"] = HID_KEYBOARD_BUTTON_4; - presetKeyboardValues["KEYBOARD_5"] = HID_KEYBOARD_BUTTON_5; - presetKeyboardValues["KEYBOARD_6"] = HID_KEYBOARD_BUTTON_6; - presetKeyboardValues["KEYBOARD_7"] = HID_KEYBOARD_BUTTON_7; - presetKeyboardValues["KEYBOARD_8"] = HID_KEYBOARD_BUTTON_8; - presetKeyboardValues["KEYBOARD_9"] = HID_KEYBOARD_BUTTON_9; - presetKeyboardValues["KEYBOARD_0"] = HID_KEYBOARD_BUTTON_0; + presetKeyboardValues["KEYBOARD_SHIFT"] = HID_KEYBOARD_BUTTON_SHIFT; + presetKeyboardValues["KEYBOARD_A"] = HID_KEYBOARD_BUTTON_A; + presetKeyboardValues["KEYBOARD_B"] = HID_KEYBOARD_BUTTON_B; + presetKeyboardValues["KEYBOARD_C"] = HID_KEYBOARD_BUTTON_C; + presetKeyboardValues["KEYBOARD_D"] = HID_KEYBOARD_BUTTON_D; + presetKeyboardValues["KEYBOARD_E"] = HID_KEYBOARD_BUTTON_E; + presetKeyboardValues["KEYBOARD_F"] = HID_KEYBOARD_BUTTON_F; + presetKeyboardValues["KEYBOARD_G"] = HID_KEYBOARD_BUTTON_G; + presetKeyboardValues["KEYBOARD_H"] = HID_KEYBOARD_BUTTON_H; + presetKeyboardValues["KEYBOARD_I"] = HID_KEYBOARD_BUTTON_I; + presetKeyboardValues["KEYBOARD_J"] = HID_KEYBOARD_BUTTON_J; + presetKeyboardValues["KEYBOARD_K"] = HID_KEYBOARD_BUTTON_K; + presetKeyboardValues["KEYBOARD_L"] = HID_KEYBOARD_BUTTON_L; + presetKeyboardValues["KEYBOARD_M"] = HID_KEYBOARD_BUTTON_M; + presetKeyboardValues["KEYBOARD_N"] = HID_KEYBOARD_BUTTON_N; + presetKeyboardValues["KEYBOARD_O"] = HID_KEYBOARD_BUTTON_O; + presetKeyboardValues["KEYBOARD_P"] = HID_KEYBOARD_BUTTON_P; + presetKeyboardValues["KEYBOARD_Q"] = HID_KEYBOARD_BUTTON_Q; + presetKeyboardValues["KEYBOARD_R"] = HID_KEYBOARD_BUTTON_R; + presetKeyboardValues["KEYBOARD_S"] = HID_KEYBOARD_BUTTON_S; + presetKeyboardValues["KEYBOARD_T"] = HID_KEYBOARD_BUTTON_T; + presetKeyboardValues["KEYBOARD_U"] = HID_KEYBOARD_BUTTON_U; + presetKeyboardValues["KEYBOARD_V"] = HID_KEYBOARD_BUTTON_V; + presetKeyboardValues["KEYBOARD_W"] = HID_KEYBOARD_BUTTON_W; + presetKeyboardValues["KEYBOARD_X"] = HID_KEYBOARD_BUTTON_X; + presetKeyboardValues["KEYBOARD_Y"] = HID_KEYBOARD_BUTTON_Y; + presetKeyboardValues["KEYBOARD_Z"] = HID_KEYBOARD_BUTTON_Z; + presetKeyboardValues["KEYBOARD_F1"] = HID_KEYBOARD_BUTTON_F1; + presetKeyboardValues["KEYBOARD_F2"] = HID_KEYBOARD_BUTTON_F2; + presetKeyboardValues["KEYBOARD_F3"] = HID_KEYBOARD_BUTTON_F3; + presetKeyboardValues["KEYBOARD_F4"] = HID_KEYBOARD_BUTTON_F4; + presetKeyboardValues["KEYBOARD_F5"] = HID_KEYBOARD_BUTTON_F5; + presetKeyboardValues["KEYBOARD_F6"] = HID_KEYBOARD_BUTTON_F6; + presetKeyboardValues["KEYBOARD_F7"] = HID_KEYBOARD_BUTTON_F7; + presetKeyboardValues["KEYBOARD_F8"] = HID_KEYBOARD_BUTTON_F8; + presetKeyboardValues["KEYBOARD_F9"] = HID_KEYBOARD_BUTTON_F9; + presetKeyboardValues["KEYBOARD_F10"] = HID_KEYBOARD_BUTTON_F10; + presetKeyboardValues["KEYBOARD_F11"] = HID_KEYBOARD_BUTTON_F11; + presetKeyboardValues["KEYBOARD_F12"] = HID_KEYBOARD_BUTTON_F12; + presetKeyboardValues["KEYBOARD_1"] = HID_KEYBOARD_BUTTON_1; + presetKeyboardValues["KEYBOARD_2"] = HID_KEYBOARD_BUTTON_2; + presetKeyboardValues["KEYBOARD_3"] = HID_KEYBOARD_BUTTON_3; + presetKeyboardValues["KEYBOARD_4"] = HID_KEYBOARD_BUTTON_4; + presetKeyboardValues["KEYBOARD_5"] = HID_KEYBOARD_BUTTON_5; + presetKeyboardValues["KEYBOARD_6"] = HID_KEYBOARD_BUTTON_6; + presetKeyboardValues["KEYBOARD_7"] = HID_KEYBOARD_BUTTON_7; + presetKeyboardValues["KEYBOARD_8"] = HID_KEYBOARD_BUTTON_8; + presetKeyboardValues["KEYBOARD_9"] = HID_KEYBOARD_BUTTON_9; + presetKeyboardValues["KEYBOARD_0"] = HID_KEYBOARD_BUTTON_0; - presetKeyboardValues["KEYBOARD_RETURN"] = HID_KEYBOARD_BUTTON_RETURN; - presetKeyboardValues["KEYBOARD_ESCAPE"] = HID_KEYBOARD_BUTTON_ESCAPE; - presetKeyboardValues["KEYBOARD_DELETE"] = HID_KEYBOARD_BUTTON_DELETE; - presetKeyboardValues["KEYBOARD_TAB"] = HID_KEYBOARD_BUTTON_TAB; - presetKeyboardValues["KEYBOARD_SPACEBAR"] = HID_KEYBOARD_BUTTON_SPACEBAR; - presetKeyboardValues["KEYBOARD_CAPSLOCK"] = HID_KEYBOARD_BUTTON_CAPSLOCK; - presetKeyboardValues["KEYBOARD_PRINTSCREEN"] = HID_KEYBOARD_BUTTON_PRINTSCREEN; - presetKeyboardValues["KEYBOARD_SCROLLLOCK"] = HID_KEYBOARD_BUTTON_SCROLLLOCK; - presetKeyboardValues["KEYBOARD_PAUSE"] = HID_KEYBOARD_BUTTON_PAUSE; - presetKeyboardValues["KEYBOARD_INSERT"] = HID_KEYBOARD_BUTTON_INSERT; - presetKeyboardValues["KEYBOARD_HOME"] = HID_KEYBOARD_BUTTON_HOME; - presetKeyboardValues["KEYBOARD_PAGEUP"] = HID_KEYBOARD_BUTTON_PAGEUP; - presetKeyboardValues["KEYBOARD_PAGEDOWN"] = HID_KEYBOARD_BUTTON_PAGEDOWN; - presetKeyboardValues["KEYBOARD_DELETEFORWARD"] = HID_KEYBOARD_BUTTON_DELETEFORWARD; - presetKeyboardValues["KEYBOARD_LEFT_CONTROL"] = HID_KEYBOARD_BUTTON_LEFT_CONTROL; - presetKeyboardValues["KEYBOARD_LEFT_ALT"] = HID_KEYBOARD_BUTTON_LEFT_ALT; - presetKeyboardValues["KEYBOARD_RIGHT_CONTROL"] = HID_KEYBOARD_BUTTON_RIGHT_CONTROL; - presetKeyboardValues["KEYBOARD_RIGHT_SHIFT"] = HID_KEYBOARD_BUTTON_RIGHT_SHIFT; - presetKeyboardValues["KEYBOARD_RIGHT_ALT"] = HID_KEYBOARD_BUTTON_RIGHT_ALT; - presetKeyboardValues["KEYBOARD_END"] = HID_KEYBOARD_BUTTON_END; + presetKeyboardValues["KEYBOARD_RETURN"] = HID_KEYBOARD_BUTTON_RETURN; + presetKeyboardValues["KEYBOARD_ESCAPE"] = HID_KEYBOARD_BUTTON_ESCAPE; + presetKeyboardValues["KEYBOARD_DELETE"] = HID_KEYBOARD_BUTTON_DELETE; + presetKeyboardValues["KEYBOARD_TAB"] = HID_KEYBOARD_BUTTON_TAB; + presetKeyboardValues["KEYBOARD_SPACEBAR"] = HID_KEYBOARD_BUTTON_SPACEBAR; + presetKeyboardValues["KEYBOARD_CAPSLOCK"] = HID_KEYBOARD_BUTTON_CAPSLOCK; + presetKeyboardValues["KEYBOARD_PRINTSCREEN"] = HID_KEYBOARD_BUTTON_PRINTSCREEN; + presetKeyboardValues["KEYBOARD_SCROLLLOCK"] = HID_KEYBOARD_BUTTON_SCROLLLOCK; + presetKeyboardValues["KEYBOARD_PAUSE"] = HID_KEYBOARD_BUTTON_PAUSE; + presetKeyboardValues["KEYBOARD_INSERT"] = HID_KEYBOARD_BUTTON_INSERT; + presetKeyboardValues["KEYBOARD_HOME"] = HID_KEYBOARD_BUTTON_HOME; + presetKeyboardValues["KEYBOARD_PAGEUP"] = HID_KEYBOARD_BUTTON_PAGEUP; + presetKeyboardValues["KEYBOARD_PAGEDOWN"] = HID_KEYBOARD_BUTTON_PAGEDOWN; + presetKeyboardValues["KEYBOARD_DELETEFORWARD"] = HID_KEYBOARD_BUTTON_DELETEFORWARD; + presetKeyboardValues["KEYBOARD_LEFT_CONTROL"] = HID_KEYBOARD_BUTTON_LEFT_CONTROL; + presetKeyboardValues["KEYBOARD_LEFT_ALT"] = HID_KEYBOARD_BUTTON_LEFT_ALT; + presetKeyboardValues["KEYBOARD_RIGHT_CONTROL"] = HID_KEYBOARD_BUTTON_RIGHT_CONTROL; + presetKeyboardValues["KEYBOARD_RIGHT_SHIFT"] = HID_KEYBOARD_BUTTON_RIGHT_SHIFT; + presetKeyboardValues["KEYBOARD_RIGHT_ALT"] = HID_KEYBOARD_BUTTON_RIGHT_ALT; + presetKeyboardValues["KEYBOARD_END"] = HID_KEYBOARD_BUTTON_END; - presetKeyboardValues["KEYBOARD_LEFT"] = HID_KEYBOARD_BUTTON_LEFT; - presetKeyboardValues["KEYBOARD_RIGHT"] = HID_KEYBOARD_BUTTON_RIGHT; - presetKeyboardValues["KEYBOARD_DOWN"] = HID_KEYBOARD_BUTTON_DOWN; - presetKeyboardValues["KEYBOARD_UP"] = HID_KEYBOARD_BUTTON_UP; + presetKeyboardValues["KEYBOARD_LEFT"] = HID_KEYBOARD_BUTTON_LEFT; + presetKeyboardValues["KEYBOARD_RIGHT"] = HID_KEYBOARD_BUTTON_RIGHT; + presetKeyboardValues["KEYBOARD_DOWN"] = HID_KEYBOARD_BUTTON_DOWN; + presetKeyboardValues["KEYBOARD_UP"] = HID_KEYBOARD_BUTTON_UP; - presetKeyboardValues["KEYBOARD_KEYPAD_1"] = HID_KEYBOARD_KEYPAD_BUTTON_1; - presetKeyboardValues["KEYBOARD_KEYPAD_2"] = HID_KEYBOARD_KEYPAD_BUTTON_2; - presetKeyboardValues["KEYBOARD_KEYPAD_3"] = HID_KEYBOARD_KEYPAD_BUTTON_3; - presetKeyboardValues["KEYBOARD_KEYPAD_4"] = HID_KEYBOARD_KEYPAD_BUTTON_4; - presetKeyboardValues["KEYBOARD_KEYPAD_5"] = HID_KEYBOARD_KEYPAD_BUTTON_5; - presetKeyboardValues["KEYBOARD_KEYPAD_6"] = HID_KEYBOARD_KEYPAD_BUTTON_6; - presetKeyboardValues["KEYBOARD_KEYPAD_7"] = HID_KEYBOARD_KEYPAD_BUTTON_7; - presetKeyboardValues["KEYBOARD_KEYPAD_8"] = HID_KEYBOARD_KEYPAD_BUTTON_8; - presetKeyboardValues["KEYBOARD_KEYPAD_9"] = HID_KEYBOARD_KEYPAD_BUTTON_9; - presetKeyboardValues["KEYBOARD_KEYPAD_0"] = HID_KEYBOARD_KEYPAD_BUTTON_0; - presetKeyboardValues["KEYBOARD_KEYPAD_NUMLOCK"] = HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK; - presetKeyboardValues["KEYBOARD_KEYPAD_MINUS"] = HID_KEYBOARD_KEYPAD_BUTTON_MINUS; - presetKeyboardValues["KEYBOARD_KEYPAD_PLUS"] = HID_KEYBOARD_KEYPAD_BUTTON_PLUS; + presetKeyboardValues["KEYBOARD_KEYPAD_1"] = HID_KEYBOARD_KEYPAD_BUTTON_1; + presetKeyboardValues["KEYBOARD_KEYPAD_2"] = HID_KEYBOARD_KEYPAD_BUTTON_2; + presetKeyboardValues["KEYBOARD_KEYPAD_3"] = HID_KEYBOARD_KEYPAD_BUTTON_3; + presetKeyboardValues["KEYBOARD_KEYPAD_4"] = HID_KEYBOARD_KEYPAD_BUTTON_4; + presetKeyboardValues["KEYBOARD_KEYPAD_5"] = HID_KEYBOARD_KEYPAD_BUTTON_5; + presetKeyboardValues["KEYBOARD_KEYPAD_6"] = HID_KEYBOARD_KEYPAD_BUTTON_6; + presetKeyboardValues["KEYBOARD_KEYPAD_7"] = HID_KEYBOARD_KEYPAD_BUTTON_7; + presetKeyboardValues["KEYBOARD_KEYPAD_8"] = HID_KEYBOARD_KEYPAD_BUTTON_8; + presetKeyboardValues["KEYBOARD_KEYPAD_9"] = HID_KEYBOARD_KEYPAD_BUTTON_9; + presetKeyboardValues["KEYBOARD_KEYPAD_0"] = HID_KEYBOARD_KEYPAD_BUTTON_0; + presetKeyboardValues["KEYBOARD_KEYPAD_NUMLOCK"] = HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK; + presetKeyboardValues["KEYBOARD_KEYPAD_MINUS"] = HID_KEYBOARD_KEYPAD_BUTTON_MINUS; + presetKeyboardValues["KEYBOARD_KEYPAD_PLUS"] = HID_KEYBOARD_KEYPAD_BUTTON_PLUS; - presetValues["VPAD_L_STICK"] = DEF_L_STICK; - presetValues["VPAD_R_STICK"] = DEF_R_STICK; + presetValues["VPAD_L_STICK"] = DEF_L_STICK; + presetValues["VPAD_R_STICK"] = DEF_R_STICK; - presetValues["DPAD_NORMAL"] = CONTRPDM_Normal; - presetValues["DPAD_HAT"] = CONTRPDM_Hat; - presetValues["DPAD_ABSOLUTE_2VALUES"] = CONTRPDM_Absolute_2Values; - presetValues["TRUE"] = 1; - presetValues["YES"] = 1; - presetValues["ON"] = 1; - presetValues["FALSE"] = 0; - presetValues["NO"] = 0; - presetValues["OFF"] = 0; + presetValues["DPAD_NORMAL"] = CONTRPDM_Normal; + presetValues["DPAD_HAT"] = CONTRPDM_Hat; + presetValues["DPAD_ABSOLUTE_2VALUES"] = CONTRPDM_Absolute_2Values; + presetValues["TRUE"] = 1; + presetValues["YES"] = 1; + presetValues["ON"] = 1; + presetValues["FALSE"] = 0; + presetValues["NO"] = 0; + presetValues["OFF"] = 0; - presetSticks["GC_STICK_L_X"] = HID_GC_STICK_L_X; - presetSticks["GC_STICK_L_Y"] = HID_GC_STICK_L_Y; - presetSticks["GC_STICK_R_X"] = HID_GC_STICK_R_X; - presetSticks["GC_STICK_R_Y"] = HID_GC_STICK_R_Y; + presetSticks["GC_STICK_L_X"] = HID_GC_STICK_L_X; + presetSticks["GC_STICK_L_Y"] = HID_GC_STICK_L_Y; + presetSticks["GC_STICK_R_X"] = HID_GC_STICK_R_X; + presetSticks["GC_STICK_R_Y"] = HID_GC_STICK_R_Y; - presetSticks["DS3_STICK_L_X"] = HID_DS3_STICK_L_X; - presetSticks["DS3_STICK_L_Y"] = HID_DS3_STICK_L_Y; - presetSticks["DS3_STICK_R_X"] = HID_DS3_STICK_R_X; - presetSticks["DS3_STICK_R_Y"] = HID_DS3_STICK_R_Y; + presetSticks["DS3_STICK_L_X"] = HID_DS3_STICK_L_X; + presetSticks["DS3_STICK_L_Y"] = HID_DS3_STICK_L_Y; + presetSticks["DS3_STICK_R_X"] = HID_DS3_STICK_R_X; + presetSticks["DS3_STICK_R_Y"] = HID_DS3_STICK_R_Y; - presetSticks["DS4_STICK_L_X"] = HID_DS4_STICK_L_X; - presetSticks["DS4_STICK_L_Y"] = HID_DS4_STICK_L_Y; - presetSticks["DS4_STICK_R_X"] = HID_DS4_STICK_R_X; - presetSticks["DS4_STICK_R_Y"] = HID_DS4_STICK_R_Y; + presetSticks["DS4_STICK_L_X"] = HID_DS4_STICK_L_X; + presetSticks["DS4_STICK_L_Y"] = HID_DS4_STICK_L_Y; + presetSticks["DS4_STICK_R_X"] = HID_DS4_STICK_R_X; + presetSticks["DS4_STICK_R_Y"] = HID_DS4_STICK_R_Y; - presetSticks["XINPUT_STICK_L_X"] = HID_XINPUT_STICK_L_X; - presetSticks["XINPUT_STICK_L_Y"] = HID_XINPUT_STICK_L_Y; - presetSticks["XINPUT_STICK_R_X"] = HID_XINPUT_STICK_R_X; - presetSticks["XINPUT_STICK_R_Y"] = HID_XINPUT_STICK_R_Y; + presetSticks["XINPUT_STICK_L_X"] = HID_XINPUT_STICK_L_X; + presetSticks["XINPUT_STICK_L_Y"] = HID_XINPUT_STICK_L_Y; + presetSticks["XINPUT_STICK_R_X"] = HID_XINPUT_STICK_R_X; + presetSticks["XINPUT_STICK_R_Y"] = HID_XINPUT_STICK_R_Y; - presetSticks["SWITCH_PRO_STICK_L_X"] = HID_SWITCH_PRO_BT_STICK_L_X; - presetSticks["SWITCH_PRO_STICK_L_Y"] = HID_SWITCH_PRO_BT_STICK_L_Y; - presetSticks["SWITCH_PRO_STICK_R_X"] = HID_SWITCH_PRO_BT_STICK_R_X; - presetSticks["SWITCH_PRO_STICK_R_Y"] = HID_SWITCH_PRO_BT_STICK_R_Y; + presetSticks["SWITCH_PRO_STICK_L_X"] = HID_SWITCH_PRO_BT_STICK_L_X; + presetSticks["SWITCH_PRO_STICK_L_Y"] = HID_SWITCH_PRO_BT_STICK_L_Y; + presetSticks["SWITCH_PRO_STICK_R_X"] = HID_SWITCH_PRO_BT_STICK_R_X; + presetSticks["SWITCH_PRO_STICK_R_Y"] = HID_SWITCH_PRO_BT_STICK_R_Y; - presetSticks["GC_DPAD_MODE"] = HID_GC_BUTTON_DPAD_TYPE; - presetSticks["DS3_DPAD_MODE"] = HID_DS3_BUTTON_DPAD_TYPE; - presetSticks["DS4_DPAD_MODE"] = HID_DS4_BUTTON_DPAD_TYPE; - presetSticks["XINPUT_DPAD_MODE"] = HID_XINPUT_BUTTON_DPAD_TYPE; - presetSticks["SWITCH_PRO_DPAD_MODE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE; + presetSticks["GC_DPAD_MODE"] = HID_GC_BUTTON_DPAD_TYPE; + presetSticks["DS3_DPAD_MODE"] = HID_DS3_BUTTON_DPAD_TYPE; + presetSticks["DS4_DPAD_MODE"] = HID_DS4_BUTTON_DPAD_TYPE; + presetSticks["XINPUT_DPAD_MODE"] = HID_XINPUT_BUTTON_DPAD_TYPE; + presetSticks["SWITCH_PRO_DPAD_MODE"] = HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L; - gGamePadValuesToCONTRPSString["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L; + gGamePadValuesToCONTRPSString["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV; - gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT; + gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT; gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_R_EMULATION_RIGHT; - gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP; - gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN; - gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT; + gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP; + gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN; + gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT; gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_L_EMULATION_RIGHT; - gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP; - gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN; + gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP; + gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN; - deviceNames[StringTools::strfmt("%04X%04X",HID_GC_VID, HID_GC_PID).c_str()] = HID_GC_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_KEYBOARD_VID, HID_KEYBOARD_PID).c_str()] = HID_KEYBOARD_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_MOUSE_VID, HID_MOUSE_PID).c_str()] = HID_MOUSE_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_DS3_VID, HID_DS3_PID).c_str()] = HID_DS3_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_NEW_DS4_VID, HID_NEW_DS4_PID).c_str()] = HID_NEW_DS4_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_DS4_VID, HID_DS4_PID).c_str()] = HID_DS4_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_XINPUT_VID, HID_XINPUT_PID).c_str()] = HID_XINPUT_STRING; - deviceNames[StringTools::strfmt("%04X%04X",HID_SWITCH_PRO_VID,HID_SWITCH_PRO_PID).c_str()] = HID_SWITCH_PRO_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_GC_VID, HID_GC_PID).c_str()] = HID_GC_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_KEYBOARD_VID, HID_KEYBOARD_PID).c_str()] = HID_KEYBOARD_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_MOUSE_VID, HID_MOUSE_PID).c_str()] = HID_MOUSE_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_DS3_VID, HID_DS3_PID).c_str()] = HID_DS3_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_NEW_DS4_VID, HID_NEW_DS4_PID).c_str()] = HID_NEW_DS4_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_DS4_VID, HID_DS4_PID).c_str()] = HID_DS4_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_XINPUT_VID, HID_XINPUT_PID).c_str()] = HID_XINPUT_STRING; + deviceNames[StringTools::strfmt("%04X%04X", HID_SWITCH_PRO_VID, HID_SWITCH_PRO_PID).c_str()] = HID_SWITCH_PRO_STRING; } - const uint8_t * getValuesForPreset(std::map values,std::string possibleValue); + const uint8_t *getValuesForPreset(std::map values, std::string possibleValue); - BOOL setIfValueIsPreset(std::map values,std::string possibleValue,int32_t slot,int32_t keyslot); - BOOL setIfValueIsAControllerPresetEx(std::string value,int32_t slot,int32_t keyslot); + BOOL setIfValueIsPreset(std::map values, std::string possibleValue, int32_t slot, int32_t keyslot); + BOOL setIfValueIsAControllerPresetEx(std::string value, int32_t slot, int32_t keyslot); - void addDeviceNameEx(uint16_t vid,uint16_t pid,std::string value); - std::string getStringByVIDPIDEx(uint16_t vid,uint16_t pid); + void addDeviceNameEx(uint16_t vid, uint16_t pid, std::string value); + std::string getStringByVIDPIDEx(uint16_t vid, uint16_t pid); }; #endif diff --git a/source/fs/CFile.cpp b/source/fs/CFile.cpp index c562f11..9ce23f5 100644 --- a/source/fs/CFile.cpp +++ b/source/fs/CFile.cpp @@ -1,13 +1,13 @@ +#include "CFile.hpp" #include #include #include -#include "CFile.hpp" CFile::CFile() { - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } CFile::CFile(const std::string &filepath, eOpenTypes mode) { @@ -33,7 +33,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) { switch (mode) { default: - case ReadOnly: // file must exist + case ReadOnly: // file must exist openMode = O_RDONLY; break; case WriteOnly: // file will be created / zerod @@ -75,10 +75,10 @@ void CFile::close() { if (iFd >= 0) ::close(iFd); - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } int32_t CFile::read(uint8_t *ptr, size_t size) { @@ -125,7 +125,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) { } int32_t CFile::seek(long int offset, int32_t origin) { - int32_t ret = 0; + int32_t ret = 0; int64_t newPos = pos; if (origin == SEEK_SET) { @@ -156,7 +156,7 @@ int32_t CFile::seek(long int offset, int32_t origin) { int32_t CFile::fwrite(const char *format, ...) { char tmp[512]; - tmp[0] = 0; + tmp[0] = 0; int32_t result = -1; va_list va; @@ -169,5 +169,3 @@ int32_t CFile::fwrite(const char *format, ...) { return result; } - - diff --git a/source/fs/CFile.hpp b/source/fs/CFile.hpp index 6c0421b..2bc9dfc 100644 --- a/source/fs/CFile.hpp +++ b/source/fs/CFile.hpp @@ -1,10 +1,10 @@ #ifndef CFILE_HPP_ #define CFILE_HPP_ -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/source/fs/FSUtils.cpp b/source/fs/FSUtils.cpp index fbb201f..a02b234 100644 --- a/source/fs/FSUtils.cpp +++ b/source/fs/FSUtils.cpp @@ -1,11 +1,11 @@ -#include -#include -#include -#include -#include #include "FSUtils.h" #include "CFile.hpp" #include "utils/logger.h" +#include +#include +#include +#include +#include int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) { //! always initialze input @@ -27,8 +27,8 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_ } uint32_t blocksize = 0x4000; - uint32_t done = 0; - int32_t readBytes = 0; + uint32_t done = 0; + int32_t readBytes = 0; while (done < filesize) { if (done + blocksize > filesize) { @@ -136,7 +136,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) { size_t size; int source = open(in.c_str(), O_RDONLY, 0); - int dest = open(out.c_str(), 0x602, 0644); + int dest = open(out.c_str(), 0x602, 0644); if (source < 0) { return false; } @@ -146,7 +146,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) { } auto bufferSize = 1024 * 1024; - char *buf = (char *) malloc(bufferSize); + char *buf = (char *) malloc(bufferSize); if (buf == NULL) { return false; } @@ -171,4 +171,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, const void *buffer, uint32_t file.close(); return written; } - diff --git a/source/fs/FSUtils.h b/source/fs/FSUtils.h index 5aa7860..0ef2d68 100644 --- a/source/fs/FSUtils.h +++ b/source/fs/FSUtils.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class FSUtils { public: diff --git a/source/network/CPTCPServer.cpp b/source/network/CPTCPServer.cpp index 80ffffc..01b002d 100644 --- a/source/network/CPTCPServer.cpp +++ b/source/network/CPTCPServer.cpp @@ -15,16 +15,16 @@ * along with this program. If not, see . ****************************************************************************/ #include "CPTCPServer.hpp" -#include #include +#include #include #include #include -CPTCPServer * CPTCPServer::instance = NULL; +CPTCPServer *CPTCPServer::instance = NULL; -CPTCPServer::CPTCPServer(int32_t port): TCPServer(port,CPTCPServer::getPriority()) { +CPTCPServer::CPTCPServer(int32_t port) : TCPServer(port, CPTCPServer::getPriority()) { CPTCPServer::AttachDetach(HID_DEVICE_DETACH); } @@ -33,34 +33,34 @@ CPTCPServer::~CPTCPServer() { } void CPTCPServer::AttachDetach(HIDAttachEvent attach) { - if(HID_DEBUG) { - if(attach) { + if (HID_DEBUG) { + if (attach) { DEBUG_FUNCTION_LINE("Network Attach"); } else { DEBUG_FUNCTION_LINE("Network Detach"); } } - for(int32_t i= 0; i< gHIDMaxDevices; i++) { - for(int32_t j= 0; j< HID_MAX_PADS_COUNT; j++) { - if(gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0) { - DEBUG_FUNCTION_LINE("Found a registered pad in deviceslot %d and padslot %d! Lets detach it.",i,j); + for (int32_t i = 0; i < gHIDMaxDevices; i++) { + for (int32_t j = 0; j < HID_MAX_PADS_COUNT; j++) { + if (gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0) { + DEBUG_FUNCTION_LINE("Found a registered pad in deviceslot %d and padslot %d! Lets detach it.", i, j); HIDDevice device; - memset(&device,0,sizeof(device)); + memset(&device, 0, sizeof(device)); - device.interfaceIndex = 0; - device.vid = gNetworkController[i][j][NETWORK_CONTROLLER_VID]; - device.pid = gNetworkController[i][j][NETWORK_CONTROLLER_PID]; - device.handle = gNetworkController[i][j][NETWORK_CONTROLLER_HANDLE]; + device.interfaceIndex = 0; + device.vid = gNetworkController[i][j][NETWORK_CONTROLLER_VID]; + device.pid = gNetworkController[i][j][NETWORK_CONTROLLER_PID]; + device.handle = gNetworkController[i][j][NETWORK_CONTROLLER_HANDLE]; device.maxPacketSizeRx = 8; - ControllerPatcherHID::externAttachDetachCallback(&device,attach); - memset(gNetworkController[i][j],0,sizeof(gNetworkController[i][j])); + ControllerPatcherHID::externAttachDetachCallback(&device, attach); + memset(gNetworkController[i][j], 0, sizeof(gNetworkController[i][j])); } } } - if(HID_DEBUG) { - if(attach) { + if (HID_DEBUG) { + if (attach) { DEBUG_FUNCTION_LINE("Network Attach DONE!"); } else { DEBUG_FUNCTION_LINE("Network Detach DONE!"); @@ -70,19 +70,19 @@ void CPTCPServer::AttachDetach(HIDAttachEvent attach) { void CPTCPServer::DetachAndDelete() { CPTCPServer::AttachDetach(HID_DEVICE_DETACH); - memset(&gNetworkController,0,sizeof(gNetworkController)); + memset(&gNetworkController, 0, sizeof(gNetworkController)); } BOOL CPTCPServer::whileLoop() { int32_t ret; int32_t clientfd = getClientFD(); while (1) { - if(shouldExit()) { + if (shouldExit()) { break; } ret = checkbyte(clientfd); if (ret < 0) { - if(errno != EWOULDBLOCK) { + if (errno != EWOULDBLOCK) { return false; } OSSleepTicks(OSMicrosecondsToTicks(1000)); @@ -90,172 +90,172 @@ BOOL CPTCPServer::whileLoop() { } //DEBUG_FUNCTION_LINE("got byte from tcp! %01X",ret); switch (ret) { - case WIIU_CP_TCP_ATTACH: { /*attach */ - if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { - int32_t handle; - ret = recvwait(clientfd, &handle, 4); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle",WIIU_CP_TCP_ATTACH); - return false; - } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("got handle %d",handle); - } - uint16_t vid = 0; - uint16_t pid = 0; - ret = recvwait(clientfd, &vid, 2); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: recvwait vid",WIIU_CP_TCP_ATTACH); - return false; - } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("got vid %04X",vid); - } - - ret = recvwait(clientfd, &pid, 2); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: recvwait pid",WIIU_CP_TCP_ATTACH); - return false; - } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("got pid %04X",pid); - } - HIDDevice device; - memset(&device,0,sizeof(device)); - device.handle = handle; - device.interfaceIndex = 0; - device.vid = SWAP16(vid); - device.pid = SWAP16(pid); - device.maxPacketSizeRx = 8; - - my_cb_user * user = NULL; - ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_ATTACH); - if((ret = ControllerPatcherUtils::getDataByHandle(handle,&user)) < 0) { - 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.",WIIU_CP_TCP_ATTACH); - 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.",WIIU_CP_TCP_ATTACH,ret); - } - return false; - } - 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.",WIIU_CP_TCP_ATTACH,ret); - return false; - } - if(user != NULL) { - 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.",WIIU_CP_TCP_ATTACH,ret); + case WIIU_CP_TCP_ATTACH: { /*attach */ + if (gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { + int32_t handle; + ret = recvwait(clientfd, &handle, 4); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle", WIIU_CP_TCP_ATTACH); return false; } + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("got handle %d", handle); + } + uint16_t vid = 0; + uint16_t pid = 0; + ret = recvwait(clientfd, &vid, 2); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: recvwait vid", WIIU_CP_TCP_ATTACH); + return false; + } + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("got vid %04X", vid); + } - ret = sendwait(clientfd,&user->slotdata.deviceslot,2); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: sendwait slotdata: %04X",WIIU_CP_TCP_ATTACH,user->slotdata.deviceslot); + ret = recvwait(clientfd, &pid, 2); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: recvwait pid", WIIU_CP_TCP_ATTACH); return false; } - ret = sendwait(clientfd,&user->pad_slot,1); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: sendwait pad_slot: %04X",WIIU_CP_TCP_ATTACH,user->pad_slot); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("got pid %04X", pid); + } + HIDDevice device; + memset(&device, 0, sizeof(device)); + device.handle = handle; + device.interfaceIndex = 0; + device.vid = SWAP16(vid); + device.pid = SWAP16(pid); + device.maxPacketSizeRx = 8; + + my_cb_user *user = NULL; + ControllerPatcherHID::externAttachDetachCallback(&device, HID_DEVICE_ATTACH); + if ((ret = ControllerPatcherUtils::getDataByHandle(handle, &user)) < 0) { + 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.", WIIU_CP_TCP_ATTACH); + 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.", WIIU_CP_TCP_ATTACH, ret); + } return false; } - } else { - 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)) { - DEBUG_FUNCTION_LINE("Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_BAD byte failed. Error: %d.",WIIU_CP_TCP_ATTACH,ret); + 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.", WIIU_CP_TCP_ATTACH, ret); return false; } - return false; + if (user != NULL) { + 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.", WIIU_CP_TCP_ATTACH, ret); + return false; + } + + ret = sendwait(clientfd, &user->slotdata.deviceslot, 2); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: sendwait slotdata: %04X", WIIU_CP_TCP_ATTACH, user->slotdata.deviceslot); + return false; + } + ret = sendwait(clientfd, &user->pad_slot, 1); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: sendwait pad_slot: %04X", WIIU_CP_TCP_ATTACH, user->pad_slot); + return false; + } + } else { + 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)) { + 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; + break; + } + + if (HID_DEBUG) { + 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_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) { + DEBUG_FUNCTION_LINE("handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d", handle, vid, pid, user->slotdata.deviceslot, user->pad_slot); + } break; } - - if(HID_DEBUG) { - 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_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) { - 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; - } - case WIIU_CP_TCP_DETACH: { /*detach */ - if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { - int32_t handle; - ret = recvwait(clientfd, &handle, 4); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle",WIIU_CP_TCP_DETACH); - return false; - break; - } + case WIIU_CP_TCP_DETACH: { /*detach */ + if (gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { + int32_t handle; + ret = recvwait(clientfd, &handle, 4); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: recvwait handle", WIIU_CP_TCP_DETACH); + return false; + break; + } - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("got detach for handle: %d",handle); - } - my_cb_user * user = NULL; - if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).",WIIU_CP_TCP_DETACH,handle,&user); - return false; - break; - } - if(user == NULL) { - DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.",WIIU_CP_TCP_DETACH); - return false; - break; - } - int32_t deviceslot = user->slotdata.deviceslot; - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("device slot is: %d , pad slot is: %d",deviceslot,user->pad_slot); - } + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("got detach for handle: %d", handle); + } + my_cb_user *user = NULL; + if (ControllerPatcherUtils::getDataByHandle(handle, &user) < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: getDataByHandle(%d,%08X).", WIIU_CP_TCP_DETACH, handle, &user); + return false; + break; + } + if (user == NULL) { + DEBUG_FUNCTION_LINE("Error in %02X: invalid user data.", WIIU_CP_TCP_DETACH); + return false; + break; + } + int32_t deviceslot = user->slotdata.deviceslot; + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("device slot is: %d , pad slot is: %d", deviceslot, user->pad_slot); + } - DeviceVIDPIDInfo vidpid; - int32_t result; - 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",WIIU_CP_TCP_DETACH,deviceslot,ret); - return false; + DeviceVIDPIDInfo vidpid; + int32_t result; + 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", WIIU_CP_TCP_DETACH, deviceslot, ret); + return false; + break; + } + + HIDDevice device; + memset(&device, 0, sizeof(device)); + device.handle = handle; + device.interfaceIndex = 0; + device.vid = SWAP16(vidpid.vid); + device.pid = SWAP16(vidpid.pid); + device.maxPacketSizeRx = 14; + + ControllerPatcherHID::externAttachDetachCallback(&device, HID_DEVICE_DETACH); + memset(gNetworkController[deviceslot][user->pad_slot], 0, sizeof(gNetworkController[deviceslot][user->pad_slot])); + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("handle %d disconnected!", handle); + } break; } - - HIDDevice device; - memset(&device,0,sizeof(device)); - device.handle = handle; - device.interfaceIndex = 0; - device.vid = SWAP16(vidpid.vid); - device.pid = SWAP16(vidpid.pid); - device.maxPacketSizeRx = 14; - - ControllerPatcherHID::externAttachDetachCallback(&device,HID_DEVICE_DETACH); - memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot])); - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("handle %d disconnected!",handle); - } break; } - break; - } - case WIIU_CP_TCP_PING: { /*ping*/ - if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("Got Ping, sending now a Pong"); - } - int32_t ret = sendbyte(clientfd, WIIU_CP_TCP_PONG); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error in %02X: sendbyte PONG"); - return false; - } + case WIIU_CP_TCP_PING: { /*ping*/ + if (gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { + if (HID_DEBUG) { + DEBUG_FUNCTION_LINE("Got Ping, sending now a Pong"); + } + int32_t ret = sendbyte(clientfd, WIIU_CP_TCP_PONG); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error in %02X: sendbyte PONG"); + return false; + } + break; + } break; } - break; - } - default: - return false; - break; + default: + return false; + break; } } return true; @@ -263,37 +263,37 @@ BOOL CPTCPServer::whileLoop() { BOOL CPTCPServer::acceptConnection() { int32_t clientfd = getClientFD(); - 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); + 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; UDPClient::createInstance(); int32_t ret; ret = sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE); //Hey I'm a WiiU console! - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error sendbyte: %02X",WIIU_CP_TCP_HANDSHAKE); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error sendbyte: %02X", WIIU_CP_TCP_HANDSHAKE); return false; } uint8_t clientProtocolVersion = recvbyte(clientfd); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error recvbyte: %02X",WIIU_CP_TCP_HANDSHAKE); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error recvbyte: %02X", WIIU_CP_TCP_HANDSHAKE); 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."); return false; } - DEBUG_FUNCTION_LINE("received protocol version: %d (0x%02X)",(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."); gUsedProtocolVersion = clientProtocolVersion; - ret = sendbyte(clientfd, clientProtocolVersion); - if(ret < 0) { - DEBUG_FUNCTION_LINE("Error sendbyte: %02X",clientProtocolVersion); + ret = sendbyte(clientfd, clientProtocolVersion); + if (ret < 0) { + DEBUG_FUNCTION_LINE("Error sendbyte: %02X", clientProtocolVersion); return false; } } else { diff --git a/source/network/CPTCPServer.hpp b/source/network/CPTCPServer.hpp index 0046c64..468a3fe 100644 --- a/source/network/CPTCPServer.hpp +++ b/source/network/CPTCPServer.hpp @@ -19,12 +19,12 @@ #include "../ControllerPatcherIncludes.hpp" -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #define WIIU_CP_TCP_HANDSHAKE WIIU_CP_TCP_HANDSHAKE_VERSION_3 @@ -35,26 +35,26 @@ #define WIIU_CP_TCP_HANDSHAKE_VERSION_2 0x13 #define WIIU_CP_TCP_HANDSHAKE_VERSION_3 0x14 -#define WIIU_CP_TCP_HANDSHAKE_ABORT 0x30 +#define WIIU_CP_TCP_HANDSHAKE_ABORT 0x30 -#define WIIU_CP_TCP_ATTACH 0x01 -#define WIIU_CP_TCP_DETACH 0x02 -#define WIIU_CP_TCP_PING 0xF0 -#define WIIU_CP_TCP_PONG 0xF1 +#define WIIU_CP_TCP_ATTACH 0x01 +#define WIIU_CP_TCP_DETACH 0x02 +#define WIIU_CP_TCP_PING 0xF0 +#define WIIU_CP_TCP_PONG 0xF1 -#define WIIU_CP_TCP_ATTACH_CONFIG_FOUND 0xE0 -#define WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND 0xE1 -#define WIIU_CP_TCP_ATTACH_USER_DATA_OKAY 0xE8 -#define WIIU_CP_TCP_ATTACH_USER_DATA_BAD 0xE9 +#define WIIU_CP_TCP_ATTACH_CONFIG_FOUND 0xE0 +#define WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND 0xE1 +#define WIIU_CP_TCP_ATTACH_USER_DATA_OKAY 0xE8 +#define WIIU_CP_TCP_ATTACH_USER_DATA_BAD 0xE9 -#define DEFAULT_TCP_PORT 8112 +#define DEFAULT_TCP_PORT 8112 -class CPTCPServer: TCPServer { +class CPTCPServer : TCPServer { friend class ControllerPatcher; private: static CPTCPServer *getInstance() { - if(!instance) { + if (!instance) { instance = new CPTCPServer(DEFAULT_TCP_PORT); } @@ -62,7 +62,7 @@ private: } static void destroyInstance() { - if(instance) { + if (instance) { delete instance; instance = NULL; } @@ -70,13 +70,13 @@ private: static int32_t getPriority() { int32_t priority = 28; - if(OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN - OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA - OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR - OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR - OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA + if (OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN + OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA + OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR + OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR + OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA priority = 10; - DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d",priority); + DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d", priority); } return priority; } @@ -97,8 +97,7 @@ private: virtual void onConnectionClosed(); - static CPTCPServer * instance; - + static CPTCPServer *instance; }; #endif //_TCPSERVER_WINDOW_H_ diff --git a/source/network/UDPClient.cpp b/source/network/UDPClient.cpp index 976db9f..3a04c84 100644 --- a/source/network/UDPClient.cpp +++ b/source/network/UDPClient.cpp @@ -23,7 +23,7 @@ #define MAX_UDP_SIZE 0x578 -UDPClient * UDPClient::instance = NULL; +UDPClient *UDPClient::instance = NULL; UDPClient::UDPClient(uint32_t ip, int32_t port) { sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); @@ -32,11 +32,11 @@ UDPClient::UDPClient(uint32_t ip, int32_t port) { struct sockaddr_in connect_addr; memset(&connect_addr, 0, sizeof(connect_addr)); - connect_addr.sin_family = AF_INET; - connect_addr.sin_port = port; + connect_addr.sin_family = AF_INET; + 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) { close(sockfd); sockfd = -1; } @@ -46,16 +46,16 @@ UDPClient::~UDPClient() { if (this->sockfd != -1) { close(sockfd); } - if(HID_DEBUG) { - log_printf("UDPClient::~UDPClient(line %d): Thread has been closed",__LINE__); + if (HID_DEBUG) { + log_printf("UDPClient::~UDPClient(line %d): Thread has been closed", __LINE__); } } -BOOL UDPClient::sendData(char * data,int32_t length) { - if(sockfd < 0 || data == 0 || length < 0 || gUsedProtocolVersion < WIIU_CP_TCP_HANDSHAKE_VERSION_3) { +BOOL UDPClient::sendData(char *data, int32_t length) { + if (sockfd < 0 || data == 0 || length < 0 || gUsedProtocolVersion < WIIU_CP_TCP_HANDSHAKE_VERSION_3) { return false; } - if(length > 1400) length = 1400; + if (length > 1400) length = 1400; int32_t ret = send(sockfd, data, length, 0); return (ret >= 0); diff --git a/source/network/UDPClient.hpp b/source/network/UDPClient.hpp index 586248d..006d6cd 100644 --- a/source/network/UDPClient.hpp +++ b/source/network/UDPClient.hpp @@ -18,20 +18,20 @@ #define _UDPCLIENT_WINDOW_H_ #include "../ControllerPatcherIncludes.hpp" -#include #include +#include -#define DEFAULT_UDP_CLIENT_PORT 8114 +#define DEFAULT_UDP_CLIENT_PORT 8114 class UDPClient { friend class ControllerPatcher; friend class ControllerPatcherHID; friend class CPTCPServer; -public: +public: private: static UDPClient *getInstance() { - if(instance == NULL) { + if (instance == NULL) { createInstance(); } return instance; @@ -39,24 +39,24 @@ private: static UDPClient *createInstance() { - if(instance != NULL) { + if (instance != NULL) { destroyInstance(); } - instance = new UDPClient(gUDPClientip,DEFAULT_UDP_CLIENT_PORT); + instance = new UDPClient(gUDPClientip, DEFAULT_UDP_CLIENT_PORT); - return getInstance(); + return getInstance(); } static void destroyInstance() { - if(instance != NULL) { + if (instance != NULL) { delete instance; instance = NULL; } } - UDPClient(uint32_t ip,int32_t port); + UDPClient(uint32_t ip, int32_t port); ~UDPClient(); - BOOL sendData(char * data, int32_t length); + BOOL sendData(char *data, int32_t length); volatile int32_t sockfd = -1; struct sockaddr_in addr; diff --git a/source/network/UDPServer.cpp b/source/network/UDPServer.cpp index 48ade89..082b4d0 100644 --- a/source/network/UDPServer.cpp +++ b/source/network/UDPServer.cpp @@ -23,32 +23,32 @@ #define MAX_UDP_SIZE 0x578 -CThread * UDPServer::pThread = NULL; -UDPServer * UDPServer::instance = NULL; +CThread *UDPServer::pThread = NULL; +UDPServer *UDPServer::instance = NULL; UDPServer::UDPServer(int32_t port) { int32_t ret; struct sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_port = port; + addr.sin_family = AF_INET; + addr.sin_port = port; addr.sin_addr.s_addr = 0; this->sockfd = ret = socket(AF_INET, SOCK_DGRAM, 0); - if(ret == -1) return; + if (ret == -1) return; int32_t enable = 1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); - ret = bind(sockfd, (sockaddr *)&addr, 16); - if(ret < 0) return; + ret = bind(sockfd, (sockaddr *) &addr, 16); + if (ret < 0) return; StartUDPThread(this); } UDPServer::~UDPServer() { - CThread * pThreadPointer = UDPServer::pThread; - if(pThreadPointer != NULL) { + CThread *pThreadPointer = UDPServer::pThread; + if (pThreadPointer != NULL) { exitThread = 1; - if(pThreadPointer != NULL) { + if (pThreadPointer != NULL) { delete pThreadPointer; UDPServer::pThread = NULL; if (this->sockfd != -1) { @@ -57,39 +57,37 @@ UDPServer::~UDPServer() { this->sockfd = -1; } } - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Thread has been closed"); } - - } -void UDPServer::StartUDPThread(UDPServer * server) { +void UDPServer::StartUDPThread(UDPServer *server) { int32_t priority = 28; - if(OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN - OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA - OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR - OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR - OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA + if (OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN + OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA + OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR + OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR + OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA priority = 10; - DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d",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(); } -BOOL UDPServer::cpyIncrementBufferOffset(void * target, void * source, int32_t * offset, int32_t typesize, int32_t maximum) { - if(((int)*offset + typesize) > maximum) { - DEBUG_FUNCTION_LINE("Transfer error. Excepted %04X bytes, but only got %04X",(*offset + typesize),maximum); +BOOL UDPServer::cpyIncrementBufferOffset(void *target, void *source, int32_t *offset, int32_t typesize, int32_t maximum) { + if (((int) *offset + typesize) > maximum) { + DEBUG_FUNCTION_LINE("Transfer error. Excepted %04X bytes, but only got %04X", (*offset + typesize), maximum); return false; } - memcpy(target,(void*)((uint32_t)source+(*offset)),typesize); + memcpy(target, (void *) ((uint32_t) source + (*offset)), typesize); *offset += typesize; return true; } void UDPServer::DoUDPThread(CThread *thread, void *arg) { - UDPServer * args = (UDPServer * )arg; + UDPServer *args = (UDPServer *) arg; args->DoUDPThreadInternal(); } @@ -97,75 +95,75 @@ void UDPServer::DoUDPThreadInternal() { uint8_t buffer[MAX_UDP_SIZE]; int32_t n; - my_cb_user user; - while(1) { + my_cb_user user; + while (1) { //int32_t usingVar = exitThread; - if(exitThread)break; - memset(buffer,0,MAX_UDP_SIZE); - n = recv(sockfd,buffer,MAX_UDP_SIZE,0); + if (exitThread) break; + memset(buffer, 0, MAX_UDP_SIZE); + n = recv(sockfd, buffer, MAX_UDP_SIZE, 0); if (n < 0) { int32_t errno_ = errno; OSSleepTicks(OSMicrosecondsToTicks(2000)); - if(errno_ != EINVAL && errno_ != ENOTCONN) { + if (errno_ != EINVAL && errno_ != ENOTCONN) { break; } continue; } int32_t bufferoffset = 0; uint8_t type; - memcpy((void *)&type,buffer,sizeof(type)); + memcpy((void *) &type, buffer, sizeof(type)); bufferoffset += sizeof(type); switch (buffer[0]) { - case WIIU_CP_UDP_CONTROLLER_READ_DATA: { - if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { - uint8_t count_commands; - memcpy((void *)&count_commands,buffer+bufferoffset,sizeof(count_commands)); - bufferoffset += sizeof(count_commands); - for(int32_t i = 0; i= WIIU_CP_TCP_HANDSHAKE_VERSION_1) { + uint8_t count_commands; + memcpy((void *) &count_commands, buffer + bufferoffset, sizeof(count_commands)); + bufferoffset += sizeof(count_commands); + for (int32_t i = 0; i < count_commands; i++) { + int32_t handle; + uint16_t deviceSlot; + uint32_t hid; + uint8_t padslot; + uint8_t datasize; - if(!cpyIncrementBufferOffset((void *)&handle, (void *)buffer,&bufferoffset,sizeof(handle), n))continue; - if(!cpyIncrementBufferOffset((void *)&deviceSlot, (void *)buffer,&bufferoffset,sizeof(deviceSlot),n))continue; - hid = (1 << deviceSlot); - if(!cpyIncrementBufferOffset((void *)&padslot, (void *)buffer,&bufferoffset,sizeof(padslot), n))continue; - if(!cpyIncrementBufferOffset((void *)&datasize, (void *)buffer,&bufferoffset,sizeof(datasize), n))continue; - uint8_t * databuffer = (uint8_t*) malloc(datasize * sizeof(uint8_t)); - if(!databuffer) { - DEBUG_FUNCTION_LINE("Allocating memory failed"); - continue; - } - - if(!cpyIncrementBufferOffset((void *)databuffer, (void *)buffer,&bufferoffset,datasize, n))continue; - //DEBUG_FUNCTION_LINE("UDPServer::DoUDPThreadInternal(): Got handle: %d slot %04X hid %04X pad %02X datasize %02X\n",handle,deviceSlot,hid,padslot,datasize); - - user.pad_slot = padslot; - user.slotdata.deviceslot = deviceSlot; - user.slotdata.hidmask = hid; - - if(gNetworkController[deviceSlot][padslot][0] == 0) { - DEBUG_FUNCTION_LINE("Ehm. Pad is not connected. STOP SENDING DATA ;) \n"); - } else { - ControllerPatcherHID::externHIDReadCallback(handle,databuffer,datasize,&user); - } - if(databuffer) { - free(databuffer); - databuffer = NULL; + if (!cpyIncrementBufferOffset((void *) &handle, (void *) buffer, &bufferoffset, sizeof(handle), n)) continue; + if (!cpyIncrementBufferOffset((void *) &deviceSlot, (void *) buffer, &bufferoffset, sizeof(deviceSlot), n)) continue; + hid = (1 << deviceSlot); + if (!cpyIncrementBufferOffset((void *) &padslot, (void *) buffer, &bufferoffset, sizeof(padslot), n)) continue; + if (!cpyIncrementBufferOffset((void *) &datasize, (void *) buffer, &bufferoffset, sizeof(datasize), n)) continue; + uint8_t *databuffer = (uint8_t *) malloc(datasize * sizeof(uint8_t)); + if (!databuffer) { + DEBUG_FUNCTION_LINE("Allocating memory failed"); + continue; + } + + if (!cpyIncrementBufferOffset((void *) databuffer, (void *) buffer, &bufferoffset, datasize, n)) continue; + //DEBUG_FUNCTION_LINE("UDPServer::DoUDPThreadInternal(): Got handle: %d slot %04X hid %04X pad %02X datasize %02X\n",handle,deviceSlot,hid,padslot,datasize); + + user.pad_slot = padslot; + user.slotdata.deviceslot = deviceSlot; + user.slotdata.hidmask = hid; + + if (gNetworkController[deviceSlot][padslot][0] == 0) { + DEBUG_FUNCTION_LINE("Ehm. Pad is not connected. STOP SENDING DATA ;) \n"); + } else { + ControllerPatcherHID::externHIDReadCallback(handle, databuffer, datasize, &user); + } + if (databuffer) { + free(databuffer); + databuffer = NULL; + } } + break; } break; } - break; - } - default: { - break; - } + default: { + break; + } } } - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("UDPServer Thread ended"); } } diff --git a/source/network/UDPServer.hpp b/source/network/UDPServer.hpp index dc07f6b..e4974a2 100644 --- a/source/network/UDPServer.hpp +++ b/source/network/UDPServer.hpp @@ -19,22 +19,22 @@ #include "../ControllerPatcherIncludes.hpp" -#define DEFAULT_UDP_PORT 8113 +#define DEFAULT_UDP_PORT 8113 -#define WIIU_CP_UDP_CONTROLLER_READ_DATA 0x03 +#define WIIU_CP_UDP_CONTROLLER_READ_DATA 0x03 class UDPServer { friend class ControllerPatcher; private: static UDPServer *getInstance() { - if(instance == NULL) + if (instance == NULL) instance = new UDPServer(DEFAULT_UDP_PORT); return instance; } static void destroyInstance() { - if(instance != NULL) { + if (instance != NULL) { delete instance; instance = NULL; } @@ -42,12 +42,12 @@ private: UDPServer(int32_t port); ~UDPServer(); - void StartUDPThread(UDPServer * server); + void StartUDPThread(UDPServer *server); static void DoUDPThread(CThread *thread, void *arg); void DoUDPThreadInternal(); - BOOL cpyIncrementBufferOffset(void * target, void * source, int32_t * offset, int32_t typesize, int32_t maximum); + BOOL cpyIncrementBufferOffset(void *target, void *source, int32_t *offset, int32_t typesize, int32_t maximum); - volatile int32_t sockfd = -1; + volatile int32_t sockfd = -1; volatile int32_t exitThread = 0; static UDPServer *instance; diff --git a/source/network/net.c b/source/network/net.c index c17cbb2..e65a622 100644 --- a/source/network/net.c +++ b/source/network/net.c @@ -4,23 +4,22 @@ static volatile int socket_lock __attribute__((section(".data"))) = 0; -void initNetwork(){ - +void initNetwork() { } int32_t recvwait(int32_t sock, void *buffer, int32_t len) { - while(socket_lock) { + while (socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } int32_t ret; while (len > 0) { ret = recv(sock, buffer, len, 0); - if(ret < 0) { + if (ret < 0) { socket_lock = 0; return ret; } len -= ret; - buffer = (void *)(((char *) buffer) + ret); + buffer = (void *) (((char *) buffer) + ret); } socket_lock = 0; return 0; @@ -45,13 +44,13 @@ uint32_t recvword(int32_t sock) { } int32_t checkbyte(int32_t sock) { - while(socket_lock) { + while (socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } unsigned char buffer[1]; int32_t ret; - ret = recv(sock, buffer, 1, MSG_DONTWAIT); + ret = recv(sock, buffer, 1, MSG_DONTWAIT); socket_lock = 0; if (ret < 0) return ret; if (ret == 0) return -1; @@ -59,20 +58,20 @@ int32_t checkbyte(int32_t sock) { } int32_t sendwait(int32_t sock, const void *buffer, int32_t len) { - while(socket_lock) { + while (socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } int32_t ret; while (len > 0) { // For some reason the send blocks/crashes if the buffer is too big.. int cur_length = len <= 0x30 ? len : 0x30; - ret = send(sock, buffer, cur_length, 0); - if(ret < 0) { + ret = send(sock, buffer, cur_length, 0); + if (ret < 0) { socket_lock = 0; return ret; } len -= ret; - buffer = (void *)(((char *) buffer) + ret); + buffer = (void *) (((char *) buffer) + ret); } socket_lock = 0; return 0; diff --git a/source/patcher/ControllerPatcherHID.cpp b/source/patcher/ControllerPatcherHID.cpp index c22d20b..522e0e3 100644 --- a/source/patcher/ControllerPatcherHID.cpp +++ b/source/patcher/ControllerPatcherHID.cpp @@ -28,12 +28,12 @@ int32_t ControllerPatcherHID::externAttachDetachCallback(HIDDevice *p_device, HIDAttachEvent attach) { HIDClient client; - memset(&client,0,sizeof(client)); - return AttachDetachCallback(&client,p_device,attach); + memset(&client, 0, sizeof(client)); + return AttachDetachCallback(&client, p_device, attach); } -void ControllerPatcherHID::externHIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user * usr) { - HIDReadCallback(handle,buf,bytes_transfered,usr); +void ControllerPatcherHID::externHIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user *usr) { + HIDReadCallback(handle, buf, bytes_transfered, usr); } /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -41,26 +41,26 @@ void ControllerPatcherHID::externHIDReadCallback(uint32_t handle, unsigned char *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ int32_t ControllerPatcherHID::myAttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach) { - return AttachDetachCallback(p_client,p_device,attach); + return AttachDetachCallback(p_client, p_device, attach); } void ControllerPatcherHID::myHIDMouseReadCallback(uint32_t handle, int32_t error, unsigned char *buf, uint32_t bytes_transfered, void *p_user) { - if(error == 0) { - my_cb_user *usr = (my_cb_user*)p_user; + if (error == 0) { + my_cb_user *usr = (my_cb_user *) p_user; uint32_t slot = 0; - if(usr->pad_slot < HID_MAX_PADS_COUNT) { + if (usr->pad_slot < HID_MAX_PADS_COUNT) { slot = usr->pad_slot; } - HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[slot]); - HID_Mouse_Data * cur_mouse_data = &data_ptr->data_union.mouse.cur_mouse_data; + HID_Data *data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[slot]); + HID_Mouse_Data *cur_mouse_data = &data_ptr->data_union.mouse.cur_mouse_data; data_ptr->type = DEVICE_TYPE_MOUSE; //DEBUG_FUNCTION_LINE("%02X %02X %02X %02X %02X bytes_transfered: %d\n",buf[0],buf[1],buf[2],buf[3],buf[4],bytes_transfered); - if(buf[0] == 2 && bytes_transfered > 3) { // using the other mouse mode - buf +=1; + if (buf[0] == 2 && bytes_transfered > 3) { // using the other mouse mode + buf += 1; } int8_t x_value = 0; @@ -75,14 +75,14 @@ void ControllerPatcherHID::myHIDMouseReadCallback(uint32_t handle, int32_t error cur_mouse_data->Y += y_value; cur_mouse_data->deltaY = y_value; - cur_mouse_data->left_click = buf[0]; - cur_mouse_data->right_click = buf[0]>>1; + cur_mouse_data->left_click = buf[0]; + cur_mouse_data->right_click = buf[0] >> 1; - if(cur_mouse_data->X < 0) cur_mouse_data->X = 0; - if(cur_mouse_data->X > 1280) cur_mouse_data->X = 1280; + if (cur_mouse_data->X < 0) cur_mouse_data->X = 0; + if (cur_mouse_data->X > 1280) cur_mouse_data->X = 1280; - if(cur_mouse_data->Y < 0) cur_mouse_data->Y = 0; - if(cur_mouse_data->Y > 720) cur_mouse_data->Y = 720; + if (cur_mouse_data->Y < 0) cur_mouse_data->Y = 0; + if (cur_mouse_data->Y > 720) cur_mouse_data->Y = 720; cur_mouse_data->valuedChanged = 1; @@ -93,12 +93,12 @@ void ControllerPatcherHID::myHIDMouseReadCallback(uint32_t handle, int32_t error } void ControllerPatcherHID::myHIDReadCallback(uint32_t handle, int32_t error, unsigned char *buf, uint32_t bytes_transfered, void *p_user) { - if(error == 0 && p_user != NULL && gHIDAttached) { - my_cb_user *usr = (my_cb_user*)p_user; + if (error == 0 && p_user != NULL && gHIDAttached) { + my_cb_user *usr = (my_cb_user *) p_user; - HIDReadCallback(handle,buf,bytes_transfered,usr); + HIDReadCallback(handle, buf, bytes_transfered, usr); - if(usr->slotdata.hidmask == gHID_LIST_DS4) { + if (usr->slotdata.hidmask == gHID_LIST_DS4) { OSSleepTicks(OSMicrosecondsToTicks(2000)); //DS4 is way tooo fast. sleeping to reduce lag. (need to check the other pads) } HIDRead(handle, usr->buf, bytes_transfered, myHIDReadCallback, usr); @@ -110,9 +110,9 @@ void ControllerPatcherHID::myHIDReadCallback(uint32_t handle, int32_t error, uns *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach) { - if(attach) { - DEBUG_FUNCTION_LINE("vid %04x pid %04x connected", SWAP16(p_device->vid),SWAP16(p_device->pid)); - if(HID_DEBUG) { + if (attach) { + DEBUG_FUNCTION_LINE("vid %04x pid %04x connected", SWAP16(p_device->vid), SWAP16(p_device->pid)); + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("interface index %02x", p_device->interfaceIndex); DEBUG_FUNCTION_LINE("sub class %02x", p_device->subClass); DEBUG_FUNCTION_LINE("protocol %02x", p_device->protocol); @@ -120,67 +120,67 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic DEBUG_FUNCTION_LINE("max packet out %02x", p_device->maxPacketSizeRx); } } - if(!attach) { - DEBUG_FUNCTION_LINE("vid %04x pid %04x disconnected", SWAP16(p_device->vid),SWAP16(p_device->pid)); + if (!attach) { + DEBUG_FUNCTION_LINE("vid %04x pid %04x disconnected", SWAP16(p_device->vid), SWAP16(p_device->pid)); } DeviceInfo device_info; - memset(&device_info,0,sizeof(DeviceInfo)); + memset(&device_info, 0, sizeof(DeviceInfo)); device_info.slotdata.deviceslot = -1; - device_info.vidpid.vid = SWAP16(p_device->vid); - device_info.vidpid.pid = SWAP16(p_device->pid); + device_info.vidpid.vid = SWAP16(p_device->vid); + device_info.vidpid.pid = SWAP16(p_device->pid); - HIDSlotData * slotdata = &(device_info.slotdata); + HIDSlotData *slotdata = &(device_info.slotdata); 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; //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 - slotdata->hidmask = gHID_LIST_MOUSE; + slotdata->hidmask = gHID_LIST_MOUSE; slotdata->deviceslot = gMouseSlot; //DEBUG_FUNCTION_LINE("Found Mouse: device: %s slot: %d",byte_to_binary(device_info.hid),device_info.slot); } else { int32_t ret; - if((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { - DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d ",ret); + if ((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0) { + DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d ", ret); return HID_DEVICE_DETACH; } else { //DEBUG_FUNCTION_LINE("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) success %d ",ret); } } - if(slotdata->hidmask) { - if(attach) { + if (slotdata->hidmask) { + if (attach) { int32_t bufSize = 64; - if(slotdata->hidmask != gHID_LIST_MOUSE && config_controller[slotdata->deviceslot][CONTRPS_BUF_SIZE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (slotdata->hidmask != gHID_LIST_MOUSE && config_controller[slotdata->deviceslot][CONTRPS_BUF_SIZE][0] == CONTROLLER_PATCHER_VALUE_SET) { bufSize = config_controller[slotdata->deviceslot][CONTRPS_BUF_SIZE][1]; } - unsigned char *buf = (unsigned char *) memalign(64,bufSize); - memset(buf,0,bufSize); - my_cb_user *usr = (my_cb_user *) memalign(64,sizeof(my_cb_user)); - usr->buf = buf; - usr->slotdata = device_info.slotdata; + unsigned char *buf = (unsigned char *) memalign(64, bufSize); + memset(buf, 0, bufSize); + my_cb_user *usr = (my_cb_user *) memalign(64, sizeof(my_cb_user)); + usr->buf = buf; + usr->slotdata = device_info.slotdata; usr->transfersize = p_device->maxPacketSizeRx; - usr->handle = p_device->handle; + usr->handle = p_device->handle; gHIDAttached |= slotdata->hidmask; gHIDCurrentDevice |= slotdata->hidmask; int32_t pads_per_device = 1; - if(config_controller[slotdata->deviceslot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[slotdata->deviceslot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { pads_per_device = config_controller[slotdata->deviceslot][CONTRPS_PAD_COUNT][1]; - if(pads_per_device > HID_MAX_PADS_COUNT) { //maximum of HID_MAX_PADS_COUNT + if (pads_per_device > HID_MAX_PADS_COUNT) { //maximum of HID_MAX_PADS_COUNT pads_per_device = HID_MAX_PADS_COUNT; } } int32_t pad_count = config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1]; - if(pad_count > 0x0F) pad_count = 0; //??? + if (pad_count > 0x0F) pad_count = 0; //??? int32_t pad_slot = 0; int32_t failed = 1; - for(int32_t i = 0; ideviceslot][CONTRPS_CONNECTED_PADS][1] = pad_count; - DCFlushRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1],sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); - DCInvalidateRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1],sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); + DCFlushRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1], sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); + DCInvalidateRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1], sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); usr->pads_per_device = pads_per_device; - usr->pad_slot = pad_slot; + usr->pad_slot = pad_slot; - for(int32_t i = 0; ideviceslot].pad_data[pad_slot+i],0,sizeof(HID_Data)); + for (int32_t i = 0; i < pads_per_device; i++) { + 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",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].slotdata = device_info.slotdata; + 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; - DCFlushRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data)); - DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data)); + DCFlushRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot + i], sizeof(HID_Data)); + DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot + i], sizeof(HID_Data)); } - if(HID_DEBUG) { + if (HID_DEBUG) { DEBUG_FUNCTION_LINE("Device successfully attached"); } - if(slotdata->hidmask == gHID_LIST_GC) { // GC PAD + if (slotdata->hidmask == gHID_LIST_GC) { // GC PAD //The GC Adapter has all ports in one device. Set them all. gHID_Devices[slotdata->deviceslot].pad_data[0].slotdata = device_info.slotdata; gHID_Devices[slotdata->deviceslot].pad_data[1].slotdata = device_info.slotdata; @@ -234,18 +234,18 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic gHID_Devices[slotdata->deviceslot].pad_data[3].slotdata = device_info.slotdata; buf[0] = 0x13; - HIDWrite(p_device->handle, usr->buf, 1, NULL,NULL); + HIDWrite(p_device->handle, usr->buf, 1, NULL, NULL); HIDRead(p_device->handle, usr->buf, usr->transfersize, myHIDReadCallback, usr); } else if (slotdata->hidmask == gHID_LIST_MOUSE) { HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 0, 0, 0); //HIDGetDescriptor(p_device->handle,0x22,0x00,0,my_buf,512,my_foo_cb,NULL); - HIDSetIdle(p_device->handle,p_device->interfaceIndex,1,NULL,NULL,NULL); + HIDSetIdle(p_device->handle, p_device->interfaceIndex, 1, NULL, NULL, NULL); gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDMouseReadCallback, usr); } else if (slotdata->hidmask == gHID_LIST_SWITCH_PRO) { int32_t read_result = HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL); - if(read_result == 64) { - if(usr->buf[01] == 0x01) { //We need to do the handshake + if (read_result == 64) { + if (usr->buf[01] == 0x01) { //We need to do the handshake DEBUG_FUNCTION_LINE("Switch Pro Controller handshake needed"); /** Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering) @@ -253,17 +253,17 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic //Get MAC buf[0] = 0x80; buf[1] = 0x01; - 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); //Do handshake buf[0] = 0x80; buf[1] = 0x02; - 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); //Talk over HID only. buf[0] = 0x80; buf[1] = 0x04; - 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); } else { DEBUG_FUNCTION_LINE("Switch Pro Controller handshake already done"); @@ -276,7 +276,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDReadCallback, usr); } else if (slotdata->hidmask == gHID_LIST_DS3) { HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0); - HIDDS3Rumble(p_device->handle,usr,0); + HIDDS3Rumble(p_device->handle, usr, 0); buf[0] = 0x42; buf[1] = 0x0c; buf[2] = 0x00; @@ -289,14 +289,14 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic return HID_DEVICE_ATTACH; } else { - my_cb_user * user_data = NULL; - int32_t founddata = 0; - for(int32_t i = 0; ideviceslot].pad_data[i].handle == p_device->handle) { + my_cb_user *user_data = NULL; + int32_t founddata = 0; + for (int32_t i = 0; i < HID_MAX_PADS_COUNT; i++) { + if (gHID_Devices[slotdata->deviceslot].pad_data[i].handle == p_device->handle) { gHID_Devices[slotdata->deviceslot].pad_data[i].handle = 0; - DCFlushRange(&gHID_Devices[slotdata->deviceslot].pad_data[i].handle,sizeof(gHID_Devices[slotdata->deviceslot].pad_data[i].handle)); - DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[i].handle,sizeof(gHID_Devices[slotdata->deviceslot].pad_data[i].handle)); + DCFlushRange(&gHID_Devices[slotdata->deviceslot].pad_data[i].handle, sizeof(gHID_Devices[slotdata->deviceslot].pad_data[i].handle)); + DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[i].handle, sizeof(gHID_Devices[slotdata->deviceslot].pad_data[i].handle)); user_data = (my_cb_user *) gHID_Devices[slotdata->deviceslot].pad_data[i].user_data; @@ -305,40 +305,40 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic } } - if(user_data) { - config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] &= ~ (1 << user_data->pad_slot); - DCFlushRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1],sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); - DCInvalidateRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1],sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); - if(user_data->buf) { + if (user_data) { + config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] &= ~(1 << user_data->pad_slot); + DCFlushRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1], sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); + DCInvalidateRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1], sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); + if (user_data->buf) { free(user_data->buf); user_data->buf = NULL; } free(user_data); user_data = NULL; } else { - if(founddata) { + if (founddata) { DEBUG_FUNCTION_LINE("user_data null. You may have a memory leak."); } return HID_DEVICE_DETACH; } - if(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0) { + if (config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0) { gHIDAttached &= ~slotdata->hidmask; gHIDCurrentDevice &= ~slotdata->hidmask; - DCFlushRange(&gHIDAttached,sizeof(gHIDAttached)); - DCInvalidateRange(&gHIDAttached,sizeof(gHIDAttached)); - DCFlushRange(&gHIDCurrentDevice,sizeof(gHIDCurrentDevice)); - DCInvalidateRange(&gHIDCurrentDevice,sizeof(gHIDCurrentDevice)); + DCFlushRange(&gHIDAttached, sizeof(gHIDAttached)); + DCInvalidateRange(&gHIDAttached, sizeof(gHIDAttached)); + DCFlushRange(&gHIDCurrentDevice, sizeof(gHIDCurrentDevice)); + DCInvalidateRange(&gHIDCurrentDevice, sizeof(gHIDCurrentDevice)); if (slotdata->hidmask == gHID_LIST_MOUSE) { gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; } } else { - if(HID_DEBUG) { - DEBUG_FUNCTION_LINE("We still have pad for deviceslot %d connected.",slotdata->deviceslot); + if (HID_DEBUG) { + 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"); } } @@ -348,19 +348,18 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic return HID_DEVICE_DETACH; } -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); +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); //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; //Copy the data for all 4 pads - for(int32_t i = 0; i<4; i++) { + for (int32_t i = 0; i < 4; i++) { data_ptr = &(gHID_Devices[gHID_SLOT_GC].pad_data[i]); - memcpy(&(data_ptr->data_union.controller.last_hid_data[0]),&(data_ptr->data_union.controller.cur_hid_data[0]),10); //save last data. - memcpy(&(data_ptr->data_union.controller.cur_hid_data[0]),&buf[(i*9)+1],9); //save new data. - + memcpy(&(data_ptr->data_union.controller.last_hid_data[0]), &(data_ptr->data_union.controller.cur_hid_data[0]), 10); //save last data. + memcpy(&(data_ptr->data_union.controller.cur_hid_data[0]), &buf[(i * 9) + 1], 9); //save new data. } /* @@ -369,13 +368,13 @@ void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, DEBUG_FUNCTION_LINE("GC2 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++; DEBUG_FUNCTION_LINE("GC3 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++; DEBUG_FUNCTION_LINE("GC4 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X \n", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);*/ - HIDGCRumble(handle,usr); - } else if(usr->slotdata.hidmask != 0) { + HIDGCRumble(handle, usr); + } else if (usr->slotdata.hidmask != 0) { //Depending on how the switch pro controller is connected, it has a different data format. At first we had the Bluetooth version, so we need to convert //the USB one into it now. (When it's connected via USB). The network client always sends the BT version, even if connected via USB to the PC. - if(usr->slotdata.hidmask == gHID_LIST_SWITCH_PRO && buf != NULL && bytes_transfered >= 0x20) { + if (usr->slotdata.hidmask == gHID_LIST_SWITCH_PRO && buf != NULL && bytes_transfered >= 0x20) { uint8_t buffer[0x13]; - memcpy(buffer,buf+0x0D,0x013); + memcpy(buffer, buf + 0x0D, 0x013); /** Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering) @@ -390,65 +389,65 @@ void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, buf[7] = 0x00; buf[8] = 0x1F; //We want to get the next input! - int32_t res = HIDWrite(handle, buf, 9, NULL,NULL); + int32_t res = HIDWrite(handle, buf, 9, NULL, NULL); - if(res == 9) { //Check if it's the USB data format. - if(buffer[1] == 0) return; + if (res == 9) { //Check if it's the USB data format. + if (buffer[1] == 0) return; //Converting the buttons - uint32_t buttons = (((uint32_t*)(buffer))[0]) & 0xFFFFFF00; + uint32_t buttons = (((uint32_t *) (buffer))[0]) & 0xFFFFFF00; uint32_t newButtons = 0; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_A_VALUE) == HID_SWITCH_PRO_USB_BUTTON_A_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_A_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_B_VALUE) == HID_SWITCH_PRO_USB_BUTTON_B_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_B_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_X_VALUE) == HID_SWITCH_PRO_USB_BUTTON_X_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_X_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_Y_VALUE) == HID_SWITCH_PRO_USB_BUTTON_Y_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_Y_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_A_VALUE) == HID_SWITCH_PRO_USB_BUTTON_A_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_A_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_B_VALUE) == HID_SWITCH_PRO_USB_BUTTON_B_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_B_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_X_VALUE) == HID_SWITCH_PRO_USB_BUTTON_X_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_X_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_Y_VALUE) == HID_SWITCH_PRO_USB_BUTTON_Y_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_Y_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_PLUS_VALUE) == HID_SWITCH_PRO_USB_BUTTON_PLUS_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_PLUS_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_MINUS_VALUE) == HID_SWITCH_PRO_USB_BUTTON_MINUS_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_MINUS_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_HOME_VALUE) == HID_SWITCH_PRO_USB_BUTTON_HOME_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_HOME_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_PLUS_VALUE) == HID_SWITCH_PRO_USB_BUTTON_PLUS_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_PLUS_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_MINUS_VALUE) == HID_SWITCH_PRO_USB_BUTTON_MINUS_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_MINUS_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_HOME_VALUE) == HID_SWITCH_PRO_USB_BUTTON_HOME_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_HOME_VALUE; //if((buttons & SWITCH_PRO_USB_BUTTON_SCREENSHOT) == HID_SWITCH_PRO_USB_BUTTON_SCREENSHOT) newButtons |= HID_SWITCH_PRO_BT_BUTTON_SCREENSHOT; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_R_VALUE) == HID_SWITCH_PRO_USB_BUTTON_R_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_R_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_ZR_VALUE) == HID_SWITCH_PRO_USB_BUTTON_ZR_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_ZR_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_STICK_R_VALUE) == HID_SWITCH_PRO_USB_BUTTON_STICK_R_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_STICK_R_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_R_VALUE) == HID_SWITCH_PRO_USB_BUTTON_R_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_R_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_ZR_VALUE) == HID_SWITCH_PRO_USB_BUTTON_ZR_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_ZR_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_STICK_R_VALUE) == HID_SWITCH_PRO_USB_BUTTON_STICK_R_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_STICK_R_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_L_VALUE) == HID_SWITCH_PRO_USB_BUTTON_L_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_L_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_ZL_VALUE) == HID_SWITCH_PRO_USB_BUTTON_ZL_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_ZL_VALUE; - if((buttons & HID_SWITCH_PRO_USB_BUTTON_STICK_L_VALUE) == HID_SWITCH_PRO_USB_BUTTON_STICK_L_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_STICK_L_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_L_VALUE) == HID_SWITCH_PRO_USB_BUTTON_L_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_L_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_ZL_VALUE) == HID_SWITCH_PRO_USB_BUTTON_ZL_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_ZL_VALUE; + if ((buttons & HID_SWITCH_PRO_USB_BUTTON_STICK_L_VALUE) == HID_SWITCH_PRO_USB_BUTTON_STICK_L_VALUE) newButtons |= HID_SWITCH_PRO_BT_BUTTON_STICK_L_VALUE; - uint8_t dpad = buffer[2]; + uint8_t dpad = buffer[2]; uint8_t dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL_VALUE; //Converting the DPAD - if(((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) && - ((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE)) { + if (((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) && + ((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE)) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_NE_VALUE; - } else if(((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) && - ((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE)) { + } else if (((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) && + ((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE)) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_SE_VALUE; - } else if(((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) && - ((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE)) { + } else if (((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) && + ((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE)) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_SW_VALUE; - } else if(((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) && - ((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE)) { + } else if (((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) && + ((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE)) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_NW_VALUE; - } else if((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) { + } else if ((dpad & HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) == HID_SWITCH_PRO_USB_BUTTON_UP_VALUE) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_N_VALUE; - } else if((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) { + } else if ((dpad & HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_RIGHT_VALUE) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_E_VALUE; - } else if((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) { + } else if ((dpad & HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) == HID_SWITCH_PRO_USB_BUTTON_DOWN_VALUE) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_S_VALUE; - } else if((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) { + } else if ((dpad & HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) == HID_SWITCH_PRO_USB_BUTTON_LEFT_VALUE) { dpadResult = HID_SWITCH_PRO_BT_BUTTON_DPAD_W_VALUE; } //Converting the stick data - uint8_t LX = (uint8_t) ((uint16_t) ((buffer[0x04] << 8 &0xFF00) | (((uint16_t)buffer[0x03])&0xFF)) >> 0x04); - uint8_t LY = (uint8_t)((buffer[0x05] *-1)); - uint8_t RX = (uint8_t) ((uint16_t) ((buffer[0x07] << 8 &0xFF00) | (((uint16_t)buffer[0x06])&0xFF)) >> 0x04); - uint8_t RY = (uint8_t)((buffer[0x08] *-1)); + uint8_t LX = (uint8_t) ((uint16_t) ((buffer[0x04] << 8 & 0xFF00) | (((uint16_t) buffer[0x03]) & 0xFF)) >> 0x04); + uint8_t LY = (uint8_t) ((buffer[0x05] * -1)); + uint8_t RX = (uint8_t) ((uint16_t) ((buffer[0x07] << 8 & 0xFF00) | (((uint16_t) buffer[0x06]) & 0xFF)) >> 0x04); + uint8_t RY = (uint8_t) ((buffer[0x08] * -1)); - buf[0] = (newButtons >> 24) & 0xFF; - buf[1] = (newButtons >> 16) & 0xFF; + buf[0] = (newButtons >> 24) & 0xFF; + buf[1] = (newButtons >> 16) & 0xFF; buf[2] |= dpadResult; buf[4] = LX; buf[6] = LY; @@ -457,33 +456,33 @@ void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, } } - int32_t dsize = (HID_MAX_DATA_LENGTH_PER_PAD > bytes_transfered)? bytes_transfered : HID_MAX_DATA_LENGTH_PER_PAD; - int32_t skip = 0; + int32_t dsize = (HID_MAX_DATA_LENGTH_PER_PAD > bytes_transfered) ? bytes_transfered : HID_MAX_DATA_LENGTH_PER_PAD; + int32_t skip = 0; //Input filter - if( config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(buf[config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][0]] != config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][1]) { + if (config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (buf[config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][0]] != config_controller[usr->slotdata.deviceslot][CONTRPS_INPUT_FILTER][1]) { skip = 1; } } - if(!skip) { + if (!skip) { uint32_t slot = 0; - if(usr->pad_slot < HID_MAX_PADS_COUNT) { + if (usr->pad_slot < HID_MAX_PADS_COUNT) { slot = usr->pad_slot; } - slot += ControllerPatcherUtils::getPadSlotInAdapter(usr->slotdata.deviceslot,buf); // If the controller has multiple slots, we need to use the right one. + slot += ControllerPatcherUtils::getPadSlotInAdapter(usr->slotdata.deviceslot, buf); // If the controller has multiple slots, we need to use the right one. - HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[slot]); + HID_Data *data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[slot]); - memcpy(&(data_ptr->data_union.controller.last_hid_data[0]),&(data_ptr->data_union.controller.cur_hid_data[0]),dsize); // save the last data. - memcpy(&(data_ptr->data_union.controller.cur_hid_data[0]),&buf[0],dsize); // save the new data. + memcpy(&(data_ptr->data_union.controller.last_hid_data[0]), &(data_ptr->data_union.controller.cur_hid_data[0]), dsize); // save the last data. + memcpy(&(data_ptr->data_union.controller.cur_hid_data[0]), &buf[0], dsize); // save the new data. - DCFlushRange(&gHID_Devices[usr->slotdata.deviceslot].pad_data[slot],sizeof(HID_Data)); + DCFlushRange(&gHID_Devices[usr->slotdata.deviceslot].pad_data[slot], sizeof(HID_Data)); data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[slot]); - HIDRumble(handle,usr,slot); + HIDRumble(handle, usr, slot); } } } @@ -492,17 +491,17 @@ void ControllerPatcherHID::HIDReadCallback(uint32_t handle, unsigned char *buf, * Other functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(VPADStatus * buffer,std::vector& data) { - if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - HID_Data * data_cur; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(VPADStatus *buffer, std::vector &data) { + if (buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + HID_Data *data_cur; int32_t buttons_hold; - for(uint32_t i = 0; islotdata.hidmask & gHID_LIST_MOUSE) { //Reset the input when we have no new inputs - HID_Mouse_Data * mouse_data = &data_cur->data_union.mouse.cur_mouse_data; - if(mouse_data->valuedChanged == 1) { //Fix for the mouse cursor + if (data_cur->slotdata.hidmask & gHID_LIST_MOUSE) { //Reset the input when we have no new inputs + HID_Mouse_Data *mouse_data = &data_cur->data_union.mouse.cur_mouse_data; + if (mouse_data->valuedChanged == 1) { //Fix for the mouse cursor mouse_data->valuedChanged = 0; } else { mouse_data->deltaX = 0; @@ -511,49 +510,49 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(V } buttons_hold = 0; - 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_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_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_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_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); + 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); - uint32_t last_emulate_stick = (data_cur->last_buttons) & VPAD_MASK_EMULATED_STICKS; // We should only need the emulated stick data. - int32_t last_realbuttons = (data_cur->last_buttons) & VPAD_MASK_BUTTONS; + uint32_t last_emulate_stick = (data_cur->last_buttons) & VPAD_MASK_EMULATED_STICKS; // We should only need the emulated stick data. + int32_t last_realbuttons = (data_cur->last_buttons) & VPAD_MASK_BUTTONS; buffer->hold |= buttons_hold; buffer->trigger |= (buttons_hold & (~last_realbuttons)); buffer->release |= (last_realbuttons & (~buttons_hold)); - ControllerPatcherUtils::convertAnalogSticks(data_cur,buffer); + ControllerPatcherUtils::convertAnalogSticks(data_cur, buffer); - ControllerPatcherUtils::setEmulatedSticks(buffer,&last_emulate_stick); + ControllerPatcherUtils::setEmulatedSticks(buffer, &last_emulate_stick); ControllerPatcherUtils::checkAndSetMouseMode(data_cur); - ControllerPatcherUtils::setTouch(data_cur,buffer); + ControllerPatcherUtils::setTouch(data_cur, buffer); data_cur->last_buttons = buttons_hold & VPAD_MASK_BUTTONS; data_cur->last_buttons |= last_emulate_stick; } // Caculates a valid stick position - if(data.size() > 0) { + if (data.size() > 0) { ControllerPatcherUtils::normalizeStickValues(&buffer->leftStick); ControllerPatcherUtils::normalizeStickValues(&buffer->rightStick); } @@ -565,17 +564,17 @@ std::vector ControllerPatcherHID::getHIDDataAll() { uint32_t hid = gHIDCurrentDevice; std::vector data_list; - for(int32_t i = 0; i < gHIDMaxDevices; i++) { - if((hid & (1 << i)) != 0) { + for (int32_t i = 0; i < gHIDMaxDevices; i++) { + if ((hid & (1 << i)) != 0) { uint32_t cur_hidmask = config_controller_hidmask[i]; - for(int32_t pad = 0; pad < HID_MAX_PADS_COUNT; pad++) { + for (int32_t pad = 0; pad < HID_MAX_PADS_COUNT; pad++) { int32_t res; - HID_Data * new_data = NULL; - if((res = ControllerPatcherHID::getHIDData(cur_hidmask,pad,&new_data)) < 0) { // Checks if the pad is invalid. + HID_Data *new_data = NULL; + if ((res = ControllerPatcherHID::getHIDData(cur_hidmask, pad, &new_data)) < 0) { // Checks if the pad is invalid. //DEBUG_FUNCTION_LINE("error: Error getting the HID data from HID(%s) CHAN(). Error %d\n",StringTools::byte_to_binary(cur_hidmask),pad,res); continue; } - if(new_data != NULL) data_list.push_back(new_data); + if (new_data != NULL) data_list.push_back(new_data); } } } @@ -585,26 +584,26 @@ std::vector ControllerPatcherHID::getHIDDataAll() { /* The slotdata in the HID_Data pointer is empty. We need to provide the hidmask via the parameter */ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(uint32_t hidmask, int32_t pad, HID_Data ** data) { - if(data == NULL) return CONTROLLER_PATCHER_ERROR_INVALID_BUFFER; - if(!(hidmask & gHIDCurrentDevice)) return CONTROLLER_PATCHER_ERROR_HID_NOT_CONNECTED; - if(pad < 0 && pad > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(uint32_t hidmask, int32_t pad, HID_Data **data) { + if (data == NULL) return CONTROLLER_PATCHER_ERROR_INVALID_BUFFER; + if (!(hidmask & gHIDCurrentDevice)) return CONTROLLER_PATCHER_ERROR_HID_NOT_CONNECTED; + if (pad < 0 && pad > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; int32_t device_slot = ControllerPatcherUtils::getDeviceSlot(hidmask); - if(device_slot < 0) { + if (device_slot < 0) { return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; } int32_t real_pad = pad; - if((device_slot != gHID_SLOT_GC) && config_controller[device_slot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if ((device_slot != gHID_SLOT_GC) && config_controller[device_slot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { int32_t pad_count = config_controller[device_slot][CONTRPS_PAD_COUNT][1]; - if(pad_count > HID_MAX_PADS_COUNT) pad_count = HID_MAX_PADS_COUNT; - pad = (pad/(pad_count))*pad_count; + if (pad_count > HID_MAX_PADS_COUNT) pad_count = HID_MAX_PADS_COUNT; + pad = (pad / (pad_count)) * pad_count; } - int32_t result = ControllerPatcherUtils::checkActivePad(hidmask,pad); + int32_t result = ControllerPatcherUtils::checkActivePad(hidmask, pad); - if(result < 0) { //Not pad connected to adapter + if (result < 0) { //Not pad connected to adapter return CONTROLLER_PATCHER_ERROR_NO_PAD_CONNECTED; } @@ -614,45 +613,45 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(uint32_t hid } -void ControllerPatcherHID::HIDGCRumble(uint32_t handle,my_cb_user *usr) { - if(usr == NULL) return; - if(!ControllerPatcher::isRumbleActivated()) return; +void ControllerPatcherHID::HIDGCRumble(uint32_t handle, my_cb_user *usr) { + if (usr == NULL) return; + if (!ControllerPatcher::isRumbleActivated()) return; int32_t rumblechanged = 0; - for(int32_t i = 0; islotdata.deviceslot].pad_data[i]); - if(data_ptr->rumbleActive != usr->rumblestatus[i]) { + for (int32_t i = 0; i < HID_GC_PAD_COUNT; i++) { + HID_Data *data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[i]); + if (data_ptr->rumbleActive != usr->rumblestatus[i]) { rumblechanged = 1; } usr->rumblestatus[i] = data_ptr->rumbleActive; - usr->buf[i+1] = usr->rumblestatus[i]; + usr->buf[i + 1] = usr->rumblestatus[i]; } usr->forceRumbleInTicks[0]--; - if(rumblechanged || usr->forceRumbleInTicks[0] <= 0) { + if (rumblechanged || usr->forceRumbleInTicks[0] <= 0) { usr->buf[0] = 0x11; HIDWrite(handle, usr->buf, 5, NULL, NULL); usr->forceRumbleInTicks[0] = 10; } } -void ControllerPatcherHID::HIDRumble(uint32_t handle,my_cb_user *usr,uint32_t pad) { - if(usr == NULL || pad > HID_MAX_PADS_COUNT) return; - if(!ControllerPatcher::isRumbleActivated()) return; +void ControllerPatcherHID::HIDRumble(uint32_t handle, my_cb_user *usr, uint32_t pad) { + if (usr == NULL || pad > HID_MAX_PADS_COUNT) return; + if (!ControllerPatcher::isRumbleActivated()) return; int32_t rumblechanged = 0; - HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[pad]); - if(data_ptr->rumbleActive != usr->rumblestatus[pad]) { + HID_Data *data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[pad]); + if (data_ptr->rumbleActive != usr->rumblestatus[pad]) { usr->rumblestatus[pad] = data_ptr->rumbleActive; - rumblechanged = 1; + rumblechanged = 1; } usr->forceRumbleInTicks[pad]--; - if(rumblechanged || usr->forceRumbleInTicks[pad] <= 0) { + if (rumblechanged || usr->forceRumbleInTicks[pad] <= 0) { //DEBUG_FUNCTION_LINE("Rumble: %d %d",usr->rumblestatus[pad],usr->rumbleForce[pad]); //Seding to the network client! char bytes[6]; - int32_t i = 0; + int32_t i = 0; bytes[i++] = 0x01; bytes[i++] = (handle >> 24) & 0xFF; bytes[i++] = (handle >> 16) & 0xFF; @@ -660,14 +659,14 @@ void ControllerPatcherHID::HIDRumble(uint32_t handle,my_cb_user *usr,uint32_t pa bytes[i++] = handle & 0xFF; bytes[i++] = usr->rumblestatus[pad]; - UDPClient * instance = UDPClient::getInstance(); - if(instance != NULL) { - instance->sendData(bytes,6); + UDPClient *instance = UDPClient::getInstance(); + if (instance != NULL) { + instance->sendData(bytes, 6); } - if(usr->slotdata.hidmask == gHID_LIST_DS3) { - HIDDS3Rumble(handle,usr,usr->rumblestatus[pad]); + if (usr->slotdata.hidmask == gHID_LIST_DS3) { + HIDDS3Rumble(handle, usr, usr->rumblestatus[pad]); } else { // Not implemented for other devices =( } @@ -676,19 +675,57 @@ void ControllerPatcherHID::HIDRumble(uint32_t handle,my_cb_user *usr,uint32_t pa } static uint8_t ds3_rumble_Report[48] = { - 0x00, 0xFF, 0x00, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x27, 0x10, 0x00, 0x32, - 0xFF, 0x27, 0x10, 0x00, 0x32, - 0xFF, 0x27, 0x10, 0x00, 0x32, - 0xFF, 0x27, 0x10, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, + 0x00, + 0xFF, + 0x00, + 0xFF, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xFF, + 0x27, + 0x10, + 0x00, + 0x32, + 0xFF, + 0x27, + 0x10, + 0x00, + 0x32, + 0xFF, + 0x27, + 0x10, + 0x00, + 0x32, + 0xFF, + 0x27, + 0x10, + 0x00, + 0x32, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, }; -void ControllerPatcherHID::HIDDS3Rumble(uint32_t handle,my_cb_user *usr,int32_t rumble) { +void ControllerPatcherHID::HIDDS3Rumble(uint32_t handle, my_cb_user *usr, int32_t rumble) { memcpy(usr->buf, ds3_rumble_Report, 48); if (rumble) { diff --git a/source/patcher/ControllerPatcherHID.hpp b/source/patcher/ControllerPatcherHID.hpp index ae9702a..f1b52e1 100644 --- a/source/patcher/ControllerPatcherHID.hpp +++ b/source/patcher/ControllerPatcherHID.hpp @@ -32,35 +32,36 @@ #include "../ControllerPatcherIncludes.hpp" //! Own definitions -#define VPAD_BUTTON_TOUCH 0x00080000 -#define VPAD_MASK_EMULATED_STICKS 0x7F800000 -#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS +#define VPAD_BUTTON_TOUCH 0x00080000 +#define VPAD_MASK_EMULATED_STICKS 0x7F800000 +#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS -#define SWAP16(x) ((x>>8) | ((x&0xFF)<<8)) -#define SWAP8(x) ((x>>4) | ((x&0xF)<<4)) +#define SWAP16(x) ((x >> 8) | ((x & 0xFF) << 8)) +#define SWAP8(x) ((x >> 4) | ((x & 0xF) << 4)) class ControllerPatcherHID { friend class ControllerPatcher; friend class ControllerPatcherUtils; + public: - static int32_t externAttachDetachCallback(HIDDevice *p_device, HIDAttachEvent attach); - static void externHIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user * usr); + static int32_t externAttachDetachCallback(HIDDevice *p_device, HIDAttachEvent attach); + static void externHIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user *usr); private: - static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADStatus * buffer,std::vector& data); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADStatus *buffer, std::vector &data); static std::vector getHIDDataAll(); - static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(uint32_t hidmask, int32_t pad, HID_Data ** data); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(uint32_t hidmask, int32_t pad, HID_Data **data); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Rumble *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - static void HIDRumble(uint32_t handle,my_cb_user *usr,uint32_t pad); + static void HIDRumble(uint32_t handle, my_cb_user *usr, uint32_t pad); - static void HIDGCRumble(uint32_t handle,my_cb_user *usr); + static void HIDGCRumble(uint32_t handle, my_cb_user *usr); - static void HIDDS3Rumble(uint32_t handle,my_cb_user *usr,int32_t rumble); + static void HIDDS3Rumble(uint32_t handle, my_cb_user *usr, int32_t rumble); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * HID Callbacks @@ -71,7 +72,7 @@ private: static void myHIDReadCallback(uint32_t handle, int32_t error, unsigned char *buf, uint32_t bytes_transfered, void *p_user); static int32_t AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, HIDAttachEvent attach); - static void HIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user * usr); + static void HIDReadCallback(uint32_t handle, unsigned char *buf, uint32_t bytes_transfered, my_cb_user *usr); }; #endif /* _CONTROLLER_PATCHER_HID_H_ */ diff --git a/source/patcher/ControllerPatcherUtils.cpp b/source/patcher/ControllerPatcherUtils.cpp index f1b71be..b6746fc 100644 --- a/source/patcher/ControllerPatcherUtils.cpp +++ b/source/patcher/ControllerPatcherUtils.cpp @@ -20,11 +20,11 @@ #include -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 j = 0; j<4; j++) { +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 j = 0; j < 4; j++) { //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; return CONTROLLER_PATCHER_ERROR_NONE; } @@ -36,36 +36,36 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDataByHandle(int32 * Analyse inputs *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_Data * data, int32_t * buttons_hold, int32_t VPADButton) { - if(data == NULL || buttons_hold == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_Data *data, int32_t *buttons_hold, int32_t VPADButton) { + if (data == NULL || buttons_hold == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t deviceslot = data->slotdata.deviceslot; int32_t result = -1; do { - if(data->type == DEVICE_TYPE_MOUSE) { - HID_Mouse_Data * ms_data = &data->data_union.mouse.cur_mouse_data; - if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { - if(VPADButton == VPAD_BUTTON_TOUCH) { - if(ms_data->left_click & 0x01) { + if (data->type == DEVICE_TYPE_MOUSE) { + HID_Mouse_Data *ms_data = &data->data_union.mouse.cur_mouse_data; + if (ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { + if (VPADButton == VPAD_BUTTON_TOUCH) { + if (ms_data->left_click & 0x01) { 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) { + } 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; } } } - 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) { + 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; } @@ -75,108 +75,108 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_ result = 0; break; } - uint8_t * cur_data = &data->data_union.controller.cur_hid_data[0]; - if(cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + uint8_t *cur_data = &data->data_union.controller.cur_hid_data[0]; + if (cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t cur_config = 0; - if(VPADButton == VPAD_BUTTON_A) { + if (VPADButton == VPAD_BUTTON_A) { cur_config = CONTRPS_VPAD_BUTTON_A; - } else if(VPADButton == VPAD_BUTTON_B) { + } else if (VPADButton == VPAD_BUTTON_B) { cur_config = CONTRPS_VPAD_BUTTON_B; - } else if(VPADButton == VPAD_BUTTON_X) { + } else if (VPADButton == VPAD_BUTTON_X) { cur_config = CONTRPS_VPAD_BUTTON_X; - } else if(VPADButton == VPAD_BUTTON_Y) { + } else if (VPADButton == VPAD_BUTTON_Y) { cur_config = CONTRPS_VPAD_BUTTON_Y; - } else if(VPADButton == VPAD_BUTTON_L) { + } else if (VPADButton == VPAD_BUTTON_L) { cur_config = CONTRPS_VPAD_BUTTON_L; - } else if(VPADButton == VPAD_BUTTON_R) { + } else if (VPADButton == VPAD_BUTTON_R) { cur_config = CONTRPS_VPAD_BUTTON_R; - } else if(VPADButton == VPAD_BUTTON_ZL) { + } else if (VPADButton == VPAD_BUTTON_ZL) { cur_config = CONTRPS_VPAD_BUTTON_ZL; - } else if(VPADButton == VPAD_BUTTON_ZR) { + } else if (VPADButton == VPAD_BUTTON_ZR) { cur_config = CONTRPS_VPAD_BUTTON_ZR; - } else if(VPADButton == VPAD_BUTTON_STICK_L) { + } else if (VPADButton == VPAD_BUTTON_STICK_L) { cur_config = CONTRPS_VPAD_BUTTON_STICK_L; - } else if(VPADButton == VPAD_BUTTON_STICK_R) { + } else if (VPADButton == VPAD_BUTTON_STICK_R) { cur_config = CONTRPS_VPAD_BUTTON_STICK_R; - } else if(VPADButton == VPAD_BUTTON_PLUS) { + } else if (VPADButton == VPAD_BUTTON_PLUS) { cur_config = CONTRPS_VPAD_BUTTON_PLUS; - } else if(VPADButton == VPAD_BUTTON_MINUS) { + } else if (VPADButton == VPAD_BUTTON_MINUS) { cur_config = CONTRPS_VPAD_BUTTON_MINUS; - } else if(VPADButton == VPAD_BUTTON_HOME) { + } else if (VPADButton == VPAD_BUTTON_HOME) { cur_config = CONTRPS_VPAD_BUTTON_HOME; } //! Special DPAD treatment. - if(config_controller[deviceslot][CONTRPS_DPAD_MODE][0] == CONTROLLER_PATCHER_VALUE_SET) { - if(config_controller[deviceslot][CONTRPS_DPAD_MODE][1] == CONTRPDM_Hat) { + if (config_controller[deviceslot][CONTRPS_DPAD_MODE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_DPAD_MODE][1] == CONTRPDM_Hat) { uint8_t mask = 0x0F; - if(config_controller[deviceslot][CONTRPS_DPAD_MASK][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_DPAD_MASK][0] == CONTROLLER_PATCHER_VALUE_SET) { mask = config_controller[deviceslot][CONTRPS_DPAD_MASK][1]; } - if(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL][0]] != config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL][1]) { // Not neutral - uint8_t dir1_0 = 0,dir1_1 = 0; - uint8_t dir2_0 = 0,dir2_1 = 0; - uint8_t dir3_0 = 0,dir3_1 = 0; + if (cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL][0]] != config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL][1]) { // Not neutral + uint8_t dir1_0 = 0, dir1_1 = 0; + uint8_t dir2_0 = 0, dir2_1 = 0; + uint8_t dir3_0 = 0, dir3_1 = 0; uint8_t direction = 0; - if(VPADButton == VPAD_BUTTON_LEFT) { - dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_W][0]; - dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][0]; - dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][0]; - dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_W][1]; - dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][1]; - dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][1]; + if (VPADButton == VPAD_BUTTON_LEFT) { + dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_W][0]; + dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][0]; + dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][0]; + dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_W][1]; + dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][1]; + dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][1]; direction = 1; - } else if(VPADButton == VPAD_BUTTON_RIGHT) { - dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_E][0]; - dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][0]; - dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][0]; - dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_E][1]; - dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][1]; - dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][1]; + } else if (VPADButton == VPAD_BUTTON_RIGHT) { + dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_E][0]; + dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][0]; + dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][0]; + dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_E][1]; + dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][1]; + dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][1]; direction = 1; - } else if(VPADButton == VPAD_BUTTON_DOWN) { - dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_S][0]; - dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][0]; - dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][0]; - dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_S][1]; - dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][1]; - dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][1]; + } else if (VPADButton == VPAD_BUTTON_DOWN) { + dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_S][0]; + dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][0]; + dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][0]; + dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_S][1]; + dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SE][1]; + dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_SW][1]; direction = 1; - } else if(VPADButton == VPAD_BUTTON_UP) { - dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_N][0]; - dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][0]; - dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][0]; - dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_N][1]; - dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][1]; - dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][1]; + } else if (VPADButton == VPAD_BUTTON_UP) { + dir1_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_N][0]; + dir2_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][0]; + dir3_0 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][0]; + dir1_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_N][1]; + dir2_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NW][1]; + dir3_1 = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_DPAD_NE][1]; direction = 1; } - if(direction && (((cur_data[dir1_0] & mask) == dir1_1) || - ((cur_data[dir2_0] & mask) == dir2_1) || - ((cur_data[dir3_0] & mask) == dir3_1))) { + 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; } } - } else if(config_controller[deviceslot][CONTRPS_DPAD_MODE][1] == CONTRPDM_Absolute_2Values) { + } else if (config_controller[deviceslot][CONTRPS_DPAD_MODE][1] == CONTRPDM_Absolute_2Values) { int32_t contrps_value = 0; - if(VPADButton == VPAD_BUTTON_LEFT) { + if (VPADButton == VPAD_BUTTON_LEFT) { contrps_value = CONTRPS_VPAD_BUTTON_DPAD_ABS_LEFT; - } else if(VPADButton == VPAD_BUTTON_RIGHT) { + } else if (VPADButton == VPAD_BUTTON_RIGHT) { contrps_value = CONTRPS_VPAD_BUTTON_DPAD_ABS_RIGHT; - } else if(VPADButton == VPAD_BUTTON_UP) { + } else if (VPADButton == VPAD_BUTTON_UP) { contrps_value = CONTRPS_VPAD_BUTTON_DPAD_ABS_UP; - } else if(VPADButton == VPAD_BUTTON_DOWN) { + } else if (VPADButton == VPAD_BUTTON_DOWN) { contrps_value = CONTRPS_VPAD_BUTTON_DPAD_ABS_DOWN; } - if(contrps_value != 0) { + if (contrps_value != 0) { int32_t value_byte = CONTROLLER_PATCHER_INVALIDVALUE; - if((value_byte = config_controller[deviceslot][contrps_value][0]) != CONTROLLER_PATCHER_INVALIDVALUE) { - if(cur_data[config_controller[deviceslot][contrps_value][0]] == config_controller[deviceslot][contrps_value][1]) { + if ((value_byte = config_controller[deviceslot][contrps_value][0]) != CONTROLLER_PATCHER_INVALIDVALUE) { + if (cur_data[config_controller[deviceslot][contrps_value][0]] == config_controller[deviceslot][contrps_value][1]) { result = 1; break; } @@ -186,56 +186,56 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_ } //! Normal DPAD treatment. - if(VPADButton == VPAD_BUTTON_LEFT) { + if (VPADButton == VPAD_BUTTON_LEFT) { cur_config = CONTRPS_VPAD_BUTTON_LEFT; - } else if(VPADButton == VPAD_BUTTON_RIGHT) { + } else if (VPADButton == VPAD_BUTTON_RIGHT) { cur_config = CONTRPS_VPAD_BUTTON_RIGHT; - } else if(VPADButton == VPAD_BUTTON_DOWN) { + } else if (VPADButton == VPAD_BUTTON_DOWN) { cur_config = CONTRPS_VPAD_BUTTON_DOWN; - } else if(VPADButton == VPAD_BUTTON_UP) { + } else if (VPADButton == VPAD_BUTTON_UP) { cur_config = CONTRPS_VPAD_BUTTON_UP; } - 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + 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)) { + if (checkValueinConfigController(deviceslot, CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED, cur_config)) { result = 0; break; } @@ -243,49 +243,49 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_ } } - if(isValueSet(data,cur_config) == 1) { + if (isValueSet(data, cur_config) == 1) { result = 1; break; } else { //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 ;) - if(result == 1) { + if (result == 1) { *buttons_hold |= VPADButton; // -1 would be also true. return 1; } return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isValueSet(HID_Data * data,int32_t cur_config) { - if(data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isValueSet(HID_Data *data, int32_t cur_config) { + if (data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - uint8_t * cur_data = &data->data_union.controller.cur_hid_data[0]; - if(cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + uint8_t *cur_data = &data->data_union.controller.cur_hid_data[0]; + if (cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - uint32_t hidmask = data->slotdata.hidmask; + uint32_t hidmask = data->slotdata.hidmask; int32_t deviceslot = data->slotdata.deviceslot; int32_t result = CONTROLLER_PATCHER_ERROR_NONE; - if(config_controller[deviceslot][cur_config][0] != CONTROLLER_PATCHER_INVALIDVALUE) { //Invalid data - if(hidmask & gHID_LIST_KEYBOARD) { - if(isInKeyboardData(cur_data,config_controller[deviceslot][cur_config][1]) > 0) { + if (config_controller[deviceslot][cur_config][0] != CONTROLLER_PATCHER_INVALIDVALUE) { //Invalid data + if (hidmask & gHID_LIST_KEYBOARD) { + if (isInKeyboardData(cur_data, config_controller[deviceslot][cur_config][1]) > 0) { result = 1; } } else { - if((cur_data[config_controller[deviceslot][cur_config][0]] & config_controller[deviceslot][cur_config][1]) == config_controller[deviceslot][cur_config][1]) { + if ((cur_data[config_controller[deviceslot][cur_config][0]] & config_controller[deviceslot][cur_config][1]) == config_controller[deviceslot][cur_config][1]) { result = 1; } } } return result; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isInKeyboardData(unsigned char * keyboardData,int32_t key) { - if(keyboardData == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - for(int32_t i = 0; i 1) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isInKeyboardData(unsigned char *keyboardData, int32_t key) { + if (keyboardData == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + for (int32_t i = 0; i < HID_KEYBOARD_DATA_LENGTH; i++) { + if (keyboardData[i] == 0 && i > 1) { break; } else if (keyboardData[i] == key) { return 1; @@ -298,27 +298,27 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isInKeyboardData(unsi * Utils for setting the Button data *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonRemappingData(VPADStatus * old_buffer, VPADStatus * new_buffer,uint32_t VPADButton, int32_t CONTRPS_SLOT) { - if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonRemappingData(VPADStatus *old_buffer, VPADStatus *new_buffer, uint32_t VPADButton, int32_t CONTRPS_SLOT) { + if (old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; uint32_t new_value = VPADButton; - if(config_controller[gGamePadSlot][CONTRPS_SLOT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { //using new value! + if (config_controller[gGamePadSlot][CONTRPS_SLOT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { //using new value! new_value = gGamePadValues[config_controller[gGamePadSlot][CONTRPS_SLOT][1]]; } - setButtonData(old_buffer,new_buffer,VPADButton,new_value); + setButtonData(old_buffer, new_buffer, VPADButton, new_value); return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADStatus * old_buffer, VPADStatus * new_buffer,uint32_t oldVPADButton,uint32_t newVPADButton) { - if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if((old_buffer->hold & oldVPADButton) == oldVPADButton) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADStatus *old_buffer, VPADStatus *new_buffer, uint32_t oldVPADButton, uint32_t newVPADButton) { + if (old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if ((old_buffer->hold & oldVPADButton) == oldVPADButton) { new_buffer->hold |= newVPADButton; } - if((old_buffer->release & oldVPADButton) == oldVPADButton) { + if ((old_buffer->release & oldVPADButton) == oldVPADButton) { new_buffer->release |= newVPADButton; } - if((old_buffer->trigger & oldVPADButton) == oldVPADButton) { + if ((old_buffer->trigger & oldVPADButton) == oldVPADButton) { new_buffer->trigger |= newVPADButton; } @@ -329,16 +329,16 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADSta * Pad Status functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkActivePad(uint32_t hidmask,int32_t pad) { - if(hidmask & gHID_LIST_GC && pad >= 0 && pad <= 3) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkActivePad(uint32_t hidmask, int32_t pad) { + if (hidmask & gHID_LIST_GC && pad >= 0 && pad <= 3) { if (!(((gHID_Devices[gHID_SLOT_GC].pad_data[pad].data_union.controller.cur_hid_data[0] & 0x10) == 0) && ((gHID_Devices[gHID_SLOT_GC].pad_data[pad].data_union.controller.cur_hid_data[0] & 0x22) != 0x22))) return 1; return CONTROLLER_PATCHER_ERROR_NO_PAD_CONNECTED; } else { int32_t deviceslot = getDeviceSlot(hidmask); - if(deviceslot < 0 ) return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; + if (deviceslot < 0) return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; int32_t connected_pads = config_controller[deviceslot][CONTRPS_CONNECTED_PADS][1]; - if((connected_pads & (1 << pad)) > 0) { + if ((connected_pads & (1 << pad)) > 0) { return 1; } } @@ -362,57 +362,57 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getActivePad(uint32_t * Stick functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::normalizeStickValues(VPADVec2D * stick) { - if(stick == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::normalizeStickValues(VPADVec2D *stick) { + if (stick == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; float max_val = 0.0f; float mul_val = 0.0f; - if((max_val = (fabs(stick->x)) + fabs(stick->y)) > 1.414f) { + if ((max_val = (fabs(stick->x)) + fabs(stick->y)) > 1.414f) { mul_val = 1.414f / max_val; stick->x *= mul_val; stick->y *= mul_val; } - if(stick->x > 1.0f) { + if (stick->x > 1.0f) { stick->x = 1.0f; } - if(stick->y > 1.0f) { + if (stick->y > 1.0f) { stick->y = 1.0f; } - if(stick->x < -1.0f) { + if (stick->x < -1.0f) { stick->x = -1.0f; } - if(stick->y < -1.0f) { + if (stick->y < -1.0f) { stick->y = -1.0f; } return CONTROLLER_PATCHER_ERROR_NONE; } -float ControllerPatcherUtils::convertAnalogValue(uint8_t value, uint8_t default_val, uint8_t min, uint8_t max, uint8_t invert,uint8_t deadzone) { - int8_t new_value = (int8_t)(value - default_val); - uint8_t range = 0; - if(value >= max) { - if(invert == 0x01) return -1.0f; +float ControllerPatcherUtils::convertAnalogValue(uint8_t value, uint8_t default_val, uint8_t min, uint8_t max, uint8_t invert, uint8_t deadzone) { + int8_t new_value = (int8_t) (value - default_val); + uint8_t range = 0; + if (value >= max) { + if (invert == 0x01) return -1.0f; return 1.0f; - } else if(value <= min) { - if(invert == 0x01) return 1.0f; + } else if (value <= min) { + if (invert == 0x01) return 1.0f; return -1.0f; } - if((value-deadzone) > default_val) { + if ((value - deadzone) > default_val) { new_value -= deadzone; range = (max - (default_val + deadzone)); - } else if((value+deadzone) < default_val) { + } else if ((value + deadzone) < default_val) { new_value += deadzone; range = ((default_val - deadzone) - min); } else { return 0.0f; } - if(invert != 0x01) { - return (new_value / (1.0f*range)); + if (invert != 0x01) { + return (new_value / (1.0f * range)); } else { - return -1.0f*(new_value / (1.0f*range)); + return -1.0f * (new_value / (1.0f * range)); } } @@ -421,37 +421,37 @@ VPADVec2D ControllerPatcherUtils::getAnalogValueByButtons(uint8_t stick_values) stick.x = 0.0f; stick.y = 0.0f; - uint8_t up = ((stick_values & STICK_VALUE_UP) == STICK_VALUE_UP); - uint8_t down = ((stick_values & STICK_VALUE_DOWN) == STICK_VALUE_DOWN); - uint8_t left = ((stick_values & STICK_VALUE_LEFT) == STICK_VALUE_LEFT); - uint8_t right = ((stick_values & STICK_VALUE_RIGHT) == STICK_VALUE_RIGHT); + uint8_t up = ((stick_values & STICK_VALUE_UP) == STICK_VALUE_UP); + uint8_t down = ((stick_values & STICK_VALUE_DOWN) == STICK_VALUE_DOWN); + uint8_t left = ((stick_values & STICK_VALUE_LEFT) == STICK_VALUE_LEFT); + uint8_t right = ((stick_values & STICK_VALUE_RIGHT) == STICK_VALUE_RIGHT); - if(up) { - if(!down) { + if (up) { + if (!down) { stick.y = 1.0f; } - if(left || right) { + if (left || right) { stick.y = 0.707f; - if(left) stick.x = -0.707f; - if(right) stick.x = 0.707f; + if (left) stick.x = -0.707f; + if (right) stick.x = 0.707f; } - } else if(down) { - if(!up) { + } else if (down) { + if (!up) { stick.y = -1.0f; } - if(left || right) { + if (left || right) { stick.y = -0.707f; - if(left) stick.x = -0.707f; - if(right) stick.x = 0.707f; + if (left) stick.x = -0.707f; + if (right) stick.x = 0.707f; } } else { - if(left) { - if(!right) { + if (left) { + if (!right) { stick.x = -1.0f; } - } else if(right) { - if(!down) { + } else if (right) { + if (!down) { stick.x = 1.0f; } } @@ -459,20 +459,20 @@ VPADVec2D ControllerPatcherUtils::getAnalogValueByButtons(uint8_t stick_values) return stick; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(HID_Data * data, VPADStatus * buffer) { - if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(HID_Data *data, VPADStatus *buffer) { + if (buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t deviceslot = data->slotdata.deviceslot; if (data->type == DEVICE_TYPE_MOUSE) { - if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM) { // TODO: tweak values - HID_Mouse_Data * ms_data = &data->data_union.mouse.cur_mouse_data; - if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (gHID_Mouse_Mode == HID_MOUSE_MODE_AIM) { // TODO: tweak values + HID_Mouse_Data *ms_data = &data->data_union.mouse.cur_mouse_data; + if (ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - float x_value = ms_data->deltaX/10.0f; - float y_value = -1.0f*(ms_data->deltaY/10.0f); + float x_value = ms_data->deltaX / 10.0f; + float y_value = -1.0f * (ms_data->deltaY / 10.0f); - if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][1] == DEF_L_STICK) { + if (config_controller[deviceslot][CONTRPS_MOUSE_STICK][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_MOUSE_STICK][1] == DEF_L_STICK) { buffer->leftStick.x += x_value; buffer->leftStick.y += y_value; return CONTROLLER_PATCHER_ERROR_NONE; @@ -483,148 +483,148 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H buffer->rightStick.y += y_value; } } else { - uint8_t * cur_data = &data->data_union.controller.cur_hid_data[0]; - if(cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + uint8_t *cur_data = &data->data_union.controller.cur_hid_data[0]; + if (cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t deadzone = 0; - if( config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE][1]; } buffer->leftStick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][0], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT][1], - deadzone); + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][0], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT][1], + deadzone); } - if( config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0] != CONTROLLER_PATCHER_INVALIDVALUE) { deadzone = 0; - if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][1]; } buffer->leftStick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][0], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT][1], - deadzone); + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][0], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT][1], + deadzone); } - if( config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0] != CONTROLLER_PATCHER_INVALIDVALUE) { deadzone = 0; - if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE][1]; } buffer->rightStick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][0], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT][1], - deadzone); + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][0], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT][1], + deadzone); } - if( config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0] != CONTROLLER_PATCHER_INVALIDVALUE) { deadzone = 0; - if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { + if (config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET) { deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE][1]; } buffer->rightStick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][0], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][1], - config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT][1], - deadzone); + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][0], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][1], + config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT][1], + deadzone); } uint8_t stick_values = 0; - if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_UP)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_L_STICK_UP)) { stick_values |= STICK_VALUE_UP; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_DOWN)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_L_STICK_DOWN)) { stick_values |= STICK_VALUE_DOWN; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_LEFT)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_L_STICK_LEFT)) { stick_values |= STICK_VALUE_LEFT; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)) { stick_values |= STICK_VALUE_RIGHT; } - if(stick_values > 0 ) { + if (stick_values > 0) { VPADVec2D stick = getAnalogValueByButtons(stick_values); buffer->leftStick.x += stick.x; buffer->leftStick.y += stick.y; } stick_values = 0; - if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_UP)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_R_STICK_UP)) { stick_values |= STICK_VALUE_UP; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_DOWN)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_R_STICK_DOWN)) { stick_values |= STICK_VALUE_DOWN; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_LEFT)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_R_STICK_LEFT)) { stick_values |= STICK_VALUE_LEFT; } - if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)) { + if (isValueSet(data, CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)) { stick_values |= STICK_VALUE_RIGHT; } - if(stick_values > 0 ) { + if (stick_values > 0) { VPADVec2D stick = getAnalogValueByButtons(stick_values); buffer->rightStick.x += stick.x; buffer->rightStick.y += stick.y; } - if(config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] == 1) { + if (config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] == 1) { uint8_t stick_values = 0; - if(buffer->hold & VPAD_BUTTON_UP) { + if (buffer->hold & VPAD_BUTTON_UP) { stick_values |= STICK_VALUE_UP; } - if(buffer->hold & VPAD_BUTTON_DOWN) { + if (buffer->hold & VPAD_BUTTON_DOWN) { stick_values |= STICK_VALUE_DOWN; } - if(buffer->hold & VPAD_BUTTON_LEFT) { + if (buffer->hold & VPAD_BUTTON_LEFT) { stick_values |= STICK_VALUE_LEFT; } - if(buffer->hold & VPAD_BUTTON_RIGHT) { + if (buffer->hold & VPAD_BUTTON_RIGHT) { stick_values |= STICK_VALUE_RIGHT; } - if(stick_values > 0 ) { + if (stick_values > 0) { VPADVec2D stick = getAnalogValueByButtons(stick_values); buffer->leftStick.x += stick.x; buffer->leftStick.y += stick.y; } } } - if(config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] == 1) { + if (config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] == 1) { uint8_t stick_values = 0; - if(buffer->hold & VPAD_BUTTON_UP) { + if (buffer->hold & VPAD_BUTTON_UP) { stick_values |= STICK_VALUE_UP; } - if(buffer->hold & VPAD_BUTTON_DOWN) { + if (buffer->hold & VPAD_BUTTON_DOWN) { stick_values |= STICK_VALUE_DOWN; } - if(buffer->hold & VPAD_BUTTON_LEFT) { + if (buffer->hold & VPAD_BUTTON_LEFT) { stick_values |= STICK_VALUE_LEFT; } - if(buffer->hold & VPAD_BUTTON_RIGHT) { + if (buffer->hold & VPAD_BUTTON_RIGHT) { stick_values |= STICK_VALUE_RIGHT; } - if(stick_values > 0 ) { + if (stick_values > 0) { VPADVec2D stick = getAnalogValueByButtons(stick_values); buffer->rightStick.x += stick.x; buffer->rightStick.y += stick.y; @@ -636,44 +636,43 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H 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.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]]);*/ - } return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPADStatus * buffer, uint32_t * last_emulatedSticks) { - if(buffer == NULL || last_emulatedSticks == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPADStatus *buffer, uint32_t *last_emulatedSticks) { + if (buffer == NULL || last_emulatedSticks == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; uint32_t emulatedSticks = 0; - int32_t l_x_full = (buffer->leftStick.x > 0.5f || buffer->leftStick.x < -0.5f)? 1:0; - int32_t l_y_full = (buffer->leftStick.y > 0.5f || buffer->leftStick.y < -0.5f)? 1:0; - int32_t r_x_full = (buffer->rightStick.x > 0.5f || buffer->rightStick.x < -0.5f)? 1:0; - int32_t r_y_full = (buffer->rightStick.y > 0.5f || buffer->rightStick.y < -0.5f)? 1:0; + int32_t l_x_full = (buffer->leftStick.x > 0.5f || buffer->leftStick.x < -0.5f) ? 1 : 0; + int32_t l_y_full = (buffer->leftStick.y > 0.5f || buffer->leftStick.y < -0.5f) ? 1 : 0; + int32_t r_x_full = (buffer->rightStick.x > 0.5f || buffer->rightStick.x < -0.5f) ? 1 : 0; + int32_t r_y_full = (buffer->rightStick.y > 0.5f || buffer->rightStick.y < -0.5f) ? 1 : 0; - if((buffer->leftStick.x > 0.5f) || (buffer->leftStick.x > 0.1f && !l_y_full)) { + if ((buffer->leftStick.x > 0.5f) || (buffer->leftStick.x > 0.1f && !l_y_full)) { emulatedSticks |= VPAD_STICK_L_EMULATION_RIGHT; } - if((buffer->leftStick.x < -0.5f) || (buffer->leftStick.x < -0.1f && !l_y_full)) { + if ((buffer->leftStick.x < -0.5f) || (buffer->leftStick.x < -0.1f && !l_y_full)) { emulatedSticks |= VPAD_STICK_L_EMULATION_LEFT; } - if((buffer->leftStick.y > 0.5f) || (buffer->leftStick.y > 0.1f && !l_x_full)) { + if ((buffer->leftStick.y > 0.5f) || (buffer->leftStick.y > 0.1f && !l_x_full)) { emulatedSticks |= VPAD_STICK_L_EMULATION_UP; } - if((buffer->leftStick.y < -0.5f) || (buffer->leftStick.y < -0.1f && !l_x_full)) { + if ((buffer->leftStick.y < -0.5f) || (buffer->leftStick.y < -0.1f && !l_x_full)) { emulatedSticks |= VPAD_STICK_L_EMULATION_DOWN; } - if((buffer->rightStick.x > 0.5f) || (buffer->rightStick.x > 0.1f && !r_y_full)) { + if ((buffer->rightStick.x > 0.5f) || (buffer->rightStick.x > 0.1f && !r_y_full)) { emulatedSticks |= VPAD_STICK_R_EMULATION_RIGHT; } - if((buffer->rightStick.x < -0.5f) || (buffer->rightStick.x < -0.1f && !r_y_full)) { + if ((buffer->rightStick.x < -0.5f) || (buffer->rightStick.x < -0.1f && !r_y_full)) { emulatedSticks |= VPAD_STICK_R_EMULATION_LEFT; } - if((buffer->rightStick.y > 0.5f) || (buffer->rightStick.y > 0.1f && !r_x_full)) { + if ((buffer->rightStick.y > 0.5f) || (buffer->rightStick.y > 0.1f && !r_x_full)) { emulatedSticks |= VPAD_STICK_R_EMULATION_UP; } - if((buffer->rightStick.y < -0.5f) || (buffer->rightStick.y < -0.1f && !r_x_full)) { + if ((buffer->rightStick.y < -0.5f) || (buffer->rightStick.y < -0.1f && !r_x_full)) { emulatedSticks |= VPAD_STICK_R_EMULATION_DOWN; } @@ -691,49 +690,49 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPA * Touch functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data * data,VPADStatus * buffer) { - if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(data->type == DEVICE_TYPE_MOUSE && gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data *data, VPADStatus *buffer) { + if (buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (data->type == DEVICE_TYPE_MOUSE && gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { int32_t buttons_hold; - if(getButtonPressed(data,&buttons_hold,VPAD_BUTTON_TOUCH)) { - HID_Mouse_Data * ms_data = &data->data_union.mouse.cur_mouse_data; - if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - int32_t x_mouse = 80 + ((int)(((ms_data->X)*1.0f/1280.0)*3890.0f)); - int32_t y_mouse = 3910 - ((int)(((ms_data->Y)*1.0f/720.0)*3760.0f)); - buffer->tpNormal.x = x_mouse; - buffer->tpNormal.y = y_mouse; - buffer->tpNormal.touched = 1; - buffer->tpNormal.validity = 0; - buffer->tpFiltered1.x = x_mouse; - buffer->tpFiltered1.y = y_mouse; - buffer->tpFiltered1.touched = 1; + if (getButtonPressed(data, &buttons_hold, VPAD_BUTTON_TOUCH)) { + HID_Mouse_Data *ms_data = &data->data_union.mouse.cur_mouse_data; + if (ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + int32_t x_mouse = 80 + ((int) (((ms_data->X) * 1.0f / 1280.0) * 3890.0f)); + int32_t y_mouse = 3910 - ((int) (((ms_data->Y) * 1.0f / 720.0) * 3760.0f)); + buffer->tpNormal.x = x_mouse; + buffer->tpNormal.y = y_mouse; + buffer->tpNormal.touched = 1; + buffer->tpNormal.validity = 0; + buffer->tpFiltered1.x = x_mouse; + buffer->tpFiltered1.y = y_mouse; + buffer->tpFiltered1.touched = 1; buffer->tpFiltered1.validity = 0; - buffer->tpFiltered2.x = x_mouse; - buffer->tpFiltered2.y = y_mouse; - buffer->tpFiltered2.touched = 1; + buffer->tpFiltered2.x = x_mouse; + buffer->tpFiltered2.y = y_mouse; + buffer->tpFiltered2.touched = 1; buffer->tpFiltered2.validity = 0; } } return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(HID_Data * data) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(HID_Data *data) { uint32_t hidmask = data->slotdata.hidmask; - if(hidmask & gHID_LIST_KEYBOARD) { - uint8_t * cur_data = &data->data_union.controller.cur_hid_data[0]; - uint8_t * last_data = &data->data_union.controller.last_hid_data[0]; - 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)) && gMouseModeCoolDown == 0) { + if (hidmask & gHID_LIST_KEYBOARD) { + uint8_t *cur_data = &data->data_union.controller.cur_hid_data[0]; + uint8_t *last_data = &data->data_union.controller.last_hid_data[0]; + 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)) && gMouseModeCoolDown == 0) { 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; //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 ",__LINE__); gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; } } - if(gMouseModeCoolDown > 0) { + if (gMouseModeCoolDown > 0) { gMouseModeCoolDown--; } } @@ -744,46 +743,46 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode( * Other functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADStatus * vpad_buffer,KPADStatus * pro_buffer,uint32_t * lastButtonsPressesPRO) { - if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesPRO == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADStatus *vpad_buffer, KPADStatus *pro_buffer, uint32_t *lastButtonsPressesPRO) { + if (vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesPRO == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t buttons_hold = 0; - if(vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A; - if(vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B; - if(vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X; - if(vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y; + if (vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A; + if (vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B; + if (vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X; + if (vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y; - if(vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS; - if(vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS; - if(vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME; + if (vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS; + if (vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS; + if (vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME; - if(vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT; - if(vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT; - if(vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP; - if(vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN; + if (vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT; + if (vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT; + if (vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP; + if (vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN; - if(vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L; - if(vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL; + if (vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L; + if (vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL; - if(vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R; - if(vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR; + if (vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R; + if (vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR; - if(vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L; - if(vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R; + if (vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L; + if (vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN; - pro_buffer->pro.leftStick.x = vpad_buffer->leftStick.x; - pro_buffer->pro.leftStick.y = vpad_buffer->leftStick.y; + pro_buffer->pro.leftStick.x = vpad_buffer->leftStick.x; + pro_buffer->pro.leftStick.y = vpad_buffer->leftStick.y; pro_buffer->pro.rightStick.x = vpad_buffer->rightStick.x; pro_buffer->pro.rightStick.y = vpad_buffer->rightStick.y; @@ -797,115 +796,115 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADSt pro_buffer->unused_7[1] = 0x3F800000; pro_buffer->unused_7[5] = 0x3F800000;*/ - pro_buffer->pro.hold = buttons_hold; + pro_buffer->pro.hold = buttons_hold; pro_buffer->pro.trigger = (buttons_hold & (~*lastButtonsPressesPRO)); pro_buffer->pro.release = (*lastButtonsPressesPRO & (~buttons_hold)); *lastButtonsPressesPRO = buttons_hold; - pro_buffer->format = WPAD_FMT_PRO_CONTROLLER; - pro_buffer->error = 0x00; + pro_buffer->format = WPAD_FMT_PRO_CONTROLLER; + pro_buffer->error = 0x00; pro_buffer->extensionType = WPAD_EXT_PRO_CONTROLLER; - pro_buffer->pro.wired = 1; - pro_buffer->pro.charging = 1; + pro_buffer->pro.wired = 1; + pro_buffer->pro.charging = 1; return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToProWPADRead(VPADStatus * vpad_buffer,WPADStatusProController * pro_buffer) { - if(vpad_buffer == NULL || pro_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToProWPADRead(VPADStatus *vpad_buffer, WPADStatusProController *pro_buffer) { + if (vpad_buffer == NULL || pro_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t buttons_hold = 0; - if(vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A; - if(vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B; - if(vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X; - if(vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y; + if (vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A; + if (vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B; + if (vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X; + if (vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y; - if(vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS; - if(vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS; - if(vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME; + if (vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS; + if (vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS; + if (vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME; - if(vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT; - if(vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT; - if(vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP; - if(vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN; + if (vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT; + if (vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT; + if (vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP; + if (vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN; - if(vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L; - if(vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL; + if (vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L; + if (vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL; - if(vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R; - if(vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR; + if (vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R; + if (vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR; - if(vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L; - if(vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R; + if (vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L; + if (vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP; - if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP; + if (vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP; - if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP; + if (vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN; - pro_buffer->leftStick.x = (int16_t) (vpad_buffer->leftStick.x * 950.0f); - pro_buffer->leftStick.y = (int16_t) (vpad_buffer->leftStick.y * 950.0f); + pro_buffer->leftStick.x = (int16_t) (vpad_buffer->leftStick.x * 950.0f); + pro_buffer->leftStick.y = (int16_t) (vpad_buffer->leftStick.y * 950.0f); pro_buffer->rightStick.x = (int16_t) (vpad_buffer->rightStick.x * 950.0f); pro_buffer->rightStick.y = (int16_t) (vpad_buffer->rightStick.y * 950.0f); pro_buffer->buttons = buttons_hold; - pro_buffer->dataFormat = WPAD_FMT_PRO_CONTROLLER; - pro_buffer->err = 0x00; + pro_buffer->dataFormat = WPAD_FMT_PRO_CONTROLLER; + pro_buffer->err = 0x00; pro_buffer->extensionType = WPAD_EXT_PRO_CONTROLLER; return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToVPAD(VPADStatus * vpad_buffer,KPADStatus * pro_buffer,uint32_t * lastButtonsPressesVPAD) { - if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesVPAD == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToVPAD(VPADStatus *vpad_buffer, KPADStatus *pro_buffer, uint32_t *lastButtonsPressesVPAD) { + if (vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesVPAD == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; int32_t buttons_hold = 0; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_A) buttons_hold |= VPAD_BUTTON_A; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_A) buttons_hold |= VPAD_BUTTON_A; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_B) buttons_hold |= VPAD_BUTTON_B; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_X) buttons_hold |= VPAD_BUTTON_X; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_Y) buttons_hold |= VPAD_BUTTON_Y; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_B) buttons_hold |= VPAD_BUTTON_B; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_X) buttons_hold |= VPAD_BUTTON_X; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_Y) buttons_hold |= VPAD_BUTTON_Y; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_PLUS) buttons_hold |= VPAD_BUTTON_PLUS; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_MINUS) buttons_hold |= VPAD_BUTTON_MINUS; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_PLUS) buttons_hold |= VPAD_BUTTON_PLUS; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_MINUS) buttons_hold |= VPAD_BUTTON_MINUS; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_HOME) buttons_hold |= VPAD_BUTTON_HOME; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_HOME) buttons_hold |= VPAD_BUTTON_HOME; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_LEFT) buttons_hold |= VPAD_BUTTON_LEFT; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_RIGHT) buttons_hold |= VPAD_BUTTON_RIGHT; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_UP) buttons_hold |= VPAD_BUTTON_UP; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_DOWN) buttons_hold |= VPAD_BUTTON_DOWN; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_LEFT) buttons_hold |= VPAD_BUTTON_LEFT; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_RIGHT) buttons_hold |= VPAD_BUTTON_RIGHT; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_UP) buttons_hold |= VPAD_BUTTON_UP; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_DOWN) buttons_hold |= VPAD_BUTTON_DOWN; - if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_L) buttons_hold |= VPAD_BUTTON_L; - if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZL) buttons_hold |= VPAD_BUTTON_ZL; + if (pro_buffer->pro.hold & WPAD_PRO_TRIGGER_L) buttons_hold |= VPAD_BUTTON_L; + if (pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZL) buttons_hold |= VPAD_BUTTON_ZL; - if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_R) buttons_hold |= VPAD_BUTTON_R; - if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZR) buttons_hold |= VPAD_BUTTON_ZR; + if (pro_buffer->pro.hold & WPAD_PRO_TRIGGER_R) buttons_hold |= VPAD_BUTTON_R; + if (pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZR) buttons_hold |= VPAD_BUTTON_ZR; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_L) buttons_hold |= VPAD_BUTTON_STICK_L; - if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_R) buttons_hold |= VPAD_BUTTON_STICK_R; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_L) buttons_hold |= VPAD_BUTTON_STICK_L; + if (pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_R) buttons_hold |= VPAD_BUTTON_STICK_R; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_LEFT) buttons_hold |= VPAD_STICK_L_EMULATION_LEFT; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_L_EMULATION_RIGHT; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_UP) buttons_hold |= VPAD_STICK_L_EMULATION_UP; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_DOWN) buttons_hold |= VPAD_STICK_L_EMULATION_DOWN; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_LEFT) buttons_hold |= VPAD_STICK_L_EMULATION_LEFT; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_L_EMULATION_RIGHT; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_UP) buttons_hold |= VPAD_STICK_L_EMULATION_UP; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_DOWN) buttons_hold |= VPAD_STICK_L_EMULATION_DOWN; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_LEFT) buttons_hold |= VPAD_STICK_R_EMULATION_LEFT; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_R_EMULATION_RIGHT; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_UP) buttons_hold |= VPAD_STICK_R_EMULATION_UP; - if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_DOWN) buttons_hold |= VPAD_STICK_R_EMULATION_DOWN; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_LEFT) buttons_hold |= VPAD_STICK_R_EMULATION_LEFT; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_R_EMULATION_RIGHT; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_UP) buttons_hold |= VPAD_STICK_R_EMULATION_UP; + if (pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_DOWN) buttons_hold |= VPAD_STICK_R_EMULATION_DOWN; - vpad_buffer->leftStick.x = pro_buffer->pro.leftStick.x; - vpad_buffer->leftStick.y = pro_buffer->pro.leftStick.y; + vpad_buffer->leftStick.x = pro_buffer->pro.leftStick.x; + vpad_buffer->leftStick.y = pro_buffer->pro.leftStick.y; vpad_buffer->rightStick.x = pro_buffer->pro.rightStick.x; vpad_buffer->rightStick.y = pro_buffer->pro.rightStick.y; @@ -918,40 +917,40 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToVPAD(VPADS return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkValueinConfigController(int32_t deviceslot,int32_t CONTRPS_slot,int32_t expectedValue) { - if(config_controller[deviceslot][CONTRPS_slot][0] != CONTROLLER_PATCHER_INVALIDVALUE) { - if(expectedValue == config_controller[deviceslot][CONTRPS_slot][1]) return 1; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkValueinConfigController(int32_t deviceslot, int32_t CONTRPS_slot, int32_t expectedValue) { + if (config_controller[deviceslot][CONTRPS_slot][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (expectedValue == config_controller[deviceslot][CONTRPS_slot][1]) return 1; } return 0; } -void ControllerPatcherUtils::setConfigValue(uint8_t * dest, uint8_t first, uint8_t second) { +void ControllerPatcherUtils::setConfigValue(uint8_t *dest, uint8_t first, uint8_t second) { dest[0] = first; dest[1] = second; } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceSlot(uint32_t hidmask) { - for(int32_t i = 0; i < gHIDMaxDevices; i++) { - if(hidmask & config_controller_hidmask[i]) { + for (int32_t i = 0; i < gHIDMaxDevices; i++) { + if (hidmask & config_controller_hidmask[i]) { return i; } } return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidPid(DeviceInfo * info) { - if(info != NULL) { - for(int32_t i = 0; i< gHIDMaxDevices; i++) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidPid(DeviceInfo *info) { + if (info != NULL) { + 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_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)",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]; + if (info->vidpid.vid == my_vid && info->vidpid.pid == my_pid) { + info->slotdata.hidmask = config_controller_hidmask[i]; info->slotdata.deviceslot = i; - info->pad_count = 1; - if(config_controller[i][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + info->pad_count = 1; + if (config_controller[i][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { info->pad_count = config_controller[i][CONTRPS_PAD_COUNT][1]; - if(info->pad_count > HID_MAX_PADS_COUNT) { + if (info->pad_count > HID_MAX_PADS_COUNT) { info->pad_count = HID_MAX_PADS_COUNT; } } @@ -966,35 +965,35 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidP return CONTROLLER_PATCHER_ERROR_INVALID_BUFFER; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getNextSlotData(HIDSlotData * slotdata) { - if(slotdata == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(gHIDRegisteredDevices >= gHIDMaxDevices) return CONTROLLER_PATCHER_ERROR_NO_FREE_SLOT; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getNextSlotData(HIDSlotData *slotdata) { + if (slotdata == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (gHIDRegisteredDevices >= gHIDMaxDevices) return CONTROLLER_PATCHER_ERROR_NO_FREE_SLOT; slotdata->deviceslot = gHIDRegisteredDevices; - slotdata->hidmask = (1 << (gHIDRegisteredDevices)); + slotdata->hidmask = (1 << (gHIDRegisteredDevices)); gHIDRegisteredDevices++; return CONTROLLER_PATCHER_ERROR_NONE; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getVIDPIDbyDeviceSlot(int32_t deviceslot, DeviceVIDPIDInfo * vidpid) { - if(vidpid == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - if(deviceslot >= gHIDMaxDevices || deviceslot < 0) return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getVIDPIDbyDeviceSlot(int32_t deviceslot, DeviceVIDPIDInfo *vidpid) { + if (vidpid == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; + if (deviceslot >= gHIDMaxDevices || deviceslot < 0) return CONTROLLER_PATCHER_ERROR_DEVICE_SLOT_NOT_FOUND; vidpid->vid = config_controller[deviceslot][CONTRPS_VID][0] * 0x100 + config_controller[deviceslot][CONTRPS_VID][1]; vidpid->pid = config_controller[deviceslot][CONTRPS_PID][0] * 0x100 + config_controller[deviceslot][CONTRPS_PID][1]; - if(vidpid->vid == 0x0000) return CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA; + if (vidpid->vid == 0x0000) return CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA; return CONTROLLER_PATCHER_ERROR_NONE; } -int32_t ControllerPatcherUtils::getPadSlotInAdapter(int32_t deviceslot, uint8_t * input_data) { +int32_t ControllerPatcherUtils::getPadSlotInAdapter(int32_t deviceslot, uint8_t *input_data) { int32_t slot_incr = 0; - if(config_controller[deviceslot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { + if (config_controller[deviceslot][CONTRPS_PAD_COUNT][0] != CONTROLLER_PATCHER_INVALIDVALUE) { int32_t pad_count = config_controller[deviceslot][CONTRPS_PAD_COUNT][1]; - if(pad_count > HID_MAX_PADS_COUNT) { + if (pad_count > HID_MAX_PADS_COUNT) { pad_count = HID_MAX_PADS_COUNT; } - for(int32_t i= 0; iactive) { +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::doSamplingSingle(WPADChan chan, uint16_t deviceslot, uint8_t padslot = 0, BOOL ignorePadSlot = false) { + ControllerMappingPADInfo *padinfo = gProPadInfo[chan]; + if (padinfo->active) { DeviceInfo device_info; - memset(&device_info,0,sizeof(device_info)); + memset(&device_info, 0, sizeof(device_info)); device_info.vidpid = padinfo->vidpid; int32_t res = -1; - if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) >= 0) { - if(!ignorePadSlot) { - int32_t real_pad = (padinfo->pad/(device_info.pad_count))*device_info.pad_count; - if(real_pad == padslot && device_info.slotdata.deviceslot == deviceslot) { - if(ControllerPatcherUtils::checkActivePad(device_info.slotdata.hidmask,padinfo->pad)) { + if ((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) >= 0) { + if (!ignorePadSlot) { + int32_t real_pad = (padinfo->pad / (device_info.pad_count)) * device_info.pad_count; + if (real_pad == padslot && device_info.slotdata.deviceslot == deviceslot) { + if (ControllerPatcherUtils::checkActivePad(device_info.slotdata.hidmask, padinfo->pad)) { gSamplingCallback(chan); } } diff --git a/source/patcher/ControllerPatcherUtils.hpp b/source/patcher/ControllerPatcherUtils.hpp index e8b37af..8710167 100644 --- a/source/patcher/ControllerPatcherUtils.hpp +++ b/source/patcher/ControllerPatcherUtils.hpp @@ -56,7 +56,7 @@ public: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. The actual result will be store in the given my_cb_user **. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getDataByHandle(int32_t handle, my_cb_user ** data); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getDataByHandle(int32_t handle, my_cb_user **data); /** \brief Returns the VID/PID for the given device slot. @@ -66,7 +66,7 @@ public: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. The actual result will be store in the given DeviceVIDPIDInfo *. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getVIDPIDbyDeviceSlot(int32_t deviceslot, DeviceVIDPIDInfo * vidpid); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getVIDPIDbyDeviceSlot(int32_t deviceslot, DeviceVIDPIDInfo *vidpid); /** \brief Set the VPAD data for a given KPAD data. * @@ -76,7 +76,8 @@ public: * \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToVPAD(VPADStatus * vpad_buffer,KPADStatus * pro_buffer,uint32_t * lastButtonsPressesVPAD); + static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToVPAD(VPADStatus *vpad_buffer, KPADStatus *pro_buffer, uint32_t *lastButtonsPressesVPAD); + private: /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Analyse inputs @@ -90,7 +91,7 @@ private: * \return When the functions failed result < 0 is returned.If the result is >= 0 the function was successful. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getButtonPressed(HID_Data * data, int32_t * buttons_hold, int32_t VPADButton); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getButtonPressed(HID_Data *data, int32_t *buttons_hold, int32_t VPADButton); /** \brief Checks if a given value is set in the HID_DATA given the data in the slot number provided by cur_config. @@ -100,7 +101,7 @@ private: * \return When the functions failed result < 0 is returned. If the value is set, 1 will be returned. Otherwise 0. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR isValueSet(HID_Data * data,int32_t cur_config); + static CONTROLLER_PATCHER_RESULT_OR_ERROR isValueSet(HID_Data *data, int32_t cur_config); /** \brief Checks if a given key in the keyboard data is pressed. @@ -110,7 +111,7 @@ private: * \return When the functions failed result < 0 is returned. If the key is active pressed, 1 is returned. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR isInKeyboardData(unsigned char * keyboardData,int32_t key); + static CONTROLLER_PATCHER_RESULT_OR_ERROR isInKeyboardData(unsigned char *keyboardData, int32_t key); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Utils for setting the Button data @@ -126,7 +127,7 @@ private: * \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonRemappingData(VPADStatus * old_buffer, VPADStatus * new_buffer,uint32_t VPADButton, int32_t CONTRPS_SLOT); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonRemappingData(VPADStatus *old_buffer, VPADStatus *new_buffer, uint32_t VPADButton, int32_t CONTRPS_SLOT); /** \brief Checks if a given button (oldVPADButton) is set in a given VPADStatus struct (old_buffer). If its set, it will set an other @@ -139,7 +140,7 @@ private: \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonData(VPADStatus * old_buffer, VPADStatus * new_buffer,uint32_t oldVPADButton,uint32_t newVPADButton); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonData(VPADStatus *old_buffer, VPADStatus *new_buffer, uint32_t oldVPADButton, uint32_t newVPADButton); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Pad Status functions @@ -152,7 +153,7 @@ private: \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR checkActivePad(uint32_t hidmask,int32_t pad); + static CONTROLLER_PATCHER_RESULT_OR_ERROR checkActivePad(uint32_t hidmask, int32_t pad); /** \brief Returns the first active pad of devices with the given HID-Mask. Currently only implemented for the GC-Adapter. Every other pad will always return 0. @@ -173,7 +174,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR normalizeStickValues(VPADVec2D * stick); + static CONTROLLER_PATCHER_RESULT_OR_ERROR normalizeStickValues(VPADVec2D *stick); /** \brief Converts the digital absolute stick data into a float value. It also applies the deadzones, and can invert the result. @@ -187,7 +188,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static float convertAnalogValue(uint8_t value, uint8_t default_val, uint8_t min, uint8_t max, uint8_t invert,uint8_t deadzone); + static float convertAnalogValue(uint8_t value, uint8_t default_val, uint8_t min, uint8_t max, uint8_t invert, uint8_t deadzone); /** \brief Calculates a the stick data (VPADVec2D) from given digital direction. @@ -206,7 +207,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR convertAnalogSticks(HID_Data * data,VPADStatus * buffer); + static CONTROLLER_PATCHER_RESULT_OR_ERROR convertAnalogSticks(HID_Data *data, VPADStatus *buffer); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Mouse functions @@ -220,7 +221,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setTouch(HID_Data * data,VPADStatus * buffer); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setTouch(HID_Data *data, VPADStatus *buffer); /** \brief Checks if the mouse mode needs to be changed. Sets it to the new mode if necessary. * Currently the incoming data needs to be from a keyboard. @@ -229,7 +230,7 @@ private: * \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR checkAndSetMouseMode(HID_Data * data); + static CONTROLLER_PATCHER_RESULT_OR_ERROR checkAndSetMouseMode(HID_Data *data); /** \brief Set the emulated sticks for a given VPAD data. @@ -239,7 +240,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR setEmulatedSticks(VPADStatus * buffer, uint32_t * last_emulatedSticks); + static CONTROLLER_PATCHER_RESULT_OR_ERROR setEmulatedSticks(VPADStatus *buffer, uint32_t *last_emulatedSticks); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Other functions @@ -252,8 +253,8 @@ private: * \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. * */ - static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToPro(VPADStatus * vpad_buffer, KPADStatus * pro_buffer, uint32_t * lastButtonsPressesPRO); - static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToProWPADRead(VPADStatus * vpad_buffer,WPADStatusProController * pro_buffer); + static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToPro(VPADStatus *vpad_buffer, KPADStatus *pro_buffer, uint32_t *lastButtonsPressesPRO); + static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToProWPADRead(VPADStatus *vpad_buffer, WPADStatusProController *pro_buffer); /** \brief Checks if the value at the given device + CONTRPS slot equals the expected value. @@ -264,7 +265,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR checkValueinConfigController(int32_t device_slot,int32_t CONTRPS_slot,int32_t expectedValue); + static CONTROLLER_PATCHER_RESULT_OR_ERROR checkValueinConfigController(int32_t device_slot, int32_t CONTRPS_slot, int32_t expectedValue); /** \brief Sets two uint8_t values to the given pointer. @@ -273,7 +274,7 @@ private: \param first: Value that will be written in @p dest[0] \param second: Value that will be written in @p dest[1] **/ - static void setConfigValue(uint8_t * dest , uint8_t first, uint8_t second); + static void setConfigValue(uint8_t *dest, uint8_t first, uint8_t second); /** \brief Saves a new free device slot and the corresponding HID-Mask in the given @p HIDSlotData pointer @@ -282,7 +283,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getNextSlotData(HIDSlotData * slotdata); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getNextSlotData(HIDSlotData *slotdata); /** \brief Fills up a given DeviceInfo, which provides a valid VID/PID, with HIDSlotData. @@ -291,7 +292,7 @@ private: \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getDeviceInfoFromVidPid(DeviceInfo * info); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getDeviceInfoFromVidPid(DeviceInfo *info); /** \brief returns the internal slot number of the device. Some adapters have multiple slot and send the data for each one @@ -302,7 +303,7 @@ private: \param current input data \return The relative slot in the device **/ - static int32_t getPadSlotInAdapter(int32_t deviceslot, uint8_t * input_data); + static int32_t getPadSlotInAdapter(int32_t deviceslot, uint8_t *input_data); /** \brief returns a pointer to the ControllerMapping to the given controller type @@ -311,9 +312,9 @@ private: \return pointer to ControllerMapping data, null is type was invalid **/ - static ControllerMappingPAD * getControllerMappingByType(UController_Type type); + static ControllerMappingPAD *getControllerMappingByType(UController_Type type); - static CONTROLLER_PATCHER_RESULT_OR_ERROR doSampling(uint16_t deviceslot,uint8_t padslot,BOOL ignorePadSlot); + static CONTROLLER_PATCHER_RESULT_OR_ERROR doSampling(uint16_t deviceslot, uint8_t padslot, BOOL ignorePadSlot); static CONTROLLER_PATCHER_RESULT_OR_ERROR doSamplingSingle(WPADChan chan, uint16_t deviceslot, uint8_t padslot, BOOL ignorePadSlot); }; diff --git a/source/system/CThread.h b/source/system/CThread.h index b91b249..56aac73 100644 --- a/source/system/CThread.h +++ b/source/system/CThread.h @@ -18,30 +18,27 @@ #define CTHREAD_H_ -#include -#include #include #include +#include +#include class CThread { public: - typedef void (* Callback)(CThread *thread, void *arg); + typedef void (*Callback)(CThread *thread, void *arg); //! constructor CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) - : pThread(NULL) - , pThreadStack(NULL) - , pCallback(callback) - , pCallbackArg(callbackArg) { + : pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) { //! save attribute assignment iAttributes = iAttr; //! allocate the thread - pThread = (OSThread*)memalign(8, sizeof(OSThread)); + pThread = (OSThread *) memalign(8, sizeof(OSThread)); //! allocate the stack pThreadStack = (uint8_t *) memalign(0x20, iStackSize); //! create the thread - if(pThread && pThreadStack) - OSCreateThread(pThread, &CThread::threadCallback, 1, (char*)this, pThreadStack+iStackSize, iStackSize, iPriority, iAttributes); + if (pThread && pThreadStack) + OSCreateThread(pThread, &CThread::threadCallback, 1, (char *) this, pThreadStack + iStackSize, iStackSize, iPriority, iAttributes); } //! destructor @@ -50,40 +47,40 @@ public: } static CThread *create(CThread::Callback callback, void *callbackArg, int32_t iAttr = eAttributeNone, int32_t iPriority = 16, int32_t iStackSize = 0x8000) { - return ( new CThread(iAttr, iPriority, iStackSize, callback, callbackArg) ); + return (new CThread(iAttr, iPriority, iStackSize, callback, callbackArg)); } //! Get thread ID - virtual void* getThread() const { + virtual void *getThread() const { return pThread; } //! Thread entry function virtual void executeThread(void) { - if(pCallback) + if (pCallback) pCallback(this, pCallbackArg); } //! Suspend thread virtual void suspendThread(void) { - if(isThreadSuspended()) return; - if(pThread) OSSuspendThread(pThread); + if (isThreadSuspended()) return; + if (pThread) OSSuspendThread(pThread); } //! Resume thread virtual void resumeThread(void) { - if(!isThreadSuspended()) return; - if(pThread) OSResumeThread(pThread); + if (!isThreadSuspended()) return; + if (pThread) OSResumeThread(pThread); } //! Set thread priority virtual void setThreadPriority(int prio) { - if(pThread) OSSetThreadPriority(pThread, prio); + if (pThread) OSSetThreadPriority(pThread, prio); } //! Check if thread is suspended virtual BOOL isThreadSuspended(void) const { - if(pThread) return OSIsThreadSuspended(pThread); + if (pThread) return OSIsThreadSuspended(pThread); return false; } //! Check if thread is terminated virtual BOOL isThreadTerminated(void) const { - if(pThread) return OSIsThreadTerminated(pThread); + if (pThread) return OSIsThreadTerminated(pThread); return false; } //! Check if thread is running @@ -93,30 +90,31 @@ public: //! Shutdown thread virtual void shutdownThread(void) { //! wait for thread to finish - if(pThread && !(iAttributes & eAttributeDetach)) { - if(isThreadSuspended()) + if (pThread && !(iAttributes & eAttributeDetach)) { + if (isThreadSuspended()) resumeThread(); OSJoinThread(pThread, NULL); } //! free the thread stack buffer - if(pThreadStack) + if (pThreadStack) free(pThreadStack); - if(pThread) + if (pThread) free(pThread); - pThread = NULL; + pThread = NULL; pThreadStack = NULL; } //! Thread attributes enum eCThreadAttributes { - eAttributeNone = 0x07, - eAttributeAffCore0 = 0x01, - eAttributeAffCore1 = 0x02, - eAttributeAffCore2 = 0x04, - eAttributeDetach = 0x08, - eAttributePinnedAff = 0x10 + eAttributeNone = 0x07, + eAttributeAffCore0 = 0x01, + eAttributeAffCore1 = 0x02, + eAttributeAffCore2 = 0x04, + eAttributeDetach = 0x08, + eAttributePinnedAff = 0x10 }; + private: static int threadCallback(int argc, const char **argv) { //! After call to start() continue with the internal function diff --git a/source/utils/CPRetainVars.cpp b/source/utils/CPRetainVars.cpp index 4624705..1f68404 100644 --- a/source/utils/CPRetainVars.cpp +++ b/source/utils/CPRetainVars.cpp @@ -19,10 +19,10 @@ ControllerMapping gControllerMapping __attribute__((section(".data"))); -uint8_t gConfig_done __attribute__((section(".data"))) = 0; +uint8_t gConfig_done __attribute__((section(".data"))) = 0; uint8_t gButtonRemappingConfigDone __attribute__((section(".data"))) = 0; -uint32_t gHIDAttached __attribute__((section(".data"))) = 0; +uint32_t gHIDAttached __attribute__((section(".data"))) = 0; uint32_t gHIDCurrentDevice __attribute__((section(".data"))) = 0; uint16_t gHIDRegisteredDevices __attribute__((section(".data"))) = 0; @@ -37,40 +37,39 @@ uint8_t gMouseModeCoolDown __attribute__((section(".data"))) = 0; uint32_t gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data"))); -uint8_t config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data"))); +uint8_t config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data"))); uint32_t config_controller_hidmask[gHIDMaxDevices] __attribute__((section(".data"))); -uint32_t gHID_LIST_GC __attribute__((section(".data"))) = 0; -uint32_t gHID_LIST_DS3 __attribute__((section(".data"))) = 0; -uint32_t gHID_LIST_DS4 __attribute__((section(".data"))) = 0; -uint32_t gHID_LIST_KEYBOARD __attribute__((section(".data"))) = 0; +uint32_t gHID_LIST_GC __attribute__((section(".data"))) = 0; +uint32_t gHID_LIST_DS3 __attribute__((section(".data"))) = 0; +uint32_t gHID_LIST_DS4 __attribute__((section(".data"))) = 0; +uint32_t gHID_LIST_KEYBOARD __attribute__((section(".data"))) = 0; uint32_t gHID_LIST_SWITCH_PRO __attribute__((section(".data"))) = 0; -uint32_t gHID_LIST_MOUSE __attribute__((section(".data"))) = 0; +uint32_t gHID_LIST_MOUSE __attribute__((section(".data"))) = 0; -uint16_t gGamePadSlot __attribute__((section(".data"))) = 0; -uint16_t gHID_SLOT_GC __attribute__((section(".data"))) = 0; +uint16_t gGamePadSlot __attribute__((section(".data"))) = 0; +uint16_t gHID_SLOT_GC __attribute__((section(".data"))) = 0; uint16_t gHID_SLOT_KEYBOARD __attribute__((section(".data"))) = 0; -uint16_t gMouseSlot __attribute__((section(".data"))) = 0; +uint16_t gMouseSlot __attribute__((section(".data"))) = 0; uint8_t gOriginalDimState __attribute__((section(".data"))) = 0; uint8_t gOriginalAPDState __attribute__((section(".data"))) = 0; uint16_t gNetworkController[gHIDMaxDevices][HID_MAX_PADS_COUNT][4] __attribute__((section(".data"))); -int32_t gHIDNetworkClientID __attribute__((section(".data"))) = 0; -uint8_t gUsedProtocolVersion __attribute__((section(".data"))) = WIIU_CP_TCP_HANDSHAKE; +int32_t gHIDNetworkClientID __attribute__((section(".data"))) = 0; +uint8_t gUsedProtocolVersion __attribute__((section(".data"))) = WIIU_CP_TCP_HANDSHAKE; WPADConnectCallback gWPADConnectCallback[4] __attribute__((section(".data"))); WPADConnectCallback gKPADConnectCallback[4] __attribute__((section(".data"))); WPADExtensionCallback gExtensionCallback[4] __attribute__((section(".data"))); WPADSamplingCallback gSamplingCallback __attribute__((section(".data"))) = 0; -uint8_t gCallbackCooldown __attribute__((section(".data"))) = 0; -uint8_t gNetworkControllerActivated __attribute__((section(".data"))) = 1; +uint8_t gCallbackCooldown __attribute__((section(".data"))) = 0; +uint8_t gNetworkControllerActivated __attribute__((section(".data"))) = 1; uint8_t gGlobalRumbleActivated __attribute__((section(".data"))) = 0; -uint32_t gUDPClientip __attribute__((section(".data"))) = 0; -ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0], +uint32_t 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]}; diff --git a/source/utils/CPRetainVars.hpp b/source/utils/CPRetainVars.hpp index 3474ed2..9c01591 100644 --- a/source/utils/CPRetainVars.hpp +++ b/source/utils/CPRetainVars.hpp @@ -71,6 +71,6 @@ extern uint8_t gGlobalRumbleActivated; extern uint8_t gNetworkControllerActivated; extern uint32_t gUDPClientip; -extern ControllerMappingPADInfo* gProPadInfo[4]; +extern ControllerMappingPADInfo *gProPadInfo[4]; #endif // CP_RETAINS_VARS_H_ diff --git a/source/utils/PadConst.cpp b/source/utils/PadConst.cpp index 830d808..51e7f6f 100644 --- a/source/utils/PadConst.cpp +++ b/source/utils/PadConst.cpp @@ -17,12 +17,12 @@ #include "PadConst.hpp" #include -const uint8_t DEF_R_STICK = 220; -const uint8_t DEF_L_STICK = 221; +const uint8_t DEF_R_STICK = 220; +const uint8_t DEF_L_STICK = 221; -const uint8_t DEF_STICK_OFFSET_INVERT = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT - CONTRPS_VPAD_BUTTON_L_STICK_X; -const uint8_t DEF_STICK_OFFSET_DEADZONE = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE - CONTRPS_VPAD_BUTTON_L_STICK_X; -const uint8_t DEF_STICK_OFFSET_MINMAX = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX - CONTRPS_VPAD_BUTTON_L_STICK_X; +const uint8_t DEF_STICK_OFFSET_INVERT = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT - CONTRPS_VPAD_BUTTON_L_STICK_X; +const uint8_t DEF_STICK_OFFSET_DEADZONE = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE - CONTRPS_VPAD_BUTTON_L_STICK_X; +const uint8_t DEF_STICK_OFFSET_MINMAX = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX - CONTRPS_VPAD_BUTTON_L_STICK_X; //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Device names @@ -40,323 +40,302 @@ const char *HID_SWITCH_PRO_STRING = "Switch\nPro Controller"; //! GC-Adapter //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -const uint8_t HID_GC_BUTTON_A[] = { 0x01,HID_GC_BUTTON_A_VALUE}; -const uint8_t HID_GC_BUTTON_B[] = { 0x01,HID_GC_BUTTON_B_VALUE}; -const uint8_t HID_GC_BUTTON_X[] = { 0x01,HID_GC_BUTTON_X_VALUE}; -const uint8_t HID_GC_BUTTON_Y[] = { 0x01,HID_GC_BUTTON_Y_VALUE}; -const uint8_t HID_GC_BUTTON_LEFT[] = { 0x01,HID_GC_BUTTON_LEFT_VALUE}; -const uint8_t HID_GC_BUTTON_RIGHT[] = { 0x01,HID_GC_BUTTON_RIGHT_VALUE}; -const uint8_t HID_GC_BUTTON_DOWN[] = { 0x01,HID_GC_BUTTON_DOWN_VALUE}; -const uint8_t HID_GC_BUTTON_UP[] = { 0x01,HID_GC_BUTTON_UP_VALUE}; +const uint8_t HID_GC_BUTTON_A[] = {0x01, HID_GC_BUTTON_A_VALUE}; +const uint8_t HID_GC_BUTTON_B[] = {0x01, HID_GC_BUTTON_B_VALUE}; +const uint8_t HID_GC_BUTTON_X[] = {0x01, HID_GC_BUTTON_X_VALUE}; +const uint8_t HID_GC_BUTTON_Y[] = {0x01, HID_GC_BUTTON_Y_VALUE}; +const uint8_t HID_GC_BUTTON_LEFT[] = {0x01, HID_GC_BUTTON_LEFT_VALUE}; +const uint8_t HID_GC_BUTTON_RIGHT[] = {0x01, HID_GC_BUTTON_RIGHT_VALUE}; +const uint8_t HID_GC_BUTTON_DOWN[] = {0x01, HID_GC_BUTTON_DOWN_VALUE}; +const uint8_t HID_GC_BUTTON_UP[] = {0x01, HID_GC_BUTTON_UP_VALUE}; -const uint8_t HID_GC_BUTTON_START[] = { 0x02,HID_GC_BUTTON_START_VALUE}; -const uint8_t HID_GC_BUTTON_Z[] = { 0x02,HID_GC_BUTTON_Z_VALUE}; +const uint8_t HID_GC_BUTTON_START[] = {0x02, HID_GC_BUTTON_START_VALUE}; +const uint8_t HID_GC_BUTTON_Z[] = {0x02, HID_GC_BUTTON_Z_VALUE}; -const uint8_t HID_GC_BUTTON_L[] = { 0x07,HID_GC_BUTTON_L_VALUE}; -const uint8_t HID_GC_BUTTON_R[] = { 0x08,HID_GC_BUTTON_R_VALUE}; +const uint8_t HID_GC_BUTTON_L[] = {0x07, HID_GC_BUTTON_L_VALUE}; +const uint8_t HID_GC_BUTTON_R[] = {0x08, HID_GC_BUTTON_R_VALUE}; -const uint8_t HID_GC_BUTTON_DPAD_TYPE[] = { CONTRPDM_Normal,0x00}; +const uint8_t HID_GC_BUTTON_DPAD_TYPE[] = {CONTRPDM_Normal, 0x00}; -const uint8_t HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION - 0x03, //STICK_CONF_BYTE, - 0x80, //STICK_CONF_DEFAULT, - 0x09, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x1A, //STICK_CONF_MIN, - 0xE4 - };//STICK_CONF_MAX, +const uint8_t HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = {STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION + 0x03, //STICK_CONF_BYTE, + 0x80, //STICK_CONF_DEFAULT, + 0x09, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x1A, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x09, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x11, //STICK_CONF_MIN, - 0xE1 - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x09, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x11, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x09, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x2B, //STICK_CONF_MIN, - 0xE2 - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x09, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x2B, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x09, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x1D, //STICK_CONF_MIN, - 0xDB - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x09, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x1D, //STICK_CONF_MIN, + 0xDB}; //STICK_CONF_MAX, //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! DS3 //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -const uint8_t HID_DS3_BUTTON_CROSS[] = { 0x03,HID_DS3_BUTTON_CROSS_VALUE}; -const uint8_t HID_DS3_BUTTON_CIRCLE[] = { 0x03,HID_DS3_BUTTON_CIRCLE_VALUE}; -const uint8_t HID_DS3_BUTTON_SQUARE [] = { 0x03,HID_DS3_BUTTON_SQUARE_VALUE}; -const uint8_t HID_DS3_BUTTON_TRIANGLE[] = { 0x03,HID_DS3_BUTTON_TRIANGLE_VALUE}; +const uint8_t HID_DS3_BUTTON_CROSS[] = {0x03, HID_DS3_BUTTON_CROSS_VALUE}; +const uint8_t HID_DS3_BUTTON_CIRCLE[] = {0x03, HID_DS3_BUTTON_CIRCLE_VALUE}; +const uint8_t HID_DS3_BUTTON_SQUARE[] = {0x03, HID_DS3_BUTTON_SQUARE_VALUE}; +const uint8_t HID_DS3_BUTTON_TRIANGLE[] = {0x03, HID_DS3_BUTTON_TRIANGLE_VALUE}; -const uint8_t HID_DS3_BUTTON_L1[] = { 0x03,HID_DS3_BUTTON_L1_VALUE}; -const uint8_t HID_DS3_BUTTON_L2[] = { 0x03,HID_DS3_BUTTON_L2_VALUE}; -const uint8_t HID_DS3_BUTTON_R1[] = { 0x03,HID_DS3_BUTTON_R1_VALUE}; -const uint8_t HID_DS3_BUTTON_R2[] = { 0x03,HID_DS3_BUTTON_R2_VALUE}; +const uint8_t HID_DS3_BUTTON_L1[] = {0x03, HID_DS3_BUTTON_L1_VALUE}; +const uint8_t HID_DS3_BUTTON_L2[] = {0x03, HID_DS3_BUTTON_L2_VALUE}; +const uint8_t HID_DS3_BUTTON_R1[] = {0x03, HID_DS3_BUTTON_R1_VALUE}; +const uint8_t HID_DS3_BUTTON_R2[] = {0x03, HID_DS3_BUTTON_R2_VALUE}; -const uint8_t HID_DS3_BUTTON_L3[] = { 0x02,HID_DS3_BUTTON_L3_VALUE}; -const uint8_t HID_DS3_BUTTON_R3[] = { 0x02,HID_DS3_BUTTON_R3_VALUE}; -const uint8_t HID_DS3_BUTTON_SELECT[] = { 0x02,HID_DS3_BUTTON_SELECT_VALUE}; -const uint8_t HID_DS3_BUTTON_START[] = { 0x02,HID_DS3_BUTTON_START_VALUE}; -const uint8_t HID_DS3_BUTTON_LEFT[] = { 0x02,HID_DS3_BUTTON_LEFT_VALUE}; -const uint8_t HID_DS3_BUTTON_RIGHT[] = { 0x02,HID_DS3_BUTTON_RIGHT_VALUE}; -const uint8_t HID_DS3_BUTTON_UP[] = { 0x02,HID_DS3_BUTTON_UP_VALUE}; -const uint8_t HID_DS3_BUTTON_DOWN[] = { 0x02,HID_DS3_BUTTON_DOWN_VALUE}; +const uint8_t HID_DS3_BUTTON_L3[] = {0x02, HID_DS3_BUTTON_L3_VALUE}; +const uint8_t HID_DS3_BUTTON_R3[] = {0x02, HID_DS3_BUTTON_R3_VALUE}; +const uint8_t HID_DS3_BUTTON_SELECT[] = {0x02, HID_DS3_BUTTON_SELECT_VALUE}; +const uint8_t HID_DS3_BUTTON_START[] = {0x02, HID_DS3_BUTTON_START_VALUE}; +const uint8_t HID_DS3_BUTTON_LEFT[] = {0x02, HID_DS3_BUTTON_LEFT_VALUE}; +const uint8_t HID_DS3_BUTTON_RIGHT[] = {0x02, HID_DS3_BUTTON_RIGHT_VALUE}; +const uint8_t HID_DS3_BUTTON_UP[] = {0x02, HID_DS3_BUTTON_UP_VALUE}; +const uint8_t HID_DS3_BUTTON_DOWN[] = {0x02, HID_DS3_BUTTON_DOWN_VALUE}; -const uint8_t HID_DS3_BUTTON_GUIDE[] = { 0x04,HID_DS3_BUTTON_GUIDE_VALUE}; +const uint8_t HID_DS3_BUTTON_GUIDE[] = {0x04, HID_DS3_BUTTON_GUIDE_VALUE}; -const uint8_t HID_DS3_BUTTON_DPAD_TYPE[] = { CONTRPDM_Normal,0x00}; +const uint8_t HID_DS3_BUTTON_DPAD_TYPE[] = {CONTRPDM_Normal, 0x00}; -const uint8_t HID_DS3_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION - 0x06, //STICK_CONF_BYTE, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 0xFF - };//STICK_CONF_MAX, +const uint8_t HID_DS3_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = {STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION + 0x06, //STICK_CONF_BYTE, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 0xFF}; //STICK_CONF_MAX, //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! DS4 //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -const uint8_t HID_DS4_BUTTON_CROSS[] = { 0x05,HID_DS4_BUTTON_CROSS_VALUE}; -const uint8_t HID_DS4_BUTTON_CIRCLE[] = { 0x05,HID_DS4_BUTTON_CIRCLE_VALUE}; -const uint8_t HID_DS4_BUTTON_SQUARE [] = { 0x05,HID_DS4_BUTTON_SQUARE_VALUE}; -const uint8_t HID_DS4_BUTTON_TRIANGLE[] = { 0x05,HID_DS4_BUTTON_TRIANGLE_VALUE}; +const uint8_t HID_DS4_BUTTON_CROSS[] = {0x05, HID_DS4_BUTTON_CROSS_VALUE}; +const uint8_t HID_DS4_BUTTON_CIRCLE[] = {0x05, HID_DS4_BUTTON_CIRCLE_VALUE}; +const uint8_t HID_DS4_BUTTON_SQUARE[] = {0x05, HID_DS4_BUTTON_SQUARE_VALUE}; +const uint8_t HID_DS4_BUTTON_TRIANGLE[] = {0x05, HID_DS4_BUTTON_TRIANGLE_VALUE}; -const uint8_t HID_DS4_BUTTON_L1[] = { 0x06,HID_DS4_BUTTON_L1_VALUE}; -const uint8_t HID_DS4_BUTTON_L2[] = { 0x06,HID_DS4_BUTTON_L2_VALUE}; -const uint8_t HID_DS4_BUTTON_L3[] = { 0x06,HID_DS4_BUTTON_L3_VALUE}; +const uint8_t HID_DS4_BUTTON_L1[] = {0x06, HID_DS4_BUTTON_L1_VALUE}; +const uint8_t HID_DS4_BUTTON_L2[] = {0x06, HID_DS4_BUTTON_L2_VALUE}; +const uint8_t HID_DS4_BUTTON_L3[] = {0x06, HID_DS4_BUTTON_L3_VALUE}; -const uint8_t HID_DS4_BUTTON_R1[] = { 0x06,HID_DS4_BUTTON_R1_VALUE}; -const uint8_t HID_DS4_BUTTON_R2[] = { 0x06,HID_DS4_BUTTON_R2_VALUE}; -const uint8_t HID_DS4_BUTTON_R3[] = { 0x06,HID_DS4_BUTTON_R3_VALUE}; +const uint8_t HID_DS4_BUTTON_R1[] = {0x06, HID_DS4_BUTTON_R1_VALUE}; +const uint8_t HID_DS4_BUTTON_R2[] = {0x06, HID_DS4_BUTTON_R2_VALUE}; +const uint8_t HID_DS4_BUTTON_R3[] = {0x06, HID_DS4_BUTTON_R3_VALUE}; -const uint8_t HID_DS4_BUTTON_SHARE[] = { 0x06,HID_DS4_BUTTON_SHARE_VALUE}; -const uint8_t HID_DS4_BUTTON_OPTIONS[] = { 0x06,HID_DS4_BUTTON_OPTIONS_VALUE}; +const uint8_t HID_DS4_BUTTON_SHARE[] = {0x06, HID_DS4_BUTTON_SHARE_VALUE}; +const uint8_t HID_DS4_BUTTON_OPTIONS[] = {0x06, HID_DS4_BUTTON_OPTIONS_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_TYPE[] = { CONTRPDM_Hat,HID_DS4_BUTTON_DPAD_MASK_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_N[] = { 0x05,HID_DS4_BUTTON_DPAD_N_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_NE[] = { 0x05,HID_DS4_BUTTON_DPAD_NE_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_E[] = { 0x05,HID_DS4_BUTTON_DPAD_E_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_SE[] = { 0x05,HID_DS4_BUTTON_DPAD_SE_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_S[] = { 0x05,HID_DS4_BUTTON_DPAD_S_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_SW[] = { 0x05,HID_DS4_BUTTON_DPAD_SW_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_W[] = { 0x05,HID_DS4_BUTTON_DPAD_W_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_NW[] = { 0x05,HID_DS4_BUTTON_DPAD_NW_VALUE}; -const uint8_t HID_DS4_BUTTON_DPAD_NEUTRAL[] = { 0x05,HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_TYPE[] = {CONTRPDM_Hat, HID_DS4_BUTTON_DPAD_MASK_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_N[] = {0x05, HID_DS4_BUTTON_DPAD_N_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_NE[] = {0x05, HID_DS4_BUTTON_DPAD_NE_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_E[] = {0x05, HID_DS4_BUTTON_DPAD_E_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_SE[] = {0x05, HID_DS4_BUTTON_DPAD_SE_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_S[] = {0x05, HID_DS4_BUTTON_DPAD_S_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_SW[] = {0x05, HID_DS4_BUTTON_DPAD_SW_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_W[] = {0x05, HID_DS4_BUTTON_DPAD_W_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_NW[] = {0x05, HID_DS4_BUTTON_DPAD_NW_VALUE}; +const uint8_t HID_DS4_BUTTON_DPAD_NEUTRAL[] = {0x05, HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE}; -const uint8_t HID_DS4_BUTTON_GUIDE[] = { 0x07,HID_DS4_BUTTON_GUIDE_VALUE}; -const uint8_t HID_DS4_BUTTON_T_PAD_CLICK[] = { 0x07,HID_DS4_BUTTON_T_PAD_CLICK_VALUE}; +const uint8_t HID_DS4_BUTTON_GUIDE[] = {0x07, HID_DS4_BUTTON_GUIDE_VALUE}; +const uint8_t HID_DS4_BUTTON_T_PAD_CLICK[] = {0x07, HID_DS4_BUTTON_T_PAD_CLICK_VALUE}; -const uint8_t HID_DS4_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION - 0x01, //STICK_CONF_BYTE, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 0xFF - };//STICK_CONF_MAX, +const uint8_t HID_DS4_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = {STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION + 0x01, //STICK_CONF_BYTE, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x05, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x05, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x07, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x07, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x09, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x09, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 0xFF}; //STICK_CONF_MAX, //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! XInput //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -const uint8_t HID_XINPUT_BUTTON_A[] = { 0x07,HID_XINPUT_BUTTON_A_VALUE}; -const uint8_t HID_XINPUT_BUTTON_B[] = { 0x07,HID_XINPUT_BUTTON_B_VALUE}; -const uint8_t HID_XINPUT_BUTTON_X[] = { 0x07,HID_XINPUT_BUTTON_X_VALUE}; -const uint8_t HID_XINPUT_BUTTON_Y[] = { 0x07,HID_XINPUT_BUTTON_Y_VALUE}; +const uint8_t HID_XINPUT_BUTTON_A[] = {0x07, HID_XINPUT_BUTTON_A_VALUE}; +const uint8_t HID_XINPUT_BUTTON_B[] = {0x07, HID_XINPUT_BUTTON_B_VALUE}; +const uint8_t HID_XINPUT_BUTTON_X[] = {0x07, HID_XINPUT_BUTTON_X_VALUE}; +const uint8_t HID_XINPUT_BUTTON_Y[] = {0x07, HID_XINPUT_BUTTON_Y_VALUE}; -const uint8_t HID_XINPUT_BUTTON_LB[] = { 0x06,HID_XINPUT_BUTTON_LB_VALUE}; -const uint8_t HID_XINPUT_BUTTON_LT[] = { 0x04,HID_XINPUT_BUTTON_LT_VALUE}; -const uint8_t HID_XINPUT_BUTTON_L3[] = { 0x06,HID_XINPUT_BUTTON_L3_VALUE}; +const uint8_t HID_XINPUT_BUTTON_LB[] = {0x06, HID_XINPUT_BUTTON_LB_VALUE}; +const uint8_t HID_XINPUT_BUTTON_LT[] = {0x04, HID_XINPUT_BUTTON_LT_VALUE}; +const uint8_t HID_XINPUT_BUTTON_L3[] = {0x06, HID_XINPUT_BUTTON_L3_VALUE}; -const uint8_t HID_XINPUT_BUTTON_RB[] = { 0x06,HID_XINPUT_BUTTON_RB_VALUE}; -const uint8_t HID_XINPUT_BUTTON_RT[] = { 0x05,HID_XINPUT_BUTTON_RT_VALUE}; -const uint8_t HID_XINPUT_BUTTON_R3[] = { 0x06,HID_XINPUT_BUTTON_R3_VALUE}; +const uint8_t HID_XINPUT_BUTTON_RB[] = {0x06, HID_XINPUT_BUTTON_RB_VALUE}; +const uint8_t HID_XINPUT_BUTTON_RT[] = {0x05, HID_XINPUT_BUTTON_RT_VALUE}; +const uint8_t HID_XINPUT_BUTTON_R3[] = {0x06, HID_XINPUT_BUTTON_R3_VALUE}; -const uint8_t HID_XINPUT_BUTTON_START[] = { 0x06,HID_XINPUT_BUTTON_START_VALUE}; -const uint8_t HID_XINPUT_BUTTON_BACK[] = { 0x06,HID_XINPUT_BUTTON_BACK_VALUE}; -const uint8_t HID_XINPUT_BUTTON_GUIDE[] = { 0x06,HID_XINPUT_BUTTON_GUIDE_VALUE}; +const uint8_t HID_XINPUT_BUTTON_START[] = {0x06, HID_XINPUT_BUTTON_START_VALUE}; +const uint8_t HID_XINPUT_BUTTON_BACK[] = {0x06, HID_XINPUT_BUTTON_BACK_VALUE}; +const uint8_t HID_XINPUT_BUTTON_GUIDE[] = {0x06, HID_XINPUT_BUTTON_GUIDE_VALUE}; -const uint8_t HID_XINPUT_BUTTON_DPAD_TYPE[] = { CONTRPDM_Normal,HID_XINPUT_BUTTON_DPAD_MASK_VALUE}; -const uint8_t HID_XINPUT_BUTTON_LEFT[] = { 0x07,HID_XINPUT_BUTTON_LEFT_VALUE}; -const uint8_t HID_XINPUT_BUTTON_RIGHT[] = { 0x07,HID_XINPUT_BUTTON_RIGHT_VALUE}; -const uint8_t HID_XINPUT_BUTTON_DOWN[] = { 0x07,HID_XINPUT_BUTTON_DOWN_VALUE}; -const uint8_t HID_XINPUT_BUTTON_UP[] = { 0x07,HID_XINPUT_BUTTON_UP_VALUE}; +const uint8_t HID_XINPUT_BUTTON_DPAD_TYPE[] = {CONTRPDM_Normal, HID_XINPUT_BUTTON_DPAD_MASK_VALUE}; +const uint8_t HID_XINPUT_BUTTON_LEFT[] = {0x07, HID_XINPUT_BUTTON_LEFT_VALUE}; +const uint8_t HID_XINPUT_BUTTON_RIGHT[] = {0x07, HID_XINPUT_BUTTON_RIGHT_VALUE}; +const uint8_t HID_XINPUT_BUTTON_DOWN[] = {0x07, HID_XINPUT_BUTTON_DOWN_VALUE}; +const uint8_t HID_XINPUT_BUTTON_UP[] = {0x07, HID_XINPUT_BUTTON_UP_VALUE}; -const uint8_t HID_XINPUT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION - 0x00, //STICK_CONF_BYTE, - 0x80, //STICK_CONF_DEFAULT, - 0x10, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 0xFF - };//STICK_CONF_MAX, +const uint8_t HID_XINPUT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = {STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION + 0x00, //STICK_CONF_BYTE, + 0x80, //STICK_CONF_DEFAULT, + 0x10, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x10, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x10, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x10, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, - 0x80, //STICK_CONF_DEFAULT, - 0x10, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x00, //STICK_CONF_MIN, - 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, + 0x80, //STICK_CONF_DEFAULT, + 0x10, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 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, + 0x80, //STICK_CONF_DEFAULT, + 0x10, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x00, //STICK_CONF_MIN, + 0xFF}; //STICK_CONF_MAX, //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Switch Pro Controller //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -const uint8_t HID_SWITCH_PRO_BT_BUTTON_A[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_A_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_B[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_B_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_X[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_X_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_Y[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_Y_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_A[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_A_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_B[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_B_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_X[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_X_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_Y[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_Y_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_L[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_L_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_ZL[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_ZL_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_STICK_L[] = { 0x01,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_STICK_L_VALUE >> 16) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_L[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_L_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_ZL[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_ZL_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_STICK_L[] = {0x01, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_STICK_L_VALUE >> 16) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_R[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_R_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_ZR[] = { 0x00,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_ZR_VALUE >> 24) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_STICK_R[] = { 0x01,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_STICK_R_VALUE >> 16) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_R[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_R_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_ZR[] = {0x00, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_ZR_VALUE >> 24) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_STICK_R[] = {0x01, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_STICK_R_VALUE >> 16) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_PLUS[] = { 0x01,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_PLUS_VALUE >> 16) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_MINUS[] = { 0x01,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_MINUS_VALUE >> 16) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_HOME[] = { 0x01,(uint8_t)((HID_SWITCH_PRO_BT_BUTTON_HOME_VALUE >> 16) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_PLUS[] = {0x01, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_PLUS_VALUE >> 16) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_MINUS[] = {0x01, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_MINUS_VALUE >> 16) & 0xFF)}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_HOME[] = {0x01, (uint8_t) ((HID_SWITCH_PRO_BT_BUTTON_HOME_VALUE >> 16) & 0xFF)}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[] = { CONTRPDM_Hat,HID_SWITCH_PRO_BT_BUTTON_DPAD_MASK_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_N[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_N_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_NE_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_E[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_E_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_SE_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_S[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_S_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_SW_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_W[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_W_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_NW_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[] = { 0x02,HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_TYPE[] = {CONTRPDM_Hat, HID_SWITCH_PRO_BT_BUTTON_DPAD_MASK_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_N[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_N_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NE[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_NE_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_E[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_E_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_SE[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_SE_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_S[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_S_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_SW[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_SW_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_W[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_W_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NW[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_NW_VALUE}; +const uint8_t HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL[] = {0x02, HID_SWITCH_PRO_BT_BUTTON_DPAD_NEUTRAL_VALUE}; -const uint8_t HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION - 0x04, //STICK_CONF_BYTE, - 0x80, //STICK_CONF_DEFAULT, - 0x01, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x28, //STICK_CONF_MIN, - 0xDF - };//STICK_CONF_MAX, +const uint8_t HID_SWITCH_PRO_BT_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = {STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION + 0x04, //STICK_CONF_BYTE, + 0x80, //STICK_CONF_DEFAULT, + 0x01, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x28, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x06, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x16, //STICK_CONF_MIN, - 0xD7 - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x06, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x16, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x04, //STICK_CONF_DEADZONE, - 0x00, //STICK_CONF_INVERT, - 0x29, //STICK_CONF_MIN, - 0xE2 - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x04, //STICK_CONF_DEADZONE, + 0x00, //STICK_CONF_INVERT, + 0x29, //STICK_CONF_MIN, + 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, - 0x80, //STICK_CONF_DEFAULT, - 0x08, //STICK_CONF_DEADZONE, - 0x01, //STICK_CONF_INVERT, - 0x22, //STICK_CONF_MIN, - 0xE4 - };//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, + 0x80, //STICK_CONF_DEFAULT, + 0x08, //STICK_CONF_DEADZONE, + 0x01, //STICK_CONF_INVERT, + 0x22, //STICK_CONF_MIN, + 0xE4}; //STICK_CONF_MAX, diff --git a/source/utils/PadConst.hpp b/source/utils/PadConst.hpp index 5c6fbdd..a3b5a3c 100644 --- a/source/utils/PadConst.hpp +++ b/source/utils/PadConst.hpp @@ -19,8 +19,8 @@ #define _PAD_CONST_H_ -#include #include +#include extern const uint8_t DEF_R_STICK; extern const uint8_t DEF_L_STICK; @@ -74,7 +74,7 @@ extern const uint8_t HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE]; extern const uint8_t HID_DS3_BUTTON_CROSS[]; extern const uint8_t HID_DS3_BUTTON_CIRCLE[]; -extern const uint8_t HID_DS3_BUTTON_SQUARE []; +extern const uint8_t HID_DS3_BUTTON_SQUARE[]; extern const uint8_t HID_DS3_BUTTON_TRIANGLE[]; extern const uint8_t HID_DS3_BUTTON_L1[]; @@ -106,7 +106,7 @@ extern const uint8_t HID_DS3_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE]; extern const uint8_t HID_DS4_BUTTON_CROSS[]; extern const uint8_t HID_DS4_BUTTON_CIRCLE[]; -extern const uint8_t HID_DS4_BUTTON_SQUARE []; +extern const uint8_t HID_DS4_BUTTON_SQUARE[]; extern const uint8_t HID_DS4_BUTTON_TRIANGLE[]; extern const uint8_t HID_DS4_BUTTON_L1[]; diff --git a/source/utils/StringTools.cpp b/source/utils/StringTools.cpp index 23b87fa..c75a0b4 100644 --- a/source/utils/StringTools.cpp +++ b/source/utils/StringTools.cpp @@ -23,25 +23,24 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include -#include #include +#include #include -#include -#include +#include +#include #include -#include -#include #include +#include +#include +#include -BOOL StringTools::EndsWith(const std::string& a, const std::string& b) { +BOOL StringTools::EndsWith(const std::string &a, const std::string &b) { if (b.size() > a.size()) return false; return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin()); } -const char * StringTools::byte_to_binary(int32_t x) { +const char *StringTools::byte_to_binary(int32_t x) { static char b[9]; b[0] = '\0'; @@ -53,25 +52,25 @@ const char * StringTools::byte_to_binary(int32_t x) { return b; } -std::string StringTools::removeCharFromString(std::string& input,char toBeRemoved) { +std::string StringTools::removeCharFromString(std::string &input, char toBeRemoved) { std::string output = input; size_t position; - while(1) { + while (1) { position = output.find(toBeRemoved); - if(position == std::string::npos) + if (position == std::string::npos) break; output.erase(position, 1); } return output; } -const char * StringTools::fmt(const char * format, ...) { +const char *StringTools::fmt(const char *format, ...) { static char strChar[512]; strChar[0] = 0; va_list va; va_start(va, format); - if((vsprintf(strChar, format, va) >= 0)) { + if ((vsprintf(strChar, format, va) >= 0)) { va_end(va); return (const char *) strChar; } @@ -80,26 +79,26 @@ const char * StringTools::fmt(const char * format, ...) { return NULL; } -const wchar_t * StringTools::wfmt(const char * format, ...) { +const wchar_t *StringTools::wfmt(const char *format, ...) { static char tmp[512]; static wchar_t strWChar[512]; strWChar[0] = 0; - tmp[0] = 0; + tmp[0] = 0; - if(!format) + if (!format) return (const wchar_t *) strWChar; - if(strcmp(format, "") == 0) + if (strcmp(format, "") == 0) return (const wchar_t *) strWChar; va_list va; va_start(va, format); - if((vsprintf(tmp, format, va) >= 0)) { - int bt; + if ((vsprintf(tmp, format, va) >= 0)) { + int bt; int32_t strlength = strlen(tmp); - bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512 ); + bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512); - if(bt > 0) { + if (bt > 0) { strWChar[bt] = 0; return (const wchar_t *) strWChar; } @@ -109,15 +108,15 @@ const wchar_t * StringTools::wfmt(const char * format, ...) { return NULL; } -int32_t StringTools::strprintf(std::string &str, const char * format, ...) { +int32_t StringTools::strprintf(std::string &str, const char *format, ...) { static char tmp[512]; - tmp[0] = 0; + tmp[0] = 0; int32_t result = 0; va_list va; va_start(va, format); - if((vsprintf(tmp, format, va) >= 0)) { - str = tmp; + if ((vsprintf(tmp, format, va) >= 0)) { + str = tmp; result = str.size(); } va_end(va); @@ -125,14 +124,14 @@ int32_t StringTools::strprintf(std::string &str, const char * format, ...) { return result; } -std::string StringTools::strfmt(const char * format, ...) { +std::string StringTools::strfmt(const char *format, ...) { std::string str; static char tmp[512]; tmp[0] = 0; va_list va; va_start(va, format); - if((vsprintf(tmp, format, va) >= 0)) { + if ((vsprintf(tmp, format, va) >= 0)) { str = tmp; } va_end(va); @@ -140,11 +139,11 @@ std::string StringTools::strfmt(const char * format, ...) { return str; } -BOOL StringTools::char2wchar_t(const char * strChar, wchar_t * dest) { - if(!strChar || !dest) +BOOL StringTools::char2wchar_t(const char *strChar, wchar_t *dest) { + if (!strChar || !dest) return false; - int bt; + int bt; bt = mbstowcs(dest, strChar, strlen(strChar)); if (bt > 0) { dest[bt] = 0; @@ -154,39 +153,39 @@ BOOL StringTools::char2wchar_t(const char * strChar, wchar_t * dest) { return false; } -int32_t StringTools::strtokcmp(const char * string, const char * compare, const char * separator) { - if(!string || !compare) +int32_t StringTools::strtokcmp(const char *string, const char *compare, const char *separator) { + if (!string || !compare) return -1; char TokCopy[512]; strncpy(TokCopy, compare, sizeof(TokCopy)); TokCopy[511] = '\0'; - char * strTok = strtok(TokCopy, separator); + char *strTok = strtok(TokCopy, separator); while (strTok != NULL) { if (strcasecmp(string, strTok) == 0) { return 0; } - strTok = strtok(NULL,separator); + strTok = strtok(NULL, separator); } return -1; } -int32_t StringTools::strextcmp(const char * string, const char * extension, char seperator) { - if(!string || !extension) +int32_t StringTools::strextcmp(const char *string, const char *extension, char seperator) { + if (!string || !extension) return -1; char *ptr = strrchr(string, seperator); - if(!ptr) + if (!ptr) return -1; return strcasecmp(ptr + 1, extension); } -std::vector StringTools::stringSplit(const std::string & inValue, const std::string & splitter) { +std::vector StringTools::stringSplit(const std::string &inValue, const std::string &splitter) { std::string value = inValue; std::vector result; while (true) { @@ -201,7 +200,7 @@ std::vector StringTools::stringSplit(const std::string & inValue, c result.push_back(""); break; } - if(index + splitter.size() > value.length()) { + if (index + splitter.size() > value.length()) { break; } value = value.substr(index + splitter.size(), value.length()); diff --git a/source/utils/StringTools.h b/source/utils/StringTools.h index e7c8527..78fbec5 100644 --- a/source/utils/StringTools.h +++ b/source/utils/StringTools.h @@ -26,56 +26,53 @@ #ifndef __STRING_TOOLS_H #define __STRING_TOOLS_H -#include #include +#include #include -class StringTools{ - public: - static BOOL EndsWith(const std::string& a, const std::string& b); - static const char * byte_to_binary(int32_t x); - static std::string removeCharFromString(std::string& input,char toBeRemoved); - static const char * fmt(const char * format, ...); - static const wchar_t * wfmt(const char * format, ...); - static int32_t strprintf(std::string &str, const char * format, ...); - static std::string strfmt(const char * format, ...); - static BOOL char2wchar_t(const char * src, wchar_t * dest); - static int32_t strtokcmp(const char * string, const char * compare, const char * separator); - static int32_t strextcmp(const char * string, const char * extension, char seperator); +class StringTools { +public: + static BOOL EndsWith(const std::string &a, const std::string &b); + static const char *byte_to_binary(int32_t x); + static std::string removeCharFromString(std::string &input, char toBeRemoved); + static const char *fmt(const char *format, ...); + static const wchar_t *wfmt(const char *format, ...); + static int32_t strprintf(std::string &str, const char *format, ...); + static std::string strfmt(const char *format, ...); + static BOOL char2wchar_t(const char *src, wchar_t *dest); + static int32_t strtokcmp(const char *string, const char *compare, const char *separator); + static int32_t strextcmp(const char *string, const char *extension, char seperator); - static const char * FullpathToFilename(const char *path){ - if(!path) return path; + static const char *FullpathToFilename(const char *path) { + if (!path) return path; - const char * ptr = path; - const char * Filename = ptr; + const char *ptr = path; + const char *Filename = ptr; - while(*ptr != '\0') - { - if(ptr[0] == '/' && ptr[1] != '\0') - Filename = ptr+1; + while (*ptr != '\0') { + if (ptr[0] == '/' && ptr[1] != '\0') + Filename = ptr + 1; - ++ptr; - } - - return Filename; + ++ptr; } - static void RemoveDoubleSlashs(std::string &str){ - uint32_t length = str.size(); + return Filename; + } - //! clear path of double slashes - for(uint32_t i = 1; i < length; ++i) - { - if(str[i-1] == '/' && str[i] == '/') - { - str.erase(i, 1); - i--; - length--; - } + static void RemoveDoubleSlashs(std::string &str) { + uint32_t length = str.size(); + + //! clear path of double slashes + for (uint32_t i = 1; i < length; ++i) { + if (str[i - 1] == '/' && str[i] == '/') { + str.erase(i, 1); + i--; + length--; } } + } - static std::vector stringSplit(const std::string & value, const std::string & splitter); + static std::vector stringSplit(const std::string &value, const std::string &splitter); }; #endif /* __STRING_TOOLS_H */ diff --git a/source/utils/TCPServer.cpp b/source/utils/TCPServer.cpp index 540f73d..3a81b55 100644 --- a/source/utils/TCPServer.cpp +++ b/source/utils/TCPServer.cpp @@ -1,20 +1,20 @@ -#include #include #include #include +#include -#include #include +#include #define wiiu_errno (*__gh_errno_ptr()) -TCPServer::TCPServer(int32_t port,int32_t priority) { - this->port = port; - this->sockfd = -1; +TCPServer::TCPServer(int32_t port, int32_t priority) { + this->port = port; + this->sockfd = -1; this->clientfd = -1; - memset(&(this->sock_addr),0,sizeof(this->sock_addr)); + memset(&(this->sock_addr), 0, sizeof(this->sock_addr)); - pThread = CThread::create(TCPServer::DoTCPThread, (void*)this, CThread::eAttributeAffCore2,priority); + pThread = CThread::create(TCPServer::DoTCPThread, (void *) this, CThread::eAttributeAffCore2, priority); pThread->resumeThread(); } @@ -23,10 +23,10 @@ TCPServer::~TCPServer() { //DEBUG_FUNCTION_LINE("Thread will be closed"); exitThread = 1; - ICInvalidateRange((void*)&exitThread, 4); - DCFlushRange((void*)&exitThread, 4); + ICInvalidateRange((void *) &exitThread, 4); + DCFlushRange((void *) &exitThread, 4); - if(pThread != NULL) { + if (pThread != NULL) { //DEBUG_FUNCTION_LINE("Deleting it!"); delete pThread; } @@ -41,13 +41,13 @@ void TCPServer::CloseSockets() { if (this->clientfd != -1) { close(this->clientfd); } - this->sockfd = -1; + this->sockfd = -1; this->clientfd = -1; } void TCPServer::ErrorHandling() { CloseSockets(); - OSSleepTicks(OSMicrosecondsToTicks(1000*1000*2)); + OSSleepTicks(OSMicrosecondsToTicks(1000 * 1000 * 2)); } void TCPServer::DoTCPThreadInternal() { @@ -55,16 +55,16 @@ void TCPServer::DoTCPThreadInternal() { socklen_t len; connected = false; while (1) { - if(exitThread) { + if (exitThread) { break; } - memset(&(this->sock_addr),0,sizeof(sock_addr)); - sock_addr.sin_family = AF_INET; - sock_addr.sin_port = this->port; + memset(&(this->sock_addr), 0, sizeof(sock_addr)); + sock_addr.sin_family = AF_INET; + sock_addr.sin_port = this->port; sock_addr.sin_addr.s_addr = 0; this->sockfd = ret = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if(ret == -1) { + if (ret == -1) { ErrorHandling(); continue; } @@ -72,31 +72,31 @@ void TCPServer::DoTCPThreadInternal() { setsockopt(this->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); - ret = bind(this->sockfd, (sockaddr *)&sock_addr, 16); - if(ret < 0) { + ret = bind(this->sockfd, (sockaddr *) &sock_addr, 16); + if (ret < 0) { ErrorHandling(); continue; } ret = listen(this->sockfd, 1); - if(ret < 0) { + if (ret < 0) { ErrorHandling(); continue; } do { DEBUG_FUNCTION_LINE("Waiting for a connection"); - if(exitThread) { + if (exitThread) { break; } - len = 16; - clientfd = ret = accept(sockfd, (sockaddr *)&(sock_addr), &len); + len = 16; + clientfd = ret = accept(sockfd, (sockaddr *) &(sock_addr), &len); - if(ret == -1) { + if (ret == -1) { ErrorHandling(); break; } - if(!acceptConnection()) { + if (!acceptConnection()) { ErrorHandling(); break; } @@ -109,11 +109,11 @@ void TCPServer::DoTCPThreadInternal() { DEBUG_FUNCTION_LINE("Client disconnected"); - if(clientfd != -1) { + if (clientfd != -1) { close(clientfd); } clientfd = -1; - } while(0); + } while (0); DEBUG_FUNCTION_LINE("Closing TCPServer"); connected = false; onConnectionClosed(); @@ -124,6 +124,6 @@ void TCPServer::DoTCPThreadInternal() { } void TCPServer::DoTCPThread(CThread *thread, void *arg) { - TCPServer * args = (TCPServer * )arg; + TCPServer *args = (TCPServer *) arg; return args->DoTCPThreadInternal(); } \ No newline at end of file diff --git a/source/utils/TCPServer.hpp b/source/utils/TCPServer.hpp index 94db849..fc35e64 100644 --- a/source/utils/TCPServer.hpp +++ b/source/utils/TCPServer.hpp @@ -1,14 +1,14 @@ #ifndef _TCPSERVER_H_ #define _TCPSERVER_H_ +#include #include #include -#include #include #include -#include #include "utils/logger.h" +#include class TCPServer { public: @@ -18,6 +18,7 @@ public: BOOL isConnected() { return connected; } + protected: BOOL shouldExit() { return (exitThread == 1); @@ -32,7 +33,7 @@ protected: } void setThreadPriority(int32_t priority) { - if(pThread != NULL){ + if (pThread != NULL) { pThread->setThreadPriority(priority); } } @@ -40,6 +41,7 @@ protected: struct sockaddr_in getSockAddr() { return sock_addr; } + private: virtual void CloseSockets(); virtual void ErrorHandling(); @@ -49,7 +51,7 @@ private: virtual BOOL acceptConnection() = 0; - virtual void onConnectionClosed(){ + virtual void onConnectionClosed() { DEBUG_FUNCTION_LINE("Default onConnectionClosed "); } @@ -59,14 +61,14 @@ private: virtual BOOL whileLoop() = 0; struct sockaddr_in sock_addr; - volatile int32_t sockfd = -1; + volatile int32_t sockfd = -1; volatile int32_t clientfd = -1; - int32_t port = 0; + int32_t port = 0; volatile BOOL connected = false; volatile int32_t exitThread = 0; - CThread *pThread = NULL; + CThread *pThread = NULL; }; #endif //_TCPSERVER_H_ \ No newline at end of file diff --git a/source/utils/logger.h b/source/utils/logger.h index ff7c896..8f6a5a0 100644 --- a/source/utils/logger.h +++ b/source/utils/logger.h @@ -8,19 +8,21 @@ extern "C" { #include #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) -#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) #ifdef __LOGGING__ -#define log_print(str) WHBLogPrint(str) -#define log_printf(FMT, ARGS...) WHBLogPrintf(FMT, ## ARGS); +#define log_print(str) WHBLogPrint(str) +#define log_printf(FMT, ARGS...) WHBLogPrintf(FMT, ##ARGS); -#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ - WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \ + do { \ + WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0); -#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ - WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \ + do { \ + WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0); #else