mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
nJoy: First implementation of an analog stick radius adjustment. Converting a square radius to a circle radius.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1698 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -207,7 +207,7 @@
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
WarnAsError="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
@@ -364,7 +364,7 @@
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
WarnAsError="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
@@ -505,6 +505,10 @@
|
||||
RelativePath=".\Src\Config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\nJoy.cpp"
|
||||
>
|
||||
@@ -541,6 +545,10 @@
|
||||
RelativePath=".\Src\GUI\ConfigBox.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\GUI\ConfigJoypad.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\readme.txt"
|
||||
|
||||
@@ -35,6 +35,12 @@
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
#include "nJoy.h"
|
||||
|
||||
Config g_Config;
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
memset(this, 0, sizeof(Config)); // Clear the memory
|
||||
}
|
||||
|
||||
|
||||
// Enable output log
|
||||
@@ -76,41 +82,90 @@ void DEBUG_QUIT()
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
|
||||
/* Check for duplicate Joypad names. An alternative to this would be to only notify the user
|
||||
that he has multiple virtual controllers assigned to the same physical controller
|
||||
and that only one of them will be saved if he has attached settings to a controller ID */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
std::string Config::CheckForDuplicateNames(std::string _Name, std::vector<std::string> &Duplicates)
|
||||
{
|
||||
// Count the number of duplicate names
|
||||
int NumDuplicates = 0;
|
||||
for(int i = 0; i < Duplicates.size(); i++)
|
||||
if(_Name == Duplicates.at(i)) NumDuplicates++;
|
||||
|
||||
Duplicates.push_back(_Name); // Add the name
|
||||
|
||||
// Return an amended name if we found a duplicate
|
||||
if(NumDuplicates > 0)
|
||||
return StringFromFormat("%s (%i)", _Name.c_str(), NumDuplicates);
|
||||
else
|
||||
return _Name;
|
||||
}
|
||||
|
||||
|
||||
// Save settings to file
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void SaveConfig()
|
||||
void Config::Save()
|
||||
{
|
||||
IniFile file;
|
||||
file.Load("nJoy.ini");
|
||||
std::vector<std::string> Duplicates;
|
||||
|
||||
file.Set("General", "SaveByID", g_Config.bSaveByID);
|
||||
file.Set("General", "ShowAdvanced", g_Config.bShowAdvanced);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
char SectionName[32];
|
||||
sprintf(SectionName, "PAD%i", i+1);
|
||||
std::string SectionName = StringFromFormat("PAD%i", i+1);
|
||||
file.Set(SectionName.c_str(), "joy_id", joysticks[i].ID);
|
||||
file.Set(SectionName.c_str(), "enabled", joysticks[i].enabled);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Save joypad specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Current joypad device ID: joysticks[i].ID
|
||||
// Current joypad name: joyinfo[joysticks[i].ID].Name
|
||||
if(g_Config.bSaveByID)
|
||||
{
|
||||
/* Save joypad specific settings. Check for "joysticks[i].ID < SDL_NumJoysticks()" to
|
||||
avoid reading a joyinfo that does't exist */
|
||||
if(joysticks[i].ID >= SDL_NumJoysticks()) continue;
|
||||
|
||||
//PanicAlert("%i", m_frame->m_Joyname[0]->GetSelection());
|
||||
//if(i == 0) PanicAlert("%i", joysticks[i].buttons[CTL_START]);
|
||||
//PanicAlert("%s", joyinfo[joysticks[i].ID].Name);
|
||||
|
||||
file.Set(SectionName, "l_shoulder", joysticks[i].buttons[CTL_L_SHOULDER]);
|
||||
file.Set(SectionName, "r_shoulder", joysticks[i].buttons[CTL_R_SHOULDER]);
|
||||
file.Set(SectionName, "a_button", joysticks[i].buttons[CTL_A_BUTTON]);
|
||||
file.Set(SectionName, "b_button", joysticks[i].buttons[CTL_B_BUTTON]);
|
||||
file.Set(SectionName, "x_button", joysticks[i].buttons[CTL_X_BUTTON]);
|
||||
file.Set(SectionName, "y_button", joysticks[i].buttons[CTL_Y_BUTTON]);
|
||||
file.Set(SectionName, "z_trigger", joysticks[i].buttons[CTL_Z_TRIGGER]);
|
||||
file.Set(SectionName, "start_button", joysticks[i].buttons[CTL_START]);
|
||||
file.Set(SectionName, "dpad", joysticks[i].dpad);
|
||||
file.Set(SectionName, "dpad_up", joysticks[i].dpad2[CTL_D_PAD_UP]);
|
||||
file.Set(SectionName, "dpad_down", joysticks[i].dpad2[CTL_D_PAD_DOWN]);
|
||||
file.Set(SectionName, "dpad_left", joysticks[i].dpad2[CTL_D_PAD_LEFT]);
|
||||
file.Set(SectionName, "dpad_right", joysticks[i].dpad2[CTL_D_PAD_RIGHT]);
|
||||
file.Set(SectionName, "main_x", joysticks[i].axis[CTL_MAIN_X]);
|
||||
file.Set(SectionName, "main_y", joysticks[i].axis[CTL_MAIN_Y]);
|
||||
file.Set(SectionName, "sub_x", joysticks[i].axis[CTL_SUB_X]);
|
||||
file.Set(SectionName, "sub_y", joysticks[i].axis[CTL_SUB_Y]);
|
||||
file.Set(SectionName, "enabled", joysticks[i].enabled);
|
||||
file.Set(SectionName, "deadzone", joysticks[i].deadzone);
|
||||
file.Set(SectionName, "halfpress", joysticks[i].halfpress);
|
||||
file.Set(SectionName, "joy_id", joysticks[i].ID);
|
||||
file.Set(SectionName, "controllertype", joysticks[i].controllertype);
|
||||
file.Set(SectionName, "eventnum", joysticks[i].eventnum);
|
||||
// Create a section name
|
||||
SectionName = CheckForDuplicateNames(joyinfo[joysticks[i].ID].Name, Duplicates);
|
||||
}
|
||||
|
||||
file.Set(SectionName.c_str(), "l_shoulder", joysticks[i].buttons[CTL_L_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "r_shoulder", joysticks[i].buttons[CTL_R_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "a_button", joysticks[i].buttons[CTL_A_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "b_button", joysticks[i].buttons[CTL_B_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "x_button", joysticks[i].buttons[CTL_X_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "y_button", joysticks[i].buttons[CTL_Y_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "z_trigger", joysticks[i].buttons[CTL_Z_TRIGGER]);
|
||||
file.Set(SectionName.c_str(), "start_button", joysticks[i].buttons[CTL_START]);
|
||||
file.Set(SectionName.c_str(), "dpad", joysticks[i].dpad);
|
||||
file.Set(SectionName.c_str(), "dpad_up", joysticks[i].dpad2[CTL_D_PAD_UP]);
|
||||
file.Set(SectionName.c_str(), "dpad_down", joysticks[i].dpad2[CTL_D_PAD_DOWN]);
|
||||
file.Set(SectionName.c_str(), "dpad_left", joysticks[i].dpad2[CTL_D_PAD_LEFT]);
|
||||
file.Set(SectionName.c_str(), "dpad_right", joysticks[i].dpad2[CTL_D_PAD_RIGHT]);
|
||||
file.Set(SectionName.c_str(), "main_x", joysticks[i].axis[CTL_MAIN_X]);
|
||||
file.Set(SectionName.c_str(), "main_y", joysticks[i].axis[CTL_MAIN_Y]);
|
||||
file.Set(SectionName.c_str(), "sub_x", joysticks[i].axis[CTL_SUB_X]);
|
||||
file.Set(SectionName.c_str(), "sub_y", joysticks[i].axis[CTL_SUB_Y]);
|
||||
|
||||
file.Set(SectionName.c_str(), "deadzone", joysticks[i].deadzone);
|
||||
file.Set(SectionName.c_str(), "halfpress", joysticks[i].halfpress);
|
||||
|
||||
file.Set(SectionName.c_str(), "controllertype", joysticks[i].controllertype);
|
||||
file.Set(SectionName.c_str(), "eventnum", joysticks[i].eventnum);
|
||||
|
||||
file.Set(SectionName.c_str(), "Diagonal", g_Config.SDiagonal);
|
||||
file.Set(SectionName.c_str(), "SquareToCircle", g_Config.bSquareToCircle);
|
||||
}
|
||||
|
||||
file.Save("nJoy.ini");
|
||||
@@ -118,39 +173,69 @@ void SaveConfig()
|
||||
|
||||
// Load settings from file
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void LoadConfig()
|
||||
void Config::Load(bool Config)
|
||||
{
|
||||
IniFile file;
|
||||
file.Load("nJoy.ini");
|
||||
std::vector<std::string> Duplicates;
|
||||
|
||||
file.Get("General", "SaveByID", &g_Config.bSaveByID, false);
|
||||
file.Get("General", "ShowAdvanced", &g_Config.bShowAdvanced, false);
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
char SectionName[32];
|
||||
sprintf(SectionName, "PAD%i", i+1);
|
||||
std::string SectionName = StringFromFormat("PAD%i", i+1);
|
||||
|
||||
file.Get(SectionName, "l_shoulder", &joysticks[i].buttons[CTL_L_SHOULDER], 4);
|
||||
file.Get(SectionName, "r_shoulder", &joysticks[i].buttons[CTL_R_SHOULDER], 5);
|
||||
file.Get(SectionName, "a_button", &joysticks[i].buttons[CTL_A_BUTTON], 0);
|
||||
file.Get(SectionName, "b_button", &joysticks[i].buttons[CTL_B_BUTTON], 1);
|
||||
file.Get(SectionName, "x_button", &joysticks[i].buttons[CTL_X_BUTTON], 3);
|
||||
file.Get(SectionName, "y_button", &joysticks[i].buttons[CTL_Y_BUTTON], 2);
|
||||
file.Get(SectionName, "z_trigger", &joysticks[i].buttons[CTL_Z_TRIGGER], 7);
|
||||
file.Get(SectionName, "start_button", &joysticks[i].buttons[CTL_START], 9);
|
||||
file.Get(SectionName, "dpad", &joysticks[i].dpad, 0);
|
||||
file.Get(SectionName, "dpad_up", &joysticks[i].dpad2[CTL_D_PAD_UP], 0);
|
||||
file.Get(SectionName, "dpad_down", &joysticks[i].dpad2[CTL_D_PAD_DOWN], 0);
|
||||
file.Get(SectionName, "dpad_left", &joysticks[i].dpad2[CTL_D_PAD_LEFT], 0);
|
||||
file.Get(SectionName, "dpad_right", &joysticks[i].dpad2[CTL_D_PAD_RIGHT], 0);
|
||||
file.Get(SectionName, "main_x", &joysticks[i].axis[CTL_MAIN_X], 0);
|
||||
file.Get(SectionName, "main_y", &joysticks[i].axis[CTL_MAIN_Y], 1);
|
||||
file.Get(SectionName, "sub_x", &joysticks[i].axis[CTL_SUB_X], 2);
|
||||
file.Get(SectionName, "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
|
||||
file.Get(SectionName, "enabled", &joysticks[i].enabled, 1);
|
||||
file.Get(SectionName, "deadzone", &joysticks[i].deadzone, 9);
|
||||
file.Get(SectionName, "halfpress", &joysticks[i].halfpress, 6);
|
||||
file.Get(SectionName, "joy_id", &joysticks[i].ID, 0);
|
||||
file.Get(SectionName, "controllertype", &joysticks[i].controllertype, 0);
|
||||
file.Get(SectionName, "eventnum", &joysticks[i].eventnum, 0);
|
||||
// Don't update this when we are loading settings from the ConfigBox
|
||||
if(!Config)
|
||||
{
|
||||
file.Get(SectionName.c_str(), "joy_id", &joysticks[i].ID, 0);
|
||||
file.Get(SectionName.c_str(), "enabled", &joysticks[i].enabled, 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Load joypad specific settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Current joypad device ID: joysticks[i].ID
|
||||
// Current joypad name: joyinfo[joysticks[i].ID].Name
|
||||
if(g_Config.bSaveByID)
|
||||
{
|
||||
/* Prevent a crash from illegal access to joyinfo that will only have values for
|
||||
the current amount of connected joysticks */
|
||||
if(joysticks[i].ID >= SDL_NumJoysticks()) continue;
|
||||
|
||||
//PanicAlert("%i %i",joysticks[i].ID, SDL_NumJoysticks());
|
||||
//PanicAlert("%s", joyinfo[joysticks[i].ID].Name);
|
||||
|
||||
// Create a section name
|
||||
SectionName = CheckForDuplicateNames(joyinfo[joysticks[i].ID].Name, Duplicates);
|
||||
}
|
||||
|
||||
file.Get(SectionName.c_str(), "l_shoulder", &joysticks[i].buttons[CTL_L_SHOULDER], 4);
|
||||
file.Get(SectionName.c_str(), "r_shoulder", &joysticks[i].buttons[CTL_R_SHOULDER], 5);
|
||||
file.Get(SectionName.c_str(), "a_button", &joysticks[i].buttons[CTL_A_BUTTON], 0);
|
||||
file.Get(SectionName.c_str(), "b_button", &joysticks[i].buttons[CTL_B_BUTTON], 1);
|
||||
file.Get(SectionName.c_str(), "x_button", &joysticks[i].buttons[CTL_X_BUTTON], 3);
|
||||
file.Get(SectionName.c_str(), "y_button", &joysticks[i].buttons[CTL_Y_BUTTON], 2);
|
||||
file.Get(SectionName.c_str(), "z_trigger", &joysticks[i].buttons[CTL_Z_TRIGGER], 7);
|
||||
file.Get(SectionName.c_str(), "start_button", &joysticks[i].buttons[CTL_START], 9);
|
||||
file.Get(SectionName.c_str(), "dpad", &joysticks[i].dpad, 0);
|
||||
file.Get(SectionName.c_str(), "dpad_up", &joysticks[i].dpad2[CTL_D_PAD_UP], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_down", &joysticks[i].dpad2[CTL_D_PAD_DOWN], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_left", &joysticks[i].dpad2[CTL_D_PAD_LEFT], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_right", &joysticks[i].dpad2[CTL_D_PAD_RIGHT], 0);
|
||||
file.Get(SectionName.c_str(), "main_x", &joysticks[i].axis[CTL_MAIN_X], 0);
|
||||
file.Get(SectionName.c_str(), "main_y", &joysticks[i].axis[CTL_MAIN_Y], 1);
|
||||
file.Get(SectionName.c_str(), "sub_x", &joysticks[i].axis[CTL_SUB_X], 2);
|
||||
file.Get(SectionName.c_str(), "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
|
||||
file.Get(SectionName.c_str(), "deadzone", &joysticks[i].deadzone, 9);
|
||||
file.Get(SectionName.c_str(), "halfpress", &joysticks[i].halfpress, 6);
|
||||
file.Get(SectionName.c_str(), "controllertype", &joysticks[i].controllertype, 0);
|
||||
file.Get(SectionName.c_str(), "eventnum", &joysticks[i].eventnum, 0);
|
||||
|
||||
file.Get(SectionName.c_str(), "Diagonal", &g_Config.SDiagonal, "100%");
|
||||
file.Get(SectionName.c_str(), "SquareToCircle", &g_Config.bSquareToCircle, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
|
||||
struct Config
|
||||
{
|
||||
Config();
|
||||
void Load(bool Config = false);
|
||||
void Save();
|
||||
std::string CheckForDuplicateNames(std::string _Name, std::vector<std::string> &Duplicates);
|
||||
|
||||
// General
|
||||
bool bShowAdvanced; // Only allow one of these
|
||||
bool bSaveByID;
|
||||
|
||||
// Joystick
|
||||
std::string SDiagonal;
|
||||
bool bSquareToCircle;
|
||||
};
|
||||
|
||||
extern Config g_Config;
|
||||
|
||||
#endif // _CONFIG_H
|
||||
@@ -41,71 +41,96 @@ extern CONTROLLER_INFO *joyinfo;
|
||||
extern bool emulator_running;
|
||||
////////////////////////
|
||||
|
||||
int main_stick_x = 0;
|
||||
/* If we don't use this hack m_MainSizer->GetMinSize().GetWidth() will not change
|
||||
when we enable and disable bShowAdvanced */
|
||||
bool StrangeHack = true;
|
||||
|
||||
// Set PAD status
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::PadGetStatus()
|
||||
{
|
||||
//
|
||||
int _numPAD = 0;
|
||||
|
||||
if (!joysticks[_numPAD].enabled)
|
||||
// Return if it's not enabled
|
||||
if (!joysticks[notebookpage].enabled)
|
||||
{
|
||||
m_TStatusIn[notebookpage]->SetLabel(wxT("Not enabled"));
|
||||
return;
|
||||
|
||||
// Clear pad status
|
||||
//memset(_pPADStatus, 0, sizeof(SPADStatus));
|
||||
|
||||
}
|
||||
|
||||
// Get pad status
|
||||
GetJoyState(_numPAD);
|
||||
|
||||
// Reset!
|
||||
/*
|
||||
int base = 0x80;
|
||||
_pPADStatus->stickY = base;
|
||||
_pPADStatus->stickX = base;
|
||||
_pPADStatus->substickX = base;
|
||||
_pPADStatus->substickY = base;
|
||||
_pPADStatus->button |= PAD_USE_ORIGIN;
|
||||
*/
|
||||
GetJoyState(notebookpage);
|
||||
|
||||
// Set analog controllers
|
||||
// Set Deadzones perhaps out of function
|
||||
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1));
|
||||
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1));
|
||||
|
||||
// Adjust range
|
||||
// The value returned by SDL_JoystickGetAxis is a signed integer (-32768 to 32768)
|
||||
// The value used for the gamecube controller is an unsigned char (0 to 255)
|
||||
int main_stick_x = (joystate[_numPAD].axis[CTL_MAIN_X] >> 8);
|
||||
int main_stick_y = -(joystate[_numPAD].axis[CTL_MAIN_Y] >> 8);
|
||||
//int sub_stick_x = (joystate[_numPAD].axis[CTL_SUB_X] >> 8);
|
||||
//int sub_stick_y = -(joystate[_numPAD].axis[CTL_SUB_Y] >> 8);
|
||||
// Get original values
|
||||
int main_x = joystate[notebookpage].axis[CTL_MAIN_X];
|
||||
int main_y = joystate[notebookpage].axis[CTL_MAIN_Y];
|
||||
//int sub_x = (joystate[_numPAD].axis[CTL_SUB_X];
|
||||
//int sub_y = -(joystate[_numPAD].axis[CTL_SUB_Y];
|
||||
|
||||
|
||||
if (joystate[_numPAD].buttons[CTL_A_BUTTON])
|
||||
// Get adjusted values
|
||||
int main_x_after = main_x, main_y_after = main_y;
|
||||
if(g_Config.bSquareToCircle)
|
||||
{
|
||||
PanicAlert("");
|
||||
//_pPADStatus->button |= PAD_BUTTON_A;
|
||||
//_pPADStatus->analogA = 255; // Perhaps support pressure?
|
||||
for(int i=0; i<4 ;i++)
|
||||
{
|
||||
m_bmpDot[i]->SetPosition(wxPoint(main_stick_x += 3, main_stick_y));
|
||||
}
|
||||
std::vector<int> main_xy = Pad_Square_to_Circle(main_x, main_y);
|
||||
main_x_after = main_xy.at(0);
|
||||
main_y_after = main_xy.at(1);
|
||||
}
|
||||
|
||||
for(int i=0; i<4 ;i++)
|
||||
{
|
||||
//m_bmpDot[i]->SetPosition(wxPoint(main_stick_x / 4, main_stick_y / 4));
|
||||
}
|
||||
//
|
||||
float f_x = main_x / 32767.0;
|
||||
float f_y = main_y / 32767.0;
|
||||
float f_x_aft = main_x_after / 32767.0;
|
||||
float f_y_aft = main_y_after / 32767.0;
|
||||
|
||||
/*
|
||||
m_pStatusBar->SetLabel(wxString::Format(
|
||||
"ID:%i | %i %i = %1.2f %1.2f | %i %i = %1.2f %1.2f",
|
||||
ID,
|
||||
main_x, main_y,
|
||||
f_x, f_y,
|
||||
main_x_after, main_y_after,
|
||||
f_x_aft, f_y_aft
|
||||
));*/
|
||||
|
||||
m_TStatusIn[notebookpage]->SetLabel(wxString::Format(
|
||||
wxT("x:%1.2f y:%1.2f"),
|
||||
f_x, f_y
|
||||
));
|
||||
|
||||
m_TStatusOut[notebookpage]->SetLabel(wxString::Format(
|
||||
wxT("x:%1.2f y:%1.2f"),
|
||||
f_x_aft, f_y_aft
|
||||
));
|
||||
|
||||
// Adjust the values for the plot
|
||||
int BoxW_ = BoxW - 2; int BoxH_ = BoxH - 2; // Border adjustment
|
||||
|
||||
main_x = (BoxW_ / 2) + (main_x * BoxW_ / (32767 * 2));
|
||||
main_y = (BoxH_ / 2) + (main_y * BoxH_ / (32767 * 2));
|
||||
|
||||
int main_x_out = (BoxW_ / 2) + (main_x_after * BoxW_ / (32767 * 2));
|
||||
int main_y_out = (BoxH_ / 2) + (main_y_after * BoxH_ / (32767 * 2));
|
||||
|
||||
// Adjust the dot
|
||||
m_bmpDot[notebookpage]->SetPosition(wxPoint(main_x, main_y));
|
||||
m_bmpDotOut[notebookpage]->SetPosition(wxPoint(main_x_out, main_y_out));
|
||||
|
||||
}
|
||||
|
||||
// Populate the advanced tab
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::Update()
|
||||
{
|
||||
//PadGetStatus();
|
||||
if(StrangeHack) PadGetStatus();
|
||||
if(!g_Config.bShowAdvanced) StrangeHack = false; else StrangeHack = true;
|
||||
|
||||
/*
|
||||
m_pStatusBar->SetLabel(wxString::Format(
|
||||
"ID: %i %i %i",
|
||||
m_Joyname[0]->GetSelection(), (int)StrangeHack, (int)g_Config.bShowAdvanced
|
||||
));*/
|
||||
}
|
||||
|
||||
|
||||
@@ -113,33 +138,43 @@ void ConfigBox::Update()
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::CreateAdvancedControls(int i)
|
||||
{
|
||||
m_pInStatus[i] = new wxPanel(m_Notebook, ID_INSTATUS1 + i, wxDefaultPosition, wxDefaultSize);
|
||||
m_pInStatus[i] = new wxPanel(m_Controller[i], ID_INSTATUS1 + i, wxDefaultPosition, wxDefaultSize);
|
||||
m_bmpSquare[i] = new wxStaticBitmap(m_pInStatus[i], ID_STATUSBMP1 + i, CreateBitmap(),
|
||||
//wxPoint(4, 15), wxSize(70,70));
|
||||
//wxPoint(4, 20), wxDefaultSize);
|
||||
wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
m_bmpDot[i] = new wxStaticBitmap(m_pInStatus[i], ID_STATUSDOTBMP1 + i, CreateBitmapDot(),
|
||||
wxPoint(40, 40), wxDefaultSize);
|
||||
wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize);
|
||||
|
||||
m_pOutStatus[i] = new wxPanel(m_Controller[i], ID_INSTATUS1 + i, wxDefaultPosition, wxDefaultSize);
|
||||
m_bmpSquareOut[i] = new wxStaticBitmap(m_pOutStatus[i], ID_STATUSBMP1 + i, CreateBitmap(),
|
||||
//wxPoint(4, 15), wxSize(70,70));
|
||||
//wxPoint(4, 20), wxDefaultSize);
|
||||
wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
m_bmpDotOut[i] = new wxStaticBitmap(m_pOutStatus[i], ID_STATUSDOTBMP1 + i, CreateBitmapDot(),
|
||||
wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize);
|
||||
}
|
||||
|
||||
|
||||
wxBitmap ConfigBox::CreateBitmap() // Create box
|
||||
{
|
||||
int w = 70, h = 70;
|
||||
wxBitmap bitmap(w, h);
|
||||
BoxW = 70, BoxH = 70;
|
||||
wxBitmap bitmap(BoxW, BoxH);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
|
||||
// Set outline and fill colors
|
||||
wxBrush LightBlueBrush(_T("#0383f0"));
|
||||
wxPen LightBluePen(_T("#80c5fd"));
|
||||
wxPen LightGrayPen(_T("#909090"));
|
||||
dc.SetPen(LightGrayPen);
|
||||
//wxBrush LightBlueBrush(_T("#0383f0"));
|
||||
//wxPen LightBluePen(_T("#80c5fd"));
|
||||
//wxPen LightGrayPen(_T("#909090"));
|
||||
wxPen LightBluePen(_T("#7f9db9")); // Windows XP color
|
||||
dc.SetPen(LightBluePen);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
|
||||
dc.Clear();
|
||||
dc.DrawRectangle(0, 0, w, h);
|
||||
dc.DrawRectangle(0, 0, BoxW, BoxH);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
@@ -152,11 +187,11 @@ wxBitmap ConfigBox::CreateBitmapDot() // Create dot
|
||||
dc.SelectObject(bitmap);
|
||||
|
||||
// Set outline and fill colors
|
||||
wxBrush LightBlueBrush(_T("#0383f0"));
|
||||
wxPen LightBluePen(_T("#80c5fd"));
|
||||
wxPen LightGrayPen(_T("#909090"));
|
||||
dc.SetPen(LightGrayPen);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
//wxBrush RedBrush(_T("#0383f0"));
|
||||
//wxPen RedPen(_T("#80c5fd"));
|
||||
//wxPen LightGrayPen(_T("#909090"));
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
|
||||
dc.Clear();
|
||||
dc.DrawRectangle(0, 0, w, h);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -65,19 +65,31 @@ class ConfigBox : public wxDialog
|
||||
void OnTimer(wxTimerEvent& WXUNUSED(event)) { Update(); }
|
||||
wxTimer m_timer;
|
||||
#endif
|
||||
|
||||
// Debugging
|
||||
wxStaticText* m_pStatusBar, * m_pStatusBar2;
|
||||
|
||||
// Status window
|
||||
int BoxW, BoxH;
|
||||
|
||||
private:
|
||||
wxButton *m_About;
|
||||
wxButton *m_OK;
|
||||
wxButton *m_Cancel;
|
||||
|
||||
wxPanel *m_Controller[4];
|
||||
wxPanel *m_Controller[4]; // Main containers
|
||||
wxNotebook *m_Notebook;
|
||||
wxBoxSizer * m_MainSizer;
|
||||
|
||||
wxPanel * m_pKeys[4], * m_pInStatus[4];
|
||||
wxBitmap WxStaticBitmap1_BITMAP;
|
||||
wxPanel * m_pKeys[4], * m_pInStatus[4], * m_pOutStatus[4];
|
||||
wxBitmap WxStaticBitmap1_BITMAP, WxStaticBitmap1_BITMAPGray;
|
||||
wxStaticBoxSizer * m_sKeys[4];
|
||||
wxBoxSizer * m_sMain[4], * m_sSettings[4];
|
||||
wxBoxSizer *m_sMain[4], *m_sMainLeft[4], *m_sMainRight[4];
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Settings
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
|
||||
wxComboBox *m_Joyname[4];
|
||||
wxComboBox *m_Controltype[4];
|
||||
@@ -86,9 +98,24 @@ class ConfigBox : public wxDialog
|
||||
wxCheckBox *m_Joyattach[4];
|
||||
wxStaticBoxSizer *m_gJoyname[4];
|
||||
|
||||
wxStaticBoxSizer *m_gExtrasettings[4]; wxGridBagSizer * m_gGBExtrasettings[4]; // Settings
|
||||
wxBoxSizer* m_sSettings[4]; // Settings
|
||||
|
||||
wxStaticBoxSizer *m_gExtrasettings[4]; wxGridBagSizer * m_gGBExtrasettings[4]; // Extra settings
|
||||
wxStaticBoxSizer *m_gControllertype[4];
|
||||
wxStaticBoxSizer *m_gStatusIn[4];
|
||||
|
||||
wxStaticBoxSizer *m_gGenSettings[4]; // General settings
|
||||
wxCheckBox *m_CBSaveByID[4], *m_CBShowAdvanced[4];
|
||||
|
||||
wxStaticBoxSizer *m_gStatusIn[4], *m_gStatusInSettings[4]; // Advanced settings
|
||||
wxBoxSizer *m_gStatusInSettingsH[4];
|
||||
wxGridBagSizer * m_GBAdvancedMainStick[4];
|
||||
wxStaticText *m_TStatusIn[4], *m_TStatusOut[4];
|
||||
wxComboBox *m_CoBDiagonal[4]; wxCheckBox *m_CBS_to_C[4]; wxStaticText *m_STDiagonal[4];
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Keys
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
|
||||
wxTextCtrl *m_JoyShoulderL[4];
|
||||
wxTextCtrl *m_JoyShoulderR[4];
|
||||
@@ -145,7 +172,8 @@ class ConfigBox : public wxDialog
|
||||
wxStaticText *m_textWebsite[4];
|
||||
|
||||
wxTextCtrl *m_PlaceholderBMP[4];
|
||||
wxStaticBitmap *m_controllerimage[4], *m_bmpSquare[4], *m_bmpDot[4];
|
||||
wxStaticBitmap *m_controllerimage[4],
|
||||
*m_bmpSquare[4], *m_bmpDot[4], *m_bmpSquareOut[4], *m_bmpDotOut[4];
|
||||
|
||||
int notebookpage;
|
||||
private:
|
||||
@@ -159,23 +187,32 @@ class ConfigBox : public wxDialog
|
||||
ID_CONTROLLERPAGE2,
|
||||
ID_CONTROLLERPAGE3,
|
||||
ID_CONTROLLERPAGE4,
|
||||
|
||||
ID_INSTATUS1, ID_INSTATUS2, ID_INSTATUS3, ID_INSTATUS4, // Advanced status
|
||||
ID_CONTROLLERPICTURE, // Background picture
|
||||
|
||||
ID_KEYSPANEL1, ID_KEYSPANEL2, ID_KEYSPANEL3, ID_KEYSPANEL4,
|
||||
|
||||
IDC_JOYNAME,
|
||||
IDC_CONTROLTYPE,
|
||||
IDC_DEADZONE,
|
||||
IDG_JOYSTICK, IDC_JOYNAME, IDC_JOYATTACH, // Controller attached
|
||||
|
||||
IDC_JOYATTACH,
|
||||
IDG_JOYSTICK,
|
||||
IDG_EXTRASETTINGS,
|
||||
IDG_CONTROLLERTYPE,
|
||||
ID_CONTROLLERPICTURE,
|
||||
IDG_EXTRASETTINGS, IDC_DEADZONE, // Extra settings
|
||||
|
||||
IDG_CONTROLLERTYPE, IDC_CONTROLTYPE, // Controller type
|
||||
|
||||
IDC_SAVEBYID, IDC_SHOWADVANCED, // Settings
|
||||
|
||||
ID_INSTATUS1, ID_INSTATUS2, ID_INSTATUS3, ID_INSTATUS4, // Advanced status
|
||||
ID_STATUSBMP1, ID_STATUSBMP2, ID_STATUSBMP3, ID_STATUSBMP4,
|
||||
ID_STATUSDOTBMP1, ID_STATUSDOTBMP2, ID_STATUSDOTBMP3, ID_STATUSDOTBMP4,
|
||||
IDT_STATUS_IN, IDT_STATUS_OUT,
|
||||
|
||||
// Advaced settings
|
||||
IDCB_MAINSTICK_DIAGONAL, IDCB_MAINSTICK_S_TO_C, IDT_MAINSTICK_DIAGONAL,
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Keys objects
|
||||
// -----------------------------
|
||||
|
||||
// Text controls
|
||||
ID_SHOULDER_L = 2000,
|
||||
ID_SHOULDER_R,
|
||||
|
||||
@@ -197,6 +234,7 @@ class ConfigBox : public wxDialog
|
||||
ID_DPAD_LEFT,
|
||||
ID_DPAD_RIGHT,
|
||||
|
||||
// Buttons controls
|
||||
IDB_SHOULDER_L = 3000,
|
||||
IDB_SHOULDER_R,
|
||||
|
||||
@@ -218,6 +256,7 @@ class ConfigBox : public wxDialog
|
||||
IDB_DPAD_LEFT,
|
||||
IDB_DPAD_RIGHT,
|
||||
|
||||
// Text controls
|
||||
IDT_ANALOG_MAIN_X = 4000,
|
||||
IDT_ANALOG_MAIN_Y,
|
||||
IDT_DPAD_UP,
|
||||
@@ -229,6 +268,7 @@ class ConfigBox : public wxDialog
|
||||
IDT_ANALOG_SUB_X,
|
||||
IDT_ANALOG_SUB_Y,
|
||||
IDT_WEBSITE,
|
||||
IDT_DEBUGGING, IDT_DEBUGGING2,
|
||||
|
||||
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
|
||||
};
|
||||
@@ -240,9 +280,14 @@ class ConfigBox : public wxDialog
|
||||
|
||||
void ChangeJoystick(wxCommandEvent& event);
|
||||
void ChangeControllertype(wxCommandEvent& event);
|
||||
void EnableDisable(wxCommandEvent& event); void DoEnableDisable(int _notebookpage);
|
||||
|
||||
void ChangeSettings(wxCommandEvent& event); // Settings
|
||||
void ComboChange(wxCommandEvent& event);
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls(); void CreateAdvancedControls(int i);
|
||||
void SizeWindow();
|
||||
wxBitmap CreateBitmap(); wxBitmap CreateBitmapDot();
|
||||
void PadGetStatus(); void Update();
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||
|
||||
// Use PAD rumble
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PAD_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_RUMBLE_DINPUT_HACK
|
||||
|
||||
@@ -19,6 +19,7 @@ if padenv['HAVE_WX']:
|
||||
files += [
|
||||
'GUI/AboutBox.cpp',
|
||||
'GUI/ConfigAdvanced.cpp',
|
||||
'GUI/ConfigJoypad.cpp',
|
||||
'GUI/ConfigBox.cpp',
|
||||
]
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,18 +32,21 @@
|
||||
// Set this if you want to use the rumble 'hack' for controller one
|
||||
//#define USE_RUMBLE_DINPUT_HACK
|
||||
|
||||
#include <vector>
|
||||
#include <vector> // System
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Common.h" // Common
|
||||
#include "pluginspecs_pad.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include "Config.h" // Local
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "GUI/AboutBox.h"
|
||||
#include "GUI/ConfigBox.h"
|
||||
#include "GUI/AboutBox.h"
|
||||
#include "GUI/ConfigBox.h"
|
||||
//extern ConfigBox* m_frame;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -167,6 +170,7 @@ enum
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _CONTROLLER_STATE_H
|
||||
extern FILE *pFile;
|
||||
extern CONTROLLER_INFO *joyinfo;
|
||||
extern CONTROLLER_STATE joystate[4];
|
||||
extern CONTROLLER_MAPPING joysticks[4];
|
||||
extern HWND m_hWnd; // Handle to window
|
||||
@@ -182,7 +186,9 @@ int Search_Devices();
|
||||
void DEBUG_INIT();
|
||||
void DEBUG_QUIT();
|
||||
|
||||
void PAD_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
|
||||
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
|
||||
u8 Pad_Convert(int _val); // Value conversion
|
||||
std::vector<int> Pad_Square_to_Circle(int _x, int _y); // Value conversion
|
||||
|
||||
void SaveConfig();
|
||||
void LoadConfig();
|
||||
//void SaveConfig();
|
||||
//void LoadConfig();
|
||||
|
||||
Reference in New Issue
Block a user