mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-10-08 16:43:25 +00:00
Made GCPadNew load the same defaults as old GCPad if GCPadNew.ini doesn't exist. (haven't tested Linux/OS X)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5654 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ce3c2700e7
commit
a82adcd5d3
@ -33,12 +33,12 @@ void ControllerInterface::Init()
|
|||||||
if ( m_is_init )
|
if ( m_is_init )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CIFACE_USE_XINPUT
|
|
||||||
ciface::XInput::Init( m_devices );
|
|
||||||
#endif
|
|
||||||
#ifdef CIFACE_USE_DIRECTINPUT
|
#ifdef CIFACE_USE_DIRECTINPUT
|
||||||
ciface::DirectInput::Init( m_devices/*, (HWND)m_hwnd*/ );
|
ciface::DirectInput::Init( m_devices/*, (HWND)m_hwnd*/ );
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CIFACE_USE_XINPUT
|
||||||
|
ciface::XInput::Init( m_devices );
|
||||||
|
#endif
|
||||||
#ifdef CIFACE_USE_XLIB
|
#ifdef CIFACE_USE_XLIB
|
||||||
ciface::Xlib::Init( m_devices, m_hwnd );
|
ciface::Xlib::Init( m_devices, m_hwnd );
|
||||||
#endif
|
#endif
|
||||||
|
@ -454,8 +454,7 @@ GETDEVDATA :
|
|||||||
if (DIERR_INPUTLOST == hr || DIERR_NOTACQUIRED == hr)
|
if (DIERR_INPUTLOST == hr || DIERR_NOTACQUIRED == hr)
|
||||||
hr = m_device->Acquire();
|
hr = m_device->Acquire();
|
||||||
|
|
||||||
return true;
|
return SUCCEEDED(hr);
|
||||||
//return SUCCEEDED(hr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Joystick::UpdateOutput()
|
bool Joystick::UpdateOutput()
|
||||||
|
@ -24,12 +24,14 @@ Plugin::~Plugin()
|
|||||||
delete *i;
|
delete *i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugin::LoadConfig()
|
bool Plugin::LoadConfig()
|
||||||
{
|
{
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini");
|
if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
|
||||||
|
return false;
|
||||||
|
|
||||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
std::vector< ControllerEmu* >::const_iterator
|
||||||
|
i = controllers.begin(),
|
||||||
e = controllers.end();
|
e = controllers.end();
|
||||||
for ( ; i!=e; ++i ) {
|
for ( ; i!=e; ++i ) {
|
||||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
|
Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
|
||||||
~Plugin();
|
~Plugin();
|
||||||
|
|
||||||
void LoadConfig();
|
bool LoadConfig();
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
|
||||||
std::vector< ControllerEmu* > controllers;
|
std::vector< ControllerEmu* > controllers;
|
||||||
|
@ -404,6 +404,8 @@ public:
|
|||||||
|
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
|
|
||||||
|
virtual void LoadDefaults() {}
|
||||||
|
|
||||||
void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
void UpdateDefaultDevice();
|
void UpdateDefaultDevice();
|
||||||
|
@ -106,3 +106,81 @@ void GCPad::SetOutput( const bool on )
|
|||||||
// only rumble if window has focus or background input is enabled
|
// only rumble if window has focus or background input is enabled
|
||||||
m_rumble->controls[0]->control_ref->State( on && (g_PADInitialize->pRendererHasFocus() || m_options[0].settings[0]->value) );
|
m_rumble->controls[0]->control_ref->State( on && (g_PADInitialize->pRendererHasFocus() || m_options[0].settings[0]->value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCPad::LoadDefaults()
|
||||||
|
{
|
||||||
|
#define set_control(group, num, str) (group)->controls[num]->control_ref->control_qualifier.name = (str)
|
||||||
|
|
||||||
|
// nvm, do the device part elsewhere
|
||||||
|
//#ifdef _WIN32
|
||||||
|
// default_device.FromString("DirectInput/0/Keyboard Mouse");
|
||||||
|
//#elif __APPLE__
|
||||||
|
// // keyboard mouse devices are named by their product name thing on OSX currently
|
||||||
|
//#else
|
||||||
|
// default_device.FromString("Xlib/0/Keyboard");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
set_control(m_buttons, 0, "X"); // A
|
||||||
|
set_control(m_buttons, 1, "Z"); // B
|
||||||
|
set_control(m_buttons, 2, "C"); // X
|
||||||
|
set_control(m_buttons, 3, "S"); // Y
|
||||||
|
set_control(m_buttons, 4, "D"); // Z
|
||||||
|
#ifdef _WIN32
|
||||||
|
set_control(m_buttons, 5, "RETURN"); // Start
|
||||||
|
#else
|
||||||
|
// osx/linux
|
||||||
|
set_control(m_buttons, 5, "Return"); // Start
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// stick modifiers to 50 %
|
||||||
|
m_main_stick->controls[4]->control_ref->range = 0.5f;
|
||||||
|
m_c_stick->controls[4]->control_ref->range = 0.5f;
|
||||||
|
|
||||||
|
// D-Pad
|
||||||
|
set_control(m_dpad, 0, "T"); // Up
|
||||||
|
set_control(m_dpad, 1, "G"); // Down
|
||||||
|
set_control(m_dpad, 2, "F"); // Left
|
||||||
|
set_control(m_dpad, 3, "H"); // Right
|
||||||
|
|
||||||
|
// C-Stick
|
||||||
|
set_control(m_c_stick, 0, "I"); // Up
|
||||||
|
set_control(m_c_stick, 1, "K"); // Down
|
||||||
|
set_control(m_c_stick, 2, "J"); // Left
|
||||||
|
set_control(m_c_stick, 3, "L"); // Right
|
||||||
|
#ifdef _WIN32
|
||||||
|
set_control(m_c_stick, 4, "LCONTROL"); // Modifier
|
||||||
|
|
||||||
|
// Main Stick
|
||||||
|
set_control(m_main_stick, 0, "UP"); // Up
|
||||||
|
set_control(m_main_stick, 1, "DOWN"); // Down
|
||||||
|
set_control(m_main_stick, 2, "LEFT"); // Left
|
||||||
|
set_control(m_main_stick, 3, "RIGHT"); // Right
|
||||||
|
set_control(m_main_stick, 4, "LSHIFT"); // Modifier
|
||||||
|
|
||||||
|
#elif __APPLE__
|
||||||
|
set_control(m_c_stick, 4, "Left Control"); // Modifier
|
||||||
|
|
||||||
|
// Main Stick
|
||||||
|
set_control(m_main_stick, 0, "Up Arrow"); // Up
|
||||||
|
set_control(m_main_stick, 1, "Down Arrow"); // Down
|
||||||
|
set_control(m_main_stick, 2, "Left Arrow"); // Left
|
||||||
|
set_control(m_main_stick, 3, "Right Arrow"); // Right
|
||||||
|
set_control(m_main_stick, 4, "Left Shift"); // Modifier
|
||||||
|
#else
|
||||||
|
// not sure if these are right
|
||||||
|
|
||||||
|
set_control(m_c_stick, 4, "Control_L"); // Modifier
|
||||||
|
|
||||||
|
// Main Stick
|
||||||
|
set_control(m_main_stick, 0, "Up"); // Up
|
||||||
|
set_control(m_main_stick, 1, "Down"); // Down
|
||||||
|
set_control(m_main_stick, 2, "Left"); // Left
|
||||||
|
set_control(m_main_stick, 3, "Right"); // Right
|
||||||
|
set_control(m_main_stick, 4, "Shift_L"); // Modifier
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Triggers
|
||||||
|
set_control(m_triggers, 0, "Q"); // L
|
||||||
|
set_control(m_triggers, 1, "W"); // R
|
||||||
|
}
|
@ -15,6 +15,7 @@ public:
|
|||||||
|
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
|
|
||||||
|
void LoadDefaults();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -110,15 +110,28 @@ void InitPlugin( void* const hwnd )
|
|||||||
for ( unsigned int i = 0; i<4; ++i )
|
for ( unsigned int i = 0; i<4; ++i )
|
||||||
g_plugin.controllers.push_back( new GCPad( i ) );
|
g_plugin.controllers.push_back( new GCPad( i ) );
|
||||||
|
|
||||||
// load the saved controller config
|
// needed for Xlib
|
||||||
g_plugin.LoadConfig();
|
g_plugin.controller_interface.SetHwnd(hwnd);
|
||||||
|
|
||||||
// needed for Xlib and exclusive dinput
|
|
||||||
g_plugin.controller_interface.SetHwnd( hwnd );
|
|
||||||
g_plugin.controller_interface.Init();
|
g_plugin.controller_interface.Init();
|
||||||
|
|
||||||
|
// load the saved controller config
|
||||||
|
if (false == g_plugin.LoadConfig())
|
||||||
|
{
|
||||||
|
// load default config for pad 1
|
||||||
|
g_plugin.controllers[0]->LoadDefaults();
|
||||||
|
|
||||||
|
// kinda silly, set default device(all controls) to first one found in ControllerInterface
|
||||||
|
// should be the keyboard device
|
||||||
|
if (g_plugin.controller_interface.Devices().size())
|
||||||
|
{
|
||||||
|
g_plugin.controllers[0]->default_device.FromDevice(g_plugin.controller_interface.Devices()[0]);
|
||||||
|
g_plugin.controllers[0]->UpdateDefaultDevice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update control refs
|
// update control refs
|
||||||
std::vector<ControllerEmu*>::const_iterator i = g_plugin.controllers.begin(),
|
std::vector<ControllerEmu*>::const_iterator
|
||||||
|
i = g_plugin.controllers.begin(),
|
||||||
e = g_plugin.controllers.end();
|
e = g_plugin.controllers.end();
|
||||||
for ( ; i!=e; ++i )
|
for ( ; i!=e; ++i )
|
||||||
(*i)->UpdateReferences( g_plugin.controller_interface );
|
(*i)->UpdateReferences( g_plugin.controller_interface );
|
||||||
|
Loading…
Reference in New Issue
Block a user