Improved deadzone handling

Improve GC pad default values
This commit is contained in:
Maschell 2016-08-04 18:53:06 +02:00
parent 3605af8358
commit e67dc213b5
2 changed files with 15 additions and 8 deletions

View File

@ -1204,10 +1204,17 @@ void setTouch(HID_Data_Struct data,VPADData * buffer){
f32 convertAnalogValue(u8 value, u8 default_val, u8 min, u8 max, u8 invert,u8 deadzone){ f32 convertAnalogValue(u8 value, u8 default_val, u8 min, u8 max, u8 invert,u8 deadzone){
s8 new_value = (s8)(value - default_val); s8 new_value = (s8)(value - default_val);
u8 range = 0; u8 range = 0;
if(value >= max){
return 1.0f;
}else if(value <= min){
return -1.0f;
}
if((value-deadzone) > default_val){ if((value-deadzone) > default_val){
range = (max - default_val); new_value -= deadzone;
range = (max - (default_val + deadzone));
}else if((value+deadzone) < default_val){ }else if((value+deadzone) < default_val){
range = (default_val - min); new_value += deadzone;
range = ((default_val - deadzone) - min);
}else{ }else{
return 0.0f; return 0.0f;
} }

View File

@ -61,15 +61,15 @@ const u8 HID_GC_STICK_L_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VAL
0x80, //STICK_CONF_DEFAULT, 0x80, //STICK_CONF_DEFAULT,
0x09, //STICK_CONF_DEADZONE, 0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT, 0x00, //STICK_CONF_INVERT,
0x1E, //STICK_CONF_MIN, 0x1A, //STICK_CONF_MIN,
0xE5};//STICK_CONF_MAX, 0xE4};//STICK_CONF_MAX,
const u8 HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION const u8 HID_GC_STICK_L_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x04, //STICK_CONF_BYTE, 0x04, //STICK_CONF_BYTE,
0x80, //STICK_CONF_DEFAULT, 0x80, //STICK_CONF_DEFAULT,
0x09, //STICK_CONF_DEADZONE, 0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT, 0x00, //STICK_CONF_INVERT,
0x18, //STICK_CONF_MIN, 0x11, //STICK_CONF_MIN,
0xE1};//STICK_CONF_MAX, 0xE1};//STICK_CONF_MAX,
const u8 HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION const u8 HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
@ -77,15 +77,15 @@ const u8 HID_GC_STICK_R_X[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VAL
0x80, //STICK_CONF_DEFAULT, 0x80, //STICK_CONF_DEFAULT,
0x09, //STICK_CONF_DEADZONE, 0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT, 0x00, //STICK_CONF_INVERT,
0x26, //STICK_CONF_MIN, 0x2B, //STICK_CONF_MIN,
0xE1};//STICK_CONF_MAX, 0xE2};//STICK_CONF_MAX,
const u8 HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION const u8 HID_GC_STICK_R_Y[STICK_CONF_ENUM_MAXVALUE] = { STICK_CONF_MAGIC_VALUE, //STICK_CONF_MAGIC_VERSION
0x06, //STICK_CONF_BYTE, 0x06, //STICK_CONF_BYTE,
0x80, //STICK_CONF_DEFAULT, 0x80, //STICK_CONF_DEFAULT,
0x09, //STICK_CONF_DEADZONE, 0x09, //STICK_CONF_DEADZONE,
0x00, //STICK_CONF_INVERT, 0x00, //STICK_CONF_INVERT,
0x1A, //STICK_CONF_MIN, 0x1D, //STICK_CONF_MIN,
0xDB};//STICK_CONF_MAX, 0xDB};//STICK_CONF_MAX,
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------