mirror of
https://github.com/Maschell/controller_patcher.git
synced 2024-11-22 03:59:16 +01:00
Huge commit
Changelog: Bugfixes: - Fixes the still moving mouse in aim mode, when mouse is actually not moving - Fixed a bug at initializing the config_controller_list; - Fixed the support for almost all mouses that uses the normal HID mouse standard (boot mode). - The emulated sticks are now supported correctly - The stick now only produces valid values. Stick absusing not possible anymore New features: - Added support for config files that can be read from an SD Card. - Added support for more keyboard buttons - Added support for gamepad button remapping - Made the double used buttons on the GC Pad configuable - The keyboard can now emulate the sticks correctly - Keyboard buttons for the sticks can be set - The mouse buttons can now be configured - The mouse can be configured to emulate the left stick - Added support for one more DPAD mode (CONTRPDM_Absolute_2Values) Other: - Removed the support for the PS2 Adapter and Saitek P2600, but they can be added trough a config file. - The engine now uses 16 hardcoded slots the devices can use. - cleaned up the logging output - Logging of the currently pressed buttons possible and more little things I dont remember
This commit is contained in:
parent
df8439eb41
commit
aa0ce59f87
370
config_parser.cpp
Normal file
370
config_parser.cpp
Normal file
@ -0,0 +1,370 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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 <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config_parser.h"
|
||||
#include "config_reader.h"
|
||||
#include "config_values.h"
|
||||
#include "string_tools.hpp"
|
||||
|
||||
ConfigParser::ConfigParser(std::string configData)
|
||||
{
|
||||
this->content = configData;
|
||||
this->contentLines = MyStringSplit(content, "\n");
|
||||
|
||||
if(contentLines.empty())
|
||||
return;
|
||||
|
||||
//remove the comments and make everything uppercase
|
||||
for(u32 i = 0; i < contentLines.size(); i++){
|
||||
std::vector<std::string> comments = MyStringSplit(contentLines[i], "//");
|
||||
if(!comments.empty()){
|
||||
contentLines[i] = comments[0];
|
||||
}
|
||||
//we want everything uppercase
|
||||
std::transform(contentLines[i].begin(), contentLines[i].end(),contentLines[i].begin(), ::toupper);
|
||||
}
|
||||
|
||||
//remove empty lines
|
||||
std::vector<std::string> contentline2;
|
||||
for(u32 i = 0; i < contentLines.size(); i++){
|
||||
if(strlen(contentLines[i].c_str()) > 0){
|
||||
contentline2.push_back(contentLines[i]);
|
||||
}
|
||||
}
|
||||
contentLines = contentline2;
|
||||
Init();
|
||||
}
|
||||
|
||||
ConfigParser::~ConfigParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PARSE_TYPE ConfigParser::getType(){
|
||||
return type_b;
|
||||
}
|
||||
|
||||
void ConfigParser::setType(PARSE_TYPE newType){
|
||||
this->type_b = newType;
|
||||
}
|
||||
|
||||
u16 ConfigParser::getSlot(){
|
||||
return this->slot_b;
|
||||
}
|
||||
|
||||
void ConfigParser::setSlot(u16 newSlot){
|
||||
this->slot_b = newSlot;
|
||||
}
|
||||
|
||||
bool ConfigParser::Init(){
|
||||
const char * line = contentLines[0].c_str();
|
||||
int len = strlen(line);
|
||||
std::string identify;
|
||||
if(line[0] == '[' && line[len-1] == ']'){
|
||||
identify = contentLines[0].substr(1,len-2);
|
||||
}else{
|
||||
log_printf("Not a proper config file!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(identify.compare("GAMEPAD") == 0){
|
||||
log_printf("Its a gamepad config file!\n");
|
||||
setSlot(gGamePadSlot);
|
||||
setType(PARSE_GAMEPAD);
|
||||
}else if(identify.compare("MOUSE") == 0){
|
||||
log_printf("Its a mouse config file!\n");
|
||||
setSlot(gMouseSlot);
|
||||
setType(PARSE_MOUSE);
|
||||
}else if(identify.compare("KEYBOARD") == 0){
|
||||
log_printf("Its a keyboard config file!\n");
|
||||
setSlot(gHID_SLOT_KEYBOARD);
|
||||
setType(PARSE_KEYBOARD);
|
||||
}else{
|
||||
log_printf("Its a controller config file!\n");
|
||||
setSlot(getSlotController(identify));
|
||||
setType(PARSE_CONTROLLER);
|
||||
}
|
||||
|
||||
if(getSlot() == HID_INVALID_SLOT){
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigReader::increaseNumberOfLoadedFiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigParser::parseSingleLine(std::string line){
|
||||
std::vector<std::string> cur_values = MyStringSplit(line,"=");
|
||||
if(cur_values.size() != 2){
|
||||
if(HID_DEBUG || cur_values.size() > 2) log_printf("Not a valid key=pair line %s\n",line.c_str());
|
||||
return;
|
||||
}else{
|
||||
|
||||
u16 hid_slot = getSlot();
|
||||
|
||||
if(HID_DEBUG) log_printf("leftpart = \"%s\" \n",cur_values[0].c_str());
|
||||
if(HID_DEBUG) log_printf("rightpart = _%s_ \n",cur_values[1].c_str());
|
||||
int keyslot = -1;
|
||||
|
||||
if(HID_DEBUG) log_printf("Checking single value\n");
|
||||
if(getType() == PARSE_GAMEPAD || getType() == PARSE_KEYBOARD){
|
||||
keyslot = ConfigValues::getKeySlotGamePad(cur_values[0]);
|
||||
}else if(getType() == PARSE_MOUSE){
|
||||
keyslot = ConfigValues::getKeySlotMouse(cur_values[0]);
|
||||
}else{
|
||||
keyslot = ConfigValues::getKeySlotDefaultSingleValue(cur_values[0]);
|
||||
}
|
||||
if(keyslot != -1){
|
||||
if(HID_DEBUG) log_printf("Its a single value\n");
|
||||
long rightValue = -1;
|
||||
bool valueSet = false;
|
||||
if(cur_values[0].compare("DPAD_MODE") == 0){
|
||||
const u8 * values_ = NULL;
|
||||
if((values_ = ConfigValues::getValuesStickPreset(cur_values[1])) != NULL){
|
||||
if(values_[STICK_CONF_MAGIC_VERSION] != STICK_CONF_MAGIC_VALUE)
|
||||
if(HID_DEBUG) log_printf("Settings preset DPAD MODE and Mask\n");
|
||||
config_controller[hid_slot][CONTRPS_DPAD_MODE][0] = CONTROLLER_PATCHER_VALUE_SET;
|
||||
config_controller[hid_slot][CONTRPS_DPAD_MODE][1] = values_[CONTRDPAD_MODE];
|
||||
if(values_[CONTRDPAD_MASK] != 0x00){
|
||||
config_controller[hid_slot][CONTRPS_DPAD_MASK][0] = CONTROLLER_PATCHER_VALUE_SET;
|
||||
config_controller[hid_slot][CONTRPS_DPAD_MASK][1] = values_[CONTRDPAD_MASK];
|
||||
}
|
||||
valueSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!valueSet){
|
||||
if(getType() == PARSE_KEYBOARD){
|
||||
if((rightValue = ConfigValues::getPresetValuesKeyboard(cur_values[1]))!= -1){
|
||||
if(HID_DEBUG) log_printf("Used pre-defined Keyboard! \"%s\" is %d\n",cur_values[1].c_str(),rightValue);
|
||||
}else{
|
||||
if(HID_DEBUG) log_printf("I need to parse %s\n",cur_values[1].c_str());
|
||||
char * ptr;
|
||||
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
||||
}
|
||||
|
||||
if(keyslot >= DEF_L_STICK_UP && keyslot <= DEF_R_STICK_RIGHT){
|
||||
if(keyslot == DEF_L_STICK_UP){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0] = rightValue;
|
||||
}else if(keyslot == DEF_L_STICK_DOWN){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_L_STICK_Y][1] = rightValue;
|
||||
}else if(keyslot == DEF_L_STICK_LEFT){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_L_STICK_X][0] = rightValue;
|
||||
}else if(keyslot == DEF_L_STICK_RIGHT){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_L_STICK_X][1] = rightValue;
|
||||
}else if(keyslot == DEF_R_STICK_UP){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y][0] = rightValue;
|
||||
}else if(keyslot == DEF_R_STICK_DOWN){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_R_STICK_Y][1] = rightValue;
|
||||
}else if(keyslot == DEF_R_STICK_LEFT){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_R_STICK_X][0] = rightValue;
|
||||
}else if(keyslot == DEF_R_STICK_RIGHT){
|
||||
config_controller[hid_slot][CONTRPS_VPAD_BUTTON_R_STICK_X][1] = rightValue;
|
||||
}else{
|
||||
log_printf("Random error in Keyboard sticks\n");
|
||||
}
|
||||
if(HID_DEBUG) log_printf("Set stick for Keyboard (%d)\n",keyslot);
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
rightValue = ConfigValues::getPresetValue(cur_values[1]);
|
||||
|
||||
if(getType() == PARSE_MOUSE){ //No parsing for the mouse
|
||||
if(rightValue == -1){
|
||||
if(HID_DEBUG) log_printf("Invalid mouse value, lets skip it %s\n",cur_values[1].c_str());
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
if(rightValue == -1){
|
||||
if(HID_DEBUG) log_printf("I need to parse %s\n",cur_values[1].c_str());
|
||||
char * ptr;
|
||||
rightValue = strtol(cur_values[1].c_str(),&ptr,16);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(HID_DEBUG) log_printf("Setting value to %d\n",rightValue);
|
||||
|
||||
config_controller[hid_slot][keyslot][0] = CONTROLLER_PATCHER_VALUE_SET;
|
||||
config_controller[hid_slot][keyslot][1] = rightValue;
|
||||
}
|
||||
}else{
|
||||
if(HID_DEBUG) log_printf("Check pair value\n");
|
||||
keyslot = ConfigValues::getKeySlotDefaultPairedValue(cur_values[0]);
|
||||
if(keyslot != -1){
|
||||
if(HID_DEBUG) log_printf("Its a pair value\n");
|
||||
|
||||
if(!ConfigValues::getInstance()->setIfValueIsAControllerPreset(cur_values[1],getSlot(),keyslot)){
|
||||
if(HID_DEBUG) log_printf("And its no preset\n");
|
||||
std::vector<std::string> rightvalues = MyStringSplit(cur_values[1],",");
|
||||
|
||||
if(rightvalues.size() != 2){
|
||||
log_printf("%d instead of 2 key=values pairs in line\n",rightvalues.size());
|
||||
return;
|
||||
}
|
||||
|
||||
char * ptr;
|
||||
long firstValue = strtol(rightvalues[0].c_str(),&ptr,16);
|
||||
long secondValue = strtol(rightvalues[1].c_str(),&ptr,16);
|
||||
config_controller[hid_slot][keyslot][0] = firstValue;
|
||||
config_controller[hid_slot][keyslot][1] = secondValue;
|
||||
|
||||
if(HID_DEBUG) log_printf("Set %02X,%02X\n",firstValue,secondValue);
|
||||
}else{
|
||||
if(HID_DEBUG) log_printf("Found preset value!!\n");
|
||||
}
|
||||
}else{
|
||||
log_printf("The setting \"%s\" is unknown!\n",cur_values[0].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ConfigParser::resetConfig(){
|
||||
int slot = getSlot();
|
||||
if(slot >= gHIDMaxDevices) return false;
|
||||
for(int j = (CONTRPS_PID+1);j< CONTRPS_MAX_VALUE;j++){
|
||||
config_controller[slot][j][0] = CONTROLLER_PATCHER_INVALIDVALUE;
|
||||
config_controller[slot][j][1] = CONTROLLER_PATCHER_INVALIDVALUE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int ConfigParser::checkExistingController(int vid, int pid){
|
||||
for(int i = 0;i< gHIDMaxDevices;i++){
|
||||
u16 used_vid = config_controller[i][CONTRPS_VID][0] * 0x100 + config_controller[i][CONTRPS_VID][1];
|
||||
u16 used_pid = config_controller[i][CONTRPS_PID][0] * 0x100 + config_controller[i][CONTRPS_PID][1];
|
||||
if((used_vid == 0x00) && (used_vid == 0x00)){
|
||||
return -1;
|
||||
}
|
||||
if(vid == used_vid && pid == used_pid){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ConfigParser::getSlotController(std::string identify){
|
||||
if(HID_DEBUG) log_printf("Getting Controller Slot\n");
|
||||
|
||||
std::vector<std::string> values = MyStringSplit(identify,",");
|
||||
|
||||
if(values.size() != 2){
|
||||
log_printf("You need to provide a VID and PID. e.g. \"[vid=0x451,pid=0x152]\". (%s)\n",identify.c_str());
|
||||
return HID_INVALID_SLOT;
|
||||
}
|
||||
|
||||
int vid = getValueFromKeyValue(values[0],"VID","=");
|
||||
if(vid < 0){
|
||||
return HID_INVALID_SLOT;
|
||||
}
|
||||
int pid = getValueFromKeyValue(values[1],"PID","=");
|
||||
if(pid < 0){
|
||||
return HID_INVALID_SLOT;
|
||||
}
|
||||
log_printf("VID: %04x PID: %04x\n",vid,pid);
|
||||
|
||||
int slot = checkExistingController(vid,pid);
|
||||
int hid = 0;
|
||||
if(slot < 0){
|
||||
log_printf("Its a new controller, lets save it\n");
|
||||
slot = gHIDRegisteredDevices;
|
||||
hid = getNextDeviceSlot();
|
||||
if(slot >= gHIDMaxDevices){
|
||||
log_printf("We don't a space for a new controller, please delete .inis\n");
|
||||
return HID_INVALID_SLOT;
|
||||
}
|
||||
if(HID_DEBUG) log_printf("Got new slot! slot: %d hid %s .. Lets registrate it!\n",slot,byte_to_binary(hid));
|
||||
config_controller[slot][CONTRPS_VID][0] = (vid & 0xFF00) >> 8;
|
||||
config_controller[slot][CONTRPS_VID][1] = (vid & 0x00FF);
|
||||
config_controller[slot][CONTRPS_PID][0] = (pid & 0xFF00) >> 8;
|
||||
config_controller[slot][CONTRPS_PID][1] = (pid & 0x00FF);
|
||||
|
||||
u16 used_vid = config_controller[slot][CONTRPS_VID][0] * 0x100 + config_controller[slot][CONTRPS_VID][1];
|
||||
u16 used_pid = config_controller[slot][CONTRPS_PID][0] * 0x100 + config_controller[slot][CONTRPS_PID][1];
|
||||
|
||||
if(HID_DEBUG) log_printf("Saved vid: %04X pid: %04X\n",used_vid,used_pid);
|
||||
|
||||
config_controller_list[slot] = hid;
|
||||
|
||||
if(HID_DEBUG) log_printf("Saves the hid\n");
|
||||
config_controller_data_ptr[slot][0] = (u32)&(gHID_Devices[slot]).pad_data[0];
|
||||
config_controller_data_ptr[slot][1] = (u32)&(gHID_Devices[slot]).pad_data[1];
|
||||
config_controller_data_ptr[slot][2] = (u32)&(gHID_Devices[slot]).pad_data[2];
|
||||
config_controller_data_ptr[slot][3] = (u32)&(gHID_Devices[slot]).pad_data[3];
|
||||
|
||||
if(HID_DEBUG) log_printf("set data ptr\n");
|
||||
|
||||
}else{
|
||||
if(slot < gHIDMaxDevices){
|
||||
hid =config_controller_list[slot];
|
||||
if(HID_DEBUG) log_printf(">>>>>> found slot %d (hid:%s). Modifing existing data <<<<<<<<\n",slot,byte_to_binary(hid));
|
||||
log_printf("We already have data of this controller, lets modify it\n");
|
||||
}else{
|
||||
log_printf("Something really odd happend to the slots. %d is bigger then max (%d)\n",slot,gHIDMaxDevices);
|
||||
return HID_INVALID_SLOT;
|
||||
}
|
||||
}
|
||||
|
||||
if(HID_DEBUG) log_printf("using slot: %d hid %s\n",slot,byte_to_binary(hid));
|
||||
return slot;
|
||||
}
|
||||
|
||||
bool ConfigParser::parseIni(){
|
||||
if(getSlot() == HID_INVALID_SLOT){
|
||||
log_printf("Couldn't parse file. Not a valid slot. Probably broken config. Or you tried to have more than %d devices\n",getType(),gHIDMaxDevices);
|
||||
|
||||
}
|
||||
|
||||
if(HID_DEBUG) log_printf("Parsing content, type %d\n",getType());
|
||||
|
||||
int start = 1;
|
||||
if(contentLines[1].compare("[IGNOREDEFAULT]") == 0){
|
||||
resetConfig();
|
||||
log_printf("Overwriting existing settings of this device\n");
|
||||
start++;
|
||||
}
|
||||
|
||||
for(u32 i = start; i < contentLines.size(); i++){
|
||||
if(HID_DEBUG) log_printf("line %d: \"%s\" \n",(i+1),contentLines[i].c_str());
|
||||
parseSingleLine(contentLines[i]);
|
||||
}
|
||||
|
||||
log_printf("Parsing of the file is done.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
int ConfigParser::getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter){
|
||||
std::vector<std::string> string_value = MyStringSplit(value_pair,delimiter);
|
||||
if(string_value.size() != 2){
|
||||
if(HID_DEBUG || string_value.size() > 2) log_printf("Not a valid key=pair line %s\n",value_pair.c_str());
|
||||
return -1;
|
||||
}
|
||||
if(string_value[0].compare(expectedKey) != 0){
|
||||
log_printf("Key part not %s, its %s",expectedKey.c_str(),string_value[0].c_str());
|
||||
return -1;
|
||||
}
|
||||
char * ptr;
|
||||
int value = strtol(string_value[1].c_str(),&ptr,16);
|
||||
|
||||
return value;
|
||||
}
|
75
config_parser.h
Normal file
75
config_parser.h
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _ConfigParser_H_
|
||||
#define _ConfigParser_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "controller_patcher.h"
|
||||
#include "pad_const.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "cp_retain_vars.h"
|
||||
|
||||
enum PARSE_TYPE{
|
||||
PARSE_CONTROLLER,
|
||||
PARSE_GAMEPAD,
|
||||
PARSE_MOUSE,
|
||||
PARSE_KEYBOARD
|
||||
};
|
||||
|
||||
class ConfigParser
|
||||
{
|
||||
public:
|
||||
//!Constructor
|
||||
ConfigParser(std::string configData);
|
||||
//!Destructor
|
||||
~ConfigParser();
|
||||
|
||||
PARSE_TYPE getType();
|
||||
void setType(PARSE_TYPE newType);
|
||||
|
||||
u16 getSlot();
|
||||
void setSlot(u16 newSlot);
|
||||
|
||||
bool parseIni();
|
||||
|
||||
private:
|
||||
bool Init();
|
||||
|
||||
bool parseConfigString(std::string content);
|
||||
|
||||
int getSlotController(std::string identify);
|
||||
|
||||
int checkExistingController(int vid, int pid);
|
||||
|
||||
int getValueFromKeyValue(std::string value_pair,std::string expectedKey,std::string delimiter);
|
||||
|
||||
bool resetConfig();
|
||||
|
||||
void parseSingleLine(std::string line);
|
||||
u16 slot_b;
|
||||
PARSE_TYPE type_b;
|
||||
std::string content;
|
||||
std::vector<std::string> contentLines;
|
||||
};
|
||||
#endif
|
205
config_reader.cpp
Normal file
205
config_reader.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config_reader.h"
|
||||
#include "config_parser.h"
|
||||
#include "config_values.h"
|
||||
#include "string_tools.hpp"
|
||||
|
||||
int ConfigReader::numberValidFiles = 0;
|
||||
ConfigReader *ConfigReader::instance = NULL;
|
||||
|
||||
ConfigReader::ConfigReader()
|
||||
{
|
||||
InitOSFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
int status = 0;
|
||||
if((status = InitSDCard()) == 0){
|
||||
log_printf("SD Card mounted for controller config!\n");
|
||||
std::vector<std::string> fileList;
|
||||
if((fileList = ScanFolder()).size() > 0){
|
||||
log_printf("Found %d config files\n",fileList.size());
|
||||
processFileList(fileList);
|
||||
}
|
||||
}else{
|
||||
log_printf("SD mounting failed! %d\n",status);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigReader::processFileList(std::vector<std::string> path){
|
||||
for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); ++it) {
|
||||
log_printf("Reading %s\n",it->c_str());
|
||||
std::string result = loadFileToString(*it);
|
||||
|
||||
ConfigParser parser(result);
|
||||
parser.parseIni();
|
||||
}
|
||||
}
|
||||
|
||||
std::string ConfigReader::loadFileToString(std::string path){
|
||||
int handle = 0;
|
||||
int status = 0;
|
||||
std::string strBuffer;
|
||||
FSStat stats;
|
||||
if((status = FSGetStat(this->pClient,this->pCmd,path.c_str(),&stats,-1)) == FS_STATUS_OK){
|
||||
char * file = (char *) malloc((sizeof(char)*stats.size)+1);
|
||||
if(!file){
|
||||
log_print("Failed to allocate space for reading the file\n");
|
||||
return false;
|
||||
}
|
||||
file[stats.size] = '\0';
|
||||
if((status = FSOpenFile(this->pClient,this->pCmd,path.c_str(),"r",&handle,-1)) == FS_STATUS_OK){
|
||||
int total_read = 0;
|
||||
int ret2 = 0;
|
||||
while ((ret2 = FSReadFile(pClient, pCmd, file+total_read, 1, stats.size-total_read, handle, 0, FS_RET_ALL_ERROR)) > 0){
|
||||
total_read += ret2;
|
||||
}
|
||||
|
||||
}else{
|
||||
log_printf("(FSOpenFile) Couldn't open file (%s), error: %d",path.c_str(),status);
|
||||
free(file);
|
||||
file=NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
FSCloseFile(this->pClient,this->pCmd,handle,-1);
|
||||
|
||||
strBuffer = std::string(file);
|
||||
free(file);
|
||||
file = NULL;
|
||||
|
||||
//! remove all windows crap signs
|
||||
size_t position;
|
||||
while(1)
|
||||
{
|
||||
position = strBuffer.find('\r');
|
||||
if(position == std::string::npos)
|
||||
break;
|
||||
strBuffer.erase(position, 1);
|
||||
}
|
||||
while(1)
|
||||
{
|
||||
position = strBuffer.find(' ');
|
||||
if(position == std::string::npos)
|
||||
break;
|
||||
strBuffer.erase(position, 1);
|
||||
}
|
||||
while(1)
|
||||
{
|
||||
position = strBuffer.find('\t');
|
||||
if(position == std::string::npos)
|
||||
break;
|
||||
strBuffer.erase(position, 1);
|
||||
}
|
||||
}else{
|
||||
log_printf("(GetStat) Couldn't open file (%s), error: %d",path.c_str(),status);
|
||||
}
|
||||
|
||||
return strBuffer;
|
||||
}
|
||||
|
||||
|
||||
ConfigReader::~ConfigReader()
|
||||
{
|
||||
if(HID_DEBUG) log_printf("~ConfigReader\n");
|
||||
freeFSHandles();
|
||||
|
||||
if(HID_DEBUG) log_printf("~destroy the ConfigValues\n");
|
||||
ConfigValues::destroyInstance();
|
||||
}
|
||||
std::vector<std::string> ConfigReader::ScanFolder()
|
||||
{
|
||||
std::string path = std::string(CAFE_OS_SD_PATH) + std::string(WIIU_PATH) + "/controller";
|
||||
int dirhandle = 0;
|
||||
if(HID_DEBUG) log_printf("Opening %s\n",path.c_str());
|
||||
std::vector<std::string> config_files;
|
||||
if (this->pClient && this->pCmd){
|
||||
int status = 0;
|
||||
if((status = FSOpenDir(this->pClient,this->pCmd,path.c_str(),&dirhandle,-1)) == FS_STATUS_OK){
|
||||
FSDirEntry dir_entry;
|
||||
while (FSReadDir(this->pClient, this->pCmd, dirhandle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK){
|
||||
std::string full_path = path + "/" + dir_entry.name;
|
||||
if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) != FS_STAT_FLAG_IS_DIRECTORY){
|
||||
if(EndsWith(std::string(dir_entry.name),".ini")){
|
||||
config_files.push_back(full_path);
|
||||
if(HID_DEBUG) log_printf("%s \n",full_path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
FSCloseDir(this->pClient,this->pCmd,dirhandle,-1);
|
||||
}else{
|
||||
log_printf("Failed to open %s!\n",path.c_str());
|
||||
}
|
||||
}
|
||||
return config_files;
|
||||
}
|
||||
|
||||
void ConfigReader::freeFSHandles(){
|
||||
if(this->pClient != NULL){
|
||||
FSDelClient(this->pClient);
|
||||
free(this->pClient);
|
||||
this->pClient = NULL;
|
||||
}
|
||||
if(this->pCmd != NULL){
|
||||
free(this->pCmd);
|
||||
this->pCmd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ConfigReader::InitSDCard(){
|
||||
if(HID_DEBUG) log_printf("InitSDCard\n");
|
||||
|
||||
char mountSrc[FS_MOUNT_SOURCE_SIZE];
|
||||
char mountPath[FS_MAX_MOUNTPATH_SIZE];
|
||||
|
||||
freeFSHandles();
|
||||
|
||||
this->pClient = malloc(FS_CLIENT_SIZE);
|
||||
this->pCmd = malloc(FS_CMD_BLOCK_SIZE);
|
||||
|
||||
int status = 0;
|
||||
|
||||
if (this->pClient && this->pCmd)
|
||||
{
|
||||
// Do an FSInit first
|
||||
FSInit();
|
||||
// Add client to FS.
|
||||
FSAddClientEx(this->pClient, FS_RET_NO_ERROR,-1);
|
||||
|
||||
// Init command block.
|
||||
FSInitCmdBlock(this->pCmd);
|
||||
|
||||
// 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)
|
||||
{
|
||||
return 0;
|
||||
}else{
|
||||
log_printf("FSMount failed %d\n",status);
|
||||
return status;
|
||||
}
|
||||
}else{
|
||||
log_printf("FSGetMountSource failed %d\n",status);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
82
config_reader.h
Normal file
82
config_reader.h
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _ConfigReader_H_
|
||||
#define _ConfigReader_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "controller_patcher.h"
|
||||
#include "pad_const.h"
|
||||
|
||||
#include "../dynamic_libs/os_functions.h"
|
||||
#include "../dynamic_libs/fs_functions.h"
|
||||
#include "cp_retain_vars.h"
|
||||
|
||||
|
||||
|
||||
class ConfigReader
|
||||
{
|
||||
public:
|
||||
static ConfigReader *getInstance() {
|
||||
if(!instance)
|
||||
instance = new ConfigReader();
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void destroyInstance() {
|
||||
if(instance){
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int getNumberOfLoadedFiles(){
|
||||
return ConfigReader::numberValidFiles;
|
||||
}
|
||||
|
||||
static void increaseNumberOfLoadedFiles(){
|
||||
ConfigReader::numberValidFiles++;
|
||||
}
|
||||
static int numberValidFiles;
|
||||
|
||||
private:
|
||||
//!Constructor
|
||||
ConfigReader();
|
||||
//!Destructor
|
||||
~ConfigReader();
|
||||
|
||||
|
||||
int InitSDCard();
|
||||
void freeFSHandles();
|
||||
|
||||
void * pClient = NULL;
|
||||
void * pCmd = NULL;
|
||||
static ConfigReader *instance;
|
||||
|
||||
|
||||
|
||||
std::string loadFileToString(std::string path);
|
||||
void processFileList(std::vector<std::string> path);
|
||||
|
||||
std::vector<std::string> ScanFolder();
|
||||
};
|
||||
#endif
|
103
config_values.cpp
Normal file
103
config_values.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config_values.h"
|
||||
#include "utils/logger.h"
|
||||
#include "cp_retain_vars.h"
|
||||
|
||||
ConfigValues *ConfigValues::instance = NULL;
|
||||
|
||||
ConfigValues::ConfigValues()
|
||||
{
|
||||
InitValues();
|
||||
}
|
||||
|
||||
ConfigValues::~ConfigValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const u8 * ConfigValues::getValuesForPreset(std::map<std::string,const u8*> values,std::string possibleValue){
|
||||
std::map<std::string,const u8*>::iterator it;
|
||||
it = values.find(possibleValue);
|
||||
if (it != values.end()){
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ConfigValues::setIfValueIsAControllerPresetEx(std::string value,int slot,int keyslot){
|
||||
if(setIfValueIsPreset(presetGCValues,value,slot,keyslot)) return true;
|
||||
if(setIfValueIsPreset(presetDS3Values,value,slot,keyslot)) return true;
|
||||
if(setIfValueIsPreset(presetDS4Values,value,slot,keyslot)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//We need this function here so we can use preset sticks.
|
||||
bool ConfigValues::setIfValueIsPreset(std::map<std::string,const u8*> values,std::string possibleValue,int slot,int keyslot){
|
||||
const u8 * values_ = NULL;
|
||||
if( keyslot == CONTRPS_VPAD_BUTTON_L_STICK_X ||
|
||||
keyslot == CONTRPS_VPAD_BUTTON_L_STICK_Y ||
|
||||
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_X ||
|
||||
keyslot == CONTRPS_VPAD_BUTTON_R_STICK_Y){
|
||||
if(HID_DEBUG) log_printf("This may be a predefined stick %s\n",possibleValue.c_str());
|
||||
if((values_ = ConfigValues::getValuesStickPreset(possibleValue)) != NULL){
|
||||
if(HID_DEBUG) log_printf("Found predefined stick!\n");
|
||||
config_controller[slot][keyslot][0] = values_[STICK_CONF_BYTE]; //CONTRPS_VPAD_BUTTON_L_STICK_X
|
||||
config_controller[slot][keyslot][1] = values_[STICK_CONF_DEFAULT];
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_INVERT][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_INVERT][1] = values_[STICK_CONF_INVERT];
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_DEADZONE][0] = CONTROLLER_PATCHER_VALUE_SET; //CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_DEADZONE][1] = values_[STICK_CONF_DEADZONE];
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_MINMAX][0] = values_[STICK_CONF_MIN]; //CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX
|
||||
config_controller[slot][keyslot+DEF_STICK_OFFSET_MINMAX][1] = values_[STICK_CONF_MAX];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if((values_ = getValuesForPreset(values,possibleValue)) != NULL){
|
||||
config_controller[slot][keyslot][0] = values_[0];
|
||||
config_controller[slot][keyslot][1] = values_[1];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int ConfigValues::getValueFromMap(std::map<std::string,int> values,std::string nameOfString){
|
||||
std::map<std::string,int>::iterator it;
|
||||
it = values.find(nameOfString);
|
||||
if (it != values.end()){
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//Value not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ConfigValues::getPresetValueEx(std::string possibleString){
|
||||
int rightValue = -1;
|
||||
if((rightValue = getValueFromMap(gGamePadValuesToCONTRPSString,possibleString))!= -1){
|
||||
if(HID_DEBUG) log_printf("Used pre-defined VPAD_VALUE! \"%s\" is %d\n",possibleString.c_str(),rightValue);
|
||||
}else if((rightValue = getValueFromMap(presetValues,possibleString))!= -1){
|
||||
if(HID_DEBUG) log_printf("Used pre-defined value! \"%s\" is %d\n",possibleString.c_str(),rightValue);
|
||||
}
|
||||
return rightValue;
|
||||
}
|
473
config_values.h
Normal file
473
config_values.h
Normal file
@ -0,0 +1,473 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _ConfigValues_H_
|
||||
#define _ConfigValues_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "controller_patcher.h"
|
||||
#include "pad_const.h"
|
||||
|
||||
class ConfigValues
|
||||
{
|
||||
public:
|
||||
static ConfigValues *getInstance() {
|
||||
if(!instance)
|
||||
instance = new ConfigValues();
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void destroyInstance() {
|
||||
if(instance){
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Returns NULL if no a preset!
|
||||
**/
|
||||
static const u8 * getValuesStickPreset(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return NULL;
|
||||
return cur_instance->getValuesForPreset(cur_instance->presetSticks,possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getKeySlotGamePad(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue,possibleValue);
|
||||
}
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getKeySlotMouse(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getValueFromMap(cur_instance->mouseLeftValues,possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getKeySlotDefaultSingleValue(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValueSingle,possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getKeySlotDefaultPairedValue(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getValueFromMap(cur_instance->CONTPRStringToValue,possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getPresetValuesKeyboard(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getValueFromMap(cur_instance->presetKeyboardValues,possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int getPresetValue(std::string possibleValue)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->getPresetValueEx(possibleValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns -1 if not found
|
||||
**/
|
||||
static int setIfValueIsAControllerPreset(std::string value,int slot,int keyslot)
|
||||
{
|
||||
ConfigValues * cur_instance = getInstance();
|
||||
if(cur_instance == NULL) return -1;
|
||||
return cur_instance->setIfValueIsAControllerPresetEx(value,slot,keyslot);
|
||||
}
|
||||
|
||||
private:
|
||||
//!Constructor
|
||||
ConfigValues();
|
||||
//!Destructor
|
||||
~ConfigValues();
|
||||
|
||||
static ConfigValues *instance;
|
||||
|
||||
std::map<std::string,int> mouseLeftValues;
|
||||
std::map<std::string,int> CONTPRStringToValue;
|
||||
std::map<std::string,int> CONTPRStringToValueSingle;
|
||||
std::map<std::string,int> presetValues;
|
||||
std::map<std::string,int> gGamePadValuesToCONTRPSString;
|
||||
std::map<std::string,int> presetKeyboardValues;
|
||||
|
||||
std::map<std::string,const u8*> presetGCValues;
|
||||
std::map<std::string,const u8*> presetDS3Values;
|
||||
std::map<std::string,const u8*> presetDS4Values;
|
||||
std::map<std::string,const u8*> presetSticks;
|
||||
|
||||
int getValueFromMap(std::map<std::string,int> values,std::string nameOfString);
|
||||
|
||||
bool checkIfValueIsAControllerPreset(std::string value,int slot,int keyslot);
|
||||
|
||||
int getPresetValueEx(std::string possibleString);
|
||||
|
||||
void InitValues(){
|
||||
CONTPRStringToValue["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A;
|
||||
CONTPRStringToValue["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B;
|
||||
CONTPRStringToValue["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X;
|
||||
CONTPRStringToValue["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y;
|
||||
/* Normal DPAD */
|
||||
CONTPRStringToValue["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT;
|
||||
CONTPRStringToValue["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT;
|
||||
CONTPRStringToValue["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN;
|
||||
/* DPAD hat mode */
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_N"] = CONTRPS_VPAD_BUTTON_DPAD_N;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_NE"] = CONTRPS_VPAD_BUTTON_DPAD_NE;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_E"] = CONTRPS_VPAD_BUTTON_DPAD_E;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_SE"] = CONTRPS_VPAD_BUTTON_DPAD_SE;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_S"] = CONTRPS_VPAD_BUTTON_DPAD_S;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_SW"] = CONTRPS_VPAD_BUTTON_DPAD_SW;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_W"] = CONTRPS_VPAD_BUTTON_DPAD_W;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_NW"] = CONTRPS_VPAD_BUTTON_DPAD_NW;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_NEUTRAL"] = CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL;
|
||||
/* DPAD Absolute mode */
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_UP"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_UP;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_DOWN"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_DOWN;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_LEFT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_LEFT;
|
||||
CONTPRStringToValue["VPAD_BUTTON_DPAD_ABS_RIGHT"] = CONTRPS_VPAD_BUTTON_DPAD_ABS_RIGHT;
|
||||
/* */
|
||||
CONTPRStringToValue["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL;
|
||||
CONTPRStringToValue["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR;
|
||||
CONTPRStringToValue["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L;
|
||||
CONTPRStringToValue["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R;
|
||||
CONTPRStringToValue["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS;
|
||||
CONTPRStringToValue["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS;
|
||||
CONTPRStringToValue["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME;
|
||||
CONTPRStringToValue["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC;
|
||||
CONTPRStringToValue["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R;
|
||||
CONTPRStringToValue["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L;
|
||||
|
||||
/*
|
||||
CONTPRStringToValue["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT;
|
||||
CONTPRStringToValue["VPAD_STICK_R_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_R_EMULATION_RIGHT;
|
||||
CONTPRStringToValue["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP;
|
||||
CONTPRStringToValue["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN;
|
||||
CONTPRStringToValue["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT;
|
||||
CONTPRStringToValue["VPAD_STICK_L_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_L_EMULATION_RIGHT;
|
||||
CONTPRStringToValue["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP;
|
||||
CONTPRStringToValue["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN;*/
|
||||
|
||||
CONTPRStringToValue["VPAD_L_STICK_UP"] = DEF_L_STICK_UP;
|
||||
CONTPRStringToValue["VPAD_L_STICK_DOWN"] = DEF_L_STICK_DOWN;
|
||||
CONTPRStringToValue["VPAD_L_STICK_LEFT"] = DEF_L_STICK_LEFT;
|
||||
CONTPRStringToValue["VPAD_L_STICK_RIGHT"] = DEF_L_STICK_RIGHT;
|
||||
|
||||
CONTPRStringToValue["VPAD_R_STICK_UP"] = DEF_R_STICK_UP;
|
||||
CONTPRStringToValue["VPAD_R_STICK_DOWN"] = DEF_R_STICK_DOWN;
|
||||
CONTPRStringToValue["VPAD_R_STICK_LEFT"] = DEF_R_STICK_LEFT;
|
||||
CONTPRStringToValue["VPAD_R_STICK_RIGHT"] = DEF_R_STICK_RIGHT;
|
||||
|
||||
CONTPRStringToValue["VPAD_L_STICK_X"] = CONTRPS_VPAD_BUTTON_L_STICK_X;
|
||||
CONTPRStringToValue["VPAD_L_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX;
|
||||
CONTPRStringToValue["VPAD_L_STICK_Y"] = CONTRPS_VPAD_BUTTON_L_STICK_Y;
|
||||
CONTPRStringToValue["VPAD_L_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX;
|
||||
CONTPRStringToValue["VPAD_R_STICK_X"] = CONTRPS_VPAD_BUTTON_R_STICK_X;
|
||||
CONTPRStringToValue["VPAD_R_STICK_X_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX;
|
||||
CONTPRStringToValue["VPAD_R_STICK_Y"] = CONTRPS_VPAD_BUTTON_R_STICK_Y;
|
||||
CONTPRStringToValue["VPAD_R_STICK_Y_MINMAX"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX;
|
||||
CONTPRStringToValue["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV;
|
||||
|
||||
CONTPRStringToValue["DOUBLE_USE_BUTTON_ACTIVATOR"] = CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR,
|
||||
CONTPRStringToValue["INPUT_FILTER"] = CONTRPS_INPUT_FILTER;
|
||||
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_PRESSED"] = CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_1_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_2_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_3_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_4_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE_BUTTON_5_RELEASED"] = CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED;
|
||||
|
||||
CONTPRStringToValueSingle["BUF_SIZE"] = CONTRPS_BUF_SIZE;
|
||||
CONTPRStringToValueSingle["DPAD_MODE"] = CONTRPS_DPAD_MODE;
|
||||
CONTPRStringToValueSingle["DPAD_MASK"] = CONTRPS_DPAD_MASK;
|
||||
CONTPRStringToValueSingle["VPAD_L_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE;
|
||||
CONTPRStringToValueSingle["VPAD_L_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_DEADZONE;
|
||||
CONTPRStringToValueSingle["VPAD_R_STICK_X_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_X_DEADZONE;
|
||||
CONTPRStringToValueSingle["VPAD_R_STICK_Y_DEADZONE"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_DEADZONE;
|
||||
CONTPRStringToValueSingle["VPAD_L_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT;
|
||||
CONTPRStringToValueSingle["VPAD_L_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_INVERT;
|
||||
CONTPRStringToValueSingle["VPAD_R_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT;
|
||||
CONTPRStringToValueSingle["VPAD_R_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT;
|
||||
CONTPRStringToValueSingle["DOUBLE_USE"] = CONTRPS_DOUBLE_USE;
|
||||
CONTPRStringToValueSingle["PAD_COUNT"] = CONTRPS_PAD_COUNT;
|
||||
|
||||
|
||||
mouseLeftValues["LEFT_CLICK"] = CONTRPS_VPAD_BUTTON_LEFT;
|
||||
mouseLeftValues["RIGHT_CLICK"] = CONTRPS_VPAD_BUTTON_RIGHT;
|
||||
mouseLeftValues["EMULATED_STICK"] = CONTRPS_MOUSE_STICK;
|
||||
|
||||
|
||||
presetGCValues["GC_BUTTON_A"] = HID_GC_BUTTON_A;
|
||||
presetGCValues["GC_BUTTON_B"] = HID_GC_BUTTON_B;
|
||||
presetGCValues["GC_BUTTON_X"] = HID_GC_BUTTON_X;
|
||||
presetGCValues["GC_BUTTON_Y"] = HID_GC_BUTTON_Y;
|
||||
presetGCValues["GC_BUTTON_LEFT"] = HID_GC_BUTTON_LEFT;
|
||||
presetGCValues["GC_BUTTON_RIGHT"] = HID_GC_BUTTON_RIGHT;
|
||||
presetGCValues["GC_BUTTON_DOWN"] = HID_GC_BUTTON_DOWN;
|
||||
presetGCValues["GC_BUTTON_UP"] = HID_GC_BUTTON_UP;
|
||||
presetGCValues["GC_BUTTON_START"] = HID_GC_BUTTON_START;
|
||||
presetGCValues["GC_BUTTON_Z"] = HID_GC_BUTTON_Z;
|
||||
presetGCValues["GC_BUTTON_L"] = HID_GC_BUTTON_L;
|
||||
presetGCValues["GC_BUTTON_R"] = HID_GC_BUTTON_R;
|
||||
|
||||
presetDS3Values["DS3_BUTTON_CROSS"] = HID_DS3_BUTTON_CROSS;
|
||||
presetDS3Values["DS3_BUTTON_CIRCLE"] = HID_DS3_BUTTON_CIRCLE;
|
||||
presetDS3Values["DS3_BUTTON_SQUARE"] = HID_DS3_BUTTON_SQUARE;
|
||||
presetDS3Values["DS3_BUTTON_TRIANGLE"] = HID_DS3_BUTTON_TRIANGLE;
|
||||
|
||||
presetDS3Values["DS3_BUTTON_L1"] = HID_DS3_BUTTON_L1;
|
||||
presetDS3Values["DS3_BUTTON_L2"] = HID_DS3_BUTTON_L2;
|
||||
presetDS3Values["DS3_BUTTON_L3"] = HID_DS3_BUTTON_L3;
|
||||
presetDS3Values["DS3_BUTTON_R1"] = HID_DS3_BUTTON_R1;
|
||||
presetDS3Values["DS3_BUTTON_R2"] = HID_DS3_BUTTON_R2;
|
||||
presetDS3Values["DS3_BUTTON_R3"] = HID_DS3_BUTTON_R3;
|
||||
|
||||
presetDS3Values["DS3_BUTTON_SELECT"] = HID_DS3_BUTTON_SELECT;
|
||||
presetDS3Values["DS3_BUTTON_START"] = HID_DS3_BUTTON_START;
|
||||
presetDS3Values["DS3_BUTTON_LEFT"] = HID_DS3_BUTTON_LEFT;
|
||||
presetDS3Values["DS3_BUTTON_RIGHT"] = HID_DS3_BUTTON_RIGHT;
|
||||
presetDS3Values["DS3_BUTTON_UP"] = HID_DS3_BUTTON_UP;
|
||||
presetDS3Values["DS3_BUTTON_DOWN"] = HID_DS3_BUTTON_DOWN;
|
||||
presetDS3Values["DS3_BUTTON_GUIDE"] = HID_DS3_BUTTON_GUIDE;
|
||||
|
||||
presetDS4Values["DS4_BUTTON_CROSS"] = HID_DS4_BUTTON_CROSS;
|
||||
presetDS4Values["DS4_BUTTON_CIRCLE"] = HID_DS4_BUTTON_CIRCLE;
|
||||
presetDS4Values["DS4_BUTTON_SQUARE"] = HID_DS4_BUTTON_SQUARE;
|
||||
presetDS4Values["DS4_BUTTON_TRIANGLE"] = HID_DS4_BUTTON_TRIANGLE;
|
||||
|
||||
presetDS4Values["DS4_BUTTON_L1"] = HID_DS4_BUTTON_L1;
|
||||
presetDS4Values["DS4_BUTTON_L2"] = HID_DS4_BUTTON_L2;
|
||||
presetDS4Values["DS4_BUTTON_L3"] = HID_DS4_BUTTON_L3;
|
||||
presetDS4Values["DS4_BUTTON_R1"] = HID_DS4_BUTTON_R1;
|
||||
presetDS4Values["DS4_BUTTON_R2"] = HID_DS4_BUTTON_R2;
|
||||
presetDS4Values["DS4_BUTTON_R3"] = HID_DS4_BUTTON_R3;
|
||||
|
||||
presetDS4Values["DS4_BUTTON_SHARE"] = HID_DS4_BUTTON_SHARE;
|
||||
presetDS4Values["DS4_BUTTON_OPTIONS"] = HID_DS4_BUTTON_OPTIONS;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_TYPE"] = HID_DS4_BUTTON_DPAD_TYPE;
|
||||
|
||||
presetDS4Values["DS4_BUTTON_DPAD_N"] = HID_DS4_BUTTON_DPAD_N;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_NE"] = HID_DS4_BUTTON_DPAD_NE;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_E"] = HID_DS4_BUTTON_DPAD_E;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_SE"] = HID_DS4_BUTTON_DPAD_SE;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_S"] = HID_DS4_BUTTON_DPAD_S;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_SW"] = HID_DS4_BUTTON_DPAD_SW;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_W"] = HID_DS4_BUTTON_DPAD_W;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_NW"] = HID_DS4_BUTTON_DPAD_NW;
|
||||
presetDS4Values["DS4_BUTTON_DPAD_NEUTRAL"] = HID_DS4_BUTTON_DPAD_NEUTRAL;
|
||||
|
||||
presetDS4Values["DS4_BUTTON_GUIDE"] = HID_DS4_BUTTON_GUIDE;
|
||||
presetDS4Values["DS4_BUTTON_T_PAD_CLICK"] = HID_DS4_BUTTON_T_PAD_CLICK;
|
||||
|
||||
presetKeyboardValues["KEYBOARD_SHIFT"] = HID_KEYBOARD_BUTTON_SHIFT;
|
||||
presetKeyboardValues["KEYBOARD_A"] = HID_KEYBOARD_BUTTON_A;
|
||||
presetKeyboardValues["KEYBOARD_B"] = HID_KEYBOARD_BUTTON_B;
|
||||
presetKeyboardValues["KEYBOARD_C"] = HID_KEYBOARD_BUTTON_C;
|
||||
presetKeyboardValues["KEYBOARD_D"] = HID_KEYBOARD_BUTTON_D;
|
||||
presetKeyboardValues["KEYBOARD_E"] = HID_KEYBOARD_BUTTON_E;
|
||||
presetKeyboardValues["KEYBOARD_F"] = HID_KEYBOARD_BUTTON_F;
|
||||
presetKeyboardValues["KEYBOARD_G"] = HID_KEYBOARD_BUTTON_G;
|
||||
presetKeyboardValues["KEYBOARD_H"] = HID_KEYBOARD_BUTTON_H;
|
||||
presetKeyboardValues["KEYBOARD_I"] = HID_KEYBOARD_BUTTON_I;
|
||||
presetKeyboardValues["KEYBOARD_J"] = HID_KEYBOARD_BUTTON_J;
|
||||
presetKeyboardValues["KEYBOARD_K"] = HID_KEYBOARD_BUTTON_K;
|
||||
presetKeyboardValues["KEYBOARD_L"] = HID_KEYBOARD_BUTTON_L;
|
||||
presetKeyboardValues["KEYBOARD_M"] = HID_KEYBOARD_BUTTON_M;
|
||||
presetKeyboardValues["KEYBOARD_N"] = HID_KEYBOARD_BUTTON_N;
|
||||
presetKeyboardValues["KEYBOARD_O"] = HID_KEYBOARD_BUTTON_O;
|
||||
presetKeyboardValues["KEYBOARD_P"] = HID_KEYBOARD_BUTTON_P;
|
||||
presetKeyboardValues["KEYBOARD_Q"] = HID_KEYBOARD_BUTTON_Q;
|
||||
presetKeyboardValues["KEYBOARD_R"] = HID_KEYBOARD_BUTTON_R;
|
||||
presetKeyboardValues["KEYBOARD_S"] = HID_KEYBOARD_BUTTON_S;
|
||||
presetKeyboardValues["KEYBOARD_T"] = HID_KEYBOARD_BUTTON_T;
|
||||
presetKeyboardValues["KEYBOARD_U"] = HID_KEYBOARD_BUTTON_U;
|
||||
presetKeyboardValues["KEYBOARD_V"] = HID_KEYBOARD_BUTTON_V;
|
||||
presetKeyboardValues["KEYBOARD_W"] = HID_KEYBOARD_BUTTON_W;
|
||||
presetKeyboardValues["KEYBOARD_X"] = HID_KEYBOARD_BUTTON_X;
|
||||
presetKeyboardValues["KEYBOARD_Y"] = HID_KEYBOARD_BUTTON_Y;
|
||||
presetKeyboardValues["KEYBOARD_Z"] = HID_KEYBOARD_BUTTON_Z;
|
||||
presetKeyboardValues["KEYBOARD_F1"] = HID_KEYBOARD_BUTTON_F1;
|
||||
presetKeyboardValues["KEYBOARD_F2"] = HID_KEYBOARD_BUTTON_F2;
|
||||
presetKeyboardValues["KEYBOARD_F3"] = HID_KEYBOARD_BUTTON_F3;
|
||||
presetKeyboardValues["KEYBOARD_F4"] = HID_KEYBOARD_BUTTON_F4;
|
||||
presetKeyboardValues["KEYBOARD_F5"] = HID_KEYBOARD_BUTTON_F5;
|
||||
presetKeyboardValues["KEYBOARD_F6"] = HID_KEYBOARD_BUTTON_F6;
|
||||
presetKeyboardValues["KEYBOARD_F7"] = HID_KEYBOARD_BUTTON_F7;
|
||||
presetKeyboardValues["KEYBOARD_F8"] = HID_KEYBOARD_BUTTON_F8;
|
||||
presetKeyboardValues["KEYBOARD_F9"] = HID_KEYBOARD_BUTTON_F9;
|
||||
presetKeyboardValues["KEYBOARD_F10"] = HID_KEYBOARD_BUTTON_F10;
|
||||
presetKeyboardValues["KEYBOARD_F11"] = HID_KEYBOARD_BUTTON_F11;
|
||||
presetKeyboardValues["KEYBOARD_F12"] = HID_KEYBOARD_BUTTON_F12;
|
||||
presetKeyboardValues["KEYBOARD_1"] = HID_KEYBOARD_BUTTON_1;
|
||||
presetKeyboardValues["KEYBOARD_2"] = HID_KEYBOARD_BUTTON_2;
|
||||
presetKeyboardValues["KEYBOARD_3"] = HID_KEYBOARD_BUTTON_3;
|
||||
presetKeyboardValues["KEYBOARD_4"] = HID_KEYBOARD_BUTTON_4;
|
||||
presetKeyboardValues["KEYBOARD_5"] = HID_KEYBOARD_BUTTON_5;
|
||||
presetKeyboardValues["KEYBOARD_6"] = HID_KEYBOARD_BUTTON_6;
|
||||
presetKeyboardValues["KEYBOARD_7"] = HID_KEYBOARD_BUTTON_7;
|
||||
presetKeyboardValues["KEYBOARD_8"] = HID_KEYBOARD_BUTTON_8;
|
||||
presetKeyboardValues["KEYBOARD_9"] = HID_KEYBOARD_BUTTON_9;
|
||||
presetKeyboardValues["KEYBOARD_0"] = HID_KEYBOARD_BUTTON_0;
|
||||
|
||||
presetKeyboardValues["KEYBOARD_RETURN"] = HID_KEYBOARD_BUTTON_RETURN;
|
||||
presetKeyboardValues["KEYBOARD_ESCAPE"] = HID_KEYBOARD_BUTTON_ESCAPE;
|
||||
presetKeyboardValues["KEYBOARD_DELETE"] = HID_KEYBOARD_BUTTON_DELETE;
|
||||
presetKeyboardValues["KEYBOARD_TAB"] = HID_KEYBOARD_BUTTON_TAB;
|
||||
presetKeyboardValues["KEYBOARD_SPACEBAR"] = HID_KEYBOARD_BUTTON_SPACEBAR;
|
||||
presetKeyboardValues["KEYBOARD_CAPSLOCK"] = HID_KEYBOARD_BUTTON_CAPSLOCK;
|
||||
presetKeyboardValues["KEYBOARD_PRINTSCREEN"] = HID_KEYBOARD_BUTTON_PRINTSCREEN;
|
||||
presetKeyboardValues["KEYBOARD_SCROLLLOCK"] = HID_KEYBOARD_BUTTON_SCROLLLOCK;
|
||||
presetKeyboardValues["KEYBOARD_PAUSE"] = HID_KEYBOARD_BUTTON_PAUSE;
|
||||
presetKeyboardValues["KEYBOARD_INSERT"] = HID_KEYBOARD_BUTTON_INSERT;
|
||||
presetKeyboardValues["KEYBOARD_HOME"] = HID_KEYBOARD_BUTTON_HOME;
|
||||
presetKeyboardValues["KEYBOARD_PAGEUP"] = HID_KEYBOARD_BUTTON_PAGEUP;
|
||||
presetKeyboardValues["KEYBOARD_PAGEDOWN"] = HID_KEYBOARD_BUTTON_PAGEDOWN;
|
||||
presetKeyboardValues["KEYBOARD_DELETEFORWARD"] = HID_KEYBOARD_BUTTON_DELETEFORWARD;
|
||||
presetKeyboardValues["KEYBOARD_LEFT_CONTROL"] = HID_KEYBOARD_BUTTON_LEFT_CONTROL;
|
||||
presetKeyboardValues["KEYBOARD_LEFT_ALT"] = HID_KEYBOARD_BUTTON_LEFT_ALT;
|
||||
presetKeyboardValues["KEYBOARD_RIGHT_CONTROL"] = HID_KEYBOARD_BUTTON_RIGHT_CONTROL;
|
||||
presetKeyboardValues["KEYBOARD_RIGHT_SHIFT"] = HID_KEYBOARD_BUTTON_RIGHT_SHIFT;
|
||||
presetKeyboardValues["KEYBOARD_RIGHT_ALT"] = HID_KEYBOARD_BUTTON_RIGHT_ALT;
|
||||
presetKeyboardValues["KEYBOARD_END"] = HID_KEYBOARD_BUTTON_END;
|
||||
|
||||
presetKeyboardValues["KEYBOARD_LEFT"] = HID_KEYBOARD_BUTTON_LEFT;
|
||||
presetKeyboardValues["KEYBOARD_RIGHT"] = HID_KEYBOARD_BUTTON_RIGHT;
|
||||
presetKeyboardValues["KEYBOARD_DOWN"] = HID_KEYBOARD_BUTTON_DOWN;
|
||||
presetKeyboardValues["KEYBOARD_UP"] = HID_KEYBOARD_BUTTON_UP;
|
||||
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_1"] = HID_KEYBOARD_KEYPAD_BUTTON_1;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_2"] = HID_KEYBOARD_KEYPAD_BUTTON_2;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_3"] = HID_KEYBOARD_KEYPAD_BUTTON_3;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_4"] = HID_KEYBOARD_KEYPAD_BUTTON_4;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_5"] = HID_KEYBOARD_KEYPAD_BUTTON_5;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_6"] = HID_KEYBOARD_KEYPAD_BUTTON_6;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_7"] = HID_KEYBOARD_KEYPAD_BUTTON_7;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_8"] = HID_KEYBOARD_KEYPAD_BUTTON_8;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_9"] = HID_KEYBOARD_KEYPAD_BUTTON_9;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_0"] = HID_KEYBOARD_KEYPAD_BUTTON_0;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_NUMLOCK"] = HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_MINUS"] = HID_KEYBOARD_KEYPAD_BUTTON_MINUS;
|
||||
presetKeyboardValues["KEYBOARD_KEYPAD_PLUS"] = HID_KEYBOARD_KEYPAD_BUTTON_PLUS;
|
||||
|
||||
presetValues["VPAD_L_STICK"] = DEF_L_STICK;
|
||||
presetValues["VPAD_R_STICK"] = DEF_R_STICK;
|
||||
|
||||
presetValues["DPAD_NORMAL"] = CONTRPDM_Normal;
|
||||
presetValues["DPAD_HAT"] = CONTRPDM_Hat;
|
||||
presetValues["DPAD_ABSOLUTE_2VALUES"] = CONTRPDM_Absolute_2Values;
|
||||
presetValues["TRUE"] = 1;
|
||||
presetValues["YES"] = 1;
|
||||
presetValues["ON"] = 1;
|
||||
presetValues["FALSE"] = 0;
|
||||
presetValues["NO"] = 0;
|
||||
presetValues["OFF"] = 0;
|
||||
|
||||
presetSticks["GC_STICK_L_X"] = HID_GC_STICK_L_X;
|
||||
presetSticks["GC_STICK_L_Y"] = HID_GC_STICK_L_Y;
|
||||
presetSticks["GC_STICK_R_X"] = HID_GC_STICK_R_X;
|
||||
presetSticks["GC_STICK_R_Y"] = HID_GC_STICK_R_Y;
|
||||
|
||||
presetSticks["DS3_STICK_L_X"] = HID_DS3_STICK_L_X;
|
||||
presetSticks["DS3_STICK_L_Y"] = HID_DS3_STICK_L_Y;
|
||||
presetSticks["DS3_STICK_R_X"] = HID_DS3_STICK_R_X;
|
||||
presetSticks["DS3_STICK_R_Y"] = HID_DS3_STICK_R_Y;
|
||||
|
||||
presetSticks["DS4_STICK_L_X"] = HID_DS4_STICK_L_X;
|
||||
presetSticks["DS4_STICK_L_Y"] = HID_DS4_STICK_L_Y;
|
||||
presetSticks["DS4_STICK_R_X"] = HID_DS4_STICK_R_X;
|
||||
presetSticks["DS4_STICK_R_Y"] = HID_DS4_STICK_R_Y;
|
||||
|
||||
presetSticks["GC_DPAD_MODE"] = HID_GC_BUTTON_DPAD_TYPE;
|
||||
presetSticks["DS3_DPAD_MODE"] = HID_DS3_BUTTON_DPAD_TYPE;
|
||||
presetSticks["DS4_DPAD_MODE"] = HID_DS4_BUTTON_DPAD_TYPE;
|
||||
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_B"] = CONTRPS_VPAD_BUTTON_B;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_X"] = CONTRPS_VPAD_BUTTON_X;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_Y"] = CONTRPS_VPAD_BUTTON_Y;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_LEFT"] = CONTRPS_VPAD_BUTTON_LEFT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_RIGHT"] = CONTRPS_VPAD_BUTTON_RIGHT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_UP"] = CONTRPS_VPAD_BUTTON_UP;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_DOWN"] = CONTRPS_VPAD_BUTTON_DOWN;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZL"] = CONTRPS_VPAD_BUTTON_ZL;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_ZR"] = CONTRPS_VPAD_BUTTON_ZR;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_L"] = CONTRPS_VPAD_BUTTON_L;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_R"] = CONTRPS_VPAD_BUTTON_R;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_PLUS"] = CONTRPS_VPAD_BUTTON_PLUS;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_MINUS"] = CONTRPS_VPAD_BUTTON_MINUS;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_HOME"] = CONTRPS_VPAD_BUTTON_HOME;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_SYNC"] = CONTRPS_VPAD_BUTTON_SYNC;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_R"] = CONTRPS_VPAD_BUTTON_STICK_R;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_STICK_L"] = CONTRPS_VPAD_BUTTON_STICK_L;
|
||||
gGamePadValuesToCONTRPSString["VPAD_BUTTON_TV"] = CONTRPS_VPAD_BUTTON_TV;
|
||||
|
||||
/*
|
||||
//Todo: think about removing it
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_R_EMULATION_LEFT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_R_EMULATION_RIGHT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_UP"] = CONTRPS_VPAD_STICK_R_EMULATION_UP;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_R_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_R_EMULATION_DOWN;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_LEFT"] = CONTRPS_VPAD_STICK_L_EMULATION_LEFT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_RIGHT"] = CONTRPS_VPAD_STICK_L_EMULATION_RIGHT;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_UP"] = CONTRPS_VPAD_STICK_L_EMULATION_UP;
|
||||
gGamePadValuesToCONTRPSString["VPAD_STICK_L_EMULATION_DOWN"] = CONTRPS_VPAD_STICK_L_EMULATION_DOWN;
|
||||
*/
|
||||
}
|
||||
|
||||
const u8 * getValuesForPreset(std::map<std::string,const u8*> values,std::string possibleValue);
|
||||
|
||||
bool setIfValueIsPreset(std::map<std::string,const u8*> values,std::string possibleValue,int slot,int keyslot);
|
||||
bool setIfValueIsAControllerPresetEx(std::string value,int slot,int keyslot);
|
||||
|
||||
};
|
||||
#endif
|
1340
controller_patcher.c
1340
controller_patcher.c
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,20 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _CONTROLLER_PATCHER_H_
|
||||
#define _CONTROLLER_PATCHER_H_
|
||||
|
||||
@ -11,33 +28,30 @@ extern "C" {
|
||||
#include "dynamic_libs/syshid_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
|
||||
#define HID_DEBUG 0
|
||||
|
||||
typedef int HID_DEVICE_LIST;
|
||||
#define HID_ALL_CONNECTED_DEVICES 0x10
|
||||
|
||||
#define HID_INIT_DONE 1
|
||||
#define HID_SDCARD_READ 2
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Don't forget to change this data!
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
enum Controller_Patcher_Devices
|
||||
enum Controller_Stick_Defines
|
||||
{
|
||||
CONTRPD_GC,
|
||||
CONTRPD_DS3,
|
||||
CONTRPD_DS4,
|
||||
CONTRPD_SP2600,
|
||||
CONTRPD_KEYBOARD,
|
||||
CONTRPD_PS2_ADAPTER,
|
||||
CONTRPD_POKKEN,
|
||||
CONTRPD_PS2,
|
||||
CONTRPD_MAX_VALUE
|
||||
STICK_CONF_MAGIC_VERSION,
|
||||
STICK_CONF_BYTE,
|
||||
STICK_CONF_DEFAULT,
|
||||
STICK_CONF_DEADZONE,
|
||||
STICK_CONF_INVERT,
|
||||
STICK_CONF_MIN,
|
||||
STICK_CONF_MAX,
|
||||
STICK_CONF_ENUM_MAXVALUE
|
||||
};
|
||||
|
||||
#define HID_LIST_GC 0x001
|
||||
#define HID_LIST_KEYBOARD 0x002
|
||||
#define HID_LIST_MOUSE 0x004
|
||||
#define HID_LIST_DS3 0x008
|
||||
#define HID_LIST_DS4 0x010
|
||||
#define HID_LIST_SP2600 0x020
|
||||
#define HID_LIST_PS2_ADAPTER 0x040
|
||||
#define HID_LIST_POKKEN 0x080
|
||||
#define HID_LIST_PS2 0x100
|
||||
#define STICK_CONF_MAGIC_VALUE 0xF0 // When you change the enum above, Dont forget to change the magic version!!!!
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! End
|
||||
@ -56,7 +70,7 @@ enum Controller_Patcher_Settings
|
||||
{
|
||||
CONTRPS_VID, //! pid: 0x451d would be 0x45,0x1d
|
||||
CONTRPS_PID, //! vid: 0x488d would be 0x48,0x8d
|
||||
CONTRPS_BUF_SIZE, //! To invert: CONTROLLER_PATCHER_VALUE_SET, BUF_SIZE (default is 64)
|
||||
CONTRPS_BUF_SIZE, //! To set: CONTROLLER_PATCHER_VALUE_SET, BUF_SIZE (default is 64)
|
||||
CONTRPS_VPAD_BUTTON_A,
|
||||
CONTRPS_VPAD_BUTTON_B,
|
||||
CONTRPS_VPAD_BUTTON_X,
|
||||
@ -78,6 +92,11 @@ enum Controller_Patcher_Settings
|
||||
CONTRPS_VPAD_BUTTON_DPAD_W,
|
||||
CONTRPS_VPAD_BUTTON_DPAD_NW,
|
||||
CONTRPS_VPAD_BUTTON_DPAD_NEUTRAL,
|
||||
/* DPAD Absolute mode */
|
||||
CONTRPS_VPAD_BUTTON_DPAD_ABS_UP,
|
||||
CONTRPS_VPAD_BUTTON_DPAD_ABS_DOWN,
|
||||
CONTRPS_VPAD_BUTTON_DPAD_ABS_LEFT,
|
||||
CONTRPS_VPAD_BUTTON_DPAD_ABS_RIGHT,
|
||||
/* */
|
||||
CONTRPS_VPAD_BUTTON_ZL,
|
||||
CONTRPS_VPAD_BUTTON_ZR,
|
||||
@ -89,6 +108,20 @@ enum Controller_Patcher_Settings
|
||||
CONTRPS_VPAD_BUTTON_SYNC,
|
||||
CONTRPS_VPAD_BUTTON_STICK_R,
|
||||
CONTRPS_VPAD_BUTTON_STICK_L,
|
||||
|
||||
/*
|
||||
Currently not needed
|
||||
|
||||
CONTRPS_VPAD_STICK_R_EMULATION_LEFT,
|
||||
CONTRPS_VPAD_STICK_R_EMULATION_RIGHT,
|
||||
CONTRPS_VPAD_STICK_R_EMULATION_UP,
|
||||
CONTRPS_VPAD_STICK_R_EMULATION_DOWN,
|
||||
CONTRPS_VPAD_STICK_L_EMULATION_LEFT,
|
||||
CONTRPS_VPAD_STICK_L_EMULATION_RIGHT,
|
||||
CONTRPS_VPAD_STICK_L_EMULATION_UP,
|
||||
CONTRPS_VPAD_STICK_L_EMULATION_DOWN,
|
||||
|
||||
*/
|
||||
CONTRPS_VPAD_BUTTON_L_STICK_X, //! byte, default value
|
||||
CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT, //! To invert: CONTROLLER_PATCHER_VALUE_SET, 0x01
|
||||
CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE, //! Deadzone
|
||||
@ -107,15 +140,33 @@ enum Controller_Patcher_Settings
|
||||
CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX, //! min,max
|
||||
CONTRPS_VPAD_BUTTON_TV,
|
||||
CONTRPS_DOUBLE_USE, //!When used: e.g. CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE
|
||||
CONTRPS_DOUBLE_USE_BUTTON,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_1_PRESSED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_2_PRESSED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_3_PRESSED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_4_PRESSED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_5_PRESSED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_1_RELEASED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_2_RELEASED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_3_RELEASED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_4_RELEASED,
|
||||
CONTRPS_DOUBLE_USE_BUTTON_5_RELEASED,
|
||||
CONTRPS_PAD_COUNT, //!
|
||||
CONTRPS_INPUT_FILTER, //!
|
||||
CONTRPS_MOUSE_STICK,
|
||||
CONTRPS_MAX_VALUE
|
||||
};
|
||||
|
||||
enum Controller_Patcher_DPAD_MODE
|
||||
{
|
||||
CONTRPDM_Normal,
|
||||
CONTRPDM_Hat
|
||||
CONTRPDM_Hat,
|
||||
CONTRPDM_Absolute_2Values,
|
||||
};
|
||||
enum Controller_Patcher_DPAD_Settings
|
||||
{
|
||||
CONTRDPAD_MODE,
|
||||
CONTRDPAD_MASK,
|
||||
};
|
||||
|
||||
#define CONTROLLER_PATCHER_VALUE_SET 0x01
|
||||
@ -145,33 +196,42 @@ typedef struct _HID_Data_Struct{
|
||||
|
||||
void setConfigValue(u8 * dest , u8 first, u8 second);
|
||||
void init_config_controller();
|
||||
void init_button_remapping();
|
||||
void deinit_config_controller();
|
||||
u32 getNextDeviceSlot();
|
||||
void printButtons(VPADData * buffer);
|
||||
void buttonRemapping(VPADData * buffer);
|
||||
void setButtonRemappingData(VPADData * buffer, VPADData * new_data,u32 VPADButton, int CONTRPS_Value);
|
||||
void setHoldButtonData(VPADData * buffer, VPADData * new_data,u32 oldVPADButton,u32 newVPADButton);
|
||||
|
||||
void setControllerReleasePressData(HID_Data_Struct data_cur, HID_Data_Struct data_last,VPADData * buffer,int VPADButton);
|
||||
void setControllerDataFromHID(VPADData * buffer,int hid);
|
||||
void setControllerDataFromHID(VPADData * buffer,HID_DEVICE_LIST hid_devices);
|
||||
int checkDoubleUseGC();
|
||||
void checkMouseMode(HID_Data_Struct data, HID_Data_Struct data_last);
|
||||
|
||||
void my_read_cb(unsigned int handle, int error, unsigned char *buf, unsigned int bytes_transfered, void *p_user);
|
||||
|
||||
int wasInKeyboard(unsigned char * src,int key);
|
||||
|
||||
const char *byte_to_binary(int x);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! GC-Adapter
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//A config would be cleaner, but no motivation atm :P
|
||||
#define HID_GC_BUTTON_A 0x01
|
||||
#define HID_GC_BUTTON_B 0x02
|
||||
#define HID_GC_BUTTON_X 0x04
|
||||
#define HID_GC_BUTTON_Y 0x08
|
||||
#define HID_GC_BUTTON_LEFT 0x10
|
||||
#define HID_GC_BUTTON_RIGHT 0x20
|
||||
#define HID_GC_BUTTON_DOWN 0x40
|
||||
#define HID_GC_BUTTON_UP 0x80
|
||||
#define HID_GC_BUTTON_START 0x01
|
||||
#define HID_GC_BUTTON_L 0x80
|
||||
#define HID_GC_BUTTON_R 0x80
|
||||
#define HID_GC_BUTTON_Z 0x02
|
||||
#define HID_GC_BUTTON_A_VALUE 0x01
|
||||
#define HID_GC_BUTTON_B_VALUE 0x02
|
||||
#define HID_GC_BUTTON_X_VALUE 0x04
|
||||
#define HID_GC_BUTTON_Y_VALUE 0x08
|
||||
#define HID_GC_BUTTON_LEFT_VALUE 0x10
|
||||
#define HID_GC_BUTTON_RIGHT_VALUE 0x20
|
||||
#define HID_GC_BUTTON_DOWN_VALUE 0x40
|
||||
#define HID_GC_BUTTON_UP_VALUE 0x80
|
||||
|
||||
#define HID_GC_BUTTON_START_VALUE 0x01
|
||||
#define HID_GC_BUTTON_L_VALUE 0x80
|
||||
#define HID_GC_BUTTON_R_VALUE 0x80
|
||||
#define HID_GC_BUTTON_Z_VALUE 0x02
|
||||
|
||||
#define HID_GC_PAD_COUNT 4
|
||||
|
||||
@ -191,24 +251,25 @@ void my_gc_write_cb(unsigned int handle, int error, unsigned char *buf, unsigned
|
||||
#define PS3_01_REPORT_ID 0x01
|
||||
#define PS3_F5_REPORT_ID 0xF5
|
||||
|
||||
#define HID_DS3_BUTTON_CROSS 0x40 // 3
|
||||
#define HID_DS3_BUTTON_CIRCLE 0x20 // 3
|
||||
#define HID_DS3_BUTTON_SQUARE 0x80 // 3
|
||||
#define HID_DS3_BUTTON_TRIANGLE 0x10 // 3
|
||||
#define HID_DS3_BUTTON_L1 0x04 // 3
|
||||
#define HID_DS3_BUTTON_L2 0x01 // 3
|
||||
#define HID_DS3_BUTTON_R1 0x08 // 3
|
||||
#define HID_DS3_BUTTON_R2 0x02 // 3
|
||||
#define HID_DS3_BUTTON_CROSS_VALUE 0x40 // 3
|
||||
#define HID_DS3_BUTTON_CIRCLE_VALUE 0x20 // 3
|
||||
#define HID_DS3_BUTTON_SQUARE_VALUE 0x80 // 3
|
||||
#define HID_DS3_BUTTON_TRIANGLE_VALUE 0x10 // 3
|
||||
#define HID_DS3_BUTTON_L1_VALUE 0x04 // 3
|
||||
#define HID_DS3_BUTTON_L2_VALUE 0x01 // 3
|
||||
#define HID_DS3_BUTTON_R1_VALUE 0x08 // 3
|
||||
#define HID_DS3_BUTTON_R2_VALUE 0x02 // 3
|
||||
|
||||
#define HID_DS3_BUTTON_L3_VALUE 0x02 // 2
|
||||
#define HID_DS3_BUTTON_R3_VALUE 0x04 // 2
|
||||
#define HID_DS3_BUTTON_SELECT_VALUE 0x01 // 2
|
||||
#define HID_DS3_BUTTON_START_VALUE 0x08 // 2
|
||||
#define HID_DS3_BUTTON_LEFT_VALUE 0x80 // 2
|
||||
#define HID_DS3_BUTTON_RIGHT_VALUE 0x20 // 2
|
||||
#define HID_DS3_BUTTON_UP_VALUE 0x10 // 2
|
||||
#define HID_DS3_BUTTON_DOWN_VALUE 0x40 // 2
|
||||
#define HID_DS3_BUTTON_GUIDE_VALUE 0x01 // 4
|
||||
|
||||
#define HID_DS3_BUTTON_L3 0x02 // 2
|
||||
#define HID_DS3_BUTTON_R3 0x04 // 2
|
||||
#define HID_DS3_BUTTON_SELECT 0x01 // 2
|
||||
#define HID_DS3_BUTTON_START 0x08 // 2
|
||||
#define HID_DS3_BUTTON_LEFT 0x80 // 2
|
||||
#define HID_DS3_BUTTON_RIGHT 0x20 // 2
|
||||
#define HID_DS3_BUTTON_UP 0x10 // 2
|
||||
#define HID_DS3_BUTTON_DOWN 0x40 // 2
|
||||
#define HID_DS3_BUTTON_GUIDE 0x01 // 4
|
||||
|
||||
#define HID_DS3_PAD_COUNT 1
|
||||
|
||||
@ -216,149 +277,41 @@ void my_gc_write_cb(unsigned int handle, int error, unsigned char *buf, unsigned
|
||||
//! DS4
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define HID_DS4_BUTTON_CROSS 0x20 // 5
|
||||
#define HID_DS4_BUTTON_SQUARE 0x10 // 5
|
||||
#define HID_DS4_BUTTON_CIRCLE 0x40 // 5
|
||||
#define HID_DS4_BUTTON_TRIANGLE 0x80 // 5
|
||||
#define HID_DS4_BUTTON_L1 0x01 // 6
|
||||
#define HID_DS4_BUTTON_L2 0x04 // 6
|
||||
#define HID_DS4_BUTTON_L3 0x40 // 6
|
||||
#define HID_DS4_BUTTON_R1 0x02 // 6
|
||||
#define HID_DS4_BUTTON_R2 0x08 // 6
|
||||
#define HID_DS4_BUTTON_R3 0x80 // 6
|
||||
#define HID_DS4_BUTTON_SHARE 0x10 // 6
|
||||
#define HID_DS4_BUTTON_OPTIONS 0x20 // 6
|
||||
#define HID_DS4_BUTTON_DPAD_N 0x00 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NE 0x01 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_E 0x02 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_SE 0x03 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_S 0x04 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_SW 0x05 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_W 0x06 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NW 0x07 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NEUTRAL 0x08 // 5
|
||||
#define HID_DS4_BUTTON_GUIDE 0x01 // 7
|
||||
#define HID_DS4_BUTTON_T_PAD_CLICK 0x02 // 7
|
||||
#define HID_DS4_BUTTON_CROSS_VALUE 0x20 // 5
|
||||
#define HID_DS4_BUTTON_SQUARE_VALUE 0x10 // 5
|
||||
#define HID_DS4_BUTTON_CIRCLE_VALUE 0x40 // 5
|
||||
#define HID_DS4_BUTTON_TRIANGLE_VALUE 0x80 // 5
|
||||
#define HID_DS4_BUTTON_L1_VALUE 0x01 // 6
|
||||
#define HID_DS4_BUTTON_L2_VALUE 0x04 // 6
|
||||
#define HID_DS4_BUTTON_L3_VALUE 0x40 // 6
|
||||
#define HID_DS4_BUTTON_R1_VALUE 0x02 // 6
|
||||
#define HID_DS4_BUTTON_R2_VALUE 0x08 // 6
|
||||
#define HID_DS4_BUTTON_R3_VALUE 0x80 // 6
|
||||
#define HID_DS4_BUTTON_SHARE_VALUE 0x10 // 6
|
||||
#define HID_DS4_BUTTON_OPTIONS_VALUE 0x20 // 6
|
||||
|
||||
#define HID_DS4_BUTTON_DPAD_MASK_VALUE 0x0F
|
||||
|
||||
#define HID_DS4_BUTTON_DPAD_N_VALUE 0x00 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NE_VALUE 0x01 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_E_VALUE 0x02 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_SE_VALUE 0x03 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_S_VALUE 0x04 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_SW_VALUE 0x05 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_W_VALUE 0x06 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NW_VALUE 0x07 // 5
|
||||
#define HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE 0x08 // 5
|
||||
|
||||
#define HID_DS4_BUTTON_GUIDE_VALUE 0x01 // 7
|
||||
#define HID_DS4_BUTTON_T_PAD_CLICK_VALUE 0x02 // 7
|
||||
|
||||
#define HID_DS4_PAD_COUNT 1
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! PS2 Adapter
|
||||
//! Keyboard (Full list is on: http://www.freebsddiary.org/APC/usb_hid_usages.php)
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define HID_PS2_ADAPTER_BUTTON_CROSS 0x40 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_CIRCLE 0x20 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_SQUARE 0x80 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_TRIANGLE 0x10 // 5
|
||||
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_N 0x00 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_NE 0x01 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_E 0x02 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_SE 0x03 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_S 0x04 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_SW 0x05 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_W 0x06 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_NW 0x07 // 5
|
||||
#define HID_PS2_ADAPTER_BUTTON_DPAD_NEUTRAL 0x0F // 5
|
||||
|
||||
#define HID_PS2_ADAPTER_BUTTON_L1 0x04 // 6
|
||||
#define HID_PS2_ADAPTER_BUTTON_L2 0x01 // 6
|
||||
#define HID_PS2_ADAPTER_BUTTON_R1 0x08 // 6
|
||||
#define HID_PS2_ADAPTER_BUTTON_R2 0x02 // 6
|
||||
#define HID_PS2_ADAPTER_BUTTON_START 0x20 // 6
|
||||
#define HID_PS2_ADAPTER_BUTTON_SELECT 0x10 // 6
|
||||
|
||||
#define HID_PS2_ADAPTER_PAD_COUNT 1
|
||||
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! PS2
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define HID_PS2_BUTTON_CROSS 0x20 // 5
|
||||
#define HID_PS2_BUTTON_SQUARE 0x40 // 5
|
||||
#define HID_PS2_BUTTON_CIRCLE 0x10 // 5
|
||||
#define HID_PS2_BUTTON_TRIANGLE 0x80 // 5
|
||||
|
||||
#define HID_PS2_BUTTON_DPAD_N 0x00 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_NE 0x01 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_E 0x02 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_SE 0x03 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_S 0x04 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_SW 0x05 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_W 0x06 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_NW 0x07 // 5
|
||||
#define HID_PS2_BUTTON_DPAD_NEUTRAL 0x0F // 5
|
||||
|
||||
#define HID_PS2_BUTTON_L1 0x04 // 6
|
||||
#define HID_PS2_BUTTON_L2 0x01 // 6
|
||||
#define HID_PS2_BUTTON_R1 0x08 // 6
|
||||
#define HID_PS2_BUTTON_R2 0x02 // 6
|
||||
#define HID_PS2_BUTTON_START 0x20 // 6
|
||||
#define HID_PS2_BUTTON_SELECT 0x10 // 6
|
||||
|
||||
#define HID_PS2_PAD_COUNT 1
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Saitek P2600
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define HID_SP2600_BUTTON_1 0x01 // 5
|
||||
#define HID_SP2600_BUTTON_2 0x02 // 5
|
||||
#define HID_SP2600_BUTTON_3 0x04 // 5
|
||||
#define HID_SP2600_BUTTON_4 0x08 // 5
|
||||
|
||||
#define HID_SP2600_BUTTON_DPAD_N 0x00 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_NE 0x10 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_E 0x20 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_SE 0x30 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_S 0x40 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_SW 0x50 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_W 0x60 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_NW 0x70 // 5
|
||||
#define HID_SP2600_BUTTON_DPAD_NEUTRAL 0xF0 // 5
|
||||
|
||||
#define HID_SP2600_BUTTON_5 0x10 // 5 //L upper
|
||||
#define HID_SP2600_BUTTON_6 0x20 // 5 //R upper
|
||||
#define HID_SP2600_BUTTON_7 0x40 // 5 //L lower
|
||||
#define HID_SP2600_BUTTON_8 0x80 // 5 //R lower
|
||||
#define HID_SP2600_BUTTON_BLACK 0x01 // 6
|
||||
#define HID_SP2600_BUTTON_WHITE 0x02 // 6
|
||||
#define HID_SP2600_BUTTON_FPS 0x04 // 6
|
||||
#define HID_SP2600_BUTTON_Analog 0x08 // 6
|
||||
|
||||
#define HID_SP2600_PAD_COUNT 1
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! POKKEN
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define HID_POKKEN_BUTTON_1 0x01
|
||||
#define HID_POKKEN_BUTTON_2 0x02
|
||||
#define HID_POKKEN_BUTTON_3 0x04
|
||||
#define HID_POKKEN_BUTTON_4 0x08
|
||||
#define HID_POKKEN_BUTTON_5 0x10
|
||||
#define HID_POKKEN_BUTTON_6 0x20
|
||||
#define HID_POKKEN_BUTTON_7 0x40
|
||||
#define HID_POKKEN_BUTTON_8 0x80
|
||||
#define HID_POKKEN_BUTTON_9 0x80
|
||||
#define HID_POKKEN_BUTTON_10 0x80
|
||||
|
||||
#define HID_POKKEN_BUTTON_DPAD_N 0x00
|
||||
#define HID_POKKEN_BUTTON_DPAD_NE 0x10
|
||||
#define HID_POKKEN_BUTTON_DPAD_E 0x20
|
||||
#define HID_POKKEN_BUTTON_DPAD_SE 0x30
|
||||
#define HID_POKKEN_BUTTON_DPAD_S 0x40
|
||||
#define HID_POKKEN_BUTTON_DPAD_SW 0x50
|
||||
#define HID_POKKEN_BUTTON_DPAD_W 0x60
|
||||
#define HID_POKKEN_BUTTON_DPAD_NW 0x70
|
||||
#define HID_POKKEN_BUTTON_DPAD_NEUTRAL 0xF0
|
||||
|
||||
#define HID_POKKEN_PAD_COUNT 1
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Keyboard
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#define HID_KEYBOARD_BUTTON_SHIFT 0x02
|
||||
|
||||
#define HID_KEYBOARD_BUTTON_A 0x04
|
||||
#define HID_KEYBOARD_BUTTON_B 0x05
|
||||
@ -398,16 +351,56 @@ void my_gc_write_cb(unsigned int handle, int error, unsigned char *buf, unsigned
|
||||
#define HID_KEYBOARD_BUTTON_F10 0x43
|
||||
#define HID_KEYBOARD_BUTTON_F11 0x44
|
||||
#define HID_KEYBOARD_BUTTON_F12 0x45
|
||||
#define HID_KEYBOARD_BUTTON_1 0x1E
|
||||
#define HID_KEYBOARD_BUTTON_2 0x1F
|
||||
#define HID_KEYBOARD_BUTTON_3 0x20
|
||||
#define HID_KEYBOARD_BUTTON_4 0x21
|
||||
#define HID_KEYBOARD_BUTTON_5 0x22
|
||||
#define HID_KEYBOARD_BUTTON_6 0x23
|
||||
#define HID_KEYBOARD_BUTTON_7 0x24
|
||||
#define HID_KEYBOARD_BUTTON_8 0x25
|
||||
#define HID_KEYBOARD_BUTTON_9 0x26
|
||||
#define HID_KEYBOARD_BUTTON_0 0x27
|
||||
|
||||
#define HID_KEYBOARD_BUTTON_RETURN 0x28
|
||||
#define HID_KEYBOARD_BUTTON_ESCAPE 0x29
|
||||
#define HID_KEYBOARD_BUTTON_DELETE 0x2A
|
||||
#define HID_KEYBOARD_BUTTON_TAB 0x2B
|
||||
#define HID_KEYBOARD_BUTTON_SPACEBAR 0x2C
|
||||
#define HID_KEYBOARD_BUTTON_CAPSLOCK 0x39
|
||||
#define HID_KEYBOARD_BUTTON_PRINTSCREEN 0x46
|
||||
#define HID_KEYBOARD_BUTTON_SCROLLLOCK 0x47
|
||||
#define HID_KEYBOARD_BUTTON_PAUSE 0x48
|
||||
#define HID_KEYBOARD_BUTTON_INSERT 0x49
|
||||
#define HID_KEYBOARD_BUTTON_HOME 0x4A
|
||||
#define HID_KEYBOARD_BUTTON_PAGEUP 0x4B
|
||||
#define HID_KEYBOARD_BUTTON_PAGEDOWN 0x4E
|
||||
#define HID_KEYBOARD_BUTTON_DELETEFORWARD 0x4C
|
||||
#define HID_KEYBOARD_BUTTON_END 0x4D
|
||||
#define HID_KEYBOARD_BUTTON_LEFT_CONTROL 0xE0
|
||||
#define HID_KEYBOARD_BUTTON_LEFT_ALT 0xE2
|
||||
#define HID_KEYBOARD_BUTTON_RIGHT_CONTROL 0xE4
|
||||
#define HID_KEYBOARD_BUTTON_RIGHT_SHIFT 0xE5
|
||||
#define HID_KEYBOARD_BUTTON_RIGHT_ALT 0xE6
|
||||
|
||||
#define HID_KEYBOARD_BUTTON_LEFT 0x50
|
||||
#define HID_KEYBOARD_BUTTON_RIGHT 0x4f
|
||||
#define HID_KEYBOARD_BUTTON_DOWN 0x51
|
||||
#define HID_KEYBOARD_BUTTON_UP 0x52
|
||||
#define HID_KEYBOARD_BUTTON_ENTER 0x28
|
||||
#define HID_KEYBOARD_BUTTON_MINUS 0x56
|
||||
#define HID_KEYBOARD_BUTTON_PLUS 0x57
|
||||
#define HID_KEYBOARD_BUTTON_SPACE 0x2C
|
||||
#define HID_KEYBOARD_BUTTON_SHIFT 0x02
|
||||
#define HID_KEYBOARD_BUTTON_TAB 0x2B
|
||||
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_1 0x59
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_2 0x5A
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_3 0x5B
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_4 0x5C
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_5 0x5D
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_6 0x5E
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_7 0x5F
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_8 0x60
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_9 0x61
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_0 0x62
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_NUMLOCK 0x53
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_MINUS 0x56
|
||||
#define HID_KEYBOARD_KEYPAD_BUTTON_PLUS 0x57
|
||||
|
||||
#define HID_KEYBOARD_PAD_COUNT 1
|
||||
#define HID_KEYBOARD_DATA_LENGTH 8
|
||||
@ -432,6 +425,7 @@ struct _HID_Mouse_Data {
|
||||
s16 Y;
|
||||
s16 deltaX;
|
||||
s16 deltaY;
|
||||
u8 valuedChanged;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef struct _HID_Mouse_Data HID_Mouse_Data;
|
||||
|
@ -1,21 +1,53 @@
|
||||
#include <gctypes.h>
|
||||
#include "dynamic_libs/syshid_functions.h"
|
||||
#include "controller_patcher/controller_patcher.h"
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
u8 config_done __attribute__((section(".data"))) = 0;
|
||||
#include <gctypes.h>
|
||||
#include "controller_patcher.h"
|
||||
#include "cp_retain_vars.h"
|
||||
|
||||
u8 gConfig_done __attribute__((section(".data"))) = 0;
|
||||
u8 gButtonRemappingConfigDone __attribute__((section(".data"))) = 0;
|
||||
|
||||
u8 gHIDSetupDone __attribute__((section(".data"))) = 0;
|
||||
u16 gHIDAttached __attribute__((section(".data"))) = 0;
|
||||
u16 gHIDCurrentDevice __attribute__((section(".data"))) = 0;
|
||||
|
||||
u16 gHIDRegisteredDevices __attribute__((section(".data"))) = 0;
|
||||
|
||||
HIDClient gHIDClient __attribute__((section(".data")));
|
||||
|
||||
HID_DEVICE_DATA gHID_Devices[CONTRPD_MAX_VALUE] __attribute__((section(".data")));
|
||||
HID_DEVICE_DATA gHID_Devices[gHIDMaxDevices] __attribute__((section(".data")));
|
||||
|
||||
HID_Mouse gHID_Mouse __attribute__((section(".data")));
|
||||
|
||||
u8 gHID_Mouse_Mode __attribute__((section(".data"))) = HID_MOUSE_MODE_TOUCH;
|
||||
|
||||
u8 config_controller[CONTRPD_MAX_VALUE][CONTRPS_MAX_VALUE][2] __attribute__((section(".data")));
|
||||
u16 config_controller_list[CONTRPD_MAX_VALUE] __attribute__((section(".data")));
|
||||
u32 config_controller_data_ptr[CONTRPD_MAX_VALUE][4] __attribute__((section(".data")));
|
||||
u32 gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data")));
|
||||
|
||||
u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data")));
|
||||
u16 config_controller_list[gHIDMaxDevices] __attribute__((section(".data")));
|
||||
u32 config_controller_data_ptr[gHIDMaxDevices][HID_MAX_PADS_COUNT] __attribute__((section(".data")));
|
||||
|
||||
u16 gHID_LIST_GC __attribute__((section(".data"))) = 0;
|
||||
u16 gHID_LIST_DS3 __attribute__((section(".data"))) = 0;
|
||||
u16 gHID_LIST_KEYBOARD __attribute__((section(".data"))) = 0;
|
||||
u16 gHID_LIST_MOUSE __attribute__((section(".data"))) = 0;
|
||||
|
||||
u16 gGamePadSlot __attribute__((section(".data"))) = 0;
|
||||
u16 gHID_SLOT_GC __attribute__((section(".data"))) = 0;
|
||||
u16 gHID_SLOT_KEYBOARD __attribute__((section(".data"))) = 0;
|
||||
u16 gMouseSlot __attribute__((section(".data"))) = 0;
|
||||
|
@ -1,24 +1,58 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef CP_RETAINS_VARS_H_
|
||||
#define CP_RETAINS_VARS_H_
|
||||
|
||||
#include "dynamic_libs/syshid_functions.h"
|
||||
#include "controller_patcher/controller_patcher.h"
|
||||
|
||||
extern u8 config_done;
|
||||
extern u8 gConfig_done;
|
||||
extern u8 gButtonRemappingConfigDone;
|
||||
|
||||
extern u8 gHIDSetupDone;
|
||||
extern u16 gHIDAttached;
|
||||
extern u16 gHIDCurrentDevice;
|
||||
extern HIDClient gHIDClient;
|
||||
|
||||
extern HID_DEVICE_DATA gHID_Devices[CONTRPD_MAX_VALUE];
|
||||
#define gHIDMaxDevices 16
|
||||
#define HID_INVALID_SLOT 0xFFFF
|
||||
|
||||
extern u16 gHIDRegisteredDevices;
|
||||
|
||||
extern HID_DEVICE_DATA gHID_Devices[gHIDMaxDevices];
|
||||
|
||||
extern HID_Mouse gHID_Mouse;
|
||||
|
||||
extern u8 gHID_Mouse_Mode;
|
||||
|
||||
extern u8 config_controller[CONTRPD_MAX_VALUE][CONTRPS_MAX_VALUE][2];
|
||||
extern u16 config_controller_list[CONTRPD_MAX_VALUE];
|
||||
extern u32 config_controller_data_ptr[CONTRPD_MAX_VALUE][4]; //currently max per device
|
||||
extern u32 gGamePadValues[CONTRPS_MAX_VALUE];
|
||||
|
||||
extern u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2];
|
||||
extern u16 config_controller_list[gHIDMaxDevices];
|
||||
extern u32 config_controller_data_ptr[gHIDMaxDevices][4]; //currently max per device
|
||||
|
||||
extern u16 gHID_LIST_GC;
|
||||
extern u16 gHID_LIST_DS3;
|
||||
extern u16 gHID_LIST_KEYBOARD;
|
||||
extern u16 gHID_LIST_MOUSE;
|
||||
extern u16 gGamePadSlot;
|
||||
|
||||
extern u16 gHID_SLOT_GC;
|
||||
extern u16 gHID_SLOT_KEYBOARD;
|
||||
extern u16 gMouseSlot;
|
||||
|
||||
#endif // CP_RETAINS_VARS_H_
|
||||
|
217
pad_const.c
Normal file
217
pad_const.c
Normal file
@ -0,0 +1,217 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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 "pad_const.h"
|
||||
|
||||
const u8 DEF_L_STICK_UP = 201;
|
||||
const u8 DEF_L_STICK_DOWN = 202;
|
||||
const u8 DEF_L_STICK_LEFT = 203;
|
||||
const u8 DEF_L_STICK_RIGHT = 204;
|
||||
|
||||
const u8 DEF_R_STICK_UP = 205;
|
||||
const u8 DEF_R_STICK_DOWN = 206;
|
||||
const u8 DEF_R_STICK_LEFT = 207;
|
||||
const u8 DEF_R_STICK_RIGHT = 208;
|
||||
|
||||
const u8 DEF_R_STICK = 220;
|
||||
const u8 DEF_L_STICK = 221;
|
||||
|
||||
const u8 DEF_STICK_OFFSET_INVERT = CONTRPS_VPAD_BUTTON_L_STICK_X_INVERT - CONTRPS_VPAD_BUTTON_L_STICK_X;
|
||||
const u8 DEF_STICK_OFFSET_DEADZONE = CONTRPS_VPAD_BUTTON_L_STICK_X_DEADZONE - CONTRPS_VPAD_BUTTON_L_STICK_X;
|
||||
const u8 DEF_STICK_OFFSET_MINMAX = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX - CONTRPS_VPAD_BUTTON_L_STICK_X;
|
||||
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! GC-Adapter
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const u8 HID_GC_BUTTON_A[] = { 0x01,HID_GC_BUTTON_A_VALUE};
|
||||
const u8 HID_GC_BUTTON_B[] = { 0x01,HID_GC_BUTTON_B_VALUE};
|
||||
const u8 HID_GC_BUTTON_X[] = { 0x01,HID_GC_BUTTON_X_VALUE};
|
||||
const u8 HID_GC_BUTTON_Y[] = { 0x01,HID_GC_BUTTON_Y_VALUE};
|
||||
const u8 HID_GC_BUTTON_LEFT[] = { 0x01,HID_GC_BUTTON_LEFT_VALUE};
|
||||
const u8 HID_GC_BUTTON_RIGHT[] = { 0x01,HID_GC_BUTTON_RIGHT_VALUE};
|
||||
const u8 HID_GC_BUTTON_DOWN[] = { 0x01,HID_GC_BUTTON_DOWN_VALUE};
|
||||
const u8 HID_GC_BUTTON_UP[] = { 0x01,HID_GC_BUTTON_UP_VALUE};
|
||||
|
||||
const u8 HID_GC_BUTTON_START[] = { 0x02,HID_GC_BUTTON_START_VALUE};
|
||||
const u8 HID_GC_BUTTON_Z[] = { 0x02,HID_GC_BUTTON_Z_VALUE};
|
||||
|
||||
const u8 HID_GC_BUTTON_L[] = { 0x07,HID_GC_BUTTON_L_VALUE};
|
||||
const u8 HID_GC_BUTTON_R[] = { 0x08,HID_GC_BUTTON_R_VALUE};
|
||||
|
||||
const u8 HID_GC_BUTTON_DPAD_TYPE[] = { CONTRPDM_Normal,0x00};
|
||||
|
||||
const u8 HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x03, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x09, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x1E, //STICK_CONF_MIN,
|
||||
0xE5};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x04, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x09, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x18, //STICK_CONF_MIN,
|
||||
0xE1};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x05, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x09, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x26, //STICK_CONF_MIN,
|
||||
0xE1};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x06, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x09, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x1A, //STICK_CONF_MIN,
|
||||
0xDB};//STICK_CONF_MAX,
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! DS3
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const u8 HID_DS3_BUTTON_CROSS[] = { 0x03,HID_DS3_BUTTON_CROSS_VALUE};
|
||||
const u8 HID_DS3_BUTTON_CIRCLE[] = { 0x03,HID_DS3_BUTTON_CIRCLE_VALUE};
|
||||
const u8 HID_DS3_BUTTON_SQUARE [] = { 0x03,HID_DS3_BUTTON_SQUARE_VALUE};
|
||||
const u8 HID_DS3_BUTTON_TRIANGLE[] = { 0x03,HID_DS3_BUTTON_TRIANGLE_VALUE};
|
||||
|
||||
const u8 HID_DS3_BUTTON_L1[] = { 0x03,HID_DS3_BUTTON_L1_VALUE};
|
||||
const u8 HID_DS3_BUTTON_L2[] = { 0x03,HID_DS3_BUTTON_L2_VALUE};
|
||||
const u8 HID_DS3_BUTTON_R1[] = { 0x03,HID_DS3_BUTTON_R1_VALUE};
|
||||
const u8 HID_DS3_BUTTON_R2[] = { 0x03,HID_DS3_BUTTON_R2_VALUE};
|
||||
|
||||
const u8 HID_DS3_BUTTON_L3[] = { 0x02,HID_DS3_BUTTON_L3_VALUE};
|
||||
const u8 HID_DS3_BUTTON_R3[] = { 0x02,HID_DS3_BUTTON_R3_VALUE};
|
||||
const u8 HID_DS3_BUTTON_SELECT[] = { 0x02,HID_DS3_BUTTON_SELECT_VALUE};
|
||||
const u8 HID_DS3_BUTTON_START[] = { 0x02,HID_DS3_BUTTON_START_VALUE};
|
||||
const u8 HID_DS3_BUTTON_LEFT[] = { 0x02,HID_DS3_BUTTON_LEFT_VALUE};
|
||||
const u8 HID_DS3_BUTTON_RIGHT[] = { 0x02,HID_DS3_BUTTON_RIGHT_VALUE};
|
||||
const u8 HID_DS3_BUTTON_UP[] = { 0x02,HID_DS3_BUTTON_UP_VALUE};
|
||||
const u8 HID_DS3_BUTTON_DOWN[] = { 0x02,HID_DS3_BUTTON_DOWN_VALUE};
|
||||
|
||||
const u8 HID_DS3_BUTTON_GUIDE[] = { 0x04,HID_DS3_BUTTON_GUIDE_VALUE};
|
||||
|
||||
const u8 HID_DS3_BUTTON_DPAD_TYPE[] = { CONTRPDM_Normal,0x00};
|
||||
|
||||
const u8 HID_DS3_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x06, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x06, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS3_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x07, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x06, //STICK_CONF_DEADZONE,
|
||||
0x01, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS3_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x08, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x06, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS3_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x09, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x06, //STICK_CONF_DEADZONE,
|
||||
0x01, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! DS4
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const u8 HID_DS4_BUTTON_CROSS[] = { 0x05,HID_DS4_BUTTON_CROSS_VALUE};
|
||||
const u8 HID_DS4_BUTTON_CIRCLE[] = { 0x05,HID_DS4_BUTTON_CIRCLE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_SQUARE [] = { 0x05,HID_DS4_BUTTON_SQUARE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_TRIANGLE[] = { 0x05,HID_DS4_BUTTON_TRIANGLE_VALUE};
|
||||
|
||||
const u8 HID_DS4_BUTTON_L1[] = { 0x06,HID_DS4_BUTTON_L1_VALUE};
|
||||
const u8 HID_DS4_BUTTON_L2[] = { 0x06,HID_DS4_BUTTON_L2_VALUE};
|
||||
const u8 HID_DS4_BUTTON_L3[] = { 0x06,HID_DS4_BUTTON_L3_VALUE};
|
||||
|
||||
const u8 HID_DS4_BUTTON_R1[] = { 0x06,HID_DS4_BUTTON_R1_VALUE};
|
||||
const u8 HID_DS4_BUTTON_R2[] = { 0x06,HID_DS4_BUTTON_R2_VALUE};
|
||||
const u8 HID_DS4_BUTTON_R3[] = { 0x06,HID_DS4_BUTTON_R3_VALUE};
|
||||
|
||||
const u8 HID_DS4_BUTTON_SHARE[] = { 0x06,HID_DS4_BUTTON_SHARE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_OPTIONS[] = { 0x06,HID_DS4_BUTTON_OPTIONS_VALUE};
|
||||
|
||||
|
||||
const u8 HID_DS4_BUTTON_DPAD_TYPE[] = { CONTRPDM_Hat,HID_DS4_BUTTON_DPAD_MASK_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_N[] = { 0x05,HID_DS4_BUTTON_DPAD_N_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_NE[] = { 0x05,HID_DS4_BUTTON_DPAD_NE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_E[] = { 0x05,HID_DS4_BUTTON_DPAD_E_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_SE[] = { 0x05,HID_DS4_BUTTON_DPAD_SE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_S[] = { 0x05,HID_DS4_BUTTON_DPAD_S_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_SW[] = { 0x05,HID_DS4_BUTTON_DPAD_SW_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_W[] = { 0x05,HID_DS4_BUTTON_DPAD_W_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_NW[] = { 0x05,HID_DS4_BUTTON_DPAD_NW_VALUE};
|
||||
const u8 HID_DS4_BUTTON_DPAD_NEUTRAL[] = { 0x05,HID_DS4_BUTTON_DPAD_NEUTRAL_VALUE};
|
||||
|
||||
const u8 HID_DS4_BUTTON_GUIDE[] = { 0x07,HID_DS4_BUTTON_GUIDE_VALUE};
|
||||
const u8 HID_DS4_BUTTON_T_PAD_CLICK[] = { 0x07,HID_DS4_BUTTON_T_PAD_CLICK_VALUE};
|
||||
|
||||
const u8 HID_DS4_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x01, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x06, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS4_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x02, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x05, //STICK_CONF_DEADZONE,
|
||||
0x01, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS4_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x03, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x07, //STICK_CONF_DEADZONE,
|
||||
0x00, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
const u8 HID_DS4_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
|
||||
0x04, //STICK_CONF_BYTE,
|
||||
0x80, //STICK_CONF_DEFAULT,
|
||||
0x09, //STICK_CONF_DEADZONE,
|
||||
0x01, //STICK_CONF_INVERT,
|
||||
0x00, //STICK_CONF_MIN,
|
||||
0xFF};//STICK_CONF_MAX,
|
||||
|
||||
|
146
pad_const.h
Normal file
146
pad_const.h
Normal file
@ -0,0 +1,146 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _PAD_CONST_H_
|
||||
#define _PAD_CONST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "controller_patcher.h"
|
||||
|
||||
extern const u8 DEF_L_STICK_UP;
|
||||
extern const u8 DEF_L_STICK_DOWN;
|
||||
extern const u8 DEF_L_STICK_LEFT;
|
||||
extern const u8 DEF_L_STICK_RIGHT;
|
||||
|
||||
extern const u8 DEF_R_STICK_UP;
|
||||
extern const u8 DEF_R_STICK_DOWN;
|
||||
extern const u8 DEF_R_STICK_LEFT;
|
||||
extern const u8 DEF_R_STICK_RIGHT;
|
||||
|
||||
extern const u8 DEF_R_STICK;
|
||||
extern const u8 DEF_L_STICK;
|
||||
|
||||
extern const u8 DEF_STICK_OFFSET_INVERT;
|
||||
extern const u8 DEF_STICK_OFFSET_DEADZONE;
|
||||
extern const u8 DEF_STICK_OFFSET_MINMAX;
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! GC_Adapter
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern const u8 HID_GC_BUTTON_A[];
|
||||
extern const u8 HID_GC_BUTTON_B[];
|
||||
extern const u8 HID_GC_BUTTON_X[];
|
||||
extern const u8 HID_GC_BUTTON_Y[];
|
||||
extern const u8 HID_GC_BUTTON_LEFT[];
|
||||
extern const u8 HID_GC_BUTTON_RIGHT[];
|
||||
extern const u8 HID_GC_BUTTON_DOWN[];
|
||||
extern const u8 HID_GC_BUTTON_UP[];
|
||||
|
||||
extern const u8 HID_GC_BUTTON_START[];
|
||||
extern const u8 HID_GC_BUTTON_Z[];
|
||||
|
||||
extern const u8 HID_GC_BUTTON_L[];
|
||||
extern const u8 HID_GC_BUTTON_R[];
|
||||
|
||||
extern const u8 HID_GC_BUTTON_DPAD_TYPE[];
|
||||
|
||||
extern const u8 HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! DS3
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern const u8 HID_DS3_BUTTON_CROSS[];
|
||||
extern const u8 HID_DS3_BUTTON_CIRCLE[];
|
||||
extern const u8 HID_DS3_BUTTON_SQUARE [];
|
||||
extern const u8 HID_DS3_BUTTON_TRIANGLE[];
|
||||
|
||||
extern const u8 HID_DS3_BUTTON_L1[];
|
||||
extern const u8 HID_DS3_BUTTON_L2[];
|
||||
extern const u8 HID_DS3_BUTTON_R1[];
|
||||
extern const u8 HID_DS3_BUTTON_R2[];
|
||||
|
||||
extern const u8 HID_DS3_BUTTON_L3[];
|
||||
extern const u8 HID_DS3_BUTTON_R3[];
|
||||
extern const u8 HID_DS3_BUTTON_SELECT[];
|
||||
extern const u8 HID_DS3_BUTTON_START[];
|
||||
extern const u8 HID_DS3_BUTTON_LEFT[];
|
||||
extern const u8 HID_DS3_BUTTON_RIGHT[];
|
||||
extern const u8 HID_DS3_BUTTON_UP[];
|
||||
extern const u8 HID_DS3_BUTTON_DOWN[];
|
||||
|
||||
extern const u8 HID_DS3_BUTTON_GUIDE[];
|
||||
|
||||
extern const u8 HID_DS3_BUTTON_DPAD_TYPE[];
|
||||
|
||||
extern const u8 HID_DS3_STICK_L_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS3_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS3_STICK_R_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS3_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! DS4
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern const u8 HID_DS4_BUTTON_CROSS[];
|
||||
extern const u8 HID_DS4_BUTTON_CIRCLE[];
|
||||
extern const u8 HID_DS4_BUTTON_SQUARE [];
|
||||
extern const u8 HID_DS4_BUTTON_TRIANGLE[];
|
||||
|
||||
extern const u8 HID_DS4_BUTTON_L1[];
|
||||
extern const u8 HID_DS4_BUTTON_L2[];
|
||||
extern const u8 HID_DS4_BUTTON_L3[];
|
||||
extern const u8 HID_DS4_BUTTON_R1[];
|
||||
extern const u8 HID_DS4_BUTTON_R2[];
|
||||
extern const u8 HID_DS4_BUTTON_R3[];
|
||||
|
||||
extern const u8 HID_DS4_BUTTON_SHARE[];
|
||||
extern const u8 HID_DS4_BUTTON_OPTIONS[];
|
||||
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_TYPE[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_N[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_NE[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_E[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_SE[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_S[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_SW[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_W[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_NW[];
|
||||
extern const u8 HID_DS4_BUTTON_DPAD_NEUTRAL[];
|
||||
|
||||
extern const u8 HID_DS4_BUTTON_GUIDE[];
|
||||
extern const u8 HID_DS4_BUTTON_T_PAD_CLICK[];
|
||||
|
||||
extern const u8 HID_DS4_STICK_L_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS4_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS4_STICK_R_X[STICK_CONF_ENUM_MAXVALUE];
|
||||
extern const u8 HID_DS4_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _PAD_CONST_H_ */
|
51
string_tools.cpp
Normal file
51
string_tools.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gctypes.h>
|
||||
#include "string_tools.hpp"
|
||||
|
||||
bool EndsWith(const std::string& a, const std::string& b) {
|
||||
if (b.size() > a.size()) return false;
|
||||
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
||||
}
|
||||
|
||||
std::vector<std::string> MyStringSplit(const std::string & inValue, const std::string & splitter)
|
||||
{
|
||||
std::string value = inValue;
|
||||
std::vector<std::string> result;
|
||||
while (true) {
|
||||
unsigned int index = value.find(splitter);
|
||||
if (index == std::string::npos) {
|
||||
result.push_back(value);
|
||||
break;
|
||||
}
|
||||
std::string first = value.substr(0, index);
|
||||
result.push_back(first);
|
||||
if (index + splitter.size() == value.length()) {
|
||||
result.push_back("");
|
||||
break;
|
||||
}
|
||||
if(index + splitter.size() > value.length()) {
|
||||
break;
|
||||
}
|
||||
value = value.substr(index + splitter.size(), value.length());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
extern "C" const char *byte_to_binary(int x)
|
||||
{
|
||||
static char b[9];
|
||||
b[0] = '\0';
|
||||
|
||||
int z;
|
||||
for (z = 128; z > 0; z >>= 1)
|
||||
{
|
||||
strcat(b, ((x & z) == z) ? "1" : "0");
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
19
string_tools.hpp
Normal file
19
string_tools.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _STRING_TOOLS_H_
|
||||
#define _STRING_TOOLS_H_
|
||||
|
||||
bool EndsWith(const std::string& a, const std::string& b);
|
||||
std::vector<std::string> MyStringSplit(const std::string & inValue, const std::string & splitter);
|
||||
|
||||
/* Main */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! C wrapper for our C++ functions
|
||||
const char *byte_to_binary(int x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STRING_TOOLS_H_ */
|
Loading…
Reference in New Issue
Block a user