2017-03-30 17:53:36 +02:00
/****************************************************************************
* Copyright ( C ) 2016 , 2017 Maschell
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2017-10-29 09:34:47 +01:00
# include "ControllerPatcherIncludes.hpp"
2017-03-30 17:53:36 +02:00
# include <malloc.h>
# include <stdlib.h>
2017-05-07 14:44:09 +02:00
2023-04-10 11:45:58 +02:00
# include <coreinit/dynload.h>
# include <coreinit/energysaver.h>
2017-05-07 14:44:09 +02:00
# include <stdio.h>
2023-04-10 11:45:58 +02:00
# include <string.h>
2017-03-30 17:53:36 +02:00
# include <vector>
2017-05-07 14:44:09 +02:00
2017-10-29 09:34:47 +01:00
# include <utils/logger.h>
2017-05-07 14:44:09 +02:00
2017-03-30 17:53:36 +02:00
// This stores the holded buttons for the gamepad after the button remapping.
2018-06-20 15:07:15 +02:00
static uint32_t buttonRemapping_lastButtonsHold = 0 ;
2017-03-30 17:53:36 +02:00
/* 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.*/
2018-06-20 15:07:15 +02:00
// This arrays stores the last hold buttons of the Pro Controllers. One uint32_t for each channel of the controllers
2023-04-10 11:45:58 +02:00
static uint32_t last_button_hold [ 4 ] = { 0 , 0 , 0 , 0 } ;
2018-06-17 20:33:39 +02:00
// 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 ] ;
2017-03-30 17:53:36 +02:00
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : InitButtonMapping ( ) {
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Init called " ) ;
2018-06-19 17:46:37 +02:00
}
2023-04-10 11:45:58 +02:00
if ( ! gButtonRemappingConfigDone ) {
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Remapping is running! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
gButtonRemappingConfigDone = 1 ;
2023-04-10 11:45:58 +02:00
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_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 ;
2017-03-30 17:53:36 +02:00
}
}
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : ResetConfig ( ) {
2023-04-10 11:45:58 +02:00
memset ( & gControllerMapping , 0 , sizeof ( gControllerMapping ) ) ;
2017-03-30 17:53:36 +02:00
disableControllerMapping ( ) ;
2023-04-10 11:45:58 +02:00
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 ) ) ;
2017-04-13 10:14:41 +02:00
gCallbackCooldown = 0 ;
2023-04-10 11:45:58 +02:00
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM ;
gHID_LIST_GC = 0 ;
gHID_LIST_DS3 = 0 ;
gHID_LIST_DS4 = 0 ;
2017-03-30 17:53:36 +02:00
gHID_LIST_KEYBOARD = 0 ;
2023-04-10 11:45:58 +02:00
gHID_LIST_MOUSE = 0 ;
gGamePadSlot = 0 ;
gHID_SLOT_GC = 0 ;
2017-03-30 17:53:36 +02:00
gHID_SLOT_KEYBOARD = 0 ;
2023-04-10 11:45:58 +02:00
gMouseSlot = 0 ;
2017-03-30 17:53:36 +02:00
HIDSlotData slotdata ;
gHIDRegisteredDevices = 0 ;
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
gGamePadSlot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
DEBUG_FUNCTION_LINE ( " Register Gamepad-Config. HID-Mask %s Device-Slot: %d " , StringTools : : byte_to_binary ( slotdata . hidmask ) , gGamePadSlot ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2023-04-10 11:45:58 +02:00
gMouseSlot = slotdata . deviceslot ;
2017-03-30 17:53:36 +02:00
gHID_LIST_MOUSE = slotdata . hidmask ;
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
DEBUG_FUNCTION_LINE ( " Register Mouse-Config. HID-Mask %s Device-Slot: %d " , StringTools : : byte_to_binary ( gHID_LIST_MOUSE ) , gMouseSlot ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t keyboard_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
uint32_t keyboard_hid = slotdata . hidmask ;
gHID_LIST_KEYBOARD = keyboard_hid ;
gHID_SLOT_KEYBOARD = keyboard_slot ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t gc_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
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 ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t ds3_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
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 ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t ds4_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
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 ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t xinput_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
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 ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
2017-04-23 12:18:36 +02:00
ControllerPatcherUtils : : getNextSlotData ( & slotdata ) ;
2018-06-20 15:07:15 +02:00
uint32_t switch_pro_slot = slotdata . deviceslot ;
2023-04-10 11:45:58 +02:00
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 ) ;
2017-04-23 12:18:36 +02:00
2017-04-23 15:19:21 +02:00
2023-04-10 11:45:58 +02:00
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 ;
2017-03-30 17:53:36 +02:00
/* We need to give the GamePad, Mouse and Keyboard a unique VID/PID to find the right slots.*/
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! GamePad
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
ControllerPatcherUtils : : setConfigValue ( ( uint8_t * ) & config_controller [ gGamePadSlot ] [ CONTRPS_VID ] , 0xAF , 0xFE ) ;
ControllerPatcherUtils : : setConfigValue ( ( uint8_t * ) & config_controller [ gGamePadSlot ] [ CONTRPS_PID ] , 0xAA , 0xAA ) ;
2017-03-30 17:53:36 +02:00
2017-04-23 12:18:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! Switch Pro Controller
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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_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_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 ] ) ;
2017-04-23 12:18:36 +02:00
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! Mouse
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! Keyboard
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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_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 ) ;
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! GC-Adapter
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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 ] ) ;
2017-03-30 17:53:36 +02:00
//Buttons that will be ignored when the CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR is pressed
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2018-06-19 17:46:37 +02:00
//Buttons that will be ignored when the CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR is released
2023-04-10 11:45:58 +02:00
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_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_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 ] ) ;
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! DS3
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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_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_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 ] ) ;
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! DS4
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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_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_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 ] ) ;
2017-03-30 17:53:36 +02:00
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! XInput
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-04-10 11:45:58 +02:00
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_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_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 ] ) ;
2017-03-30 17:53:36 +02:00
}
2024-10-13 10:37:09 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : UpdateSamplingFunctionAddress ( ) {
OSDynLoad_Module handle = nullptr ;
WPADSamplingCallback newAddr = nullptr ;
auto err = OSDynLoad_IsModuleLoaded ( " padscore " , & handle ) ;
if ( err = = OS_DYNLOAD_OK & & handle ! = nullptr ) {
void * kpad_ptr = nullptr ;
if ( OSDynLoad_FindExport ( handle , OS_DYNLOAD_EXPORT_FUNC , " KPADRead " , & kpad_ptr ) = = OS_DYNLOAD_OK ) {
newAddr = ( WPADSamplingCallback ) ( ( uint32_t ) kpad_ptr + 0x1F0 ) ;
if ( * ( uint32_t * ) newAddr ! = FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK ) {
//In Firmware <= 5.1.2 the offset changes
newAddr = ( WPADSamplingCallback ) ( ( uint32_t ) kpad_ptr + 0x1F8 ) ;
if ( * ( uint32_t * ) newAddr ! = FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK ) {
//Should never happen. I looked into the padscore.rpl of ALL firmwares.
newAddr = nullptr ;
}
}
2017-04-23 15:19:21 +02:00
}
2024-10-13 10:37:09 +02:00
} else {
OSReport ( " Failed to update sampling addr \n " ) ;
}
gSamplingCallback = newAddr ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
BOOL ControllerPatcher : : Init ( const char * pathToConfig ) {
gSamplingCallback = nullptr ;
if ( gSamplingCallback ! = nullptr ) {
DEBUG_FUNCTION_LINE ( " Found the gSamplingCallback at %08X " , gSamplingCallback ) ;
2017-04-23 15:19:21 +02:00
}
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Init called! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( gConfig_done = = HID_INIT_NOT_DONE ) {
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " First time calling the Init " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
gConfig_done = HID_INIT_DONE ;
ControllerPatcher : : ResetConfig ( ) ;
2018-06-19 17:46:37 +02:00
} else {
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Config already done! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-04-06 12:49:50 +02:00
}
2023-04-10 11:45:58 +02:00
if ( pathToConfig ! = NULL & & gConfig_done ! = HID_SDCARD_READ ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Reading config files from SD Card " ) ;
2023-04-10 11:45:58 +02:00
ConfigReader * reader = ConfigReader : : getInstance ( ) ;
2017-10-14 15:45:45 +02:00
2023-04-10 11:45:58 +02:00
if ( reader - > ReadConfigs ( pathToConfig ) ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Done with reading config files from SD Card " ) ;
2017-04-06 12:49:50 +02:00
gConfig_done = HID_SDCARD_READ ;
}
2017-03-30 17:53:36 +02:00
}
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Initializing the data for button remapping " ) ;
2017-03-30 17:53:36 +02:00
InitButtonMapping ( ) ;
2023-04-10 11:45:58 +02:00
if ( ! gHIDAttached ) {
2017-03-30 17:53:36 +02:00
HIDAddClient ( & gHIDClient , ControllerPatcherHID : : myAttachDetachCallback ) ;
}
return true ;
}
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : startNetworkServer ( ) {
2023-04-10 11:45:58 +02:00
if ( ! gNetworkControllerActivated ) return ;
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " statedNetworkServer! " ) ;
2017-03-30 17:53:36 +02:00
UDPServer : : getInstance ( ) ;
2018-03-07 18:42:36 +01:00
CPTCPServer : : getInstance ( ) ;
2017-03-30 17:53:36 +02:00
}
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : stopNetworkServer ( ) {
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " called!! " ) ;
2017-03-30 17:53:36 +02:00
UDPServer : : destroyInstance ( ) ;
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " called! " ) ;
2017-04-13 15:30:40 +02:00
UDPClient : : destroyInstance ( ) ;
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " called! " ) ;
2018-03-07 18:42:36 +01:00
CPTCPServer : : destroyInstance ( ) ;
2017-03-30 17:53:36 +02:00
}
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : DeInit ( ) {
2023-04-10 11:45:58 +02:00
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " called! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( gHIDAttached ) HIDDelClient ( & gHIDClient ) ;
2017-03-30 17:53:36 +02:00
//Resetting the state of the last pressed data.
buttonRemapping_lastButtonsHold = 0 ;
2023-04-10 11:45:58 +02:00
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 ) ) ;
2017-04-13 10:14:41 +02:00
gCallbackCooldown = 0 ;
2023-04-10 11:45:58 +02:00
gConfig_done = HID_INIT_NOT_DONE ;
2017-03-30 17:53:36 +02:00
gButtonRemappingConfigDone = 0 ;
2023-04-10 11:45:58 +02:00
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 ;
2017-03-30 17:53:36 +02:00
gHID_SLOT_KEYBOARD = 0 ;
2023-04-10 11:45:58 +02:00
gMouseSlot = 0 ;
2017-03-30 17:53:36 +02:00
gOriginalDimState = 0 ;
gOriginalAPDState = 0 ;
gHIDNetworkClientID = 0 ;
destroyConfigHelper ( ) ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : enableControllerMapping ( ) {
2017-03-30 17:53:36 +02:00
gControllerMapping . gamepad . useAll = 0 ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : disableControllerMapping ( ) {
2017-03-30 17:53:36 +02:00
gControllerMapping . gamepad . useAll = 1 ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : disableWiiUEnergySetting ( ) {
uint32_t res ;
2023-04-10 11:45:58 +02:00
if ( IMIsDimEnabled ( & res ) = = 0 ) {
if ( res = = 1 ) {
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Dim was orignally enabled! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
gOriginalDimState = 1 ;
}
}
2023-04-10 11:45:58 +02:00
if ( IMIsAPDEnabled ( & res ) = = 0 ) {
if ( res = = 1 ) {
if ( HID_DEBUG ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Auto power down was orignally enabled! " ) ;
2018-06-19 17:46:37 +02:00
}
2017-03-30 17:53:36 +02:00
gOriginalAPDState = 1 ;
}
}
IMDisableDim ( ) ;
IMDisableAPD ( ) ;
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Disable Energy savers " ) ;
2017-03-30 17:53:36 +02:00
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : restoreWiiUEnergySetting ( ) {
2017-03-30 17:53:36 +02:00
//Check if we need to enable Auto Power down again on exiting
2023-04-10 11:45:58 +02:00
if ( gOriginalAPDState = = 1 ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Auto shutdown was on before using HID to VPAD. Setting it to on again. " ) ;
2017-03-30 17:53:36 +02:00
IMEnableAPD ( ) ;
}
2023-04-10 11:45:58 +02:00
if ( gOriginalDimState = = 1 ) {
2020-12-16 02:04:31 +01:00
DEBUG_FUNCTION_LINE ( " Burn-in reduction was on before using HID to VPAD. Setting it to on again. " ) ;
2017-03-30 17:53:36 +02:00
IMEnableDim ( ) ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : resetControllerMapping ( UController_Type type ) {
2023-04-10 11:45:58 +02:00
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils : : getControllerMappingByType ( type ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( cm_map_pad = = NULL ) {
2018-06-19 17:46:37 +02:00
return CONTROLLER_PATCHER_ERROR_NULL_POINTER ;
}
2023-04-10 11:45:58 +02:00
memset ( cm_map_pad , 0 , sizeof ( * cm_map_pad ) ) ;
2017-03-30 17:53:36 +02:00
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : addControllerMapping ( UController_Type type , ControllerMappingPADInfo config ) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils : : getControllerMappingByType ( type ) ;
2017-03-30 17:53:36 +02:00
2018-06-20 15:07:15 +02:00
int32_t result = 0 ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ;
2017-03-30 17:53:36 +02:00
result = 1 ;
break ;
}
}
2023-04-10 11:45:58 +02:00
if ( result = = 0 ) {
2017-03-30 17:53:36 +02:00
//No free slot.
return - 1 ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
int32_t ControllerPatcher : : getActiveMappingSlot ( UController_Type type ) {
2023-04-10 11:45:58 +02:00
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils : : getControllerMappingByType ( type ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( cm_map_pad = = NULL ) {
2018-06-19 17:46:37 +02:00
return - 1 ;
}
2017-03-30 17:53:36 +02:00
2018-06-20 15:07:15 +02:00
int32_t connected = - 1 ;
2023-04-10 11:45:58 +02:00
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 ) {
2017-03-30 17:53:36 +02:00
connected = i ;
break ;
}
}
return connected ;
}
2023-04-10 11:45:58 +02:00
BOOL ControllerPatcher : : isControllerConnectedAndActive ( UController_Type type , int32_t mapping_slot ) {
ControllerMappingPADInfo * padinfo = getControllerMappingInfo ( type , mapping_slot ) ;
if ( ! padinfo ) {
2017-03-30 17:53:36 +02:00
return false ;
}
2023-04-10 11:45:58 +02:00
if ( padinfo - > active ) {
2017-03-30 17:53:36 +02:00
DeviceInfo device_info ;
2023-04-10 11:45:58 +02:00
memset ( & device_info , 0 , sizeof ( device_info ) ) ;
2017-03-30 17:53:36 +02:00
2017-04-23 15:19:21 +02:00
device_info . vidpid = padinfo - > vidpid ;
2017-03-30 17:53:36 +02:00
2018-06-20 15:07:15 +02:00
int32_t res ;
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherUtils : : getDeviceInfoFromVidPid ( & device_info ) ) < 0 ) {
2017-03-30 17:53:36 +02:00
return false ;
}
2018-06-20 15:07:15 +02:00
uint32_t hidmask = device_info . slotdata . hidmask ;
2023-04-10 11:45:58 +02:00
uint32_t pad = padinfo - > pad ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
HID_Data * data_cur ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherHID : : getHIDData ( hidmask , pad , & data_cur ) ) < 0 ) {
2018-06-19 17:46:37 +02:00
return false ;
2017-03-30 17:53:36 +02:00
}
return true ;
}
return false ;
}
2023-04-10 11:45:58 +02:00
ControllerMappingPADInfo * ControllerPatcher : : getControllerMappingInfo ( UController_Type type , int32_t mapping_slot ) {
ControllerMappingPAD * cm_map_pad = ControllerPatcherUtils : : getControllerMappingByType ( type ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( cm_map_pad = = NULL ) {
2018-06-19 17:46:37 +02:00
return NULL ;
}
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( mapping_slot < 0 | | mapping_slot > HID_MAX_DEVICES_PER_SLOT - 1 ) {
2018-06-19 17:46:37 +02:00
return NULL ;
}
2017-03-30 17:53:36 +02:00
return & ( cm_map_pad - > pad_infos [ mapping_slot ] ) ;
}
2023-04-10 11:45:58 +02:00
HID_Mouse_Data * ControllerPatcher : : getMouseData ( ) {
if ( gHID_Mouse_Mode ! = HID_MOUSE_MODE_TOUCH ) return NULL ;
ControllerMappingPAD * CMPAD = ControllerPatcherUtils : : getControllerMappingByType ( UController_Type_Gamepad ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( CMPAD = = NULL ) {
2017-03-30 17:53:36 +02:00
return NULL ;
}
2023-04-10 11:45:58 +02:00
HID_Mouse_Data * result = NULL ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
for ( int32_t i = 0 ; i < HID_MAX_DEVICES_PER_SLOT ; i + + ) {
ControllerMappingPADInfo * padinfo = & ( CMPAD - > pad_infos [ i ] ) ;
if ( ! padinfo - > active ) {
2017-03-30 17:53:36 +02:00
break ;
}
2023-04-10 11:45:58 +02:00
if ( padinfo - > type = = CM_Type_Mouse ) {
2017-03-30 17:53:36 +02:00
result = & ( gHID_Devices [ gMouseSlot ] . pad_data [ padinfo - > pad ] . data_union . mouse . cur_mouse_data ) ;
2023-04-10 11:45:58 +02:00
DCFlushRange ( & result , sizeof ( result ) ) ;
DCInvalidateRange ( & result , sizeof ( result ) ) ;
2018-02-16 18:57:45 +01:00
break ;
2017-03-30 17:53:36 +02:00
}
}
return result ;
}
2023-04-10 11:45:58 +02:00
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 ) {
2018-06-19 17:46:37 +02:00
return - 1 ;
}
2017-03-30 17:53:36 +02:00
cm_map_pad - > rumble = ! ! status ; //to make sure it's only 0 or 1.
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : gettingInputAllDevices ( InputData * output , int32_t array_size ) {
2018-06-20 15:07:15 +02:00
int32_t hid = gHIDCurrentDevice ;
2023-04-10 11:45:58 +02:00
HID_Data * data_cur ;
2018-06-17 20:33:39 +02:00
VPADStatus pad_buffer ;
2023-04-10 11:45:58 +02:00
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 ) ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
uint32_t newhid = ( 1 < < i ) ;
2018-06-20 15:07:15 +02:00
int32_t deviceslot = ControllerPatcherUtils : : getDeviceSlot ( newhid ) ;
2023-04-10 11:45:58 +02:00
if ( deviceslot < 0 ) continue ;
2018-02-16 18:57:45 +01:00
output [ result ] . type = CM_Type_Controller ;
2023-04-10 11:45:58 +02:00
DeviceInfo * deviceinfo = & ( output [ result ] . device_info ) ;
InputButtonData * buttondata = output [ result ] . button_data ;
2017-03-30 17:53:36 +02:00
2017-04-23 15:19:21 +02:00
deviceinfo - > slotdata . deviceslot = deviceslot ;
2023-04-10 11:45:58 +02:00
deviceinfo - > slotdata . hidmask = newhid ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( newhid = = gHID_LIST_MOUSE ) {
2018-02-16 18:57:45 +01:00
output [ result ] . type = CM_Type_Mouse ;
2023-04-10 11:45:58 +02:00
} else if ( newhid = = gHID_LIST_KEYBOARD ) {
2018-02-16 18:57:45 +01:00
output [ result ] . type = CM_Type_Keyboard ;
}
2017-04-23 15:19:21 +02:00
deviceinfo - > vidpid . vid = config_controller [ deviceslot ] [ CONTRPS_VID ] [ 0 ] * 0x100 + config_controller [ deviceslot ] [ CONTRPS_VID ] [ 1 ] ;
deviceinfo - > vidpid . pid = config_controller [ deviceslot ] [ CONTRPS_PID ] [ 0 ] * 0x100 + config_controller [ deviceslot ] [ CONTRPS_PID ] [ 1 ] ;
2017-03-30 17:53:36 +02:00
2017-05-03 21:44:08 +02:00
/* not needed
2017-03-30 17:53:36 +02:00
if ( config_controller [ deviceslot ] [ CONTRPS_PAD_COUNT ] [ 0 ] ! = CONTROLLER_PATCHER_INVALIDVALUE ) {
deviceinfo - > pad_count = config_controller [ deviceslot ] [ CONTRPS_PAD_COUNT ] [ 1 ] ;
} else {
deviceinfo - > pad_count = HID_MAX_PADS_COUNT ;
2017-05-03 21:44:08 +02:00
} */
2017-03-30 17:53:36 +02:00
2018-06-20 15:07:15 +02:00
int32_t buttons_hold = 0 ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
for ( int32_t pad = 0 ; pad < HID_MAX_PADS_COUNT ; pad + + ) {
buttons_hold = 0 ;
2017-03-30 17:53:36 +02:00
buttondata [ pad ] . btn_h = 0 ;
buttondata [ pad ] . btn_d = 0 ;
buttondata [ pad ] . btn_r = 0 ;
2018-06-20 15:07:15 +02:00
int32_t res ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherHID : : getHIDData ( deviceinfo - > slotdata . hidmask , pad , & data_cur ) ) < 0 ) {
2018-06-19 17:46:37 +02:00
continue ;
2017-03-30 17:53:36 +02:00
}
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
buttondata [ pad ] . btn_h | = buttons_hold ;
buttondata [ pad ] . btn_d | = ( buttons_hold & ( ~ ( data_cur - > last_buttons ) ) ) ;
buttondata [ pad ] . btn_r | = ( ( data_cur - > last_buttons ) & ( ~ buttons_hold ) ) ;
data_cur - > last_buttons = buttons_hold ;
}
result + + ;
2023-04-10 11:45:58 +02:00
if ( result > = array_size ) {
2017-03-30 17:53:36 +02:00
break ;
}
}
}
return result ;
}
2023-04-10 11:45:58 +02:00
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 ;
2017-03-30 17:53:36 +02:00
//if(gControllerMapping.proController[chan].enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
2023-04-10 11:45:58 +02:00
VPADStatus * vpad_buffer = & myVPADBuffer [ chan ] ;
memset ( vpad_buffer , 0 , sizeof ( * vpad_buffer ) ) ;
2017-03-30 17:53:36 +02:00
std : : vector < HID_Data * > data_list ;
2023-04-10 11:45:58 +02:00
for ( int32_t i = 0 ; i < HID_MAX_DEVICES_PER_SLOT ; i + + ) {
2017-03-30 17:53:36 +02:00
ControllerMappingPADInfo cm_map_pad_info = gControllerMapping . proController [ chan ] . pad_infos [ i ] ;
2023-04-10 11:45:58 +02:00
if ( ! cm_map_pad_info . active ) {
2017-03-30 17:53:36 +02:00
continue ;
}
DeviceInfo device_info ;
2023-04-10 11:45:58 +02:00
memset ( & device_info , 0 , sizeof ( device_info ) ) ;
2017-03-30 17:53:36 +02:00
2017-04-23 15:19:21 +02:00
device_info . vidpid = cm_map_pad_info . vidpid ;
2017-03-30 17:53:36 +02:00
2018-06-20 15:07:15 +02:00
int32_t res ;
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherUtils : : getDeviceInfoFromVidPid ( & device_info ) ) < 0 ) {
DEBUG_FUNCTION_LINE ( " ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) = %d " , res ) ;
2017-03-30 17:53:36 +02:00
continue ;
}
2018-06-20 15:07:15 +02:00
int32_t hidmask = device_info . slotdata . hidmask ;
2023-04-10 11:45:58 +02:00
int32_t pad = cm_map_pad_info . pad ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
HID_Data * data_cur ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherHID : : getHIDData ( hidmask , pad , & data_cur ) ) < 0 ) {
2020-12-16 02:04:31 +01:00
//DEBUG_FUNCTION_LINE("ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) = %d",res);
2017-03-30 17:53:36 +02:00
continue ;
}
data_list . push_back ( data_cur ) ;
}
2023-04-10 11:45:58 +02:00
if ( data_list . empty ( ) ) {
2017-03-30 17:53:36 +02:00
return CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA ;
}
2018-06-20 15:07:15 +02:00
int32_t res = 0 ;
2023-04-10 11:45:58 +02:00
if ( ( res = ControllerPatcherHID : : setVPADControllerData ( vpad_buffer , data_list ) ) < 0 ) return res ;
2017-03-30 17:53:36 +02:00
//make it configurable?
//ControllerPatcher::printVPADButtons(vpad_buffer); //Leads to random crashes on transitions.
//a bit hacky?
2023-04-10 11:45:58 +02:00
if ( mode = = PRO_CONTROLLER_MODE_KPADDATA ) {
KPADStatus * pro_buffer = ( KPADStatus * ) data ;
if ( ( res = ControllerPatcherUtils : : translateToPro ( vpad_buffer , pro_buffer , & last_button_hold [ chan ] ) ) < 0 ) return res ;
} else if ( mode = = PRO_CONTROLLER_MODE_WPADReadData ) {
WPADStatusProController * pro_buffer = ( WPADStatusProController * ) data ;
if ( ( res = ControllerPatcherUtils : : translateToProWPADRead ( vpad_buffer , pro_buffer ) ) < 0 ) return res ;
2017-03-30 17:53:36 +02:00
}
2023-04-10 11:45:58 +02:00
for ( std : : vector < HID_Data * > : : iterator it = data_list . begin ( ) ; it ! = data_list . end ( ) ; + + it ) {
HID_Data * cur_ptr = * it ;
2017-03-30 17:53:36 +02:00
cur_ptr - > rumbleActive = ! ! gControllerMapping . proController [ chan ] . rumble ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setControllerDataFromHID ( VPADStatus * buffer ) {
if ( buffer = = NULL ) return CONTROLLER_PATCHER_ERROR_NULL_POINTER ;
2017-03-30 17:53:36 +02:00
//if(gControllerMapping.gamepad.enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
2018-06-20 15:07:15 +02:00
int32_t hidmask = 0 ;
2023-04-10 11:45:58 +02:00
int32_t pad = 0 ;
2017-03-30 17:53:36 +02:00
ControllerMappingPAD cm_map_pad = gControllerMapping . gamepad ;
std : : vector < HID_Data * > data_list ;
if ( cm_map_pad . useAll = = 1 ) {
data_list = ControllerPatcherHID : : getHIDDataAll ( ) ;
2018-06-19 17:46:37 +02:00
} else {
2023-04-10 11:45:58 +02:00
for ( int32_t i = 0 ; i < HID_MAX_DEVICES_PER_SLOT ; i + + ) {
2017-03-30 17:53:36 +02:00
ControllerMappingPADInfo cm_map_pad_info = cm_map_pad . pad_infos [ i ] ;
2023-04-10 11:45:58 +02:00
if ( cm_map_pad_info . active ) {
2017-03-30 17:53:36 +02:00
DeviceInfo device_info ;
2023-04-10 11:45:58 +02:00
memset ( & device_info , 0 , sizeof ( device_info ) ) ;
2017-04-23 15:19:21 +02:00
device_info . vidpid = cm_map_pad_info . vidpid ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
if ( ControllerPatcherUtils : : getDeviceInfoFromVidPid ( & device_info ) < 0 ) {
2017-03-30 17:53:36 +02:00
continue ;
//return CONTROLLER_PATCHER_ERROR_UNKNOWN_VID_PID;
}
hidmask = device_info . slotdata . hidmask ;
2023-04-10 11:45:58 +02:00
HID_Data * data ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
pad = cm_map_pad_info . pad ;
int32_t res = ControllerPatcherHID : : getHIDData ( hidmask , pad , & data ) ;
if ( res < 0 ) {
2017-03-30 17:53:36 +02:00
continue ;
//return CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA;
}
2023-04-10 11:45:58 +02:00
if ( data ! = NULL ) data_list . push_back ( data ) ;
2017-03-30 17:53:36 +02:00
}
}
}
2023-04-10 11:45:58 +02:00
if ( data_list . empty ( ) ) {
2017-03-30 17:53:36 +02:00
return CONTROLLER_PATCHER_ERROR_FAILED_TO_GET_HIDDATA ;
}
2023-04-10 11:45:58 +02:00
ControllerPatcherHID : : setVPADControllerData ( buffer , data_list ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
for ( uint32_t i = 0 ; i < data_list . size ( ) ; i + + ) {
2017-03-30 17:53:36 +02:00
data_list [ i ] - > rumbleActive = ! ! gControllerMapping . gamepad . rumble ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : printVPADButtons ( VPADStatus * buffer ) {
2017-04-02 10:41:13 +02:00
return CONTROLLER_PATCHER_ERROR_NONE ;
2017-03-30 17:53:36 +02:00
/* BROKEN on transitions.*/
2023-04-10 11:45:58 +02:00
if ( buffer = = NULL ) return CONTROLLER_PATCHER_ERROR_NULL_POINTER ;
if ( buffer - > trigger ! = 0x00000000 ) {
2017-03-30 17:53:36 +02:00
char output [ 250 ] ;
output [ 0 ] = 0 ; //null terminate it. just in case.
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
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 + + ) {
2018-06-17 20:33:39 +02:00
VPADStatus new_data ;
2023-04-10 11:45:58 +02:00
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_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 ) ;
2017-03-30 17:53:36 +02:00
//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.
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
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 ) ;
2017-03-30 17:53:36 +02:00
2023-04-10 11:45:58 +02:00
buffer [ i ] . hold = new_data . hold ;
2018-06-17 20:33:39 +02:00
buffer [ i ] . trigger = new_data . trigger ;
buffer [ i ] . release = new_data . release ;
2017-03-30 17:53:36 +02:00
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2023-04-10 11:45:58 +02:00
std : : string ControllerPatcher : : getIdentifierByVIDPID ( uint16_t vid , uint16_t pid ) {
return ConfigValues : : getStringByVIDPID ( vid , pid ) ;
2017-03-30 17:53:36 +02:00
}
2018-06-19 17:46:37 +02:00
void ControllerPatcher : : destroyConfigHelper ( ) {
2017-03-30 17:53:36 +02:00
ConfigReader : : destroyInstance ( ) ;
ConfigValues : : destroyInstance ( ) ;
}
2017-04-23 15:19:21 +02:00
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : doSamplingForDeviceSlot ( uint16_t device_slot ) {
2023-04-10 11:45:58 +02:00
return ControllerPatcherUtils : : doSampling ( device_slot , 0 , true ) ;
2017-04-23 15:19:21 +02:00
}
2017-05-07 14:29:19 +02:00
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setRumbleActivated ( BOOL value ) {
2017-05-07 14:29:19 +02:00
gGlobalRumbleActivated = value ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setNetworkControllerActivated ( BOOL value ) {
2017-07-20 17:28:14 +02:00
gNetworkControllerActivated = value ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
BOOL ControllerPatcher : : isRumbleActivated ( ) {
2017-05-07 14:29:19 +02:00
return gGlobalRumbleActivated ;
}
2017-10-29 09:34:47 +01:00
2018-06-20 15:07:15 +02:00
BOOL ControllerPatcher : : isButtonRemappingDone ( ) {
2017-10-29 09:34:47 +01:00
return gButtonRemappingConfigDone ;
}
2018-06-20 15:07:15 +02:00
BOOL ControllerPatcher : : isKeyboardConnected ( ) {
2017-10-29 09:34:47 +01:00
return ( gHIDCurrentDevice & gHID_LIST_KEYBOARD ) = = gHID_LIST_KEYBOARD ;
}
2018-06-20 15:07:15 +02:00
BOOL ControllerPatcher : : areControllersConnected ( ) {
2017-10-29 09:34:47 +01:00
return gHIDAttached > 0 ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : sampleKeyboardData ( ) {
2023-04-10 11:45:58 +02:00
if ( ControllerPatcher : : isKeyboardConnected ( ) ) {
2017-10-29 09:34:47 +01:00
ControllerPatcher : : doSamplingForDeviceSlot ( gHID_SLOT_KEYBOARD ) ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : resetCallbackData ( ) {
2023-04-10 11:45:58 +02:00
memset ( gWPADConnectCallback , 0 , sizeof ( gWPADConnectCallback ) ) ;
memset ( gKPADConnectCallback , 0 , sizeof ( gKPADConnectCallback ) ) ;
memset ( gExtensionCallback , 0 , sizeof ( gExtensionCallback ) ) ;
2024-10-13 10:37:09 +02:00
gSamplingCallback = nullptr ;
2017-10-29 09:34:47 +01:00
gCallbackCooldown = 0 ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setKPADConnectedCallback ( int32_t chan , WPADConnectCallback callback ) {
2023-04-10 11:45:58 +02:00
if ( chan > = 4 ) {
2018-06-19 17:46:37 +02:00
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN ;
}
2017-10-29 09:34:47 +01:00
gKPADConnectCallback [ chan ] = callback ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setKPADExtensionCallback ( int32_t chan , WPADConnectCallback callback ) {
2023-04-10 11:45:58 +02:00
if ( chan > = 4 ) {
2018-06-19 17:46:37 +02:00
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN ;
}
2017-10-29 09:34:47 +01:00
gExtensionCallback [ chan ] = callback ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : setWPADConnectCallback ( int32_t chan , WPADConnectCallback callback ) {
2023-04-10 11:45:58 +02:00
if ( chan > = 4 ) {
2018-06-19 17:46:37 +02:00
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN ;
}
2017-10-29 09:34:47 +01:00
gWPADConnectCallback [ chan ] = callback ;
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-20 15:07:15 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : handleCallbackData ( BOOL button_pressed ) {
2023-04-10 11:45:58 +02:00
if ( button_pressed & & gCallbackCooldown = = 0 ) {
2017-10-29 09:34:47 +01:00
gCallbackCooldown = 0xFF ;
2020-12-16 02:04:31 +01:00
/*if(HID_DEBUG){ log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!",__LINE__); }
if ( HID_DEBUG ) { log_printf ( " my_VPADRead(line %d): gExtensionCallback = %08X %08X %08X %08X " , __LINE__ , gExtensionCallback [ 0 ] , gExtensionCallback [ 1 ] , gExtensionCallback [ 2 ] , gExtensionCallback [ 3 ] ) ; }
if ( HID_DEBUG ) { log_printf ( " my_VPADRead(line %d): gWPADConnectCallback = %08X %08X %08X %08X " , __LINE__ , gWPADConnectCallback [ 0 ] , gWPADConnectCallback [ 1 ] , gWPADConnectCallback [ 2 ] , gWPADConnectCallback [ 3 ] ) ; }
if ( HID_DEBUG ) { log_printf ( " my_VPADRead(line %d): gKPADConnectCallback = %08X %08X %08X %08X " , __LINE__ , gKPADConnectCallback [ 0 ] , gKPADConnectCallback [ 1 ] , gKPADConnectCallback [ 2 ] , gKPADConnectCallback [ 3 ] ) ; } */
2017-10-29 09:34:47 +01:00
2023-04-10 11:45:58 +02:00
if ( ControllerPatcher : : isControllerConnectedAndActive ( UController_Type_Pro1 ) ) {
2018-06-19 17:46:37 +02:00
ControllerPatcher : : handleCallbackDataInternal ( WPAD_CHAN_0 ) ;
}
2023-04-10 11:45:58 +02:00
if ( ControllerPatcher : : isControllerConnectedAndActive ( UController_Type_Pro2 ) ) {
2018-06-19 17:46:37 +02:00
ControllerPatcher : : handleCallbackDataInternal ( WPAD_CHAN_1 ) ;
}
2023-04-10 11:45:58 +02:00
if ( ControllerPatcher : : isControllerConnectedAndActive ( UController_Type_Pro3 ) ) {
2018-06-19 17:46:37 +02:00
ControllerPatcher : : handleCallbackDataInternal ( WPAD_CHAN_2 ) ;
}
2023-04-10 11:45:58 +02:00
if ( ControllerPatcher : : isControllerConnectedAndActive ( UController_Type_Pro4 ) ) {
2018-06-19 17:46:37 +02:00
ControllerPatcher : : handleCallbackDataInternal ( WPAD_CHAN_3 ) ;
2017-10-29 09:34:47 +01:00
}
}
2023-04-10 11:45:58 +02:00
if ( gCallbackCooldown > 0 ) {
2017-10-29 09:34:47 +01:00
gCallbackCooldown - - ;
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}
2018-06-19 17:46:37 +02:00
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher : : handleCallbackDataInternal ( WPADChan chan ) {
2023-04-10 11:45:58 +02:00
if ( gWPADConnectCallback [ chan ] ! = NULL ) {
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " Called WPAD connect callback for pro controller in slot %d! " , chan + 1 ) ;
2023-04-10 11:45:58 +02:00
gWPADConnectCallback [ chan ] ( chan , 0 ) ;
2018-06-19 17:46:37 +02:00
}
2023-04-10 11:45:58 +02:00
if ( gKPADConnectCallback [ chan ] ! = NULL ) {
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " Called KPAD connect callback for pro controller in slot %d! " , chan + 1 ) ;
2023-04-10 11:45:58 +02:00
gKPADConnectCallback [ chan ] ( chan , 0 ) ;
2018-06-19 17:46:37 +02:00
}
2023-04-10 11:45:58 +02:00
if ( gExtensionCallback [ chan ] ! = NULL ) {
2024-10-13 10:37:09 +02:00
DEBUG_FUNCTION_LINE ( " Called extension callback for pro controller in slot %d! " , chan + 1 ) ;
2023-04-10 11:45:58 +02:00
gExtensionCallback [ chan ] ( chan , WPAD_EXT_PRO_CONTROLLER ) ;
2018-06-19 17:46:37 +02:00
}
return CONTROLLER_PATCHER_ERROR_NONE ;
}