mirror of
https://github.com/Maschell/controller_patcher.git
synced 2024-11-25 13:36:53 +01:00
Adaptions necessary before it can be included in retroarch
This commit is contained in:
parent
3559a18408
commit
9fb5404dd7
116
ConfigReader.cpp
116
ConfigReader.cpp
@ -21,34 +21,40 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "dynamic_libs/fs_functions.h"
|
#include "wiiu/fs.h"
|
||||||
#include "utils/logger.h"
|
|
||||||
|
#define FS_MOUNT_SOURCE_SIZE 0x300
|
||||||
|
#define FS_MAX_MOUNTPATH_SIZE 12
|
||||||
|
|
||||||
|
#define FS_CLIENT_SIZE 0x1700
|
||||||
|
#define FS_CMD_BLOCK_SIZE 0xA80
|
||||||
|
|
||||||
|
#define FS_SOURCETYPE_EXTERNAL 0
|
||||||
|
#define FS_SOURCETYPE_HFIO 1
|
||||||
|
|
||||||
s32 ConfigReader::numberValidFiles = 0;
|
s32 ConfigReader::numberValidFiles = 0;
|
||||||
ConfigReader *ConfigReader::instance = NULL;
|
ConfigReader *ConfigReader::instance = NULL;
|
||||||
|
|
||||||
ConfigReader::ConfigReader(){
|
ConfigReader::ConfigReader(){
|
||||||
InitOSFunctionPointers();
|
|
||||||
InitFSFunctionPointers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigReader::ReadAllConfigs(){
|
void ConfigReader::ReadAllConfigs(){
|
||||||
std::vector<std::string> fileList = ScanFolder();
|
std::vector<std::string> fileList = ScanFolder();
|
||||||
if(fileList.size() > 0){
|
if(fileList.size() > 0){
|
||||||
if(HID_DEBUG){ log_printf("ConfigReader::ConfigReader(line %d): Found %d config files\n",__LINE__,fileList.size()); }
|
if(HID_DEBUG){ printf("ConfigReader::ConfigReader(line %d): Found %d config files\n",__LINE__,fileList.size()); }
|
||||||
processFileList(fileList);
|
processFileList(fileList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConfigReader::~ConfigReader(){
|
ConfigReader::~ConfigReader(){
|
||||||
if(HID_DEBUG){ log_printf("ConfigReader::~ConfigReader(line %d): ~ConfigReader\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigReader::~ConfigReader(line %d): ~ConfigReader\n",__LINE__); }
|
||||||
freeFSHandles();
|
freeFSHandles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigReader::freeFSHandles(){
|
void ConfigReader::freeFSHandles(){
|
||||||
if(this->pClient != NULL){
|
if(this->pClient != NULL){
|
||||||
FSDelClient(this->pClient);
|
FSDelClient((FSClient *)this->pClient,-1);
|
||||||
free(this->pClient);
|
free(this->pClient);
|
||||||
this->pClient = NULL;
|
this->pClient = NULL;
|
||||||
}
|
}
|
||||||
@ -60,67 +66,87 @@ void ConfigReader::freeFSHandles(){
|
|||||||
|
|
||||||
// Mounting the sdcard without any external lib to be portable
|
// Mounting the sdcard without any external lib to be portable
|
||||||
s32 ConfigReader::InitSDCard(){
|
s32 ConfigReader::InitSDCard(){
|
||||||
if(HID_DEBUG){ log_printf("ConfigReader::InitSDCard(line %d): InitSDCard\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): InitSDCard\n",__LINE__); }
|
||||||
|
|
||||||
char mountSrc[FS_MOUNT_SOURCE_SIZE];
|
void *mountSrc = malloc(FS_MOUNT_SOURCE_SIZE);
|
||||||
char mountPath[FS_MAX_MOUNTPATH_SIZE];
|
if(!mountSrc)
|
||||||
|
return -3;
|
||||||
|
|
||||||
|
char* mountPath = (char*) malloc(FS_MAX_MOUNTPATH_SIZE);
|
||||||
|
if(!mountPath) {
|
||||||
|
free(mountSrc);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(mountSrc, 0, FS_MOUNT_SOURCE_SIZE);
|
||||||
|
memset(mountPath, 0, FS_MAX_MOUNTPATH_SIZE);
|
||||||
|
|
||||||
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
|
|
||||||
freeFSHandles();
|
freeFSHandles();
|
||||||
|
|
||||||
this->pClient = malloc(FS_CLIENT_SIZE);
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
this->pCmd = malloc(FS_CMD_BLOCK_SIZE);
|
|
||||||
|
this->pClient = malloc(sizeof(FSClient));
|
||||||
|
this->pCmd = malloc(sizeof(FSCmdBlock));
|
||||||
|
|
||||||
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
|
|
||||||
s32 status = 0;
|
s32 status = 0;
|
||||||
|
|
||||||
if (this->pClient && this->pCmd)
|
if (this->pClient && this->pCmd){
|
||||||
{
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
// Do an FSInit first
|
|
||||||
FSInit();
|
FSInit();
|
||||||
// Add client to FS.
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
FSAddClientEx(this->pClient, FS_RET_NO_ERROR,-1);
|
FSInitCmdBlock((FSCmdBlock*)pCmd);
|
||||||
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
// Init command block.
|
FSAddClientEx((FSClient*)pClient,0, -1);
|
||||||
FSInitCmdBlock(this->pCmd);
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
|
if ((status = FSGetMountSource((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd, FS_MOUNT_SOURCE_SD, (FSMountSource *)mountSrc, 0)) == FS_STATUS_OK)
|
||||||
// Mount sdcard
|
|
||||||
if ((status = FSGetMountSource(this->pClient, this->pCmd, FS_SOURCETYPE_EXTERNAL, &mountSrc, FS_RET_NO_ERROR)) == FS_STATUS_OK)
|
|
||||||
{
|
{
|
||||||
if ((status = FSMount(this->pClient, this->pCmd, &mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, FS_RET_UNSUPPORTED_CMD)) == FS_STATUS_OK)
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
|
if ((status = FSMount((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd, (FSMountSource*)mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, 0x0400)) == FS_STATUS_OK)
|
||||||
{
|
{
|
||||||
|
if(HID_DEBUG){ printf("ConfigReader::InitSDCard(line %d): \n",__LINE__); }
|
||||||
|
free(mountSrc);free(mountPath);
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigReader::InitSDCard(line %d): error: FSMount failed %d\n",__LINE__,status);
|
printf("ConfigReader::InitSDCard(line %d): error: FSMount failed %d\n",__LINE__,status);
|
||||||
|
free(mountSrc);free(mountPath);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigReader::InitSDCard(line %d): error: FSGetMountSource failed %d\n",__LINE__,status);
|
printf("ConfigReader::InitSDCard(line %d): error: FSGetMountSource failed %d\n",__LINE__,status);
|
||||||
|
free(mountSrc);free(mountPath);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(mountSrc);free(mountPath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> ConfigReader::ScanFolder(){
|
std::vector<std::string> ConfigReader::ScanFolder(){
|
||||||
std::string path = CONTROLLER_PATCHER_PATH;
|
std::string path = CONTROLLER_PATCHER_PATH;
|
||||||
s32 dirhandle = 0;
|
s32 dirhandle = 0;
|
||||||
if(HID_DEBUG){ log_printf("ConfigReader::ScanFolder(line %d): Opening %s\n",__LINE__,path.c_str()); }
|
if(HID_DEBUG){ printf("ConfigReader::ScanFolder(line %d): Opening %s\n",__LINE__,path.c_str()); }
|
||||||
std::vector<std::string> config_files;
|
std::vector<std::string> config_files;
|
||||||
if (this->pClient && this->pCmd){
|
if (this->pClient && this->pCmd){
|
||||||
s32 status = 0;
|
s32 status = 0;
|
||||||
if((status = FSOpenDir(this->pClient,this->pCmd,path.c_str(),&dirhandle,-1)) == FS_STATUS_OK){
|
if((status = FSOpenDir((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd,path.c_str(),(FSDirectoryHandle *)&dirhandle,-1)) == FS_STATUS_OK){
|
||||||
FSDirEntry dir_entry;
|
FSDirectoryEntry dir_entry;
|
||||||
while (FSReadDir(this->pClient, this->pCmd, dirhandle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK){
|
while (FSReadDir((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd, dirhandle, &dir_entry, -1) == FS_STATUS_OK){
|
||||||
std::string full_path = path + "/" + dir_entry.name;
|
std::string full_path = path + "/" + dir_entry.name;
|
||||||
if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) != FS_STAT_FLAG_IS_DIRECTORY){
|
if((dir_entry.info.flags&FS_STAT_DIRECTORY) != FS_STAT_DIRECTORY){
|
||||||
if(CPStringTools::EndsWith(std::string(dir_entry.name),".ini")){
|
if(CPStringTools::EndsWith(std::string(dir_entry.name),".ini")){
|
||||||
config_files.push_back(full_path);
|
config_files.push_back(full_path);
|
||||||
if(HID_DEBUG){ log_printf("ConfigReader::ScanFolder(line %d): %s \n",__LINE__,full_path.c_str()); }
|
if(HID_DEBUG){ printf("ConfigReader::ScanFolder(line %d): %s \n",__LINE__,full_path.c_str()); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FSCloseDir(this->pClient,this->pCmd,dirhandle,-1);
|
FSCloseDir((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd,dirhandle,-1);
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigReader::ScanFolder(line %d): Failed to open %s!\n",__LINE__,path.c_str());
|
printf("ConfigReader::ScanFolder(line %d): Failed to open %s!\n",__LINE__,path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return config_files;
|
return config_files;
|
||||||
@ -128,7 +154,7 @@ std::vector<std::string> ConfigReader::ScanFolder(){
|
|||||||
|
|
||||||
void ConfigReader::processFileList(std::vector<std::string> path){
|
void ConfigReader::processFileList(std::vector<std::string> path){
|
||||||
for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); ++it) {
|
for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); ++it) {
|
||||||
log_printf("ConfigReader::processFileList(line %d): Reading %s\n",__LINE__,it->c_str());
|
printf("ConfigReader::processFileList(line %d): Reading %s\n",__LINE__,it->c_str());
|
||||||
std::string result = loadFileToString(*it);
|
std::string result = loadFileToString(*it);
|
||||||
|
|
||||||
ConfigParser parser(result);
|
ConfigParser parser(result);
|
||||||
@ -137,34 +163,34 @@ void ConfigReader::processFileList(std::vector<std::string> path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ConfigReader::loadFileToString(std::string path){
|
std::string ConfigReader::loadFileToString(std::string path){
|
||||||
s32 handle = 0;
|
FSFileHandle handle = 0;
|
||||||
s32 status = 0;
|
s32 status = 0;
|
||||||
std::string strBuffer;
|
std::string strBuffer;
|
||||||
FSStat stats;
|
FSStat stats;
|
||||||
if((status = FSGetStat(this->pClient,this->pCmd,path.c_str(),&stats,-1)) == FS_STATUS_OK){
|
if((status = FSGetStat((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd,path.c_str(),&stats,-1)) == FS_STATUS_OK){
|
||||||
char * file = (char *) malloc((sizeof(char)*stats.size)+1);
|
uint8_t * file = (uint8_t *) malloc((sizeof(uint8_t)*stats.size)+1);
|
||||||
if(!file){
|
if(!file){
|
||||||
log_printf("ConfigReader::loadFileToString(line %d): error: Failed to allocate space for reading the file\n",__LINE__);
|
printf("ConfigReader::loadFileToString(line %d): error: Failed to allocate space for reading the file\n",__LINE__);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
file[stats.size] = '\0';
|
file[stats.size] = '\0';
|
||||||
if((status = FSOpenFile(this->pClient,this->pCmd,path.c_str(),"r",&handle,-1)) == FS_STATUS_OK){
|
if((status = FSOpenFile((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd,path.c_str(),"r",&handle,-1)) == FS_STATUS_OK){
|
||||||
s32 total_read = 0;
|
s32 total_read = 0;
|
||||||
s32 ret2 = 0;
|
s32 ret2 = 0;
|
||||||
while ((ret2 = FSReadFile(pClient, pCmd, file+total_read, 1, stats.size-total_read, handle, 0, FS_RET_ALL_ERROR)) > 0){
|
while ((ret2 = FSReadFile((FSClient*)pClient,(FSCmdBlock*)pCmd, file+total_read, 1, stats.size-total_read, handle, 0, -1)) > 0){
|
||||||
total_read += ret2;
|
total_read += ret2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigReader::loadFileToString(line %d): error: (FSOpenFile) Couldn't open file (%s), error: %d",__LINE__,path.c_str(),status);
|
printf("ConfigReader::loadFileToString(line %d): error: (FSOpenFile) Couldn't open file (%s), error: %d",__LINE__,path.c_str(),status);
|
||||||
free(file);
|
free(file);
|
||||||
file=NULL;
|
file=NULL;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
FSCloseFile(this->pClient,this->pCmd,handle,-1);
|
FSCloseFile((FSClient*)this->pClient,(FSCmdBlock*)this->pCmd,handle,-1);
|
||||||
|
|
||||||
strBuffer = std::string(file);
|
strBuffer = std::string((char *)file);
|
||||||
free(file);
|
free(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
|
|
||||||
@ -174,7 +200,7 @@ std::string ConfigReader::loadFileToString(std::string path){
|
|||||||
strBuffer = CPStringTools::removeCharFromString(strBuffer,'\t');
|
strBuffer = CPStringTools::removeCharFromString(strBuffer,'\t');
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigReader::loadFileToString(line %d): error: (GetStat) Couldn't open file (%s), error: %d",__LINE__,path.c_str(),status);
|
printf("ConfigReader::loadFileToString(line %d): error: (GetStat) Couldn't open file (%s), error: %d",__LINE__,path.c_str(),status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return strBuffer;
|
return strBuffer;
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
#ifndef _ConfigReader_H_
|
#ifndef _ConfigReader_H_
|
||||||
#define _ConfigReader_H_
|
#define _ConfigReader_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
#include <wiiu/types.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "wiiu/sysapp.h"
|
||||||
|
#include "wiiu/syshid.h"
|
||||||
|
#include "sys/socket.h"
|
||||||
|
#include "wiiu/kpad.h"
|
||||||
|
|
||||||
#include "dynamic_libs/sys_functions.h"
|
#include "utils/CPRetainVars.hpp"
|
||||||
#include "dynamic_libs/syshid_functions.h"
|
|
||||||
#include "dynamic_libs/socket_functions.h"
|
|
||||||
#include "dynamic_libs/padscore_functions.h"
|
|
||||||
|
|
||||||
// This stores the holded buttons for the gamepad after the button remapping.
|
// This stores the holded buttons for the gamepad after the button remapping.
|
||||||
static u32 buttonRemapping_lastButtonsHold = 0;
|
static u32 buttonRemapping_lastButtonsHold = 0;
|
||||||
@ -36,13 +36,13 @@ static u32 buttonRemapping_lastButtonsHold = 0;
|
|||||||
|
|
||||||
// This arrays stores the last hold buttons of the Pro Controllers. One u32 for each channel of the controllers
|
// This arrays stores the last hold buttons of the Pro Controllers. One u32 for each channel of the controllers
|
||||||
static u32 last_button_hold[4] = {0,0,0,0};
|
static u32 last_button_hold[4] = {0,0,0,0};
|
||||||
// This arrays stores the VPADDATA that will be used to get the HID Data for the Pro Controllers. One for each channel.
|
// This arrays stores the VPADStatus that will be used to get the HID Data for the Pro Controllers. One for each channel.
|
||||||
static VPADData myVPADBuffer[4];
|
static VPADStatus myVPADBuffer[4];
|
||||||
|
|
||||||
void ControllerPatcher::InitButtonMapping(){
|
void ControllerPatcher::InitButtonMapping(){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::InitButtonMapping(line %d): Init called \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::InitButtonMapping(line %d): Init called \n",__LINE__); }
|
||||||
if(!gButtonRemappingConfigDone){
|
if(!gButtonRemappingConfigDone){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::InitButtonMapping(line %d): Remapping is running! \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::InitButtonMapping(line %d): Remapping is running! \n",__LINE__); }
|
||||||
gButtonRemappingConfigDone = 1;
|
gButtonRemappingConfigDone = 1;
|
||||||
memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything
|
memset(gGamePadValues,0,sizeof(gGamePadValues)); // Init / Invalid everything
|
||||||
|
|
||||||
@ -105,12 +105,12 @@ void ControllerPatcher::ResetConfig(){
|
|||||||
gHIDRegisteredDevices = 0;
|
gHIDRegisteredDevices = 0;
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
gGamePadSlot = slotdata.deviceslot;
|
gGamePadSlot = slotdata.deviceslot;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register Gamepad-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(slotdata.hidmask),gGamePadSlot); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
gMouseSlot = slotdata.deviceslot;
|
gMouseSlot = slotdata.deviceslot;
|
||||||
gHID_LIST_MOUSE = slotdata.hidmask;
|
gHID_LIST_MOUSE = slotdata.hidmask;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register Mouse-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_MOUSE),gMouseSlot); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 keyboard_slot = slotdata.deviceslot;
|
u32 keyboard_slot = slotdata.deviceslot;
|
||||||
@ -118,36 +118,36 @@ void ControllerPatcher::ResetConfig(){
|
|||||||
gHID_LIST_KEYBOARD = keyboard_hid;
|
gHID_LIST_KEYBOARD = keyboard_hid;
|
||||||
gHID_SLOT_KEYBOARD = keyboard_slot;
|
gHID_SLOT_KEYBOARD = keyboard_slot;
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register Keyboard-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register Keyboard-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_KEYBOARD),gHID_SLOT_KEYBOARD); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 gc_slot = slotdata.deviceslot;
|
u32 gc_slot = slotdata.deviceslot;
|
||||||
u32 gc_hid = slotdata.hidmask;
|
u32 gc_hid = slotdata.hidmask;
|
||||||
gHID_LIST_GC = gc_hid;
|
gHID_LIST_GC = gc_hid;
|
||||||
gHID_SLOT_GC = gc_slot;
|
gHID_SLOT_GC = gc_slot;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register GC-Adapter-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_GC),gHID_SLOT_GC); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 ds3_slot = slotdata.deviceslot;
|
u32 ds3_slot = slotdata.deviceslot;
|
||||||
u32 ds3_hid = slotdata.hidmask;
|
u32 ds3_hid = slotdata.hidmask;
|
||||||
gHID_LIST_DS3 = ds3_hid;
|
gHID_LIST_DS3 = ds3_hid;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register DS3-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register DS3-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_DS3),ds3_slot); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 ds4_slot = slotdata.deviceslot;
|
u32 ds4_slot = slotdata.deviceslot;
|
||||||
u32 ds4_hid = slotdata.hidmask;
|
u32 ds4_hid = slotdata.hidmask;
|
||||||
gHID_LIST_DS4 = ds4_hid;
|
gHID_LIST_DS4 = ds4_hid;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register DS4-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(ds4_hid),ds4_slot); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register DS4-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(ds4_hid),ds4_slot); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 xinput_slot = slotdata.deviceslot;
|
u32 xinput_slot = slotdata.deviceslot;
|
||||||
u32 xinput_hid = slotdata.hidmask;
|
u32 xinput_hid = slotdata.hidmask;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::ResetConfig(line %d): Register XInput-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(xinput_hid),xinput_slot); }
|
if(HID_DEBUG){ printf("ControllerPatcher::ResetConfig(line %d): Register XInput-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(xinput_hid),xinput_slot); }
|
||||||
|
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
u32 switch_pro_slot = slotdata.deviceslot;
|
u32 switch_pro_slot = slotdata.deviceslot;
|
||||||
gHID_LIST_SWITCH_PRO = slotdata.hidmask;
|
gHID_LIST_SWITCH_PRO = slotdata.hidmask;
|
||||||
log_printf("ControllerPatcher::ResetConfig(line %d): Register Switch-Pro-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_SWITCH_PRO),switch_pro_slot);
|
printf("ControllerPatcher::ResetConfig(line %d): Register Switch-Pro-Config. HID-Mask %s Device-Slot: %d\n",__LINE__,CPStringTools::byte_to_binary(gHID_LIST_SWITCH_PRO),switch_pro_slot);
|
||||||
|
|
||||||
|
|
||||||
config_controller_hidmask[gc_slot] = gHID_LIST_GC;
|
config_controller_hidmask[gc_slot] = gHID_LIST_GC;
|
||||||
@ -471,11 +471,12 @@ void ControllerPatcher::ResetConfig(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ControllerPatcher::Init(){
|
bool ControllerPatcher::Init(){
|
||||||
|
/*
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSocketFunctionPointers();
|
InitSocketFunctionPointers();
|
||||||
InitSysHIDFunctionPointers();
|
InitSysHIDFunctionPointers();
|
||||||
InitVPadFunctionPointers();
|
InitVPadFunctionPointers();
|
||||||
InitPadScoreFunctionPointers();
|
InitPadScoreFunctionPointers();*/
|
||||||
|
|
||||||
gSamplingCallback = (wpad_sampling_callback_t)((u32)KPADRead + 0x1F0);
|
gSamplingCallback = (wpad_sampling_callback_t)((u32)KPADRead + 0x1F0);
|
||||||
if(*(u32*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK){
|
if(*(u32*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK){
|
||||||
@ -486,39 +487,40 @@ bool ControllerPatcher::Init(){
|
|||||||
gSamplingCallback = NULL;
|
gSamplingCallback = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_printf("ControllerPatcher::Init(line %d): Found the gSamplingCallback at %08X \n",__LINE__,gSamplingCallback);
|
printf("ControllerPatcher::Init(line %d): Found the gSamplingCallback at %08X \n",__LINE__,gSamplingCallback);
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): Init called! \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::Init(line %d): Init called! \n",__LINE__); }
|
||||||
|
|
||||||
if(syshid_handle == 0){
|
/* if(syshid_handle == 0){
|
||||||
log_printf("ControllerPatcher::Init(line %d): Failed to load the HID API \n",__LINE__);
|
printf("ControllerPatcher::Init(line %d): Failed to load the HID API \n",__LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(gConfig_done == HID_INIT_NOT_DONE){
|
if(gConfig_done == HID_INIT_NOT_DONE){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): First time calling the Init\n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::Init(line %d): First time calling the Init\n",__LINE__); }
|
||||||
gConfig_done = HID_INIT_DONE;
|
gConfig_done = HID_INIT_DONE;
|
||||||
ControllerPatcher::ResetConfig();
|
ControllerPatcher::ResetConfig();
|
||||||
}else{
|
}else{
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): ControllerPatcher::Init(): Config already done!\n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::Init(line %d): ControllerPatcher::Init(): Config already done!\n",__LINE__); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gConfig_done != HID_SDCARD_READ){
|
//Broken
|
||||||
log_printf("ControllerPatcher::Init(line %d): Reading config files from SD Card\n",__LINE__);
|
/*if(gConfig_done != HID_SDCARD_READ){
|
||||||
|
printf("ControllerPatcher::Init(line %d): Reading config files from SD Card\n",__LINE__);
|
||||||
ConfigReader* reader = ConfigReader::getInstance();
|
ConfigReader* reader = ConfigReader::getInstance();
|
||||||
s32 status = 0;
|
s32 status = 0;
|
||||||
if((status = reader->InitSDCard()) == 0){
|
if((status = reader->InitSDCard()) == 0){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::Init(line %d): SD Card mounted for controller config!\n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::Init(line %d): SD Card mounted for controller config!\n",__LINE__); }
|
||||||
reader->ReadAllConfigs();
|
reader->ReadAllConfigs();
|
||||||
log_printf("ControllerPatcher::Init(line %d): Done with reading config files from SD Card\n",__LINE__);
|
printf("ControllerPatcher::Init(line %d): Done with reading config files from SD Card\n",__LINE__);
|
||||||
gConfig_done = HID_SDCARD_READ;
|
gConfig_done = HID_SDCARD_READ;
|
||||||
}else{
|
}else{
|
||||||
log_printf("ControllerPatcher::Init(line %d): SD mounting failed! %d\n",__LINE__,status);
|
printf("ControllerPatcher::Init(line %d): SD mounting failed! %d\n",__LINE__,status);
|
||||||
}
|
}
|
||||||
ConfigReader::destroyInstance();
|
ConfigReader::destroyInstance();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
log_printf("ControllerPatcher::Init(line %d): Initializing the data for button remapping\n",__LINE__);
|
printf("ControllerPatcher::Init(line %d): Initializing the data for button remapping\n",__LINE__);
|
||||||
InitButtonMapping();
|
InitButtonMapping();
|
||||||
|
|
||||||
if(!gHIDAttached){
|
if(!gHIDAttached){
|
||||||
@ -540,7 +542,7 @@ void ControllerPatcher::stopNetworkServer(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllerPatcher::DeInit(){
|
void ControllerPatcher::DeInit(){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcher::DeInit(line %d) called! \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcher::DeInit(line %d) called! \n",__LINE__); }
|
||||||
|
|
||||||
if(gHIDAttached) HIDDelClient(&gHIDClient);
|
if(gHIDAttached) HIDDelClient(&gHIDClient);
|
||||||
|
|
||||||
@ -601,21 +603,21 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::disableWiiUEnergySetting()
|
|||||||
s32 res;
|
s32 res;
|
||||||
if(IMIsDimEnabled(&res) == 0){
|
if(IMIsDimEnabled(&res) == 0){
|
||||||
if(res == 1){
|
if(res == 1){
|
||||||
if(HID_DEBUG){ log_print("ControllerPatcher::disableWiiUEnergySetting(): Dim was orignally enabled!\n"); }
|
if(HID_DEBUG){ printf("ControllerPatcher::disableWiiUEnergySetting(): Dim was orignally enabled!\n"); }
|
||||||
gOriginalDimState = 1;
|
gOriginalDimState = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IMIsAPDEnabled(&res) == 0){
|
if(IMIsAPDEnabled(&res) == 0){
|
||||||
if(res == 1){
|
if(res == 1){
|
||||||
if(HID_DEBUG){ log_print("ControllerPatcher::disableWiiUEnergySetting(): Auto power down was orignally enabled!\n"); }
|
if(HID_DEBUG){ printf("ControllerPatcher::disableWiiUEnergySetting(): Auto power down was orignally enabled!\n"); }
|
||||||
gOriginalAPDState = 1;
|
gOriginalAPDState = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMDisableDim();
|
IMDisableDim();
|
||||||
IMDisableAPD();
|
IMDisableAPD();
|
||||||
log_print("ControllerPatcher::disableWiiUEnergySetting(): Disable Energy savers\n");
|
printf("ControllerPatcher::disableWiiUEnergySetting(): Disable Energy savers\n");
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,11 +625,11 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::restoreWiiUEnergySetting()
|
|||||||
|
|
||||||
//Check if we need to enable Auto Power down again on exiting
|
//Check if we need to enable Auto Power down again on exiting
|
||||||
if(gOriginalAPDState == 1){
|
if(gOriginalAPDState == 1){
|
||||||
log_print("ControllerPatcher::restoreWiiUEnergySetting(): Auto shutdown was on before using HID to VPAD. Setting it to on again.\n");
|
printf("ControllerPatcher::restoreWiiUEnergySetting(): Auto shutdown was on before using HID to VPAD. Setting it to on again.\n");
|
||||||
IMEnableAPD();
|
IMEnableAPD();
|
||||||
}
|
}
|
||||||
if(gOriginalDimState == 1){
|
if(gOriginalDimState == 1){
|
||||||
log_print("ControllerPatcher::restoreWiiUEnergySetting(): Burn-in reduction was on before using HID to VPAD. Setting it to on again.\n");
|
printf("ControllerPatcher::restoreWiiUEnergySetting(): Burn-in reduction was on before using HID to VPAD. Setting it to on again.\n");
|
||||||
IMEnableDim();
|
IMEnableDim();
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
@ -756,8 +758,8 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumble(UController_Type
|
|||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(InputData * output,s32 array_size){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(InputData * output,s32 array_size){
|
||||||
s32 hid = gHIDCurrentDevice;
|
s32 hid = gHIDCurrentDevice;
|
||||||
HID_Data * data_cur;
|
HID_Data * data_cur;
|
||||||
VPADData pad_buffer;
|
VPADStatus pad_buffer;
|
||||||
VPADData * buffer = &pad_buffer;
|
VPADStatus * buffer = &pad_buffer;
|
||||||
s32 result = CONTROLLER_PATCHER_ERROR_NONE;
|
s32 result = CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
||||||
if((hid & (1 << i)) != 0){
|
if((hid & (1 << i)) != 0){
|
||||||
@ -786,9 +788,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp
|
|||||||
|
|
||||||
for(s32 pad = 0;pad<HID_MAX_PADS_COUNT;pad++){
|
for(s32 pad = 0;pad<HID_MAX_PADS_COUNT;pad++){
|
||||||
buttons_hold = 0;
|
buttons_hold = 0;
|
||||||
buttondata[pad].btn_h = 0;
|
buttondata[pad].hold = 0;
|
||||||
buttondata[pad].btn_d = 0;
|
buttondata[pad].trigger = 0;
|
||||||
buttondata[pad].btn_r = 0;
|
buttondata[pad].release = 0;
|
||||||
s32 res;
|
s32 res;
|
||||||
|
|
||||||
if((res = ControllerPatcherHID::getHIDData(deviceinfo->slotdata.hidmask,pad,&data_cur)) < 0){
|
if((res = ControllerPatcherHID::getHIDData(deviceinfo->slotdata.hidmask,pad,&data_cur)) < 0){
|
||||||
@ -817,9 +819,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp
|
|||||||
ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_L);
|
ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_L);
|
||||||
ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_R);
|
ControllerPatcherUtils::getButtonPressed(data_cur,&buttons_hold,VPAD_BUTTON_STICK_R);
|
||||||
|
|
||||||
buttondata[pad].btn_h |= buttons_hold;
|
buttondata[pad].hold |= buttons_hold;
|
||||||
buttondata[pad].btn_d |= (buttons_hold & (~(data_cur->last_buttons)));
|
buttondata[pad].trigger |= (buttons_hold & (~(data_cur->last_buttons)));
|
||||||
buttondata[pad].btn_r |= ((data_cur->last_buttons) & (~buttons_hold));
|
buttondata[pad].release |= ((data_cur->last_buttons) & (~buttons_hold));
|
||||||
|
|
||||||
data_cur->last_buttons = buttons_hold;
|
data_cur->last_buttons = buttons_hold;
|
||||||
}
|
}
|
||||||
@ -839,7 +841,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
|
|||||||
if(chan < 0 || chan > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
|
if(chan < 0 || chan > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
|
||||||
//if(gControllerMapping.proController[chan].enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
|
//if(gControllerMapping.proController[chan].enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
|
||||||
|
|
||||||
VPADData * vpad_buffer = &myVPADBuffer[chan];
|
VPADStatus * vpad_buffer = &myVPADBuffer[chan];
|
||||||
memset(vpad_buffer,0,sizeof(*vpad_buffer));
|
memset(vpad_buffer,0,sizeof(*vpad_buffer));
|
||||||
|
|
||||||
std::vector<HID_Data *> data_list;
|
std::vector<HID_Data *> data_list;
|
||||||
@ -856,7 +858,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
|
|||||||
|
|
||||||
s32 res;
|
s32 res;
|
||||||
if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0){
|
if((res = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0){
|
||||||
log_printf("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) = %d\n",res);
|
printf("ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) = %d\n",res);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,7 +868,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
|
|||||||
HID_Data * data_cur;
|
HID_Data * data_cur;
|
||||||
|
|
||||||
if((res = ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) < 0) {
|
if((res = ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) < 0) {
|
||||||
//log_printf("ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) = %d\n",res);
|
//printf("ControllerPatcherHID::getHIDData(hidmask,pad,&data_cur)) = %d\n",res);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data_list.push_back(data_cur);
|
data_list.push_back(data_cur);
|
||||||
@ -896,7 +898,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setProControllerDataFromHI
|
|||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(VPADData * buffer){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(VPADStatus * buffer){
|
||||||
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
//if(gControllerMapping.gamepad.enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
|
//if(gControllerMapping.gamepad.enabled == 0) return CONTROLLER_PATCHER_ERROR_MAPPING_DISABLED;
|
||||||
|
|
||||||
@ -948,52 +950,52 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setControllerDataFromHID(V
|
|||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::printVPADButtons(VPADData * buffer){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::printVPADButtons(VPADStatus * buffer){
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
/* BROKEN on transitions.*/
|
/* BROKEN on transitions.*/
|
||||||
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
if(buffer->btns_d != 0x00000000){
|
if(buffer->trigger != 0x00000000){
|
||||||
char output[250];
|
char output[250];
|
||||||
|
|
||||||
output[0] = 0; //null terminate it. just in case.
|
output[0] = 0; //null terminate it. just in case.
|
||||||
|
|
||||||
if((buffer->btns_d & VPAD_BUTTON_A) == VPAD_BUTTON_A) strcat(output,"A ");
|
if((buffer->trigger & VPAD_BUTTON_A) == VPAD_BUTTON_A) strcat(output,"A ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_B) == VPAD_BUTTON_B) strcat(output,"B ");
|
if((buffer->trigger & VPAD_BUTTON_B) == VPAD_BUTTON_B) strcat(output,"B ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_X) == VPAD_BUTTON_X) strcat(output,"X ");
|
if((buffer->trigger & VPAD_BUTTON_X) == VPAD_BUTTON_X) strcat(output,"X ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_Y) == VPAD_BUTTON_Y) strcat(output,"Y ");
|
if((buffer->trigger & VPAD_BUTTON_Y) == VPAD_BUTTON_Y) strcat(output,"Y ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_L) == VPAD_BUTTON_L) strcat(output,"L ");
|
if((buffer->trigger & VPAD_BUTTON_L) == VPAD_BUTTON_L) strcat(output,"L ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_R) == VPAD_BUTTON_R) strcat(output,"R ");
|
if((buffer->trigger & VPAD_BUTTON_R) == VPAD_BUTTON_R) strcat(output,"R ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_ZR) == VPAD_BUTTON_ZR) strcat(output,"ZR ");
|
if((buffer->trigger & VPAD_BUTTON_ZR) == VPAD_BUTTON_ZR) strcat(output,"ZR ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_ZL) == VPAD_BUTTON_ZL) strcat(output,"ZL ");
|
if((buffer->trigger & VPAD_BUTTON_ZL) == VPAD_BUTTON_ZL) strcat(output,"ZL ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_LEFT) == VPAD_BUTTON_LEFT) strcat(output,"Left ");
|
if((buffer->trigger & VPAD_BUTTON_LEFT) == VPAD_BUTTON_LEFT) strcat(output,"Left ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_RIGHT) == VPAD_BUTTON_RIGHT) strcat(output,"Right ");
|
if((buffer->trigger & VPAD_BUTTON_RIGHT) == VPAD_BUTTON_RIGHT) strcat(output,"Right ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_UP) == VPAD_BUTTON_UP) strcat(output,"Up ");
|
if((buffer->trigger & VPAD_BUTTON_UP) == VPAD_BUTTON_UP) strcat(output,"Up ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_DOWN) == VPAD_BUTTON_DOWN) strcat(output,"Down ");
|
if((buffer->trigger & VPAD_BUTTON_DOWN) == VPAD_BUTTON_DOWN) strcat(output,"Down ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_PLUS) == VPAD_BUTTON_PLUS) strcat(output,"+ ");
|
if((buffer->trigger & VPAD_BUTTON_PLUS) == VPAD_BUTTON_PLUS) strcat(output,"+ ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_MINUS) == VPAD_BUTTON_MINUS) strcat(output,"- ");
|
if((buffer->trigger & VPAD_BUTTON_MINUS) == VPAD_BUTTON_MINUS) strcat(output,"- ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_TV) == VPAD_BUTTON_TV) strcat(output,"TV ");
|
if((buffer->trigger & VPAD_BUTTON_TV) == VPAD_BUTTON_TV) strcat(output,"TV ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_HOME) == VPAD_BUTTON_HOME) strcat(output,"HOME ");
|
if((buffer->trigger & VPAD_BUTTON_HOME) == VPAD_BUTTON_HOME) strcat(output,"HOME ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_STICK_L) == VPAD_BUTTON_STICK_L) strcat(output,"SL ");
|
if((buffer->trigger & VPAD_BUTTON_STICK_L) == VPAD_BUTTON_STICK_L) strcat(output,"SL ");
|
||||||
if((buffer->btns_d & VPAD_BUTTON_STICK_R) == VPAD_BUTTON_STICK_R) strcat(output,"SR ");
|
if((buffer->trigger & VPAD_BUTTON_STICK_R) == VPAD_BUTTON_STICK_R) strcat(output,"SR ");
|
||||||
if((buffer->btns_d & VPAD_STICK_R_EMULATION_LEFT) == VPAD_STICK_R_EMULATION_LEFT) strcat(output,"RE_Left ");
|
if((buffer->trigger & VPAD_STICK_R_EMULATION_LEFT) == VPAD_STICK_R_EMULATION_LEFT) strcat(output,"RE_Left ");
|
||||||
if((buffer->btns_d & VPAD_STICK_R_EMULATION_RIGHT) == VPAD_STICK_R_EMULATION_RIGHT) strcat(output,"RE_Right ");
|
if((buffer->trigger & VPAD_STICK_R_EMULATION_RIGHT) == VPAD_STICK_R_EMULATION_RIGHT) strcat(output,"RE_Right ");
|
||||||
if((buffer->btns_d & VPAD_STICK_R_EMULATION_UP) == VPAD_STICK_R_EMULATION_UP) strcat(output,"RE_Up ");
|
if((buffer->trigger & VPAD_STICK_R_EMULATION_UP) == VPAD_STICK_R_EMULATION_UP) strcat(output,"RE_Up ");
|
||||||
if((buffer->btns_d & VPAD_STICK_R_EMULATION_DOWN) == VPAD_STICK_R_EMULATION_DOWN) strcat(output,"RE_Down ");
|
if((buffer->trigger & VPAD_STICK_R_EMULATION_DOWN) == VPAD_STICK_R_EMULATION_DOWN) strcat(output,"RE_Down ");
|
||||||
if((buffer->btns_d & VPAD_STICK_L_EMULATION_LEFT) == VPAD_STICK_L_EMULATION_LEFT) strcat(output,"LE_Left ");
|
if((buffer->trigger & VPAD_STICK_L_EMULATION_LEFT) == VPAD_STICK_L_EMULATION_LEFT) strcat(output,"LE_Left ");
|
||||||
if((buffer->btns_d & VPAD_STICK_L_EMULATION_RIGHT) == VPAD_STICK_L_EMULATION_RIGHT) strcat(output,"LE_Right ");
|
if((buffer->trigger & VPAD_STICK_L_EMULATION_RIGHT) == VPAD_STICK_L_EMULATION_RIGHT) strcat(output,"LE_Right ");
|
||||||
if((buffer->btns_d & VPAD_STICK_L_EMULATION_UP) == VPAD_STICK_L_EMULATION_UP) strcat(output,"LE_Up ");
|
if((buffer->trigger & VPAD_STICK_L_EMULATION_UP) == VPAD_STICK_L_EMULATION_UP) strcat(output,"LE_Up ");
|
||||||
if((buffer->btns_d & VPAD_STICK_L_EMULATION_DOWN) == VPAD_STICK_L_EMULATION_DOWN) strcat(output,"LE_Down ");
|
if((buffer->trigger & VPAD_STICK_L_EMULATION_DOWN) == VPAD_STICK_L_EMULATION_DOWN) strcat(output,"LE_Down ");
|
||||||
|
|
||||||
log_printf("%spressed Sticks: LX %f LY %f RX %f RY %f\n",output,buffer->lstick.x,buffer->lstick.y,buffer->rstick.x,buffer->rstick.y);
|
printf("%spressed Sticks: LX %f LY %f RX %f RY %f\n",output,buffer->leftStick.x,buffer->leftStick.y,buffer->rightStick.x,buffer->rightStick.y);
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::buttonRemapping(VPADData * buffer,s32 buffer_count){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::buttonRemapping(VPADStatus * buffer,s32 buffer_count){
|
||||||
if(!gButtonRemappingConfigDone) return CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE;
|
if(!gButtonRemappingConfigDone) return CONTROLLER_PATCHER_ERROR_CONFIG_NOT_DONE;
|
||||||
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
for(s32 i = 0;i < buffer_count;i++){
|
for(s32 i = 0;i < buffer_count;i++){
|
||||||
VPADData new_data;
|
VPADStatus new_data;
|
||||||
memset(&new_data,0,sizeof(new_data));
|
memset(&new_data,0,sizeof(new_data));
|
||||||
|
|
||||||
ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_A, CONTRPS_VPAD_BUTTON_A);
|
ControllerPatcherUtils::setButtonRemappingData(&buffer[i],&new_data,VPAD_BUTTON_A, CONTRPS_VPAD_BUTTON_A);
|
||||||
@ -1037,9 +1039,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::buttonRemapping(VPADData *
|
|||||||
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_UP, VPAD_STICK_R_EMULATION_UP);
|
||||||
ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_DOWN, VPAD_STICK_R_EMULATION_DOWN);
|
ControllerPatcherUtils::setButtonData(&buffer[i],&new_data,VPAD_STICK_R_EMULATION_DOWN, VPAD_STICK_R_EMULATION_DOWN);
|
||||||
|
|
||||||
buffer[i].btns_h = new_data.btns_h;
|
buffer[i].hold = new_data.hold;
|
||||||
buffer[i].btns_d = new_data.btns_d;
|
buffer[i].trigger = new_data.trigger;
|
||||||
buffer[i].btns_r = new_data.btns_r;
|
buffer[i].release = new_data.release;
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,8 @@
|
|||||||
#ifndef _CONTROLLER_PATCHER_H_
|
#ifndef _CONTROLLER_PATCHER_H_
|
||||||
#define _CONTROLLER_PATCHER_H_
|
#define _CONTROLLER_PATCHER_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#include "./patcher/ControllerPatcherDefs.h"
|
#include "./patcher/ControllerPatcherDefs.h"
|
||||||
#include "./utils/ControllerPatcherThread.hpp"
|
#include "./utils/ControllerPatcherThread.hpp"
|
||||||
#include "./utils/CPRetainVars.hpp"
|
#include "./utils/CPRetainVars.hpp"
|
||||||
@ -49,8 +47,14 @@
|
|||||||
#include "./network/UDPClient.hpp"
|
#include "./network/UDPClient.hpp"
|
||||||
#include "./ConfigReader.hpp"
|
#include "./ConfigReader.hpp"
|
||||||
|
|
||||||
#include "dynamic_libs/vpad_functions.h"
|
#include "wiiu/vpad.h"
|
||||||
|
|
||||||
|
#define BUS_SPEED 248625000
|
||||||
|
#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4))
|
||||||
|
#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000)
|
||||||
|
#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000)
|
||||||
|
|
||||||
|
#define wiiu_os_usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs))
|
||||||
|
|
||||||
#define HID_DEBUG 0
|
#define HID_DEBUG 0
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ class ControllerPatcher{
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the data in a given VPADData from HID Devices. The information about which HID Device will be used is stored in the gControllerMapping array in slot 0.
|
Sets the data in a given VPADStatus from HID Devices. The information about which HID Device will be used is stored in the gControllerMapping array in slot 0.
|
||||||
|
|
||||||
@param buffer: A pointer to an KPADData struct where the result will be stored.
|
@param buffer: A pointer to an KPADData struct where the result will be stored.
|
||||||
@param chan: Indicates the channel from which slot the information about the mapped HID Device will be used.
|
@param chan: Indicates the channel from which slot the information about the mapped HID Device will be used.
|
||||||
@ -114,7 +118,7 @@ class ControllerPatcher{
|
|||||||
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADData * buffer);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus * buffer);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
* Useful functions
|
* Useful functions
|
||||||
@ -215,23 +219,23 @@ class ControllerPatcher{
|
|||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Remaps the buttons in the given \p VPADData pointer. InitButtonMapping() needs to be called before calling this. The information about the remapping is stored in the config_controller array.
|
Remaps the buttons in the given \p VPADStatus pointer. InitButtonMapping() needs to be called before calling this. The information about the remapping is stored in the config_controller array.
|
||||||
One easy way to set it is using the a config file on the SD Card.
|
One easy way to set it is using the a config file on the SD Card.
|
||||||
|
|
||||||
@param buffer: A pointer to the buffer where the input will be read from and the result will be stored.
|
@param buffer: A pointer to the buffer where the input will be read from and the result will be stored.
|
||||||
|
|
||||||
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR buttonRemapping(VPADData * buffer, s32 buffer_count);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR buttonRemapping(VPADStatus * buffer, s32 buffer_count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints the current pressed down buttons of the given \p VPADData pointer. Uses the utils/logger.c UDP logger..
|
Prints the current pressed down buttons of the given \p VPADStatus pointer. Uses the utils/logger.c UDP logger..
|
||||||
|
|
||||||
@param buffer: A pointer to the buffer where the input will be read from.
|
@param buffer: A pointer to the buffer where the input will be read from.
|
||||||
|
|
||||||
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR printVPADButtons(VPADData * buffer);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR printVPADButtons(VPADStatus * buffer);
|
||||||
|
|
||||||
static std::string getIdentifierByVIDPID(u16 vid,u16 pid);
|
static std::string getIdentifierByVIDPID(u16 vid,u16 pid);
|
||||||
|
|
||||||
|
38
ControllerPatcherWrapper.cpp
Normal file
38
ControllerPatcherWrapper.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#include "controller_patcher/ControllerPatcher.hpp"
|
||||||
|
#include "controller_patcher/ControllerPatcherWrapper.h"
|
||||||
|
extern "C" void ControllerPatcherInit(void){
|
||||||
|
ControllerPatcher::Init();
|
||||||
|
ControllerPatcher::disableControllerMapping();
|
||||||
|
ControllerPatcher::startNetworkServer();
|
||||||
|
ControllerPatcher::disableWiiUEnergySetting();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus * data){
|
||||||
|
ControllerPatcher::setControllerDataFromHID(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size){
|
||||||
|
ControllerPatcher::gettingInputAllDevices(output,array_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void ControllerPatcherDeInit(void){
|
||||||
|
ControllerPatcher::restoreWiiUEnergySetting();
|
||||||
|
ControllerPatcher::stopNetworkServer();
|
||||||
|
ControllerPatcher::DeInit();
|
||||||
|
}
|
23
ControllerPatcherWrapper.h
Normal file
23
ControllerPatcherWrapper.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef _CONTROLLER_PATCHER_WRAPPER_H_
|
||||||
|
#define _CONTROLLER_PATCHER_WRAPPER_H_
|
||||||
|
|
||||||
|
#include "wiiu/vpad.h"
|
||||||
|
|
||||||
|
/* Main */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./patcher/ControllerPatcherDefs.h"
|
||||||
|
|
||||||
|
//! C wrapper for our C++ functions
|
||||||
|
void ControllerPatcherInit(void);
|
||||||
|
void ControllerPatcherDeInit(void);
|
||||||
|
CONTROLLER_PATCHER_RESULT_OR_ERROR setControllerDataFromHID(VPADStatus * data);
|
||||||
|
CONTROLLER_PATCHER_RESULT_OR_ERROR gettingInputAllDevices(InputData * output,s32 array_size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -70,7 +70,7 @@ void ConfigParser::setSlot(u16 newSlot){
|
|||||||
|
|
||||||
bool ConfigParser::Init(){
|
bool ConfigParser::Init(){
|
||||||
if(contentLines.size() == 0){
|
if(contentLines.size() == 0){
|
||||||
log_printf("ConfigParser::Init(line %d): Files seems to be empty. Make sure to have a proper header\n",__LINE__);
|
printf("ConfigParser::Init(line %d): Files seems to be empty. Make sure to have a proper header\n",__LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const char * line = contentLines[0].c_str();
|
const char * line = contentLines[0].c_str();
|
||||||
@ -79,28 +79,28 @@ bool ConfigParser::Init(){
|
|||||||
if(line[0] == '[' && line[len-1] == ']'){
|
if(line[0] == '[' && line[len-1] == ']'){
|
||||||
identify = contentLines[0].substr(1,len-2);
|
identify = contentLines[0].substr(1,len-2);
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigParser::Init((line %d): Not a proper config file!\n",__LINE__);
|
printf("ConfigParser::Init((line %d): Not a proper config file!\n",__LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(identify.compare("GAMEPAD") == 0){
|
if(identify.compare("GAMEPAD") == 0){
|
||||||
log_printf("ConfigParser::Init((line %d): Its a gamepad config file!\n",__LINE__);
|
printf("ConfigParser::Init((line %d): Its a gamepad config file!\n",__LINE__);
|
||||||
setSlot(gGamePadSlot);
|
setSlot(gGamePadSlot);
|
||||||
setType(PARSE_GAMEPAD);
|
setType(PARSE_GAMEPAD);
|
||||||
}else if(identify.compare("MOUSE") == 0){
|
}else if(identify.compare("MOUSE") == 0){
|
||||||
log_printf("ConfigParser::Init((line %d): Its a mouse config file!\n",__LINE__);
|
printf("ConfigParser::Init((line %d): Its a mouse config file!\n",__LINE__);
|
||||||
setSlot(gMouseSlot);
|
setSlot(gMouseSlot);
|
||||||
setType(PARSE_MOUSE);
|
setType(PARSE_MOUSE);
|
||||||
this->vid = HID_MOUSE_VID;
|
this->vid = HID_MOUSE_VID;
|
||||||
this->pid = HID_MOUSE_PID;
|
this->pid = HID_MOUSE_PID;
|
||||||
}else if(identify.compare("KEYBOARD") == 0){
|
}else if(identify.compare("KEYBOARD") == 0){
|
||||||
log_printf("ConfigParser::Init((line %d): Its a keyboard config file!\n",__LINE__);
|
printf("ConfigParser::Init((line %d): Its a keyboard config file!\n",__LINE__);
|
||||||
setSlot(gHID_SLOT_KEYBOARD);
|
setSlot(gHID_SLOT_KEYBOARD);
|
||||||
setType(PARSE_KEYBOARD);
|
setType(PARSE_KEYBOARD);
|
||||||
this->vid = HID_KEYBOARD_VID;
|
this->vid = HID_KEYBOARD_VID;
|
||||||
this->pid = HID_KEYBOARD_PID;
|
this->pid = HID_KEYBOARD_PID;
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigParser::Init((line %d): Its a controller config file!\n",__LINE__);
|
printf("ConfigParser::Init((line %d): Its a controller config file!\n",__LINE__);
|
||||||
|
|
||||||
setSlot(getSlotController(identify));
|
setSlot(getSlotController(identify));
|
||||||
setType(PARSE_CONTROLLER);
|
setType(PARSE_CONTROLLER);
|
||||||
@ -118,16 +118,16 @@ bool ConfigParser::Init(){
|
|||||||
void ConfigParser::parseSingleLine(std::string line){
|
void ConfigParser::parseSingleLine(std::string line){
|
||||||
std::vector<std::string> cur_values = CPStringTools::StringSplit(line,"=");
|
std::vector<std::string> cur_values = CPStringTools::StringSplit(line,"=");
|
||||||
if(cur_values.size() != 2){
|
if(cur_values.size() != 2){
|
||||||
if(HID_DEBUG || cur_values.size() > 2){ log_printf("ConfigParser::parseSingleLine(line %d): Not a valid key=pair line %s\n",__LINE__,line.c_str()); }
|
if(HID_DEBUG || cur_values.size() > 2){ printf("ConfigParser::parseSingleLine(line %d): Not a valid key=pair line %s\n",__LINE__,line.c_str()); }
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
u16 hid_slot = getSlot();
|
u16 hid_slot = getSlot();
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): leftpart = \"%s\" \n",__LINE__,cur_values[0].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): leftpart = \"%s\" \n",__LINE__,cur_values[0].c_str()); }
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): rightpart = \"%s\" \n",__LINE__,cur_values[1].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): rightpart = \"%s\" \n",__LINE__,cur_values[1].c_str()); }
|
||||||
s32 keyslot = -1;
|
s32 keyslot = -1;
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Checking single value\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Checking single value\n",__LINE__); }
|
||||||
if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD){
|
if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD){
|
||||||
keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]);
|
keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]);
|
||||||
}else if(getType() == PARSE_MOUSE){
|
}else if(getType() == PARSE_MOUSE){
|
||||||
@ -136,14 +136,14 @@ void ConfigParser::parseSingleLine(std::string line){
|
|||||||
keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]);
|
keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]);
|
||||||
}
|
}
|
||||||
if(keyslot != -1){
|
if(keyslot != -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Its a single value\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Its a single value\n",__LINE__); }
|
||||||
long rightValue = -1;
|
long rightValue = -1;
|
||||||
bool valueSet = false;
|
bool valueSet = false;
|
||||||
if(cur_values[0].compare("DPAD_MODE") == 0){
|
if(cur_values[0].compare("DPAD_MODE") == 0){
|
||||||
const u8 * values_ = NULL;
|
const u8 * values_ = NULL;
|
||||||
if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL){
|
if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL){
|
||||||
if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE)
|
if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE)
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Settings preset DPAD MODE and Mask\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Settings preset DPAD MODE and Mask\n",__LINE__); }
|
||||||
config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET;
|
config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET;
|
||||||
config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE];
|
config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE];
|
||||||
if(values_[CONTRDPAD_MASK] != 0x00){
|
if(values_[CONTRDPAD_MASK] != 0x00){
|
||||||
@ -157,9 +157,9 @@ void ConfigParser::parseSingleLine(std::string line){
|
|||||||
if(!valueSet){
|
if(!valueSet){
|
||||||
if(getType() == PARSE_KEYBOARD){
|
if(getType() == PARSE_KEYBOARD){
|
||||||
if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1){
|
if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Used pre-defined Keyboard! \"%s\" is %d\n",__LINE__,cur_values[1].c_str(),rightValue);}
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Used pre-defined Keyboard! \"%s\" is %d\n",__LINE__,cur_values[1].c_str(),rightValue);}
|
||||||
}else{
|
}else{
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); }
|
||||||
char * ptr;
|
char * ptr;
|
||||||
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
||||||
}
|
}
|
||||||
@ -168,34 +168,34 @@ void ConfigParser::parseSingleLine(std::string line){
|
|||||||
|
|
||||||
if(getType() == PARSE_MOUSE){ //No parsing for the mouse
|
if(getType() == PARSE_MOUSE){ //No parsing for the mouse
|
||||||
if(rightValue == -1){
|
if(rightValue == -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Invalid mouse value, lets skip it %s\n",__LINE__,cur_values[1].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Invalid mouse value, lets skip it %s\n",__LINE__,cur_values[1].c_str()); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(rightValue == -1){
|
if(rightValue == -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): I need to parse %s\n",__LINE__,cur_values[1].c_str()); }
|
||||||
char * ptr;
|
char * ptr;
|
||||||
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Setting value to %d\n",__LINE__,rightValue); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Setting value to %d\n",__LINE__,rightValue); }
|
||||||
|
|
||||||
config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET;
|
config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET;
|
||||||
config_controller[hid_slot][keyslot][1] = rightValue;
|
config_controller[hid_slot][keyslot][1] = rightValue;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Check pair value\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Check pair value\n",__LINE__); }
|
||||||
keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]);
|
keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]);
|
||||||
if(keyslot != -1){
|
if(keyslot != -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Its a pair value\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Its a pair value\n",__LINE__); }
|
||||||
|
|
||||||
if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)){
|
if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): And its no preset\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): And its no preset\n",__LINE__); }
|
||||||
std::vector<std::string> rightvalues = CPStringTools::StringSplit(cur_values[1],",");
|
std::vector<std::string> rightvalues = CPStringTools::StringSplit(cur_values[1],",");
|
||||||
|
|
||||||
if(rightvalues.size() != 2){
|
if(rightvalues.size() != 2){
|
||||||
log_printf("ConfigParser::parseSingleLine(line %d): %d instead of 2 key=values pairs in line\n",__LINE__,rightvalues.size());
|
printf("ConfigParser::parseSingleLine(line %d): %d instead of 2 key=values pairs in line\n",__LINE__,rightvalues.size());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,12 +205,12 @@ void ConfigParser::parseSingleLine(std::string line){
|
|||||||
config_controller[hid_slot][keyslot][0] = firstValue;
|
config_controller[hid_slot][keyslot][0] = firstValue;
|
||||||
config_controller[hid_slot][keyslot][1] = secondValue;
|
config_controller[hid_slot][keyslot][1] = secondValue;
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Set %02X,%02X\n",__LINE__,firstValue,secondValue); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Set %02X,%02X\n",__LINE__,firstValue,secondValue); }
|
||||||
}else{
|
}else{
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseSingleLine(line %d): Found preset value!!\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseSingleLine(line %d): Found preset value!!\n",__LINE__); }
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigParser::parseSingleLine(line %d): The setting \"%s\" is unknown!\n",__LINE__,cur_values[0].c_str());
|
printf("ConfigParser::parseSingleLine(line %d): The setting \"%s\" is unknown!\n",__LINE__,cur_values[0].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,12 +227,12 @@ bool ConfigParser::resetConfig(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 ConfigParser::getSlotController(std::string identify){
|
s32 ConfigParser::getSlotController(std::string identify){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Getting Controller Slot\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::getSlotController(line %d): Getting Controller Slot\n",__LINE__); }
|
||||||
|
|
||||||
std::vector<std::string> values = CPStringTools::StringSplit(identify,",");
|
std::vector<std::string> values = CPStringTools::StringSplit(identify,",");
|
||||||
|
|
||||||
if(values.size() != 2){
|
if(values.size() != 2){
|
||||||
log_printf("ConfigParser::getSlotController(line %d): You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)\n",__LINE__,identify.c_str());
|
printf("ConfigParser::getSlotController(line %d): You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)\n",__LINE__,identify.c_str());
|
||||||
return HID_INVALID_SLOT;
|
return HID_INVALID_SLOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ s32 ConfigParser::getSlotController(std::string identify){
|
|||||||
if(pid < 0){
|
if(pid < 0){
|
||||||
return HID_INVALID_SLOT;
|
return HID_INVALID_SLOT;
|
||||||
}
|
}
|
||||||
log_printf("ConfigParser::getSlotController(line %d): VID: %04x PID: %04x\n",__LINE__,vid,pid);
|
printf("ConfigParser::getSlotController(line %d): VID: %04x PID: %04x\n",__LINE__,vid,pid);
|
||||||
|
|
||||||
this->vid = vid;
|
this->vid = vid;
|
||||||
this->pid = pid;
|
this->pid = pid;
|
||||||
@ -256,7 +256,7 @@ s32 ConfigParser::getSlotController(std::string identify){
|
|||||||
s32 slot = deviceinfo.slotdata.deviceslot;
|
s32 slot = deviceinfo.slotdata.deviceslot;
|
||||||
s32 hid = 0;
|
s32 hid = 0;
|
||||||
if(result < 0){
|
if(result < 0){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Its a new controller, lets save it\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::getSlotController(line %d): Its a new controller, lets save it\n",__LINE__); }
|
||||||
|
|
||||||
HIDSlotData slotdata;
|
HIDSlotData slotdata;
|
||||||
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
ControllerPatcherUtils::getNextSlotData(&slotdata);
|
||||||
@ -265,69 +265,69 @@ s32 ConfigParser::getSlotController(std::string identify){
|
|||||||
hid = slotdata.hidmask;
|
hid = slotdata.hidmask;
|
||||||
|
|
||||||
if(slot >= gHIDMaxDevices){
|
if(slot >= gHIDMaxDevices){
|
||||||
log_printf("ConfigParser::getSlotController(line %d): ConfigParser::getSlotController: We don't a space for a new controller, please delete .inis\n",__LINE__);
|
printf("ConfigParser::getSlotController(line %d): ConfigParser::getSlotController: We don't a space for a new controller, please delete .inis\n",__LINE__);
|
||||||
return HID_INVALID_SLOT;
|
return HID_INVALID_SLOT;
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Got new slot! slot: %d hid %s .. Lets registrate it!\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); }
|
if(HID_DEBUG){ printf("ConfigParser::getSlotController(line %d): Got new slot! slot: %d hid %s .. Lets registrate it!\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); }
|
||||||
config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8;
|
config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8;
|
||||||
config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF);
|
config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF);
|
||||||
config_controller[slot][CONTRPS_PID][0] = (pid & 0xFF00) >> 8;
|
config_controller[slot][CONTRPS_PID][0] = (pid & 0xFF00) >> 8;
|
||||||
config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF);
|
config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF);
|
||||||
|
|
||||||
if(HID_DEBUG){
|
if(HID_DEBUG){
|
||||||
log_printf("ConfigParser::getSlotController(line %d): Saved vid: %04X pid: %04X\n",__LINE__,
|
printf("ConfigParser::getSlotController(line %d): Saved vid: %04X pid: %04X\n",__LINE__,
|
||||||
config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1],
|
config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1],
|
||||||
config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]); }
|
config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1]); }
|
||||||
|
|
||||||
config_controller_hidmask[slot] = hid;
|
config_controller_hidmask[slot] = hid;
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): Saved the hid\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::getSlotController(line %d): Saved the hid\n",__LINE__); }
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if(slot < gHIDMaxDevices){
|
if(slot < gHIDMaxDevices){
|
||||||
hid = config_controller_hidmask[slot];
|
hid = config_controller_hidmask[slot];
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::getSlotController(line %d): >>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); }
|
if(HID_DEBUG){ printf("ConfigParser::getSlotController(line %d): >>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",__LINE__,slot,CPStringTools::byte_to_binary(hid)); }
|
||||||
log_printf("ConfigParser::getSlotController(line %d): We already have data of this controller, lets modify it\n",__LINE__);
|
printf("ConfigParser::getSlotController(line %d): We already have data of this controller, lets modify it\n",__LINE__);
|
||||||
}else{
|
}else{
|
||||||
log_printf("ConfigParser::getSlotController(line %d): Something really odd happend to the slots. %d is bigger then max (%d)\n",__LINE__,slot,gHIDMaxDevices);
|
printf("ConfigParser::getSlotController(line %d): Something really odd happend to the slots. %d is bigger then max (%d)\n",__LINE__,slot,gHIDMaxDevices);
|
||||||
return HID_INVALID_SLOT;
|
return HID_INVALID_SLOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_printf("ConfigParser::getSlotController(line %d): using slot: %d hid %08X\n",__LINE__,slot,hid);
|
printf("ConfigParser::getSlotController(line %d): using slot: %d hid %08X\n",__LINE__,slot,hid);
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigParser::parseIni(){
|
bool ConfigParser::parseIni(){
|
||||||
if(getSlot() == HID_INVALID_SLOT){
|
if(getSlot() == HID_INVALID_SLOT){
|
||||||
log_printf("ConfigParser::parseIni(line %d): Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices\n",__LINE__,getType(),gHIDMaxDevices);
|
printf("ConfigParser::parseIni(line %d): Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices\n",__LINE__,getType(),gHIDMaxDevices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): Parsing content, type %d\n",__LINE__,getType()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseIni(line %d): Parsing content, type %d\n",__LINE__,getType()); }
|
||||||
|
|
||||||
s32 start = 1;
|
s32 start = 1;
|
||||||
if(contentLines[1].compare("[IGNOREDEFAULT]") == 0){
|
if(contentLines[1].compare("[IGNOREDEFAULT]") == 0){
|
||||||
resetConfig();
|
resetConfig();
|
||||||
log_printf("ConfigParser::parseIni(line %d): Ignoring existing settings of this device\n",__LINE__);
|
printf("ConfigParser::parseIni(line %d): Ignoring existing settings of this device\n",__LINE__);
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(u32 i = start; i < contentLines.size(); i++){
|
for(u32 i = start; i < contentLines.size(); i++){
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): line %d: \"%s\" \n",__LINE__,(i+1),contentLines[i].c_str()); }
|
if(HID_DEBUG){ printf("ConfigParser::parseIni(line %d): line %d: \"%s\" \n",__LINE__,(i+1),contentLines[i].c_str()); }
|
||||||
parseSingleLine(contentLines[i]);
|
parseSingleLine(contentLines[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ConfigParser::parseIni(line %d): Parsing of the file is done.\n",__LINE__); }
|
if(HID_DEBUG){ printf("ConfigParser::parseIni(line %d): Parsing of the file is done.\n",__LINE__); }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter){
|
s32 ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter){
|
||||||
std::vector<std::string> string_value = CPStringTools::StringSplit(value_pair,delimiter);
|
std::vector<std::string> string_value = CPStringTools::StringSplit(value_pair,delimiter);
|
||||||
if(string_value.size() != 2){
|
if(string_value.size() != 2){
|
||||||
if(HID_DEBUG || string_value.size() > 2){ log_printf("ConfigParser::getValueFromKeyValue(line %d): Not a valid key=pair line %s\n",__LINE__,value_pair.c_str()); }
|
if(HID_DEBUG || string_value.size() > 2){ printf("ConfigParser::getValueFromKeyValue(line %d): Not a valid key=pair line %s\n",__LINE__,value_pair.c_str()); }
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(string_value[0].compare(expectedKey) != 0){
|
if(string_value[0].compare(expectedKey) != 0){
|
||||||
log_printf("ConfigParser::getValueFromKeyValue(line %d): Key part not %s, its %s",__LINE__,expectedKey.c_str(),string_value[0].c_str());
|
printf("ConfigParser::getValueFromKeyValue(line %d): Key part not %s, its %s",__LINE__,expectedKey.c_str(),string_value[0].c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char * ptr;
|
char * ptr;
|
||||||
|
@ -22,12 +22,9 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gctypes.h>
|
|
||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
enum PARSE_TYPE{
|
enum PARSE_TYPE{
|
||||||
PARSE_CONTROLLER,
|
PARSE_CONTROLLER,
|
||||||
PARSE_GAMEPAD,
|
PARSE_GAMEPAD,
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
ConfigValues *ConfigValues::instance = NULL;
|
ConfigValues *ConfigValues::instance = NULL;
|
||||||
|
|
||||||
ConfigValues::ConfigValues(){
|
ConfigValues::ConfigValues(){
|
||||||
@ -28,7 +26,7 @@ ConfigValues::ConfigValues(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigValues::~ConfigValues(){
|
ConfigValues::~ConfigValues(){
|
||||||
if(HID_DEBUG){ log_printf("ConfigValues::~ConfigValues(line %d){\n",__LINE__);}
|
if(HID_DEBUG){ printf("ConfigValues::~ConfigValues(line %d){\n",__LINE__);}
|
||||||
}
|
}
|
||||||
|
|
||||||
const u8 * ConfigValues::getValuesForPreset(std::map<std::string,const u8*> values,std::string possibleValue){
|
const u8 * ConfigValues::getValuesForPreset(std::map<std::string,const u8*> values,std::string possibleValue){
|
||||||
@ -59,9 +57,9 @@ bool ConfigValues::setIfValueIsPreset(std::map<std::string,const u8*> values,std
|
|||||||
keyslot == CONTRPS_VPAD_BUTTON_L_STICK_Y ||
|
keyslot == CONTRPS_VPAD_BUTTON_L_STICK_Y ||
|
||||||
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X ||
|
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X ||
|
||||||
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y){
|
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y){
|
||||||
if(HID_DEBUG){ log_printf("ConfigValues::setIfValueIsPreset(line %d): This may be a predefined stick %s\n",__LINE__,possibleValue.c_str());}
|
if(HID_DEBUG){ printf("ConfigValues::setIfValueIsPreset(line %d): This may be a predefined stick %s\n",__LINE__,possibleValue.c_str());}
|
||||||
if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL){
|
if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL){
|
||||||
if(HID_DEBUG){ log_printf("ConfigValues::setIfValueIsPreset(line %d): Found predefined stick!\n",__LINE__);}
|
if(HID_DEBUG){ printf("ConfigValues::setIfValueIsPreset(line %d): Found predefined stick!\n",__LINE__);}
|
||||||
config_controller[slot][keyslot][0] = values_[STICK_CONF_BYTE]; //CONTRPS_VPAD_BUTTON_L_STICK_X
|
config_controller[slot][keyslot][0] = values_[STICK_CONF_BYTE]; //CONTRPS_VPAD_BUTTON_L_STICK_X
|
||||||
config_controller[slot][keyslot][1] = values_[STICK_CONF_DEFAULT];
|
config_controller[slot][keyslot][1] = values_[STICK_CONF_DEFAULT];
|
||||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_INVERT][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT
|
config_controller[slot][keyslot+DEF_STICK_OFFSET_INVERT][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT
|
||||||
@ -98,9 +96,9 @@ s32 ConfigValues::getValueFromMap(std::map<std::string,int> values,std::string n
|
|||||||
s32 ConfigValues::getPresetValueEx(std::string possibleString){
|
s32 ConfigValues::getPresetValueEx(std::string possibleString){
|
||||||
s32 rightValue = -1;
|
s32 rightValue = -1;
|
||||||
if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1){
|
if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined VPAD_VALUE! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); }
|
if(HID_DEBUG){ printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined VPAD_VALUE! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); }
|
||||||
}else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1){
|
}else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1){
|
||||||
if(HID_DEBUG){ log_printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined value! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); }
|
if(HID_DEBUG){ printf("ConfigValues::getPresetValueEx(line %d): Used pre-defined value! \"%s\" is %d\n",__LINE__,possibleString.c_str(),rightValue); }
|
||||||
}
|
}
|
||||||
return rightValue;
|
return rightValue;
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <gctypes.h>
|
|
||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
class ConfigValues
|
class ConfigValues
|
||||||
{
|
{
|
||||||
friend class ConfigParser;
|
friend class ConfigParser;
|
||||||
@ -33,7 +30,7 @@ friend class ControllerPatcher;
|
|||||||
private:
|
private:
|
||||||
static ConfigValues *getInstance() {
|
static ConfigValues *getInstance() {
|
||||||
if(instance == NULL){
|
if(instance == NULL){
|
||||||
log_printf("ConfigValues: We need a new instance!!!\n");
|
printf("ConfigValues: We need a new instance!!!\n");
|
||||||
instance = new ConfigValues();
|
instance = new ConfigValues();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
@ -171,7 +168,7 @@ private:
|
|||||||
s32 getPresetValueEx(std::string possibleString);
|
s32 getPresetValueEx(std::string possibleString);
|
||||||
|
|
||||||
void InitValues(){
|
void InitValues(){
|
||||||
log_printf("ConfigValues::InitValues: Init values for the configuration\n");
|
printf("ConfigValues::InitValues: Init values for the configuration\n");
|
||||||
CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A;
|
CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A;
|
||||||
CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B;
|
CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B;
|
||||||
CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X;
|
CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ControllerPatcherNet.hpp"
|
#include "ControllerPatcherNet.hpp"
|
||||||
#include "dynamic_libs/os_functions.h"
|
#include "wiiu/os.h"
|
||||||
#include "dynamic_libs/socket_functions.h"
|
#include "sys/socket.h"
|
||||||
|
|
||||||
s32 ControllerPatcherNet::recvwait(s32 sock, void *buffer, s32 len) {
|
s32 ControllerPatcherNet::recvwait(s32 sock, void *buffer, s32 len) {
|
||||||
s32 ret;
|
s32 ret;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _CONTROLLERPATCHERNET_H_
|
#ifndef _CONTROLLERPATCHERNET_H_
|
||||||
#define _CONTROLLERPATCHERNET_H_
|
#define _CONTROLLERPATCHERNET_H_
|
||||||
|
|
||||||
#include<gctypes.h>
|
#include "wiiu/types.h"
|
||||||
|
|
||||||
class ControllerPatcherNet{
|
class ControllerPatcherNet{
|
||||||
friend class TCPServer;
|
friend class TCPServer;
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
#define wiiu_errno (*__gh_errno_ptr())
|
#define wiiu_errno (*__gh_errno_ptr())
|
||||||
|
|
||||||
ControllerPatcherThread * TCPServer::pThread = NULL;
|
ControllerPatcherThread * TCPServer::pThread = NULL;
|
||||||
@ -36,14 +34,14 @@ TCPServer::TCPServer(s32 port){
|
|||||||
|
|
||||||
TCPServer::~TCPServer(){
|
TCPServer::~TCPServer(){
|
||||||
CloseSockets();
|
CloseSockets();
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Thread will be closed\n",__LINE__); }
|
if(HID_DEBUG){ printf("TCPServer::~TCPServer(line %d): Thread will be closed\n",__LINE__); }
|
||||||
TCPServer::AttachDetach(DETACH);
|
TCPServer::AttachDetach(DETACH);
|
||||||
exitThread = 1;
|
exitThread = 1;
|
||||||
if(TCPServer::pThread != NULL){
|
if(TCPServer::pThread != NULL){
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Deleting it!\n",__LINE__); }
|
if(HID_DEBUG){ printf("TCPServer::~TCPServer(line %d): Deleting it!\n",__LINE__); }
|
||||||
delete TCPServer::pThread;
|
delete TCPServer::pThread;
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::~TCPServer(line %d): Thread done\n",__LINE__); }
|
if(HID_DEBUG){ printf("TCPServer::~TCPServer(line %d): Thread done\n",__LINE__); }
|
||||||
TCPServer::pThread = NULL;
|
TCPServer::pThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +64,7 @@ void TCPServer::StartTCPThread(TCPServer * server){
|
|||||||
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
|
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
|
||||||
OSGetTitleID() == 0x00050000101a3c00){ //The Binding of Isaac: Rebirth USA
|
OSGetTitleID() == 0x00050000101a3c00){ //The Binding of Isaac: Rebirth USA
|
||||||
priority = 10;
|
priority = 10;
|
||||||
log_printf("TCPServer::StartTCPThread(line %d): This game needs higher thread priority. We set it to %d\n",__LINE__,priority);
|
printf("TCPServer::StartTCPThread(line %d): This game needs higher thread priority. We set it to %d\n",__LINE__,priority);
|
||||||
}
|
}
|
||||||
TCPServer::pThread = ControllerPatcherThread::create(TCPServer::DoTCPThread, (void*)server, ControllerPatcherThread::eAttributeAffCore2,priority);
|
TCPServer::pThread = ControllerPatcherThread::create(TCPServer::DoTCPThread, (void*)server, ControllerPatcherThread::eAttributeAffCore2,priority);
|
||||||
TCPServer::pThread->resumeThread();
|
TCPServer::pThread->resumeThread();
|
||||||
@ -75,16 +73,16 @@ void TCPServer::StartTCPThread(TCPServer * server){
|
|||||||
void TCPServer::AttachDetach(s32 attach){
|
void TCPServer::AttachDetach(s32 attach){
|
||||||
if(HID_DEBUG){
|
if(HID_DEBUG){
|
||||||
if(attach){
|
if(attach){
|
||||||
log_printf("TCPServer::AttachDetach(line %d): Network Attach\n",__LINE__);
|
printf("TCPServer::AttachDetach(line %d): Network Attach\n",__LINE__);
|
||||||
}else{
|
}else{
|
||||||
log_printf("TCPServer::AttachDetach(line %d): Network Detach\n",__LINE__);
|
printf("TCPServer::AttachDetach(line %d): Network Detach\n",__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(s32 i= 0;i< gHIDMaxDevices;i++){
|
for(s32 i= 0;i< gHIDMaxDevices;i++){
|
||||||
for(s32 j= 0;j< HID_MAX_PADS_COUNT;j++){
|
for(s32 j= 0;j< HID_MAX_PADS_COUNT;j++){
|
||||||
if(gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0){
|
if(gNetworkController[i][j][NETWORK_CONTROLLER_ACTIVE] > 0){
|
||||||
log_printf("TCPServer::AttachDetach(line %d): Found a registered pad in deviceslot %d and padslot %d! Lets detach it.\n",__LINE__,i,j);
|
printf("TCPServer::AttachDetach(line %d): Found a registered pad in deviceslot %d and padslot %d! Lets detach it.\n",__LINE__,i,j);
|
||||||
HIDDevice device;
|
HIDDevice device;
|
||||||
memset(&device,0,sizeof(device));
|
memset(&device,0,sizeof(device));
|
||||||
|
|
||||||
@ -101,9 +99,9 @@ void TCPServer::AttachDetach(s32 attach){
|
|||||||
|
|
||||||
if(HID_DEBUG){
|
if(HID_DEBUG){
|
||||||
if(attach){
|
if(attach){
|
||||||
log_printf("TCPServer::AttachDetach(line %d): Network Attach DONE!\n",__LINE__);
|
printf("TCPServer::AttachDetach(line %d): Network Attach DONE!\n",__LINE__);
|
||||||
}else{
|
}else{
|
||||||
log_printf("TCPServer::AttachDetach(line %d): Network Detach DONE!\n",__LINE__);
|
printf("TCPServer::AttachDetach(line %d): Network Detach DONE!\n",__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,35 +118,35 @@ s32 TCPServer::RunTCP(){
|
|||||||
ret = ControllerPatcherNet::checkbyte(clientfd);
|
ret = ControllerPatcherNet::checkbyte(clientfd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if(wiiu_errno != 6) return ret;
|
if(wiiu_errno != 6) return ret;
|
||||||
os_usleep(1000);
|
wiiu_os_usleep(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//log_printf("got byte from tcp! %01X\n",ret);
|
//printf("got byte from tcp! %01X\n",ret);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case WIIU_CP_TCP_ATTACH: { /*attach */
|
case WIIU_CP_TCP_ATTACH: { /*attach */
|
||||||
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1){
|
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1){
|
||||||
s32 handle;
|
s32 handle;
|
||||||
ret = ControllerPatcherNet::recvwait(clientfd, &handle, 4);
|
ret = ControllerPatcherNet::recvwait(clientfd, &handle, 4);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait handle\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait handle\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got handle %d\n",handle); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): got handle %d\n",handle); }
|
||||||
u16 vid = 0;
|
u16 vid = 0;
|
||||||
u16 pid = 0;
|
u16 pid = 0;
|
||||||
ret = ControllerPatcherNet::recvwait(clientfd, &vid, 2);
|
ret = ControllerPatcherNet::recvwait(clientfd, &vid, 2);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait vid\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait vid\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got vid %04X\n",vid); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): got vid %04X\n",vid); }
|
||||||
|
|
||||||
ret = ControllerPatcherNet::recvwait(clientfd, &pid, 2);
|
ret = ControllerPatcherNet::recvwait(clientfd, &pid, 2);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait pid\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait pid\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got pid %04X\n",pid); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): got pid %04X\n",pid); }
|
||||||
HIDDevice device;
|
HIDDevice device;
|
||||||
memset(&device,0,sizeof(device));
|
memset(&device,0,sizeof(device));
|
||||||
device.handle = handle;
|
device.handle = handle;
|
||||||
@ -160,51 +158,51 @@ s32 TCPServer::RunTCP(){
|
|||||||
my_cb_user * user = NULL;
|
my_cb_user * user = NULL;
|
||||||
ControllerPatcherHID::externAttachDetachCallback(&device,1);
|
ControllerPatcherHID::externAttachDetachCallback(&device,1);
|
||||||
if((ret = ControllerPatcherUtils::getDataByHandle(handle,&user)) < 0){
|
if((ret = ControllerPatcherUtils::getDataByHandle(handle,&user)) < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: getDataByHandle(%d,%08X).\n",__LINE__,WIIU_CP_TCP_ATTACH,handle,&user);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: getDataByHandle(%d,%08X).\n",__LINE__,WIIU_CP_TCP_ATTACH,handle,&user);
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Config for the controller is missing.\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Config for the controller is missing.\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
||||||
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND) < 0)){
|
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND) < 0)){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_FOUND) < 0)){
|
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_CONFIG_FOUND) < 0)){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_FOUND byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_CONFIG_FOUND byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(user != NULL){
|
if(user != NULL){
|
||||||
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_OKAY) < 0)){
|
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_OKAY) < 0)){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_OKAY byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_OKAY byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ControllerPatcherNet::sendwait(clientfd,&user->slotdata.deviceslot,2);
|
ret = ControllerPatcherNet::sendwait(clientfd,&user->slotdata.deviceslot,2);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: sendwait slotdata: %04X\n",__LINE__,WIIU_CP_TCP_ATTACH,user->slotdata.deviceslot);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: sendwait slotdata: %04X\n",__LINE__,WIIU_CP_TCP_ATTACH,user->slotdata.deviceslot);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ControllerPatcherNet::sendwait(clientfd,&user->pad_slot,1);
|
ret = ControllerPatcherNet::sendwait(clientfd,&user->pad_slot,1);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: sendwait pad_slot: %04X\n",__LINE__,WIIU_CP_TCP_ATTACH,user->pad_slot);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: sendwait pad_slot: %04X\n",__LINE__,WIIU_CP_TCP_ATTACH,user->pad_slot);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: invalid user data.\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: invalid user data.\n",__LINE__,WIIU_CP_TCP_ATTACH);
|
||||||
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_BAD) < 0)){
|
if((ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_ATTACH_USER_DATA_BAD) < 0)){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_BAD byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Sending the WIIU_CP_TCP_ATTACH_USER_DATA_BAD byte failed. Error: %d.\n",__LINE__,WIIU_CP_TCP_ATTACH,ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): attachted to device slot: %d , pad slot is: %d\n",__LINE__,user->slotdata.deviceslot,user->pad_slot); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): attachted to device slot: %d , pad slot is: %d\n",__LINE__,user->slotdata.deviceslot,user->pad_slot); }
|
||||||
|
|
||||||
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_VID] = device.vid;
|
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_VID] = device.vid;
|
||||||
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_PID] = device.pid;
|
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_PID] = device.pid;
|
||||||
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_ACTIVE] = 1;
|
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_ACTIVE] = 1;
|
||||||
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_HANDLE] = handle;
|
gNetworkController[user->slotdata.deviceslot][user->pad_slot][NETWORK_CONTROLLER_HANDLE] = handle;
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d\n",__LINE__,handle,vid,pid,user->slotdata.deviceslot,user->pad_slot); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): handle %d connected! vid: %02X pid: %02X deviceslot %d, padslot %d\n",__LINE__,handle,vid,pid,user->slotdata.deviceslot,user->pad_slot); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -214,30 +212,30 @@ s32 TCPServer::RunTCP(){
|
|||||||
s32 handle;
|
s32 handle;
|
||||||
ret = ControllerPatcherNet::recvwait(clientfd, &handle, 4);
|
ret = ControllerPatcherNet::recvwait(clientfd, &handle, 4);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait handle\n",__LINE__,WIIU_CP_TCP_DETACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: recvwait handle\n",__LINE__,WIIU_CP_TCP_DETACH);
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): got detach for handle: %d\n",__LINE__,handle); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): got detach for handle: %d\n",__LINE__,handle); }
|
||||||
my_cb_user * user = NULL;
|
my_cb_user * user = NULL;
|
||||||
if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0){
|
if(ControllerPatcherUtils::getDataByHandle(handle,&user) < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: getDataByHandle(%d,%08X).\n",__LINE__,WIIU_CP_TCP_DETACH,handle,&user);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: getDataByHandle(%d,%08X).\n",__LINE__,WIIU_CP_TCP_DETACH,handle,&user);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(user == NULL){
|
if(user == NULL){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: invalid user data.\n",__LINE__,WIIU_CP_TCP_DETACH);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: invalid user data.\n",__LINE__,WIIU_CP_TCP_DETACH);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s32 deviceslot = user->slotdata.deviceslot;
|
s32 deviceslot = user->slotdata.deviceslot;
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): device slot is: %d , pad slot is: %d\n",__LINE__,deviceslot,user->pad_slot); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): device slot is: %d , pad slot is: %d\n",__LINE__,deviceslot,user->pad_slot); }
|
||||||
|
|
||||||
DeviceVIDPIDInfo vidpid;
|
DeviceVIDPIDInfo vidpid;
|
||||||
s32 result;
|
s32 result;
|
||||||
if((result = ControllerPatcherUtils::getVIDPIDbyDeviceSlot(deviceslot,&vidpid)) < 0){
|
if((result = ControllerPatcherUtils::getVIDPIDbyDeviceSlot(deviceslot,&vidpid)) < 0){
|
||||||
log_printf("TCPServer::RunTCP(line %d): Error in %02X: Couldn't find a valid VID/PID for device slot %d. Error: %d\n",__LINE__,WIIU_CP_TCP_DETACH,deviceslot,ret);
|
printf("TCPServer::RunTCP(line %d): Error in %02X: Couldn't find a valid VID/PID for device slot %d. Error: %d\n",__LINE__,WIIU_CP_TCP_DETACH,deviceslot,ret);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -252,16 +250,16 @@ s32 TCPServer::RunTCP(){
|
|||||||
|
|
||||||
ControllerPatcherHID::externAttachDetachCallback(&device,DETACH);
|
ControllerPatcherHID::externAttachDetachCallback(&device,DETACH);
|
||||||
memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot]));
|
memset(gNetworkController[deviceslot][user->pad_slot],0,sizeof(gNetworkController[deviceslot][user->pad_slot]));
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): handle %d disconnected!\n",__LINE__,handle); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): handle %d disconnected!\n",__LINE__,handle); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIIU_CP_TCP_PING: { /*ping*/
|
case WIIU_CP_TCP_PING: { /*ping*/
|
||||||
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1){
|
if(gUsedProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_1){
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::RunTCP(line %d): Got Ping, sending now a Pong\n",__LINE__); }
|
if(HID_DEBUG){ printf("TCPServer::RunTCP(line %d): Got Ping, sending now a Pong\n",__LINE__); }
|
||||||
s32 ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_PONG);
|
s32 ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_PONG);
|
||||||
if(ret < 0){ log_printf("TCPServer::RunTCP(line %d): Error in %02X: sendbyte PONG\n",__LINE__); return -1;}
|
if(ret < 0){ printf("TCPServer::RunTCP(line %d): Error in %02X: sendbyte PONG\n",__LINE__); return -1;}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -277,7 +275,7 @@ s32 TCPServer::RunTCP(){
|
|||||||
|
|
||||||
void TCPServer::ErrorHandling(){
|
void TCPServer::ErrorHandling(){
|
||||||
CloseSockets();
|
CloseSockets();
|
||||||
os_usleep(1000*1000*2);
|
wiiu_os_usleep(1000*1000*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPServer::DoTCPThreadInternal(){
|
void TCPServer::DoTCPThreadInternal(){
|
||||||
@ -302,7 +300,7 @@ void TCPServer::DoTCPThreadInternal(){
|
|||||||
if(ret < 0){ ErrorHandling(); continue;}
|
if(ret < 0){ ErrorHandling(); continue;}
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if(HID_DEBUG){ log_printf("TCPServer::DoTCPThreadInternal(line %d): Waiting for a connection\n",__LINE__); }
|
if(HID_DEBUG){ printf("TCPServer::DoTCPThreadInternal(line %d): Waiting for a connection\n",__LINE__); }
|
||||||
if(exitThread) break;
|
if(exitThread) break;
|
||||||
len = 16;
|
len = 16;
|
||||||
|
|
||||||
@ -314,40 +312,40 @@ void TCPServer::DoTCPThreadInternal(){
|
|||||||
3b. If the client sent his highest supported version, the server confirm that he is able to use this version (by sending the version back) or sending a abort command to disconnect.
|
3b. If the client sent his highest supported version, the server confirm that he is able to use this version (by sending the version back) or sending a abort command to disconnect.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
clientfd = ret = accept(sockfd, (sockaddr *)&(sock_addr), &len);
|
clientfd = ret = (s32)accept(sockfd, (sockaddr *)&(sock_addr),(socklen_t *) &len);
|
||||||
|
|
||||||
if(ret == -1){ ErrorHandling(); break;}
|
if(ret == -1){ ErrorHandling(); break;}
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): TCP Connection accepted! Sending my protocol version: %d (0x%02X)\n",__LINE__, (WIIU_CP_TCP_HANDSHAKE - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,WIIU_CP_TCP_HANDSHAKE);
|
printf("TCPServer::DoTCPThreadInternal(line %d): TCP Connection accepted! Sending my protocol version: %d (0x%02X)\n",__LINE__, (WIIU_CP_TCP_HANDSHAKE - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,WIIU_CP_TCP_HANDSHAKE);
|
||||||
|
|
||||||
gUDPClientip = sock_addr.sin_addr.s_addr;
|
gUDPClientip = sock_addr.sin_addr.s_addr;
|
||||||
UDPClient::createInstance();
|
UDPClient::createInstance();
|
||||||
|
|
||||||
s32 ret;
|
s32 ret;
|
||||||
ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE); //Hey I'm a WiiU console!
|
ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE); //Hey I'm a WiiU console!
|
||||||
if(ret < 0){ log_printf("TCPServer::DoTCPThreadInternal(line %d): Error sendbyte: %02X\n",__LINE__,WIIU_CP_TCP_HANDSHAKE); ErrorHandling(); break;}
|
if(ret < 0){ printf("TCPServer::DoTCPThreadInternal(line %d): Error sendbyte: %02X\n",__LINE__,WIIU_CP_TCP_HANDSHAKE); ErrorHandling(); break;}
|
||||||
|
|
||||||
u8 clientProtocolVersion = ControllerPatcherNet::recvbyte(clientfd);
|
u8 clientProtocolVersion = ControllerPatcherNet::recvbyte(clientfd);
|
||||||
if(ret < 0){ log_printf("TCPServer::DoTCPThreadInternal(line %d): Error recvbyte: %02X\n",__LINE__,WIIU_CP_TCP_HANDSHAKE); ErrorHandling(); break;}
|
if(ret < 0){ printf("TCPServer::DoTCPThreadInternal(line %d): Error recvbyte: %02X\n",__LINE__,WIIU_CP_TCP_HANDSHAKE); ErrorHandling(); break;}
|
||||||
|
|
||||||
if(clientProtocolVersion == WIIU_CP_TCP_HANDSHAKE_ABORT){
|
if(clientProtocolVersion == WIIU_CP_TCP_HANDSHAKE_ABORT){
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): The network client wants to abort.\n",__LINE__);
|
printf("TCPServer::DoTCPThreadInternal(line %d): The network client wants to abort.\n",__LINE__);
|
||||||
ErrorHandling(); break;
|
ErrorHandling(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): received protocol version: %d (0x%02X)\n",__LINE__,(clientProtocolVersion - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,clientProtocolVersion);
|
printf("TCPServer::DoTCPThreadInternal(line %d): received protocol version: %d (0x%02X)\n",__LINE__,(clientProtocolVersion - WIIU_CP_TCP_HANDSHAKE_VERSION_1)+1,clientProtocolVersion);
|
||||||
|
|
||||||
if(clientProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_MIN && clientProtocolVersion <= WIIU_CP_TCP_HANDSHAKE_VERSION_MAX){
|
if(clientProtocolVersion >= WIIU_CP_TCP_HANDSHAKE_VERSION_MIN && clientProtocolVersion <= WIIU_CP_TCP_HANDSHAKE_VERSION_MAX){
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): We support this protocol version. Let's confirm it to the network client.\n",__LINE__);
|
printf("TCPServer::DoTCPThreadInternal(line %d): We support this protocol version. Let's confirm it to the network client.\n",__LINE__);
|
||||||
gUsedProtocolVersion = clientProtocolVersion;
|
gUsedProtocolVersion = clientProtocolVersion;
|
||||||
ret = ControllerPatcherNet::sendbyte(clientfd, clientProtocolVersion);
|
ret = ControllerPatcherNet::sendbyte(clientfd, clientProtocolVersion);
|
||||||
if(ret < 0){ log_printf("TCPServer::DoTCPThreadInternal(line %d): Error sendbyte: %02X\n",__LINE__,clientProtocolVersion); ErrorHandling(); break;}
|
if(ret < 0){ printf("TCPServer::DoTCPThreadInternal(line %d): Error sendbyte: %02X\n",__LINE__,clientProtocolVersion); ErrorHandling(); break;}
|
||||||
}else{
|
}else{
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): We don't support this protocol version. We need to abort =(.\n",__LINE__);
|
printf("TCPServer::DoTCPThreadInternal(line %d): We don't support this protocol version. We need to abort =(.\n",__LINE__);
|
||||||
ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE_ABORT);
|
ret = ControllerPatcherNet::sendbyte(clientfd, WIIU_CP_TCP_HANDSHAKE_ABORT);
|
||||||
ErrorHandling(); break;
|
ErrorHandling(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): Handshake done! Success!\n",__LINE__);
|
printf("TCPServer::DoTCPThreadInternal(line %d): Handshake done! Success!\n",__LINE__);
|
||||||
|
|
||||||
TCPServer::DetachAndDelete(); //Clear connected controller
|
TCPServer::DetachAndDelete(); //Clear connected controller
|
||||||
RunTCP();
|
RunTCP();
|
||||||
@ -357,7 +355,7 @@ void TCPServer::DoTCPThreadInternal(){
|
|||||||
}
|
}
|
||||||
clientfd = -1;
|
clientfd = -1;
|
||||||
}while(0);
|
}while(0);
|
||||||
log_printf("TCPServer::DoTCPThreadInternal(line %d): Connection closed\n",__LINE__);
|
printf("TCPServer::DoTCPThreadInternal(line %d): Connection closed\n",__LINE__);
|
||||||
gUDPClientip = 0;
|
gUDPClientip = 0;
|
||||||
UDPClient::destroyInstance();
|
UDPClient::destroyInstance();
|
||||||
TCPServer::DetachAndDelete(); //Clear connected controller
|
TCPServer::DetachAndDelete(); //Clear connected controller
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
#include "dynamic_libs/socket_functions.h"
|
#include "sys/socket.h"
|
||||||
#include "dynamic_libs/os_functions.h"
|
#include "wiiu/os.h"
|
||||||
|
|
||||||
#define WIIU_CP_TCP_HANDSHAKE WIIU_CP_TCP_HANDSHAKE_VERSION_3
|
#define WIIU_CP_TCP_HANDSHAKE WIIU_CP_TCP_HANDSHAKE_VERSION_3
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
#define MAX_UDP_SIZE 0x578
|
#define MAX_UDP_SIZE 0x578
|
||||||
|
|
||||||
UDPClient * UDPClient::instance = NULL;
|
UDPClient * UDPClient::instance = NULL;
|
||||||
@ -46,7 +44,7 @@ UDPClient::~UDPClient(){
|
|||||||
if (this->sockfd != -1){
|
if (this->sockfd != -1){
|
||||||
socketclose(sockfd);
|
socketclose(sockfd);
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("UDPClient::~UDPClient(line %d): Thread has been closed\n",__LINE__); }
|
if(HID_DEBUG){ printf("UDPClient::~UDPClient(line %d): Thread has been closed\n",__LINE__); }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDPClient::sendData(char * data,s32 length){
|
bool UDPClient::sendData(char * data,s32 length){
|
||||||
|
@ -17,11 +17,9 @@
|
|||||||
#ifndef _UDPCLIENT_WINDOW_H_
|
#ifndef _UDPCLIENT_WINDOW_H_
|
||||||
#define _UDPCLIENT_WINDOW_H_
|
#define _UDPCLIENT_WINDOW_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
|
||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
#include "dynamic_libs/socket_functions.h"
|
#include "sys/socket.h"
|
||||||
|
|
||||||
#define DEFAULT_UDP_CLIENT_PORT 8114
|
#define DEFAULT_UDP_CLIENT_PORT 8114
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "dynamic_libs/socket_functions.h"
|
#include "sys/socket.h"
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
#define MAX_UDP_SIZE 0x578
|
#define MAX_UDP_SIZE 0x578
|
||||||
#define wiiu_errno (*__gh_errno_ptr())
|
#define wiiu_errno (*__gh_errno_ptr())
|
||||||
@ -59,7 +58,7 @@ UDPServer::~UDPServer(){
|
|||||||
this->sockfd = -1;
|
this->sockfd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("UDPServer::~UDPServer(line %d): Thread has been closed\n",__LINE__); }
|
if(HID_DEBUG){ printf("UDPServer::~UDPServer(line %d): Thread has been closed\n",__LINE__); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -72,7 +71,7 @@ void UDPServer::StartUDPThread(UDPServer * server){
|
|||||||
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
|
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
|
||||||
OSGetTitleID() == 0x00050000101a3c00){ //The Binding of Isaac: Rebirth USA
|
OSGetTitleID() == 0x00050000101a3c00){ //The Binding of Isaac: Rebirth USA
|
||||||
priority = 10;
|
priority = 10;
|
||||||
log_printf("UDPServer::StartUDPThread(line %d): This game needs higher thread priority. We set it to %d\n",__LINE__,priority);
|
printf("UDPServer::StartUDPThread(line %d): This game needs higher thread priority. We set it to %d\n",__LINE__,priority);
|
||||||
}
|
}
|
||||||
UDPServer::pThread = ControllerPatcherThread::create(UDPServer::DoUDPThread, (void*)server, ControllerPatcherThread::eAttributeAffCore2,priority);
|
UDPServer::pThread = ControllerPatcherThread::create(UDPServer::DoUDPThread, (void*)server, ControllerPatcherThread::eAttributeAffCore2,priority);
|
||||||
UDPServer::pThread->resumeThread();
|
UDPServer::pThread->resumeThread();
|
||||||
@ -80,7 +79,7 @@ void UDPServer::StartUDPThread(UDPServer * server){
|
|||||||
|
|
||||||
bool UDPServer::cpyIncrementBufferOffset(void * target, void * source, s32 * offset, s32 typesize, s32 maximum){
|
bool UDPServer::cpyIncrementBufferOffset(void * target, void * source, s32 * offset, s32 typesize, s32 maximum){
|
||||||
if(((int)*offset + typesize) > maximum){
|
if(((int)*offset + typesize) > maximum){
|
||||||
log_printf("UDPServer::cpyIncrementBufferOffset(line %d): Transfer error. Excepted %04X bytes, but only got %04X\n",__LINE__,(*offset + typesize),maximum);
|
printf("UDPServer::cpyIncrementBufferOffset(line %d): Transfer error. Excepted %04X bytes, but only got %04X\n",__LINE__,(*offset + typesize),maximum);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memcpy(target,(void*)((u32)source+(*offset)),typesize);
|
memcpy(target,(void*)((u32)source+(*offset)),typesize);
|
||||||
@ -105,7 +104,7 @@ void UDPServer::DoUDPThreadInternal(){
|
|||||||
n = recv(sockfd,buffer,MAX_UDP_SIZE,0);
|
n = recv(sockfd,buffer,MAX_UDP_SIZE,0);
|
||||||
if (n < 0){
|
if (n < 0){
|
||||||
s32 errno_ = wiiu_errno;
|
s32 errno_ = wiiu_errno;
|
||||||
os_usleep(2000);
|
wiiu_os_usleep(2000);
|
||||||
if(errno_ != 11 && errno_ != 9){
|
if(errno_ != 11 && errno_ != 9){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -135,19 +134,19 @@ void UDPServer::DoUDPThreadInternal(){
|
|||||||
if(!cpyIncrementBufferOffset((void *)&datasize, (void *)buffer,&bufferoffset,sizeof(datasize), n))continue;
|
if(!cpyIncrementBufferOffset((void *)&datasize, (void *)buffer,&bufferoffset,sizeof(datasize), n))continue;
|
||||||
u8 * databuffer = (u8*) malloc(datasize * sizeof(u8));
|
u8 * databuffer = (u8*) malloc(datasize * sizeof(u8));
|
||||||
if(!databuffer){
|
if(!databuffer){
|
||||||
log_printf("UDPServer::DoUDPThreadInternal(line %d): Allocating memory failed\n",__LINE__);
|
printf("UDPServer::DoUDPThreadInternal(line %d): Allocating memory failed\n",__LINE__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!cpyIncrementBufferOffset((void *)databuffer, (void *)buffer,&bufferoffset,datasize, n))continue;
|
if(!cpyIncrementBufferOffset((void *)databuffer, (void *)buffer,&bufferoffset,datasize, n))continue;
|
||||||
//log_printf("UDPServer::DoUDPThreadInternal(): Got handle: %d slot %04X hid %04X pad %02X datasize %02X\n",handle,deviceSlot,hid,padslot,datasize);
|
//printf("UDPServer::DoUDPThreadInternal(): Got handle: %d slot %04X hid %04X pad %02X datasize %02X\n",handle,deviceSlot,hid,padslot,datasize);
|
||||||
|
|
||||||
user.pad_slot = padslot;
|
user.pad_slot = padslot;
|
||||||
user.slotdata.deviceslot = deviceSlot;
|
user.slotdata.deviceslot = deviceSlot;
|
||||||
user.slotdata.hidmask = hid;
|
user.slotdata.hidmask = hid;
|
||||||
|
|
||||||
if(gNetworkController[deviceSlot][padslot][0] == 0){
|
if(gNetworkController[deviceSlot][padslot][0] == 0){
|
||||||
log_printf("UDPServer::DoUDPThreadInternal(line %d): Ehm. Pad is not connected. STOP SENDING DATA ;) \n",__LINE__);
|
printf("UDPServer::DoUDPThreadInternal(line %d): Ehm. Pad is not connected. STOP SENDING DATA ;) \n",__LINE__);
|
||||||
}else{
|
}else{
|
||||||
ControllerPatcherHID::externHIDReadCallback(handle,databuffer,datasize,&user);
|
ControllerPatcherHID::externHIDReadCallback(handle,databuffer,datasize,&user);
|
||||||
}
|
}
|
||||||
@ -165,5 +164,5 @@ void UDPServer::DoUDPThreadInternal(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){ log_printf("UDPServer::DoUDPThreadInternal(line %d): UDPServer Thread ended\n",__LINE__); }
|
if(HID_DEBUG){ printf("UDPServer::DoUDPThreadInternal(line %d): UDPServer Thread ended\n",__LINE__); }
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef _CONTROLLER_PATCHER_DEFS_H_
|
#ifndef _CONTROLLER_PATCHER_DEFS_H_
|
||||||
#define _CONTROLLER_PATCHER_DEFS_H_
|
#define _CONTROLLER_PATCHER_DEFS_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
#include <wiiu/types.h>
|
||||||
|
|
||||||
#define FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK 0x9421FFB8
|
#define FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK 0x9421FFB8
|
||||||
|
|
||||||
@ -253,11 +253,11 @@ typedef struct _HID_Mouse_Data {
|
|||||||
/**
|
/**
|
||||||
* @brief The enumeration of device types
|
* @brief The enumeration of device types
|
||||||
*/
|
*/
|
||||||
enum DEVICE_TYPE
|
typedef enum DEVICE_TYPE_
|
||||||
{
|
{
|
||||||
DEVICE_TYPE_CONTROLLER = 0, /**< Normal Controller */
|
DEVICE_TYPE_CONTROLLER = 0, /**< Normal Controller */
|
||||||
DEVICE_TYPE_MOUSE = 1, /**< Mouse */
|
DEVICE_TYPE_MOUSE = 1, /**< Mouse */
|
||||||
};
|
}DEVICE_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stores all data of the HID Device for accessing
|
* @brief Stores all data of the HID Device for accessing
|
||||||
@ -310,12 +310,12 @@ typedef struct _DeviceInfo{
|
|||||||
/**
|
/**
|
||||||
* @brief The enumeration of Controller-Mapping types
|
* @brief The enumeration of Controller-Mapping types
|
||||||
*/
|
*/
|
||||||
enum ControllerMapping_Type_Defines{
|
typedef enum ControllerMapping_Type_Defines_{
|
||||||
CM_Type_Controller = 0, /**< Device with single input */
|
CM_Type_Controller = 0, /**< Device with single input */
|
||||||
CM_Type_RealController = 1, /**< Real Pro Controller */
|
CM_Type_RealController = 1, /**< Real Pro Controller */
|
||||||
CM_Type_Mouse = 2, /**< Mouse */
|
CM_Type_Mouse = 2, /**< Mouse */
|
||||||
CM_Type_Keyboard = 3, /**< Keyboard */
|
CM_Type_Keyboard = 3, /**< Keyboard */
|
||||||
};
|
} ControllerMapping_Type_Defines;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Infos of a mapped controller
|
* @brief Infos of a mapped controller
|
||||||
@ -348,11 +348,10 @@ typedef struct _ControllerMapping{
|
|||||||
* @brief Pressed/Released/Down Button data.
|
* @brief Pressed/Released/Down Button data.
|
||||||
*/
|
*/
|
||||||
typedef struct _InputButtonData{
|
typedef struct _InputButtonData{
|
||||||
u32 btn_h; /**< Buttons beeing hold */
|
u32 hold; /**< Buttons beeing hold */
|
||||||
u32 btn_d; /**< Buttons that started pressing */
|
u32 trigger; /**< Buttons that started pressing */
|
||||||
u32 btn_r; /**< Buttons that were button released */
|
u32 release; /**< Buttons that were button released */
|
||||||
}InputButtonData;
|
}InputButtonData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Struct where the inputdata of a device for all HID_MAX_PADS_COUNT pads can be stored
|
* @brief Struct where the inputdata of a device for all HID_MAX_PADS_COUNT pads can be stored
|
||||||
*/
|
*/
|
||||||
@ -360,7 +359,6 @@ typedef struct _InputData{
|
|||||||
DeviceInfo device_info; /**< Infos about the device where the data is coming from */
|
DeviceInfo device_info; /**< Infos about the device where the data is coming from */
|
||||||
InputButtonData button_data[HID_MAX_PADS_COUNT];
|
InputButtonData button_data[HID_MAX_PADS_COUNT];
|
||||||
}InputData;
|
}InputData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The enumeration of WiiU Controller types
|
* @brief The enumeration of WiiU Controller types
|
||||||
*/
|
*/
|
||||||
|
@ -19,11 +19,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gctypes.h>
|
|
||||||
|
|
||||||
#include "dynamic_libs/os_functions.h"
|
#include "wiiu/os.h"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* public implementation for the network controller
|
* public implementation for the network controller
|
||||||
@ -60,7 +57,7 @@ void ControllerPatcherHID::myHIDMouseReadCallback(u32 handle, s32 error, unsigne
|
|||||||
HID_Mouse_Data * cur_mouse_data = &data_ptr->data_union.mouse.cur_mouse_data;
|
HID_Mouse_Data * cur_mouse_data = &data_ptr->data_union.mouse.cur_mouse_data;
|
||||||
|
|
||||||
data_ptr->type = DEVICE_TYPE_MOUSE;
|
data_ptr->type = DEVICE_TYPE_MOUSE;
|
||||||
//log_printf("%02X %02X %02X %02X %02X bytes_transfered: %d\n",buf[0],buf[1],buf[2],buf[3],buf[4],bytes_transfered);
|
//printf("%02X %02X %02X %02X %02X bytes_transfered: %d\n",buf[0],buf[1],buf[2],buf[3],buf[4],bytes_transfered);
|
||||||
|
|
||||||
if(buf[0] == 2 && bytes_transfered > 3){ // using the other mouse mode
|
if(buf[0] == 2 && bytes_transfered > 3){ // using the other mouse mode
|
||||||
buf +=1;
|
buf +=1;
|
||||||
@ -89,7 +86,7 @@ void ControllerPatcherHID::myHIDMouseReadCallback(u32 handle, s32 error, unsigne
|
|||||||
|
|
||||||
cur_mouse_data->valuedChanged = 1;
|
cur_mouse_data->valuedChanged = 1;
|
||||||
|
|
||||||
//log_printf("%02X %02X %02X %02X %02X %02X %02X %02X %d = X: %d Y: %d \n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7],bytes_transfered,x_value,y_value);
|
//printf("%02X %02X %02X %02X %02X %02X %02X %02X %d = X: %d Y: %d \n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7],bytes_transfered,x_value,y_value);
|
||||||
|
|
||||||
HIDRead(handle, usr->buf, bytes_transfered, myHIDMouseReadCallback, usr);
|
HIDRead(handle, usr->buf, bytes_transfered, myHIDMouseReadCallback, usr);
|
||||||
}
|
}
|
||||||
@ -102,7 +99,7 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha
|
|||||||
HIDReadCallback(handle,buf,bytes_transfered,usr);
|
HIDReadCallback(handle,buf,bytes_transfered,usr);
|
||||||
|
|
||||||
if(usr->slotdata.hidmask == gHID_LIST_DS4){
|
if(usr->slotdata.hidmask == gHID_LIST_DS4){
|
||||||
os_usleep(1000*2); //DS4 is way tooo fast. sleeping to reduce lag. (need to check the other pads)
|
wiiu_os_usleep(1000*2); //DS4 is way tooo fast. sleeping to reduce lag. (need to check the other pads)
|
||||||
}
|
}
|
||||||
HIDRead(handle, usr->buf, bytes_transfered, myHIDReadCallback, usr);
|
HIDRead(handle, usr->buf, bytes_transfered, myHIDReadCallback, usr);
|
||||||
}
|
}
|
||||||
@ -114,15 +111,15 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha
|
|||||||
|
|
||||||
s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, u32 attach){
|
s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, u32 attach){
|
||||||
if(attach){
|
if(attach){
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x connected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid));
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x connected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid));
|
||||||
if(HID_DEBUG){ log_printf("interface index %02x\n", p_device->interface_index);
|
if(HID_DEBUG){ printf("interface index %02x\n", p_device->interface_index);
|
||||||
log_printf("sub class %02x\n", p_device->sub_class);
|
printf("sub class %02x\n", p_device->sub_class);
|
||||||
log_printf("protocol %02x\n", p_device->protocol);
|
printf("protocol %02x\n", p_device->protocol);
|
||||||
log_printf("max packet in %02x\n", p_device->max_packet_size_rx);
|
printf("max packet in %02x\n", p_device->max_packet_size_rx);
|
||||||
log_printf("max packet out %02x\n", p_device->max_packet_size_tx); }
|
printf("max packet out %02x\n", p_device->max_packet_size_tx); }
|
||||||
}
|
}
|
||||||
if(!attach){
|
if(!attach){
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x disconnected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid));
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): vid %04x pid %04x disconnected\n",__LINE__, SWAP16(p_device->vid),SWAP16(p_device->pid));
|
||||||
}
|
}
|
||||||
DeviceInfo device_info;
|
DeviceInfo device_info;
|
||||||
memset(&device_info,0,sizeof(DeviceInfo));
|
memset(&device_info,0,sizeof(DeviceInfo));
|
||||||
@ -135,18 +132,18 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
if ((p_device->sub_class == 1) && (p_device->protocol == 1)) { //Keyboard
|
if ((p_device->sub_class == 1) && (p_device->protocol == 1)) { //Keyboard
|
||||||
slotdata->hidmask = gHID_LIST_KEYBOARD;
|
slotdata->hidmask = gHID_LIST_KEYBOARD;
|
||||||
slotdata->deviceslot = gHID_SLOT_KEYBOARD;
|
slotdata->deviceslot = gHID_SLOT_KEYBOARD;
|
||||||
//log_printf("Found Keyboard: device: %s slot: %d\n",byte_to_binary(device_info.slotdata.hidmask),device_info.slotdata.deviceslot);
|
//printf("Found Keyboard: device: %s slot: %d\n",byte_to_binary(device_info.slotdata.hidmask),device_info.slotdata.deviceslot);
|
||||||
}else if ((p_device->sub_class == 1) && (p_device->protocol == 2)){ // MOUSE
|
}else if ((p_device->sub_class == 1) && (p_device->protocol == 2)){ // MOUSE
|
||||||
slotdata->hidmask = gHID_LIST_MOUSE;
|
slotdata->hidmask = gHID_LIST_MOUSE;
|
||||||
slotdata->deviceslot = gMouseSlot;
|
slotdata->deviceslot = gMouseSlot;
|
||||||
//log_printf("Found Mouse: device: %s slot: %d\n",byte_to_binary(device_info.hid),device_info.slot);
|
//printf("Found Mouse: device: %s slot: %d\n",byte_to_binary(device_info.hid),device_info.slot);
|
||||||
}else{
|
}else{
|
||||||
s32 ret;
|
s32 ret;
|
||||||
if((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0){
|
if((ret = ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info)) < 0){
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d \n",__LINE__,ret);
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) failed %d \n",__LINE__,ret);
|
||||||
return HID_DEVICE_DETACH;
|
return HID_DEVICE_DETACH;
|
||||||
}else{
|
}else{
|
||||||
//log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) success %d \n",__LINE__,ret);
|
//printf("ControllerPatcherHID::AttachDetachCallback(line %d): ControllerPatcherUtils::getDeviceInfoFromVidPid(&device_info) success %d \n",__LINE__,ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +187,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(failed){
|
if(failed){
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d) error: I can only handle %d devices of the same type. Sorry \n",__LINE__,HID_MAX_PADS_COUNT);
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d) error: I can only handle %d devices of the same type. Sorry \n",__LINE__,HID_MAX_PADS_COUNT);
|
||||||
if(buf){
|
if(buf){
|
||||||
free(buf);
|
free(buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
@ -214,7 +211,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
memset(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],0,sizeof(HID_Data));
|
memset(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],0,sizeof(HID_Data));
|
||||||
|
|
||||||
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].handle = p_device->handle;
|
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].handle = p_device->handle;
|
||||||
//log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): saved handle %d to slot %d and pad %d\n",__LINE__,p_device->handle,slotdata->deviceslot,pad_slot);
|
//printf("ControllerPatcherHID::AttachDetachCallback(line %d): saved handle %d to slot %d and pad %d\n",__LINE__,p_device->handle,slotdata->deviceslot,pad_slot);
|
||||||
|
|
||||||
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].user_data = usr;
|
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].user_data = usr;
|
||||||
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].slotdata = device_info.slotdata;
|
gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i].slotdata = device_info.slotdata;
|
||||||
@ -223,7 +220,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data));
|
DCInvalidateRange(&gHID_Devices[slotdata->deviceslot].pad_data[pad_slot+i],sizeof(HID_Data));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully attached\n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully attached\n",__LINE__); }
|
||||||
|
|
||||||
if(slotdata->hidmask == gHID_LIST_GC){ // GC PAD
|
if(slotdata->hidmask == gHID_LIST_GC){ // GC PAD
|
||||||
//The GC Adapter has all ports in one device. Set them all.
|
//The GC Adapter has all ports in one device. Set them all.
|
||||||
@ -245,7 +242,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
s32 read_result = HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
|
s32 read_result = HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
|
||||||
if(read_result == 64){
|
if(read_result == 64){
|
||||||
if(usr->buf[01] == 0x01){ //We need to do the handshake
|
if(usr->buf[01] == 0x01){ //We need to do the handshake
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Switch Pro Controller handshake needed\n",__LINE__);
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): Switch Pro Controller handshake needed\n",__LINE__);
|
||||||
/**
|
/**
|
||||||
Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering)
|
Thanks to ShinyQuagsire23 for the values (https://github.com/shinyquagsire23/HID-Joy-Con-Whispering)
|
||||||
**/
|
**/
|
||||||
@ -265,7 +262,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
HIDWrite(p_device->handle, usr->buf, 2, NULL,NULL);
|
HIDWrite(p_device->handle, usr->buf, 2, NULL,NULL);
|
||||||
HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
|
HIDRead(p_device->handle, usr->buf, usr->transfersize, NULL, NULL);
|
||||||
}else{
|
}else{
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Switch Pro Controller handshake already done\n",__LINE__);
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): Switch Pro Controller handshake already done\n",__LINE__);
|
||||||
}
|
}
|
||||||
HIDRead(p_device->handle, usr->buf, usr->transfersize, myHIDReadCallback, usr);
|
HIDRead(p_device->handle, usr->buf, usr->transfersize, myHIDReadCallback, usr);
|
||||||
}
|
}
|
||||||
@ -312,7 +309,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
free(user_data);
|
free(user_data);
|
||||||
user_data = NULL;
|
user_data = NULL;
|
||||||
}else{
|
}else{
|
||||||
if(founddata){ log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): user_data null. You may have a memory leak.\n",__LINE__); }
|
if(founddata){ printf("ControllerPatcherHID::AttachDetachCallback(line %d): user_data null. You may have a memory leak.\n",__LINE__); }
|
||||||
return HID_DEVICE_DETACH;
|
return HID_DEVICE_DETACH;
|
||||||
}
|
}
|
||||||
if(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0){
|
if(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] == 0){
|
||||||
@ -328,12 +325,12 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(HID_DEBUG){log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): We still have pad for deviceslot %d connected.\n",__LINE__,slotdata->deviceslot); }
|
if(HID_DEBUG){printf("ControllerPatcherHID::AttachDetachCallback(line %d): We still have pad for deviceslot %d connected.\n",__LINE__,slotdata->deviceslot); }
|
||||||
}
|
}
|
||||||
if(HID_DEBUG){log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully detached\n",__LINE__); }
|
if(HID_DEBUG){printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully detached\n",__LINE__); }
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
log_printf("ControllerPatcherHID::AttachDetachCallback(line %d): HID-Device currently not supported! You can add support through config files\n",__LINE__);
|
printf("ControllerPatcherHID::AttachDetachCallback(line %d): HID-Device currently not supported! You can add support through config files\n",__LINE__);
|
||||||
}
|
}
|
||||||
return HID_DEVICE_DETACH;
|
return HID_DEVICE_DETACH;
|
||||||
}
|
}
|
||||||
@ -341,7 +338,7 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p
|
|||||||
void ControllerPatcherHID::HIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr){
|
void ControllerPatcherHID::HIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr){
|
||||||
ControllerPatcherUtils::doSampling(usr->slotdata.deviceslot,usr->pad_slot,false);
|
ControllerPatcherUtils::doSampling(usr->slotdata.deviceslot,usr->pad_slot,false);
|
||||||
|
|
||||||
//log_printf("my_read_cbInternal: %d %08X %d\n",bytes_transfered,usr->slotdata.hidmask,usr->slotdata.deviceslot);
|
//printf("my_read_cbInternal: %d %08X %d\n",bytes_transfered,usr->slotdata.hidmask,usr->slotdata.deviceslot);
|
||||||
if(usr->slotdata.hidmask == gHID_LIST_GC){
|
if(usr->slotdata.hidmask == gHID_LIST_GC){
|
||||||
|
|
||||||
HID_Data * data_ptr = NULL;
|
HID_Data * data_ptr = NULL;
|
||||||
@ -355,10 +352,10 @@ void ControllerPatcherHID::HIDReadCallback(u32 handle, unsigned char *buf, u32 b
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
s32 i = 0;
|
s32 i = 0;
|
||||||
log_printf("GC1 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
printf("GC1 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
||||||
log_printf("GC2 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
printf("GC2 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
||||||
log_printf("GC3 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
printf("GC3 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X ", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);i++;
|
||||||
log_printf("GC4 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X \n", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);*/
|
printf("GC4 %08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X \n", buf[i*9+0],buf[i*9+1],buf[i*9+2],buf[i*9+3],buf[i*9+4],buf[i*9+5],buf[i*9+6],buf[i*9+7],buf[i*9+8]);*/
|
||||||
HIDGCRumble(handle,usr);
|
HIDGCRumble(handle,usr);
|
||||||
}else if(usr->slotdata.hidmask != 0){
|
}else if(usr->slotdata.hidmask != 0){
|
||||||
//Depending on how the switch pro controller is connected, it has a different data format. At first we had the Bluetooth version, so we need to convert
|
//Depending on how the switch pro controller is connected, it has a different data format. At first we had the Bluetooth version, so we need to convert
|
||||||
@ -482,7 +479,7 @@ void ControllerPatcherHID::HIDReadCallback(u32 handle, unsigned char *buf, u32 b
|
|||||||
* Other functions
|
* Other functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(VPADData * buffer,std::vector<HID_Data *>& data){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(VPADStatus * buffer,std::vector<HID_Data *>& data){
|
||||||
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
HID_Data * data_cur;
|
HID_Data * data_cur;
|
||||||
|
|
||||||
@ -526,9 +523,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(V
|
|||||||
u32 last_emulate_stick = (data_cur->last_buttons) & VPAD_MASK_EMULATED_STICKS; // We should only need the emulated stick data.
|
u32 last_emulate_stick = (data_cur->last_buttons) & VPAD_MASK_EMULATED_STICKS; // We should only need the emulated stick data.
|
||||||
s32 last_realbuttons = (data_cur->last_buttons) & VPAD_MASK_BUTTONS;
|
s32 last_realbuttons = (data_cur->last_buttons) & VPAD_MASK_BUTTONS;
|
||||||
|
|
||||||
buffer->btns_h |= buttons_hold;
|
buffer->hold |= buttons_hold;
|
||||||
buffer->btns_d |= (buttons_hold & (~last_realbuttons));
|
buffer->trigger |= (buttons_hold & (~last_realbuttons));
|
||||||
buffer->btns_r |= (last_realbuttons & (~buttons_hold));
|
buffer->release |= (last_realbuttons & (~buttons_hold));
|
||||||
|
|
||||||
ControllerPatcherUtils::convertAnalogSticks(data_cur,buffer);
|
ControllerPatcherUtils::convertAnalogSticks(data_cur,buffer);
|
||||||
|
|
||||||
@ -544,8 +541,8 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(V
|
|||||||
|
|
||||||
// Caculates a valid stick position
|
// Caculates a valid stick position
|
||||||
if(data.size() > 0){
|
if(data.size() > 0){
|
||||||
ControllerPatcherUtils::normalizeStickValues(&buffer->lstick);
|
ControllerPatcherUtils::normalizeStickValues(&buffer->leftStick);
|
||||||
ControllerPatcherUtils::normalizeStickValues(&buffer->rstick);
|
ControllerPatcherUtils::normalizeStickValues(&buffer->rightStick);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
@ -562,7 +559,7 @@ std::vector<HID_Data *> ControllerPatcherHID::getHIDDataAll(){
|
|||||||
s32 res;
|
s32 res;
|
||||||
HID_Data * new_data = NULL;
|
HID_Data * new_data = NULL;
|
||||||
if((res = ControllerPatcherHID::getHIDData(cur_hidmask,pad,&new_data)) < 0){ // Checks if the pad is invalid.
|
if((res = ControllerPatcherHID::getHIDData(cur_hidmask,pad,&new_data)) < 0){ // Checks if the pad is invalid.
|
||||||
log_printf("ControllerPatcherHID::getHIDDataAll(line %d): error: Error getting the HID data from HID(%s) CHAN(). Error %d\n",__LINE__,CPStringTools::byte_to_binary(cur_hidmask),pad,res);
|
//printf("ControllerPatcherHID::getHIDDataAll(line %d): error: Error getting the HID data from HID(%s) CHAN(). Error %d\n",__LINE__,CPStringTools::byte_to_binary(cur_hidmask),pad,res);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(new_data != NULL) data_list.push_back(new_data);
|
if(new_data != NULL) data_list.push_back(new_data);
|
||||||
@ -638,7 +635,7 @@ void ControllerPatcherHID::HIDRumble(u32 handle,my_cb_user *usr,u32 pad){
|
|||||||
}
|
}
|
||||||
usr->forceRumbleInTicks[pad]--;
|
usr->forceRumbleInTicks[pad]--;
|
||||||
if(rumblechanged || usr->forceRumbleInTicks[pad] <= 0){
|
if(rumblechanged || usr->forceRumbleInTicks[pad] <= 0){
|
||||||
//log_printf("Rumble: %d %d\n",usr->rumblestatus[pad],usr->rumbleForce[pad]);
|
//printf("Rumble: %d %d\n",usr->rumblestatus[pad],usr->rumbleForce[pad]);
|
||||||
//Seding to the network client!
|
//Seding to the network client!
|
||||||
char bytes[6];
|
char bytes[6];
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dynamic_libs/syshid_functions.h"
|
#include "wiiu/syshid.h"
|
||||||
#include "dynamic_libs/vpad_functions.h"
|
#include "wiiu/vpad.h"
|
||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class ControllerPatcherHID{
|
|||||||
static void externHIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr);
|
static void externHIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADData * buffer,std::vector<HID_Data *>& data);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADStatus * buffer,std::vector<HID_Data *>& data);
|
||||||
static std::vector<HID_Data *> getHIDDataAll();
|
static std::vector<HID_Data *> getHIDDataAll();
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(u32 hidmask, s32 pad, HID_Data ** data);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(u32 hidmask, s32 pad, HID_Data ** data);
|
||||||
|
|
||||||
|
@ -18,12 +18,10 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDataByHandle(s32 handle, my_cb_user ** data){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDataByHandle(s32 handle, my_cb_user ** data){
|
||||||
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
||||||
for(s32 j = 0;j<4;j++){
|
for(s32 j = 0;j<4;j++){
|
||||||
//log_printf("%d %d %d %d\n",i,j,gHID_Devices[i].pad_data[j].handle,(u32)handle);
|
//printf("%d %d %d %d\n",i,j,gHID_Devices[i].pad_data[j].handle,(u32)handle);
|
||||||
if(gHID_Devices[i].pad_data[j].handle == (u32)handle){
|
if(gHID_Devices[i].pad_data[j].handle == (u32)handle){
|
||||||
*data = gHID_Devices[i].pad_data[j].user_data;
|
*data = gHID_Devices[i].pad_data[j].user_data;
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
@ -209,7 +207,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getButtonPressed(HID_
|
|||||||
if(isValueSet(data,cur_config) == 1){
|
if(isValueSet(data,cur_config) == 1){
|
||||||
result = 1; break;
|
result = 1; break;
|
||||||
}else{
|
}else{
|
||||||
//log_printf("Invalid data! deviceslot(slot): %d config: %d\n",deviceslot,cur_config);
|
//printf("Invalid data! deviceslot(slot): %d config: %d\n",deviceslot,cur_config);
|
||||||
}
|
}
|
||||||
}while(0); //The break will become handy ;)
|
}while(0); //The break will become handy ;)
|
||||||
|
|
||||||
@ -260,7 +258,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isInKeyboardData(unsi
|
|||||||
* Utils for setting the Button data
|
* Utils for setting the Button data
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonRemappingData(VPADData * old_buffer, VPADData * new_buffer,u32 VPADButton, s32 CONTRPS_SLOT){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonRemappingData(VPADStatus * old_buffer, VPADStatus * new_buffer,u32 VPADButton, s32 CONTRPS_SLOT){
|
||||||
if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
u32 new_value = VPADButton;
|
u32 new_value = VPADButton;
|
||||||
|
|
||||||
@ -272,16 +270,16 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonRemappingDat
|
|||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADData * old_buffer, VPADData * new_buffer,u32 oldVPADButton,u32 newVPADButton){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADStatus * old_buffer, VPADStatus * new_buffer,u32 oldVPADButton,u32 newVPADButton){
|
||||||
if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(old_buffer == NULL || new_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
if((old_buffer->btns_h & oldVPADButton) == oldVPADButton){
|
if((old_buffer->hold & oldVPADButton) == oldVPADButton){
|
||||||
new_buffer->btns_h |= newVPADButton;
|
new_buffer->hold |= newVPADButton;
|
||||||
}
|
}
|
||||||
if((old_buffer->btns_r & oldVPADButton) == oldVPADButton){
|
if((old_buffer->release & oldVPADButton) == oldVPADButton){
|
||||||
new_buffer->btns_r |= newVPADButton;
|
new_buffer->release |= newVPADButton;
|
||||||
}
|
}
|
||||||
if((old_buffer->btns_d & oldVPADButton) == oldVPADButton){
|
if((old_buffer->trigger & oldVPADButton) == oldVPADButton){
|
||||||
new_buffer->btns_d |= newVPADButton;
|
new_buffer->trigger |= newVPADButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
@ -324,7 +322,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getActivePad(u32 hidm
|
|||||||
* Stick functions
|
* Stick functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::normalizeStickValues(Vec2D * stick){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::normalizeStickValues(VPADVec2D * stick){
|
||||||
if(stick == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(stick == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
f32 max_val = 0.0f;
|
f32 max_val = 0.0f;
|
||||||
@ -370,8 +368,8 @@ f32 ControllerPatcherUtils::convertAnalogValue(u8 value, u8 default_val, u8 min,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2D ControllerPatcherUtils::getAnalogValueByButtons(u8 stick_values){
|
VPADVec2D ControllerPatcherUtils::getAnalogValueByButtons(u8 stick_values){
|
||||||
Vec2D stick;
|
VPADVec2D stick;
|
||||||
stick.x = 0.0f;
|
stick.x = 0.0f;
|
||||||
stick.y = 0.0f;
|
stick.y = 0.0f;
|
||||||
|
|
||||||
@ -413,7 +411,7 @@ Vec2D ControllerPatcherUtils::getAnalogValueByButtons(u8 stick_values){
|
|||||||
return stick;
|
return stick;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(HID_Data * data, VPADData * buffer){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(HID_Data * data, VPADStatus * buffer){
|
||||||
if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
s32 deviceslot = data->slotdata.deviceslot;
|
s32 deviceslot = data->slotdata.deviceslot;
|
||||||
@ -428,14 +426,14 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
|
|
||||||
if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][0] != CONTROLLER_PATCHER_INVALIDVALUE){
|
if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][0] != CONTROLLER_PATCHER_INVALIDVALUE){
|
||||||
if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][1] == DEF_L_STICK){
|
if(config_controller[deviceslot][CONTRPS_MOUSE_STICK][1] == DEF_L_STICK){
|
||||||
buffer->lstick.x += x_value;
|
buffer->leftStick.x += x_value;
|
||||||
buffer->lstick.y += y_value;
|
buffer->leftStick.y += y_value;
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->rstick.x += x_value;
|
buffer->rightStick.x += x_value;
|
||||||
buffer->rstick.y += y_value;
|
buffer->rightStick.y += y_value;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
u8 * cur_data = &data->data_union.controller.cur_hid_data[0];
|
u8 * cur_data = &data->data_union.controller.cur_hid_data[0];
|
||||||
@ -448,7 +446,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE][1];
|
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->lstick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]],
|
buffer->leftStick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][1],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][0],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][0],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX][1],
|
||||||
@ -461,7 +459,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET){
|
if(config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][0] == CONTROLLER_PATCHER_VALUE_SET){
|
||||||
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][1];
|
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE][1];
|
||||||
}
|
}
|
||||||
buffer->lstick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]],
|
buffer->leftStick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][1],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][0],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][0],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX][1],
|
||||||
@ -475,7 +473,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE][1];
|
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->rstick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],
|
buffer->rightStick.x += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][1],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][0],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][0],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX][1],
|
||||||
@ -489,7 +487,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE][1];
|
deadzone = config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->rstick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]],
|
buffer->rightStick.y += convertAnalogValue(cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][1],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][0],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][0],
|
||||||
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][1],
|
config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX][1],
|
||||||
@ -505,9 +503,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
|
if(isValueSet(data,CONTRPS_VPAD_BUTTON_L_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
|
||||||
|
|
||||||
if(stick_values > 0 ){
|
if(stick_values > 0 ){
|
||||||
Vec2D stick = getAnalogValueByButtons(stick_values);
|
VPADVec2D stick = getAnalogValueByButtons(stick_values);
|
||||||
buffer->lstick.x += stick.x;
|
buffer->leftStick.x += stick.x;
|
||||||
buffer->lstick.y += stick.y;
|
buffer->leftStick.y += stick.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
stick_values = 0;
|
stick_values = 0;
|
||||||
@ -517,60 +515,60 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H
|
|||||||
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
|
if(isValueSet(data,CONTRPS_VPAD_BUTTON_R_STICK_RIGHT)){ stick_values |= STICK_VALUE_RIGHT; }
|
||||||
|
|
||||||
if(stick_values > 0 ){
|
if(stick_values > 0 ){
|
||||||
Vec2D stick = getAnalogValueByButtons(stick_values);
|
VPADVec2D stick = getAnalogValueByButtons(stick_values);
|
||||||
buffer->rstick.x += stick.x;
|
buffer->rightStick.x += stick.x;
|
||||||
buffer->rstick.y += stick.y;
|
buffer->rightStick.y += stick.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*log_printf("LX %f(%02X) LY %f(%02X) RX %f(%02X) RY %f(%02X)\n",buffer->lstick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]],
|
/*printf("LX %f(%02X) LY %f(%02X) RX %f(%02X) RY %f(%02X)\n",buffer->leftStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]],
|
||||||
buffer->lstick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]],
|
buffer->leftStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]],
|
||||||
buffer->rstick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],
|
buffer->rightStick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],
|
||||||
buffer->rstick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]]);*/
|
buffer->rightStick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0]]);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPADData * buffer, u32 * last_emulatedSticks){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPADStatus * buffer, u32 * last_emulatedSticks){
|
||||||
if(buffer == NULL || last_emulatedSticks == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL || last_emulatedSticks == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
u32 emulatedSticks = 0;
|
u32 emulatedSticks = 0;
|
||||||
|
|
||||||
s32 l_x_full = (buffer->lstick.x > 0.5f || buffer->lstick.x < -0.5f)? 1:0;
|
s32 l_x_full = (buffer->leftStick.x > 0.5f || buffer->leftStick.x < -0.5f)? 1:0;
|
||||||
s32 l_y_full = (buffer->lstick.y > 0.5f || buffer->lstick.y < -0.5f)? 1:0;
|
s32 l_y_full = (buffer->leftStick.y > 0.5f || buffer->leftStick.y < -0.5f)? 1:0;
|
||||||
s32 r_x_full = (buffer->rstick.x > 0.5f || buffer->rstick.x < -0.5f)? 1:0;
|
s32 r_x_full = (buffer->rightStick.x > 0.5f || buffer->rightStick.x < -0.5f)? 1:0;
|
||||||
s32 r_y_full = (buffer->rstick.y > 0.5f || buffer->rstick.y < -0.5f)? 1:0;
|
s32 r_y_full = (buffer->rightStick.y > 0.5f || buffer->rightStick.y < -0.5f)? 1:0;
|
||||||
|
|
||||||
if((buffer->lstick.x > 0.5f) || (buffer->lstick.x > 0.1f && !l_y_full)){
|
if((buffer->leftStick.x > 0.5f) || (buffer->leftStick.x > 0.1f && !l_y_full)){
|
||||||
emulatedSticks |= VPAD_STICK_L_EMULATION_RIGHT;
|
emulatedSticks |= VPAD_STICK_L_EMULATION_RIGHT;
|
||||||
}
|
}
|
||||||
if((buffer->lstick.x < -0.5f) || (buffer->lstick.x < -0.1f && !l_y_full)){
|
if((buffer->leftStick.x < -0.5f) || (buffer->leftStick.x < -0.1f && !l_y_full)){
|
||||||
emulatedSticks |= VPAD_STICK_L_EMULATION_LEFT;
|
emulatedSticks |= VPAD_STICK_L_EMULATION_LEFT;
|
||||||
}
|
}
|
||||||
if((buffer->lstick.y > 0.5f) || (buffer->lstick.y > 0.1f && !l_x_full)){
|
if((buffer->leftStick.y > 0.5f) || (buffer->leftStick.y > 0.1f && !l_x_full)){
|
||||||
emulatedSticks |= VPAD_STICK_L_EMULATION_UP;
|
emulatedSticks |= VPAD_STICK_L_EMULATION_UP;
|
||||||
}
|
}
|
||||||
if((buffer->lstick.y < -0.5f) || (buffer->lstick.y < -0.1f && !l_x_full)){
|
if((buffer->leftStick.y < -0.5f) || (buffer->leftStick.y < -0.1f && !l_x_full)){
|
||||||
emulatedSticks |= VPAD_STICK_L_EMULATION_DOWN;
|
emulatedSticks |= VPAD_STICK_L_EMULATION_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((buffer->rstick.x > 0.5f) || (buffer->rstick.x > 0.1f && !r_y_full)){
|
if((buffer->rightStick.x > 0.5f) || (buffer->rightStick.x > 0.1f && !r_y_full)){
|
||||||
emulatedSticks |= VPAD_STICK_R_EMULATION_RIGHT;
|
emulatedSticks |= VPAD_STICK_R_EMULATION_RIGHT;
|
||||||
}
|
}
|
||||||
if((buffer->rstick.x < -0.5f) || (buffer->rstick.x < -0.1f && !r_y_full)){
|
if((buffer->rightStick.x < -0.5f) || (buffer->rightStick.x < -0.1f && !r_y_full)){
|
||||||
emulatedSticks |= VPAD_STICK_R_EMULATION_LEFT;
|
emulatedSticks |= VPAD_STICK_R_EMULATION_LEFT;
|
||||||
}
|
}
|
||||||
if((buffer->rstick.y > 0.5f) || (buffer->rstick.y > 0.1f && !r_x_full)){
|
if((buffer->rightStick.y > 0.5f) || (buffer->rightStick.y > 0.1f && !r_x_full)){
|
||||||
emulatedSticks |= VPAD_STICK_R_EMULATION_UP;
|
emulatedSticks |= VPAD_STICK_R_EMULATION_UP;
|
||||||
}
|
}
|
||||||
if((buffer->rstick.y < -0.5f) || (buffer->rstick.y < -0.1f && !r_x_full)){
|
if((buffer->rightStick.y < -0.5f) || (buffer->rightStick.y < -0.1f && !r_x_full)){
|
||||||
emulatedSticks |= VPAD_STICK_R_EMULATION_DOWN;
|
emulatedSticks |= VPAD_STICK_R_EMULATION_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Setting the emulated sticks
|
//Setting the emulated sticks
|
||||||
buffer->btns_h |= emulatedSticks;
|
buffer->hold |= emulatedSticks;
|
||||||
buffer->btns_d |= (emulatedSticks & (~*last_emulatedSticks));
|
buffer->trigger |= (emulatedSticks & (~*last_emulatedSticks));
|
||||||
buffer->btns_r |= (*last_emulatedSticks & (~emulatedSticks));
|
buffer->release |= (*last_emulatedSticks & (~emulatedSticks));
|
||||||
|
|
||||||
*last_emulatedSticks = emulatedSticks;
|
*last_emulatedSticks = emulatedSticks;
|
||||||
|
|
||||||
@ -581,7 +579,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setEmulatedSticks(VPA
|
|||||||
* Touch functions
|
* Touch functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data * data,VPADData * buffer){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data * data,VPADStatus * buffer){
|
||||||
if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(buffer == NULL || data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
if(data->type == DEVICE_TYPE_MOUSE && gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
if(data->type == DEVICE_TYPE_MOUSE && gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
||||||
s32 buttons_hold;
|
s32 buttons_hold;
|
||||||
@ -590,18 +588,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data * d
|
|||||||
if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
s32 x_mouse = 80 + ((int)(((ms_data->X)*1.0f/1280.0)*3890.0f));
|
s32 x_mouse = 80 + ((int)(((ms_data->X)*1.0f/1280.0)*3890.0f));
|
||||||
s32 y_mouse = 3910 - ((int)(((ms_data->Y)*1.0f/720.0)*3760.0f));
|
s32 y_mouse = 3910 - ((int)(((ms_data->Y)*1.0f/720.0)*3760.0f));
|
||||||
buffer->tpdata.x = x_mouse;
|
buffer->tpNormal.x = x_mouse;
|
||||||
buffer->tpdata.y = y_mouse;
|
buffer->tpNormal.y = y_mouse;
|
||||||
buffer->tpdata.touched = 1;
|
buffer->tpNormal.touched = 1;
|
||||||
buffer->tpdata.invalid = 0;
|
buffer->tpNormal.validity = 0;
|
||||||
buffer->tpdata1.x = x_mouse;
|
buffer->tpFiltered1.x = x_mouse;
|
||||||
buffer->tpdata1.y = y_mouse;
|
buffer->tpFiltered1.y = y_mouse;
|
||||||
buffer->tpdata1.touched = 1;
|
buffer->tpFiltered1.touched = 1;
|
||||||
buffer->tpdata1.invalid = 0;
|
buffer->tpFiltered1.validity = 0;
|
||||||
buffer->tpdata2.x = x_mouse;
|
buffer->tpFiltered2.x = x_mouse;
|
||||||
buffer->tpdata2.y = y_mouse;
|
buffer->tpFiltered2.y = y_mouse;
|
||||||
buffer->tpdata2.touched = 1;
|
buffer->tpFiltered2.touched = 1;
|
||||||
buffer->tpdata2.invalid = 0;
|
buffer->tpFiltered2.validity = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
@ -616,9 +614,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(
|
|||||||
if((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) && ((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) != (isInKeyboardData(last_data,HID_KEYBOARD_BUTTON_F1) > 0))){
|
if((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) && ((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) != (isInKeyboardData(last_data,HID_KEYBOARD_BUTTON_F1) > 0))){
|
||||||
if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){
|
if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){
|
||||||
gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH;
|
gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); }
|
||||||
}else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
}else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); }
|
if(HID_DEBUG){ printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); }
|
||||||
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,48 +628,48 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(
|
|||||||
* Other functions
|
* Other functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADData * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesPRO){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADStatus * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesPRO){
|
||||||
if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesPRO == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesPRO == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
s32 buttons_hold = 0;
|
s32 buttons_hold = 0;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A;
|
if(vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B;
|
if(vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X;
|
if(vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y;
|
if(vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS;
|
if(vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS;
|
if(vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME;
|
if(vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT;
|
if(vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT;
|
if(vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP;
|
if(vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN;
|
if(vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L;
|
if(vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL;
|
if(vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R;
|
if(vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR;
|
if(vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L;
|
if(vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R;
|
if(vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN;
|
||||||
|
|
||||||
pro_buffer->pro.lstick_x = vpad_buffer->lstick.x;
|
pro_buffer->pro.lstick_x = vpad_buffer->leftStick.x;
|
||||||
pro_buffer->pro.lstick_y = vpad_buffer->lstick.y;
|
pro_buffer->pro.lstick_x = vpad_buffer->leftStick.y;
|
||||||
pro_buffer->pro.rstick_x = vpad_buffer->rstick.x;
|
pro_buffer->pro.rstick_x = vpad_buffer->rightStick.x;
|
||||||
pro_buffer->pro.rstick_y = vpad_buffer->rstick.y;
|
pro_buffer->pro.rstick_x = vpad_buffer->rightStick.y;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
pro_buffer->unused_1[1] = 0xBF800000;
|
pro_buffer->unused_1[1] = 0xBF800000;
|
||||||
@ -683,9 +681,9 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADDa
|
|||||||
pro_buffer->unused_7[1] = 0x3F800000;
|
pro_buffer->unused_7[1] = 0x3F800000;
|
||||||
pro_buffer->unused_7[5] = 0x3F800000;*/
|
pro_buffer->unused_7[5] = 0x3F800000;*/
|
||||||
|
|
||||||
pro_buffer->pro.btns_h = buttons_hold;
|
pro_buffer->pro.hold = buttons_hold;
|
||||||
pro_buffer->pro.btns_d = (buttons_hold & (~*lastButtonsPressesPRO));
|
pro_buffer->pro.trigger = (buttons_hold & (~*lastButtonsPressesPRO));
|
||||||
pro_buffer->pro.btns_r = (*lastButtonsPressesPRO & (~buttons_hold));
|
pro_buffer->pro.release = (*lastButtonsPressesPRO & (~buttons_hold));
|
||||||
|
|
||||||
*lastButtonsPressesPRO = buttons_hold;
|
*lastButtonsPressesPRO = buttons_hold;
|
||||||
|
|
||||||
@ -698,48 +696,48 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToPro(VPADDa
|
|||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToProWPADRead(VPADData * vpad_buffer,WPADReadData * pro_buffer){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToProWPADRead(VPADStatus * vpad_buffer,WPADReadData * pro_buffer){
|
||||||
if(vpad_buffer == NULL || pro_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(vpad_buffer == NULL || pro_buffer == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
s32 buttons_hold = 0;
|
s32 buttons_hold = 0;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A;
|
if(vpad_buffer->hold & VPAD_BUTTON_A) buttons_hold |= WPAD_PRO_BUTTON_A;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B;
|
if(vpad_buffer->hold & VPAD_BUTTON_B) buttons_hold |= WPAD_PRO_BUTTON_B;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X;
|
if(vpad_buffer->hold & VPAD_BUTTON_X) buttons_hold |= WPAD_PRO_BUTTON_X;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y;
|
if(vpad_buffer->hold & VPAD_BUTTON_Y) buttons_hold |= WPAD_PRO_BUTTON_Y;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS;
|
if(vpad_buffer->hold & VPAD_BUTTON_PLUS) buttons_hold |= WPAD_PRO_BUTTON_PLUS;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS;
|
if(vpad_buffer->hold & VPAD_BUTTON_MINUS) buttons_hold |= WPAD_PRO_BUTTON_MINUS;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME;
|
if(vpad_buffer->hold & VPAD_BUTTON_HOME) buttons_hold |= WPAD_PRO_BUTTON_HOME;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT;
|
if(vpad_buffer->hold & VPAD_BUTTON_LEFT) buttons_hold |= WPAD_PRO_BUTTON_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT;
|
if(vpad_buffer->hold & VPAD_BUTTON_RIGHT) buttons_hold |= WPAD_PRO_BUTTON_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP;
|
if(vpad_buffer->hold & VPAD_BUTTON_UP) buttons_hold |= WPAD_PRO_BUTTON_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN;
|
if(vpad_buffer->hold & VPAD_BUTTON_DOWN) buttons_hold |= WPAD_PRO_BUTTON_DOWN;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L;
|
if(vpad_buffer->hold & VPAD_BUTTON_L) buttons_hold |= WPAD_PRO_TRIGGER_L;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL;
|
if(vpad_buffer->hold & VPAD_BUTTON_ZL) buttons_hold |= WPAD_PRO_TRIGGER_ZL;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R;
|
if(vpad_buffer->hold & VPAD_BUTTON_R) buttons_hold |= WPAD_PRO_TRIGGER_R;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR;
|
if(vpad_buffer->hold & VPAD_BUTTON_ZR) buttons_hold |= WPAD_PRO_TRIGGER_ZR;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L;
|
if(vpad_buffer->hold & VPAD_BUTTON_STICK_L) buttons_hold |= WPAD_PRO_BUTTON_STICK_L;
|
||||||
if(vpad_buffer->btns_h & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R;
|
if(vpad_buffer->hold & VPAD_BUTTON_STICK_R) buttons_hold |= WPAD_PRO_BUTTON_STICK_R;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN;
|
if(vpad_buffer->hold & VPAD_STICK_L_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_L_EMULATION_DOWN;
|
||||||
|
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_LEFT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_LEFT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_RIGHT) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_RIGHT;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_UP) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_UP;
|
||||||
if(vpad_buffer->btns_h & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN;
|
if(vpad_buffer->hold & VPAD_STICK_R_EMULATION_DOWN) buttons_hold |= WPAD_PRO_STICK_R_EMULATION_DOWN;
|
||||||
|
|
||||||
pro_buffer->l_stick_x = (s16) (vpad_buffer->lstick.x * 950.0f);
|
pro_buffer->l_stick_x = (s16) (vpad_buffer->leftStick.x * 950.0f);
|
||||||
pro_buffer->l_stick_y = (s16) (vpad_buffer->lstick.y * 950.0f);
|
pro_buffer->l_stick_y = (s16) (vpad_buffer->leftStick.y * 950.0f);
|
||||||
pro_buffer->r_stick_x = (s16) (vpad_buffer->rstick.x * 950.0f);
|
pro_buffer->r_stick_x = (s16) (vpad_buffer->rightStick.x * 950.0f);
|
||||||
pro_buffer->r_stick_y = (s16) (vpad_buffer->rstick.y * 950.0f);
|
pro_buffer->r_stick_y = (s16) (vpad_buffer->rightStick.y * 950.0f);
|
||||||
|
|
||||||
pro_buffer->buttons = buttons_hold;
|
pro_buffer->buttons = buttons_hold;
|
||||||
|
|
||||||
@ -750,54 +748,54 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToProWPADRea
|
|||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToVPAD(VPADData * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesVPAD){
|
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::translateToVPAD(VPADStatus * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesVPAD){
|
||||||
if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesVPAD == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
if(vpad_buffer == NULL || pro_buffer == NULL || lastButtonsPressesVPAD == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
s32 buttons_hold = 0;
|
s32 buttons_hold = 0;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_A) buttons_hold |= VPAD_BUTTON_A;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_A) buttons_hold |= VPAD_BUTTON_A;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_B) buttons_hold |= VPAD_BUTTON_B;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_B) buttons_hold |= VPAD_BUTTON_B;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_X) buttons_hold |= VPAD_BUTTON_X;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_X) buttons_hold |= VPAD_BUTTON_X;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_Y) buttons_hold |= VPAD_BUTTON_Y;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_Y) buttons_hold |= VPAD_BUTTON_Y;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_PLUS) buttons_hold |= VPAD_BUTTON_PLUS;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_PLUS) buttons_hold |= VPAD_BUTTON_PLUS;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_MINUS) buttons_hold |= VPAD_BUTTON_MINUS;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_MINUS) buttons_hold |= VPAD_BUTTON_MINUS;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_HOME) buttons_hold |= VPAD_BUTTON_HOME;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_HOME) buttons_hold |= VPAD_BUTTON_HOME;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_LEFT) buttons_hold |= VPAD_BUTTON_LEFT;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_LEFT) buttons_hold |= VPAD_BUTTON_LEFT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_RIGHT) buttons_hold |= VPAD_BUTTON_RIGHT;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_RIGHT) buttons_hold |= VPAD_BUTTON_RIGHT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_UP) buttons_hold |= VPAD_BUTTON_UP;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_UP) buttons_hold |= VPAD_BUTTON_UP;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_DOWN) buttons_hold |= VPAD_BUTTON_DOWN;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_DOWN) buttons_hold |= VPAD_BUTTON_DOWN;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_TRIGGER_L) buttons_hold |= VPAD_BUTTON_L;
|
if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_L) buttons_hold |= VPAD_BUTTON_L;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_TRIGGER_ZL) buttons_hold |= VPAD_BUTTON_ZL;
|
if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZL) buttons_hold |= VPAD_BUTTON_ZL;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_TRIGGER_R) buttons_hold |= VPAD_BUTTON_R;
|
if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_R) buttons_hold |= VPAD_BUTTON_R;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_TRIGGER_ZR) buttons_hold |= VPAD_BUTTON_ZR;
|
if(pro_buffer->pro.hold & WPAD_PRO_TRIGGER_ZR) buttons_hold |= VPAD_BUTTON_ZR;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_STICK_L) buttons_hold |= VPAD_BUTTON_STICK_L;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_L) buttons_hold |= VPAD_BUTTON_STICK_L;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_BUTTON_STICK_R) buttons_hold |= VPAD_BUTTON_STICK_R;
|
if(pro_buffer->pro.hold & WPAD_PRO_BUTTON_STICK_R) buttons_hold |= VPAD_BUTTON_STICK_R;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_L_EMULATION_LEFT) buttons_hold |= VPAD_STICK_L_EMULATION_LEFT;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_LEFT) buttons_hold |= VPAD_STICK_L_EMULATION_LEFT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_L_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_L_EMULATION_RIGHT;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_L_EMULATION_RIGHT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_L_EMULATION_UP) buttons_hold |= VPAD_STICK_L_EMULATION_UP;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_UP) buttons_hold |= VPAD_STICK_L_EMULATION_UP;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_L_EMULATION_DOWN) buttons_hold |= VPAD_STICK_L_EMULATION_DOWN;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_L_EMULATION_DOWN) buttons_hold |= VPAD_STICK_L_EMULATION_DOWN;
|
||||||
|
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_R_EMULATION_LEFT) buttons_hold |= VPAD_STICK_R_EMULATION_LEFT;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_LEFT) buttons_hold |= VPAD_STICK_R_EMULATION_LEFT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_R_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_R_EMULATION_RIGHT;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_RIGHT) buttons_hold |= VPAD_STICK_R_EMULATION_RIGHT;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_R_EMULATION_UP) buttons_hold |= VPAD_STICK_R_EMULATION_UP;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_UP) buttons_hold |= VPAD_STICK_R_EMULATION_UP;
|
||||||
if(pro_buffer->pro.btns_h & WPAD_PRO_STICK_R_EMULATION_DOWN) buttons_hold |= VPAD_STICK_R_EMULATION_DOWN;
|
if(pro_buffer->pro.hold & WPAD_PRO_STICK_R_EMULATION_DOWN) buttons_hold |= VPAD_STICK_R_EMULATION_DOWN;
|
||||||
|
|
||||||
vpad_buffer->lstick.x = pro_buffer->pro.lstick_x;
|
vpad_buffer->leftStick.x = pro_buffer->pro.lstick_x;
|
||||||
vpad_buffer->lstick.y = pro_buffer->pro.lstick_y;
|
vpad_buffer->leftStick.y = pro_buffer->pro.lstick_x;
|
||||||
vpad_buffer->rstick.x = pro_buffer->pro.rstick_x;
|
vpad_buffer->rightStick.x = pro_buffer->pro.rstick_x;
|
||||||
vpad_buffer->rstick.y = pro_buffer->pro.rstick_y;
|
vpad_buffer->rightStick.y = pro_buffer->pro.rstick_x;
|
||||||
|
|
||||||
vpad_buffer->btns_h |= buttons_hold;
|
vpad_buffer->hold |= buttons_hold;
|
||||||
vpad_buffer->btns_d |= (buttons_hold & (~*lastButtonsPressesVPAD));
|
vpad_buffer->trigger |= (buttons_hold & (~*lastButtonsPressesVPAD));
|
||||||
vpad_buffer->btns_r |= (*lastButtonsPressesVPAD & (~buttons_hold));
|
vpad_buffer->release |= (*lastButtonsPressesVPAD & (~buttons_hold));
|
||||||
|
|
||||||
*lastButtonsPressesVPAD = buttons_hold;
|
*lastButtonsPressesVPAD = buttons_hold;
|
||||||
|
|
||||||
@ -830,7 +828,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidP
|
|||||||
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
for(s32 i = 0;i< gHIDMaxDevices;i++){
|
||||||
u16 my_vid = config_controller[i][CONTRPS_VID][0] * 0x100 + config_controller[i][CONTRPS_VID][1];
|
u16 my_vid = config_controller[i][CONTRPS_VID][0] * 0x100 + config_controller[i][CONTRPS_VID][1];
|
||||||
u16 my_pid = config_controller[i][CONTRPS_PID][0] * 0x100 + config_controller[i][CONTRPS_PID][1];
|
u16 my_pid = config_controller[i][CONTRPS_PID][0] * 0x100 + config_controller[i][CONTRPS_PID][1];
|
||||||
//log_printf("info->vidpid.vid (%04X) == my_vid (%04X) && info->vidpid.pid (%04X) == my_pid (%04X)\n",info->vidpid.vid,my_vid,info->vidpid.pid,my_pid);
|
//printf("info->vidpid.vid (%04X) == my_vid (%04X) && info->vidpid.pid (%04X) == my_pid (%04X)\n",info->vidpid.vid,my_vid,info->vidpid.pid,my_pid);
|
||||||
if(info->vidpid.vid == my_vid && info->vidpid.pid == my_pid){
|
if(info->vidpid.vid == my_vid && info->vidpid.pid == my_pid){
|
||||||
info->slotdata.hidmask = config_controller_hidmask[i];
|
info->slotdata.hidmask = config_controller_hidmask[i];
|
||||||
info->slotdata.deviceslot = i;
|
info->slotdata.deviceslot = i;
|
||||||
@ -843,7 +841,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceInfoFromVidP
|
|||||||
}
|
}
|
||||||
|
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
//log_printf("Found device: device: %s slot: %d\n",byte_to_binary(device),deviceSlot);
|
//printf("Found device: device: %s slot: %d\n",byte_to_binary(device),deviceSlot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,9 @@
|
|||||||
#ifndef _CONTROLLER_PATCHER_UTIL_H_
|
#ifndef _CONTROLLER_PATCHER_UTIL_H_
|
||||||
#define _CONTROLLER_PATCHER_UTIL_H_
|
#define _CONTROLLER_PATCHER_UTIL_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
|
||||||
|
|
||||||
#include "dynamic_libs/vpad_functions.h"
|
#include "wiiu/vpad.h"
|
||||||
#include "dynamic_libs/padscore_functions.h"
|
#include "wiiu/kpad.h"
|
||||||
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
@ -72,13 +71,13 @@ class ControllerPatcherUtils{
|
|||||||
|
|
||||||
/** \brief Set the VPAD data for a given KPAD data.
|
/** \brief Set the VPAD data for a given KPAD data.
|
||||||
*
|
*
|
||||||
* \param vpad_buffer VPADData* A pointer to the VPAD Data where the result will be stored.
|
* \param vpad_buffer VPADStatus* A pointer to the VPAD Data where the result will be stored.
|
||||||
* \param pro_buffer KPADData* A pointer to the given KPADData data.
|
* \param pro_buffer KPADData* A pointer to the given KPADData data.
|
||||||
* \param lastButtonsPressesPRO u32* A pointer to the button presses of the previous call. Will be updated while calling.
|
* \param lastButtonsPressesPRO u32* A pointer to the button presses of the previous call. Will be updated while calling.
|
||||||
* \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
* \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToVPAD(VPADData * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesVPAD);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToVPAD(VPADStatus * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesVPAD);
|
||||||
private:
|
private:
|
||||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* Analyse inputs
|
* Analyse inputs
|
||||||
@ -121,27 +120,27 @@ class ControllerPatcherUtils{
|
|||||||
/** \brief Checks if a @p VPADButton (VPAD_BUTTON_XXX) is set in the given @p CONTRPS_SLOT (usually the one for buttons remapping) of the GamePad. When its set it'll be
|
/** \brief Checks if a @p VPADButton (VPAD_BUTTON_XXX) is set in the given @p CONTRPS_SLOT (usually the one for buttons remapping) of the GamePad. When its set it'll be
|
||||||
* set for the corresponding Button (aka button remapping). When the @p CONTRPS_SLOT is not valid, the normal buttons layout will be used.
|
* set for the corresponding Button (aka button remapping). When the @p CONTRPS_SLOT is not valid, the normal buttons layout will be used.
|
||||||
*
|
*
|
||||||
* \param old_buffer A pointer to a VPADData struct from which will be read.
|
* \param old_buffer A pointer to a VPADStatus struct from which will be read.
|
||||||
* \param new_buffer A pointer to a VPADData struct where the result will be written.
|
* \param new_buffer A pointer to a VPADStatus struct where the result will be written.
|
||||||
* \param VPADButton The buttons that will be may replaced
|
* \param VPADButton The buttons that will be may replaced
|
||||||
* \param CONTRPS_SLOT The CONTRPS_SLOT where the VPAD_Buttons we want to use instead of the parameter "VPADButton" could be saved.
|
* \param CONTRPS_SLOT The CONTRPS_SLOT where the VPAD_Buttons we want to use instead of the parameter "VPADButton" could be saved.
|
||||||
* \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned.
|
* \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonRemappingData(VPADData * old_buffer, VPADData * new_buffer,u32 VPADButton, s32 CONTRPS_SLOT);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonRemappingData(VPADStatus * old_buffer, VPADStatus * new_buffer,u32 VPADButton, s32 CONTRPS_SLOT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Checks if a given button (oldVPADButton) is set in a given VPADData struct (old_buffer). If its set, it will set an other
|
\brief Checks if a given button (oldVPADButton) is set in a given VPADStatus struct (old_buffer). If its set, it will set an other
|
||||||
button (newVPADButton) to the second given VPADData struct (new_buffer)
|
button (newVPADButton) to the second given VPADStatus struct (new_buffer)
|
||||||
|
|
||||||
\param old_buffer A pointer to a VPADData struct from which will be read.
|
\param old_buffer A pointer to a VPADStatus struct from which will be read.
|
||||||
\param new_buffer A pointer to a VPADData struct where the result will be written.
|
\param new_buffer A pointer to a VPADStatus struct where the result will be written.
|
||||||
\param oldVPADButton The buttons that need to be set in the first VPADData
|
\param oldVPADButton The buttons that need to be set in the first VPADStatus
|
||||||
\param newVPADButton The buttons that will be set in the second VPADData, when the oldVPADButton is pressed in the first buffer.
|
\param newVPADButton The buttons that will be set in the second VPADStatus, when the oldVPADButton is pressed in the first buffer.
|
||||||
|
|
||||||
\return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned.
|
\return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonData(VPADData * old_buffer, VPADData * new_buffer,u32 oldVPADButton,u32 newVPADButton);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setButtonData(VPADStatus * old_buffer, VPADStatus * new_buffer,u32 oldVPADButton,u32 newVPADButton);
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* Pad Status functions
|
* Pad Status functions
|
||||||
@ -175,7 +174,7 @@ class ControllerPatcherUtils{
|
|||||||
|
|
||||||
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR normalizeStickValues(Vec2D * stick);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR normalizeStickValues(VPADVec2D * stick);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Converts the digital absolute stick data into a float value. It also applies the deadzones, and can invert the result.
|
\brief Converts the digital absolute stick data into a float value. It also applies the deadzones, and can invert the result.
|
||||||
@ -192,37 +191,37 @@ class ControllerPatcherUtils{
|
|||||||
static f32 convertAnalogValue(u8 value, u8 default_val, u8 min, u8 max, u8 invert,u8 deadzone);
|
static f32 convertAnalogValue(u8 value, u8 default_val, u8 min, u8 max, u8 invert,u8 deadzone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Calculates a the stick data (Vec2D) from given digital direction.
|
\brief Calculates a the stick data (VPADVec2D) from given digital direction.
|
||||||
|
|
||||||
\param stick_values bits need to set for each direction. (STICK_VALUE_UP,STICK_VALUE_DOWN,STICK_VALUE_LEFT,STICK_VALUE_RIGHT)
|
\param stick_values bits need to set for each direction. (STICK_VALUE_UP,STICK_VALUE_DOWN,STICK_VALUE_LEFT,STICK_VALUE_RIGHT)
|
||||||
|
|
||||||
\return The Vec2D with the set values.
|
\return The VPADVec2D with the set values.
|
||||||
**/
|
**/
|
||||||
static Vec2D getAnalogValueByButtons(u8 stick_values);
|
static VPADVec2D getAnalogValueByButtons(u8 stick_values);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Handles the analog-stick data of HID devices. The result will written in the VPADData buffer.
|
\brief Handles the analog-stick data of HID devices. The result will written in the VPADStatus buffer.
|
||||||
|
|
||||||
\param data Pointer to the current data of the HID device
|
\param data Pointer to the current data of the HID device
|
||||||
\param buffer Pointer to VPADData where the analog-stick data will be set.
|
\param buffer Pointer to VPADStatus where the analog-stick data will be set.
|
||||||
|
|
||||||
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR convertAnalogSticks(HID_Data * data,VPADData * buffer);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR convertAnalogSticks(HID_Data * data,VPADStatus * buffer);
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* Mouse functions
|
* Mouse functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
\brief Set the touch data in the VPADData buffer.
|
\brief Set the touch data in the VPADStatus buffer.
|
||||||
Currently its only possible to set the touch data from a Mouse
|
Currently its only possible to set the touch data from a Mouse
|
||||||
|
|
||||||
\param data The current data of the HID device
|
\param data The current data of the HID device
|
||||||
\param buffer Pointer to VPADData where the touch data will be set.
|
\param buffer Pointer to VPADStatus where the touch data will be set.
|
||||||
|
|
||||||
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setTouch(HID_Data * data,VPADData * buffer);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setTouch(HID_Data * data,VPADStatus * buffer);
|
||||||
|
|
||||||
/** \brief Checks if the mouse mode needs to be changed. Sets it to the new mode if necessary.
|
/** \brief Checks if the mouse mode needs to be changed. Sets it to the new mode if necessary.
|
||||||
* Currently the incoming data needs to be from a keyboard.
|
* Currently the incoming data needs to be from a keyboard.
|
||||||
@ -241,21 +240,21 @@ class ControllerPatcherUtils{
|
|||||||
|
|
||||||
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
\return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
**/
|
**/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR setEmulatedSticks(VPADData * buffer, u32 * last_emulatedSticks);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setEmulatedSticks(VPADStatus * buffer, u32 * last_emulatedSticks);
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* Other functions
|
* Other functions
|
||||||
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
/** \brief Set the Pro Controller for a given VPAD data.
|
/** \brief Set the Pro Controller for a given VPAD data.
|
||||||
*
|
*
|
||||||
* \param vpad_buffer VPADData* A pointer to the given VPAD Data.
|
* \param vpad_buffer VPADStatus* A pointer to the given VPAD Data.
|
||||||
* \param pro_buffer KPADData* A pointer to the KPADData where the result will be stored.
|
* \param pro_buffer KPADData* A pointer to the KPADData where the result will be stored.
|
||||||
* \param lastButtonsPressesPRO u32* A pointer to the button presses of the previous call. Will be updated while calling.
|
* \param lastButtonsPressesPRO u32* A pointer to the button presses of the previous call. Will be updated while calling.
|
||||||
* \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
* \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToPro(VPADData * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesPRO);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToPro(VPADStatus * vpad_buffer,KPADData * pro_buffer,u32 * lastButtonsPressesPRO);
|
||||||
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToProWPADRead(VPADData * vpad_buffer,WPADReadData * pro_buffer);
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR translateToProWPADRead(VPADStatus * vpad_buffer,WPADReadData * pro_buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Checks if the value at the given device + CONTRPS slot equals the expected value.
|
\brief Checks if the value at the given device + CONTRPS slot equals the expected value.
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <gctypes.h>
|
|
||||||
#include "../ControllerPatcher.hpp"
|
#include "../ControllerPatcher.hpp"
|
||||||
|
|
||||||
ControllerMapping gControllerMapping __attribute__((section(".data")));
|
ControllerMapping gControllerMapping __attribute__((section(".data")));
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#ifndef CP_RETAINS_VARS_H_
|
#ifndef CP_RETAINS_VARS_H_
|
||||||
#define CP_RETAINS_VARS_H_
|
#define CP_RETAINS_VARS_H_
|
||||||
|
|
||||||
#include "dynamic_libs/syshid_functions.h"
|
#include "wiiu/syshid.h"
|
||||||
#include "dynamic_libs/padscore_functions.h"
|
#include "wiiu/kpad.h"
|
||||||
#include "../patcher/ControllerPatcherDefs.h"
|
#include "../patcher/ControllerPatcherDefs.h"
|
||||||
|
|
||||||
extern ControllerMapping gControllerMapping;
|
extern ControllerMapping gControllerMapping;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "wiiu/types.h"
|
||||||
|
|
||||||
bool CPStringTools::EndsWith(const std::string& a, const std::string& b) {
|
bool CPStringTools::EndsWith(const std::string& a, const std::string& b) {
|
||||||
if (b.size() > a.size()) return false;
|
if (b.size() > a.size()) return false;
|
||||||
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
||||||
@ -60,6 +62,7 @@ std::string CPStringTools::removeCharFromString(std::string& input,char toBeRemo
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string CPStringTools::strfmt(const char * format, ...){
|
std::string CPStringTools::strfmt(const char * format, ...){
|
||||||
std::string str;
|
std::string str;
|
||||||
char * tmp = NULL;
|
char * tmp = NULL;
|
||||||
|
@ -2,14 +2,15 @@
|
|||||||
#define _CPSTRING_TOOLS_H_
|
#define _CPSTRING_TOOLS_H_
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <gctypes.h>
|
|
||||||
|
#include "wiiu/types.h"
|
||||||
|
|
||||||
class CPStringTools{
|
class CPStringTools{
|
||||||
public:
|
public:
|
||||||
static bool EndsWith(const std::string& a, const std::string& b);
|
static bool EndsWith(const std::string& a, const std::string& b);
|
||||||
static std::vector<std::string> StringSplit(const std::string & inValue, const std::string & splitter);
|
static std::vector<std::string> StringSplit(const std::string & inValue, const std::string & splitter);
|
||||||
static std::string removeCharFromString(std::string& input,char toBeRemoved);
|
static std::string removeCharFromString(std::string& input,char toBeRemoved);
|
||||||
static const char *byte_to_binary(s32 x);
|
static const char * byte_to_binary(s32 test);
|
||||||
static std::string strfmt(const char * format, ...);
|
static std::string strfmt(const char * format, ...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,14 +14,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef CONTROLLERPATCHERTHREAD_H_
|
#ifndef ControllerPatcherThread_H_
|
||||||
#define CONTROLLERPATCHERTHREAD_H_
|
#define ControllerPatcherThread_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "dynamic_libs/os_functions.h"
|
#include "wiiu/os/thread.h"
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
class ControllerPatcherThread
|
class ControllerPatcherThread
|
||||||
{
|
{
|
||||||
@ -29,7 +27,7 @@ public:
|
|||||||
typedef void (* Callback)(ControllerPatcherThread *thread, void *arg);
|
typedef void (* Callback)(ControllerPatcherThread *thread, void *arg);
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
ControllerPatcherThread(s32 iAttr, s32 iPriority = 16, s32 iStackSize = 0x8000, ControllerPatcherThread::Callback callback = NULL, void *callbackArg = NULL)
|
ControllerPatcherThread(int iAttr, int iPriority = 16, int iStackSize = 0x8000, ControllerPatcherThread::Callback callback = NULL, void *callbackArg = NULL)
|
||||||
: pThread(NULL)
|
: pThread(NULL)
|
||||||
, pThreadStack(NULL)
|
, pThreadStack(NULL)
|
||||||
, pCallback(callback)
|
, pCallback(callback)
|
||||||
@ -38,18 +36,18 @@ public:
|
|||||||
//! save attribute assignment
|
//! save attribute assignment
|
||||||
iAttributes = iAttr;
|
iAttributes = iAttr;
|
||||||
//! allocate the thread
|
//! allocate the thread
|
||||||
pThread = memalign(8, 0x1000);
|
pThread = (OSThread*)memalign(8, sizeof(OSThread));
|
||||||
//! allocate the stack
|
//! allocate the stack
|
||||||
pThreadStack = (u8 *) memalign(0x20, iStackSize);
|
pThreadStack = (u8 *) memalign(0x20, iStackSize);
|
||||||
//! create the thread
|
//! create the thread
|
||||||
if(pThread && pThreadStack)
|
if(pThread && pThreadStack)
|
||||||
OSCreateThread(pThread, &ControllerPatcherThread::threadCallback, 1, this, (u32)pThreadStack+iStackSize, iStackSize, iPriority, iAttributes);
|
OSCreateThread(pThread, &ControllerPatcherThread::threadCallback, 1, (char*)this, pThreadStack+iStackSize, iStackSize, iPriority, iAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~ControllerPatcherThread() {shutdownThread(); }
|
virtual ~ControllerPatcherThread() { shutdownThread(); }
|
||||||
|
|
||||||
static ControllerPatcherThread *create(ControllerPatcherThread::Callback callback, void *callbackArg, s32 iAttr = eAttributeNone, s32 iPriority = 16, s32 iStackSize = 0x8000)
|
static ControllerPatcherThread *create(ControllerPatcherThread::Callback callback, void *callbackArg, int iAttr = eAttributeNone, int iPriority = 16, int iStackSize = 0x8000)
|
||||||
{
|
{
|
||||||
return ( new ControllerPatcherThread(iAttr, iPriority, iStackSize, callback, callbackArg) );
|
return ( new ControllerPatcherThread(iAttr, iPriority, iStackSize, callback, callbackArg) );
|
||||||
}
|
}
|
||||||
@ -67,7 +65,7 @@ public:
|
|||||||
//! Resume thread
|
//! Resume thread
|
||||||
virtual void resumeThread(void) { if(!isThreadSuspended()) return; if(pThread) OSResumeThread(pThread); }
|
virtual void resumeThread(void) { if(!isThreadSuspended()) return; if(pThread) OSResumeThread(pThread); }
|
||||||
//! Set thread priority
|
//! Set thread priority
|
||||||
virtual void setThreadPriority(s32 prio) { if(pThread) OSSetThreadPriority(pThread, prio); }
|
virtual void setThreadPriority(int prio) { if(pThread) OSSetThreadPriority(pThread, prio); }
|
||||||
//! Check if thread is suspended
|
//! Check if thread is suspended
|
||||||
virtual bool isThreadSuspended(void) const { if(pThread) return OSIsThreadSuspended(pThread); return false; }
|
virtual bool isThreadSuspended(void) const { if(pThread) return OSIsThreadSuspended(pThread); return false; }
|
||||||
//! Check if thread is terminated
|
//! Check if thread is terminated
|
||||||
@ -80,22 +78,22 @@ public:
|
|||||||
//! wait for thread to finish
|
//! wait for thread to finish
|
||||||
if(pThread && !(iAttributes & eAttributeDetach))
|
if(pThread && !(iAttributes & eAttributeDetach))
|
||||||
{
|
{
|
||||||
while(isThreadSuspended()){
|
if(isThreadSuspended())
|
||||||
resumeThread();
|
resumeThread();
|
||||||
}
|
|
||||||
OSJoinThread(pThread, NULL);
|
OSJoinThread(pThread, NULL);
|
||||||
}
|
}
|
||||||
//! free the thread stack buffer
|
//! free the thread stack buffer
|
||||||
if(pThreadStack){
|
if(pThreadStack)
|
||||||
free(pThreadStack);
|
free(pThreadStack);
|
||||||
}
|
|
||||||
if(pThread)
|
if(pThread)
|
||||||
free(pThread);
|
free(pThread);
|
||||||
|
|
||||||
pThread = NULL;
|
pThread = NULL;
|
||||||
pThreadStack = NULL;
|
pThreadStack = NULL;
|
||||||
}
|
}
|
||||||
//! Thread attributes
|
//! Thread attributes
|
||||||
enum eCThreadAttributes
|
enum eControllerPatcherThreadAttributes
|
||||||
{
|
{
|
||||||
eAttributeNone = 0x07,
|
eAttributeNone = 0x07,
|
||||||
eAttributeAffCore0 = 0x01,
|
eAttributeAffCore0 = 0x01,
|
||||||
@ -105,14 +103,14 @@ public:
|
|||||||
eAttributePinnedAff = 0x10
|
eAttributePinnedAff = 0x10
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
static s32 threadCallback(s32 argc, void *arg)
|
static int threadCallback(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
//! After call to start() continue with the internal function
|
//! After call to start() continue with the internal function
|
||||||
((ControllerPatcherThread *) arg)->executeThread();
|
((ControllerPatcherThread *) argv)->executeThread();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
s32 iAttributes;
|
int iAttributes;
|
||||||
void *pThread;
|
OSThread *pThread;
|
||||||
u8 *pThreadStack;
|
u8 *pThreadStack;
|
||||||
Callback pCallback;
|
Callback pCallback;
|
||||||
void *pCallbackArg;
|
void *pCallbackArg;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#ifndef _PAD_CONST_H_
|
#ifndef _PAD_CONST_H_
|
||||||
#define _PAD_CONST_H_
|
#define _PAD_CONST_H_
|
||||||
|
|
||||||
#include <gctypes.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../patcher/ControllerPatcherDefs.h"
|
#include "../patcher/ControllerPatcherDefs.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user