2009-07-28 21:32:10 +00:00
// Copyright (C) 2003 Dolphin Project.
2008-12-08 05:25:12 +00:00
// 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/
2009-06-14 10:01:01 +00:00
#include "Common.h"
2008-12-08 05:25:12 +00:00
#include "ConfigDlg.h"
#include "../PadSimple.h"
#ifdef _WIN32
#include "XInput.h"
2009-02-15 18:23:42 +00:00
#include "../../../../Core/InputCommon/Src/DirectInputBase.h" // Core
2008-12-08 05:25:12 +00:00
DInput m_dinput ;
#endif
2009-07-02 19:00:27 +00:00
BEGIN_EVENT_TABLE ( PADConfigDialogSimple , wxDialog )
EVT_CLOSE ( PADConfigDialogSimple :: OnClose )
EVT_BUTTON ( ID_CLOSE , PADConfigDialogSimple :: OnCloseClick )
EVT_BUTTON ( ID_PAD_ABOUT , PADConfigDialogSimple :: DllAbout )
2009-02-10 14:02:01 +00:00
2009-07-02 19:00:27 +00:00
EVT_CHECKBOX ( ID_X360PAD , PADConfigDialogSimple :: ControllerSettingsChanged )
EVT_CHOICE ( ID_X360PAD_CHOICE , PADConfigDialogSimple :: ControllerSettingsChanged )
EVT_CHECKBOX ( ID_RUMBLE , PADConfigDialogSimple :: ControllerSettingsChanged )
EVT_CHECKBOX ( ID_DISABLE , PADConfigDialogSimple :: ControllerSettingsChanged )
2009-02-16 06:18:18 +00:00
// Input recording
#ifdef RERECORDING
2009-07-02 19:00:27 +00:00
EVT_CHECKBOX ( ID_RECORDING , PADConfigDialogSimple :: ControllerSettingsChanged )
EVT_CHECKBOX ( ID_PLAYBACK , PADConfigDialogSimple :: ControllerSettingsChanged )
EVT_BUTTON ( ID_SAVE_RECORDING , PADConfigDialogSimple :: ControllerSettingsChanged )
2009-02-16 06:18:18 +00:00
# endif
2009-02-10 14:02:01 +00:00
2009-07-02 19:00:27 +00:00
EVT_BUTTON ( CTL_A , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_B , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_X , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_Y , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_Z , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_START , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_L , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_R , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_MAINUP , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_MAINDOWN , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_MAINLEFT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_MAINRIGHT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_SUBUP , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_SUBDOWN , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_SUBLEFT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_SUBRIGHT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_DPADUP , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_DPADDOWN , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_DPADLEFT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_DPADRIGHT , PADConfigDialogSimple :: OnButtonClick )
EVT_BUTTON ( CTL_HALFPRESS , PADConfigDialogSimple :: OnButtonClick )
2008-12-08 05:25:12 +00:00
END_EVENT_TABLE ()
2009-07-02 19:00:27 +00:00
PADConfigDialogSimple :: PADConfigDialogSimple ( wxWindow * parent , wxWindowID id , const wxString & title , const wxPoint & position , const wxSize & size , long style )
2008-12-08 05:25:12 +00:00
: wxDialog ( parent , id , title , position , size , style )
{
#ifdef _WIN32
m_dinput . Init (( HWND ) parent );
#endif
2009-02-15 18:23:42 +00:00
ClickedButton = NULL ;
2008-12-08 05:25:12 +00:00
CreateGUIControls ();
Fit ();
2009-06-13 11:59:58 +00:00
// Connect keydown to the window
wxTheApp -> Connect ( wxID_ANY , wxEVT_KEY_DOWN ,
2009-07-02 19:00:27 +00:00
wxKeyEventHandler ( PADConfigDialogSimple :: OnKeyDown ),
2009-06-13 11:59:58 +00:00
( wxObject * ) NULL , this );
2008-12-08 05:25:12 +00:00
}
2009-07-02 19:00:27 +00:00
PADConfigDialogSimple ::~ PADConfigDialogSimple ()
2008-12-08 05:25:12 +00:00
{
}
2009-02-15 18:23:42 +00:00
//////////////////////////////////////////////////////////////////////////////////////////
// Create input button controls
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
2008-12-08 05:25:12 +00:00
inline void AddControl ( wxPanel * pan , wxButton ** button , wxStaticBoxSizer * sizer ,
const char * name , int ctl , int controller )
{
wxBoxSizer * hButton = new wxBoxSizer ( wxHORIZONTAL );
char keyStr [ 10 ] = { 0 };
2009-02-15 18:23:42 +00:00
// Add the label
2008-12-08 05:25:12 +00:00
hButton -> Add ( new wxStaticText ( pan , 0 , wxString :: FromAscii ( name ),
wxDefaultPosition , wxDefaultSize ), 0 ,
wxALIGN_CENTER_VERTICAL | wxALL );
2009-02-15 18:23:42 +00:00
// Give it the mapped key name
2008-12-08 05:25:12 +00:00
#ifdef _WIN32
DInput :: DIKToString ( pad [ controller ]. keyForControl [ ctl ], keyStr );
2009-01-13 00:34:36 +00:00
#elif defined(HAVE_X11) && HAVE_X11
2009-07-09 06:50:22 +00:00
InputCommon :: XKeyToString ( pad [ controller ]. keyForControl [ ctl ], keyStr );
2008-12-08 05:25:12 +00:00
#endif
2009-02-15 18:23:42 +00:00
// Add the button to its sizer
2008-12-08 05:25:12 +00:00
* button = new wxButton ( pan , ctl , wxString :: FromAscii ( keyStr ),
wxDefaultPosition , wxDefaultSize , wxWANTS_CHARS );
hButton -> Add ( * button , 0 , wxALIGN_RIGHT | wxALL );
sizer -> Add ( hButton , 0 , wxALIGN_RIGHT | wxALL );
}
2009-02-15 18:23:42 +00:00
////////////////////////////////////
2008-12-08 05:25:12 +00:00
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: CreateGUIControls ()
2008-12-08 05:25:12 +00:00
{
// Notebook
m_Notebook = new wxNotebook ( this , ID_NOTEBOOK , wxDefaultPosition , wxDefaultSize );
// Controller pages
m_Controller [ 0 ] = new wxPanel ( m_Notebook , ID_CONTROLLERPAGE1 , wxDefaultPosition , wxDefaultSize );
m_Notebook -> AddPage ( m_Controller [ 0 ], wxT ( "Controller 1" ));
m_Controller [ 1 ] = new wxPanel ( m_Notebook , ID_CONTROLLERPAGE2 , wxDefaultPosition , wxDefaultSize );
m_Notebook -> AddPage ( m_Controller [ 1 ], wxT ( "Controller 2" ));
m_Controller [ 2 ] = new wxPanel ( m_Notebook , ID_CONTROLLERPAGE3 , wxDefaultPosition , wxDefaultSize );
m_Notebook -> AddPage ( m_Controller [ 2 ], wxT ( "Controller 3" ));
m_Controller [ 3 ] = new wxPanel ( m_Notebook , ID_CONTROLLERPAGE4 , wxDefaultPosition , wxDefaultSize );
m_Notebook -> AddPage ( m_Controller [ 3 ], wxT ( "Controller 4" ));
// Standard buttons
m_Close = new wxButton ( this , ID_CLOSE , wxT ( "Close" ), wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator );
m_About = new wxButton ( this , ID_PAD_ABOUT , wxT ( "About" ), wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator );
// Put notebook and standard buttons in sizers
wxBoxSizer * sSButtons ;
sSButtons = new wxBoxSizer ( wxHORIZONTAL );
sSButtons -> Add ( m_About , 0 , wxALL , 5 );
sSButtons -> Add ( 0 , 0 , 1 , wxEXPAND , 5 );
sSButtons -> Add ( m_Close , 0 , wxALL , 5 );
wxBoxSizer * sMain ;
sMain = new wxBoxSizer ( wxVERTICAL );
sMain -> Add ( m_Notebook , 1 , wxEXPAND | wxALL , 5 );
sMain -> Add ( sSButtons , 0 , wxEXPAND , 5 );
this -> SetSizer ( sMain );
this -> Layout ();
#ifdef _WIN32
// Add connected XPads
for ( int x = 0 ; x < 4 ; x ++ )
{
XINPUT_STATE xstate ;
DWORD xresult = XInputGetState ( x , & xstate );
if ( xresult == ERROR_SUCCESS )
{
2009-07-30 07:08:31 +00:00
arrayStringFor_X360Pad . Add ( wxString :: Format ( wxT ( "%i" ), x + 1 ));
2008-12-08 05:25:12 +00:00
}
}
#endif
for ( int i = 0 ; i < 4 ; i ++ )
2009-02-10 14:02:01 +00:00
{
// --------------------------------------------------------------------
// Settings
// -----------------------------
// Main horizontal container
2009-02-10 12:40:06 +00:00
sDevice [ i ] = new wxBoxSizer ( wxHORIZONTAL );
2009-02-10 14:02:01 +00:00
sbDevice [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Controller Settings" ));
m_Disable [ i ] = new wxCheckBox ( m_Controller [ i ], ID_DISABLE , wxT ( "Disable when Dolphin is not in focus" ), wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator );
sbDevice [ i ] -> Add ( m_Disable [ i ], 0 , wxEXPAND | wxALL , 1 );
2008-12-08 05:25:12 +00:00
#ifdef _WIN32
2009-07-11 00:27:32 +00:00
m_SizeXInput [ i ] = new wxStaticBoxSizer ( wxHORIZONTAL , m_Controller [ i ], wxT ( "XInput Pad" ));
2008-12-08 05:25:12 +00:00
m_X360Pad [ i ] = new wxCheckBox ( m_Controller [ i ], ID_X360PAD , wxT ( "Enable X360Pad" ), wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator );
m_X360PadC [ i ] = new wxChoice ( m_Controller [ i ], ID_X360PAD_CHOICE , wxDefaultPosition , wxDefaultSize , arrayStringFor_X360Pad , 0 , wxDefaultValidator );
m_Rumble [ i ] = new wxCheckBox ( m_Controller [ i ], ID_RUMBLE , wxT ( "Enable rumble" ), wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator );
2009-02-10 14:02:01 +00:00
m_SizeXInput [ i ] -> Add ( m_X360Pad [ i ], 0 , wxEXPAND | wxALL , 1 );
m_SizeXInput [ i ] -> Add ( m_X360PadC [ i ], 0 , wxEXPAND | wxALL , 1 );
m_SizeXInput [ i ] -> Add ( m_Rumble [ i ], 0 , wxEXPAND | wxALL , 1 );
2008-12-08 05:25:12 +00:00
#endif
2009-02-10 14:02:01 +00:00
// Set values
m_Disable [ i ] -> SetValue ( pad [ i ]. bDisable );
2008-12-08 05:25:12 +00:00
#ifdef _WIN32
2009-02-10 14:02:01 +00:00
// Check if any XInput pad was found
2008-12-08 05:25:12 +00:00
if ( arrayStringFor_X360Pad . IsEmpty ())
{
m_X360Pad [ i ] -> SetLabel ( wxT ( "Enable X360Pad - No pad connected" ));
m_X360Pad [ i ] -> SetValue ( false );
m_X360Pad [ i ] -> Enable ( false );
pad [ i ]. bEnableXPad = false ;
m_X360PadC [ i ] -> Hide ();
m_Rumble [ i ] -> Hide ();
}
else
{
m_X360Pad [ i ] -> SetValue ( pad [ i ]. bEnableXPad );
m_X360PadC [ i ] -> SetSelection ( pad [ i ]. XPadPlayer );
m_X360PadC [ i ] -> Enable ( m_X360Pad [ i ] -> IsChecked ());
m_Rumble [ i ] -> SetValue ( pad [ i ]. bRumble );
m_Rumble [ i ] -> Enable ( m_X360Pad [ i ] -> IsChecked ());
}
#endif
2009-02-10 14:02:01 +00:00
// Sizers
sDevice [ i ] -> Add ( sbDevice [ i ], 0 , wxEXPAND | wxALL , 1 );
//sDevice[i]->AddStretchSpacer();
2008-12-08 05:25:12 +00:00
#ifdef _WIN32
2009-02-10 14:02:01 +00:00
sDevice [ i ] -> Add ( m_SizeXInput [ i ], 0 , wxEXPAND | wxALL , 1 );
2008-12-08 05:25:12 +00:00
#endif
2009-02-10 14:02:01 +00:00
// -----------------------------------
2008-12-08 05:25:12 +00:00
2009-02-10 14:02:01 +00:00
2009-02-16 06:18:18 +00:00
/////////////////////////////////////////////////////////////////////////////////////
// Rerecording
// ¯¯¯¯¯¯¯¯¯
#ifdef RERECORDING
// Create controls
m_SizeRecording [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Input Recording" ));
m_CheckRecording [ i ] = new wxCheckBox ( m_Controller [ i ], ID_RECORDING , wxT ( "Record input" ));
m_CheckPlayback [ i ] = new wxCheckBox ( m_Controller [ i ], ID_PLAYBACK , wxT ( "Play back input" ));
m_BtnSaveRecording [ i ] = new wxButton ( m_Controller [ i ], ID_SAVE_RECORDING , wxT ( "Save recording" ), wxDefaultPosition , wxDefaultSize );
// Tool tips
m_CheckRecording [ i ] -> SetToolTip ( wxT ( "Your recording will be saved to pad-record.bin in the Dolphin dir when you stop the game" ));
m_CheckPlayback [ i ] -> SetToolTip ( wxT ( "Play back the pad-record.bin file from the Dolphin dir" ));
m_BtnSaveRecording [ i ] -> SetToolTip ( wxT (
"This will save the current recording to pad-record.bin. Your recording will \n "
"also be automatically saved every 60 * 10 frames. And when you shut down the \n "
"game." ));
// Sizers
m_SizeRecording [ i ] -> Add ( m_CheckRecording [ i ], 0 , wxEXPAND | wxALL , 1 );
m_SizeRecording [ i ] -> Add ( m_CheckPlayback [ i ], 0 , wxEXPAND | wxALL , 1 );
m_SizeRecording [ i ] -> Add ( m_BtnSaveRecording [ i ], 0 , wxEXPAND | wxALL , 1 );
// Only enable these options for pad 0
m_CheckRecording [ i ] -> Enable ( false ); m_CheckRecording [ 0 ] -> Enable ( true );
m_CheckPlayback [ i ] -> Enable ( false ); m_CheckPlayback [ 0 ] -> Enable ( true );
m_BtnSaveRecording [ i ] -> Enable ( false ); m_BtnSaveRecording [ 0 ] -> Enable ( true );
// Don't allow saving when we are not recording
m_BtnSaveRecording [ i ] -> Enable ( g_EmulatorRunning && pad [ 0 ]. bRecording );
sDevice [ i ] -> Add ( m_SizeRecording [ i ], 0 , wxEXPAND | wxALL , 1 );
// Set values
m_CheckRecording [ 0 ] -> SetValue ( pad [ 0 ]. bRecording );
m_CheckPlayback [ 0 ] -> SetValue ( pad [ 0 ]. bPlayback );
2009-03-18 17:17:58 +00:00
//DEBUG_LOG(CONSOLE, "m_CheckRecording: %i\n", pad[0].bRecording, pad[0].bPlayback);
2009-02-16 06:18:18 +00:00
#endif
//////////////////////////////////////
2009-02-10 14:02:01 +00:00
// --------------------------------------------------------------------
// Buttons
// -----------------------------
2008-12-08 05:25:12 +00:00
sButtons [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Buttons" ));
AddControl ( m_Controller [ i ], & ( m_ButtonA [ i ]), sButtons [ i ], "A: " , CTL_A , i );
AddControl ( m_Controller [ i ], & ( m_ButtonB [ i ]), sButtons [ i ], "B: " , CTL_B , i );
AddControl ( m_Controller [ i ], & ( m_ButtonX [ i ]), sButtons [ i ], "X: " , CTL_X , i );
AddControl ( m_Controller [ i ], & ( m_ButtonY [ i ]), sButtons [ i ], "Y: " , CTL_Y , i );
AddControl ( m_Controller [ i ], & ( m_ButtonZ [ i ]), sButtons [ i ], "Z: " , CTL_Z , i );
AddControl ( m_Controller [ i ], & ( m_ButtonStart [ i ]), sButtons [ i ], "Start: " , CTL_START , i );
sTriggers [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Triggers" ));
AddControl ( m_Controller [ i ], & ( m_ButtonL [ i ]), sTriggers [ i ], " L: " , CTL_L , i );
AddControl ( m_Controller [ i ], & ( m_ButtonR [ i ]), sTriggers [ i ], " R: " , CTL_R , i );
sModifiers [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Modifiers" ));
AddControl ( m_Controller [ i ], & ( m_HalfPress [ i ]), sModifiers [ i ], "1/2 Press: " , CTL_HALFPRESS , i );
sStick [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "Main Stick" ));
AddControl ( m_Controller [ i ], & ( m_StickUp [ i ]), sStick [ i ], "Up: " , CTL_MAINUP , i );
AddControl ( m_Controller [ i ], & ( m_StickDown [ i ]), sStick [ i ], "Down: " , CTL_MAINDOWN , i );
AddControl ( m_Controller [ i ], & ( m_StickLeft [ i ]), sStick [ i ], "Left: " , CTL_MAINLEFT , i );
AddControl ( m_Controller [ i ], & ( m_StickRight [ i ]), sStick [ i ], "Right: " , CTL_MAINRIGHT , i );
sDPad [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "D-Pad" ));
AddControl ( m_Controller [ i ], & ( m_DPadUp [ i ]), sDPad [ i ], "Up: " , CTL_DPADUP , i );
AddControl ( m_Controller [ i ], & ( m_DPadDown [ i ]), sDPad [ i ], "Down: " , CTL_DPADDOWN , i );
AddControl ( m_Controller [ i ], & ( m_DPadLeft [ i ]), sDPad [ i ], "Left: " , CTL_DPADLEFT , i );
AddControl ( m_Controller [ i ], & ( m_DPadRight [ i ]), sDPad [ i ], "Right: " , CTL_DPADRIGHT , i );
sCStick [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ], wxT ( "C-Stick" ));
AddControl ( m_Controller [ i ], & ( m_CStickUp [ i ]), sCStick [ i ], "Up: " , CTL_SUBUP , i );
AddControl ( m_Controller [ i ], & ( m_CStickDown [ i ]), sCStick [ i ], "Down: " , CTL_SUBDOWN , i );
AddControl ( m_Controller [ i ], & ( m_CStickLeft [ i ]), sCStick [ i ], "Left: " , CTL_SUBLEFT , i );
AddControl ( m_Controller [ i ], & ( m_CStickRight [ i ]), sCStick [ i ], "Right: " , CTL_SUBRIGHT , i );
2009-02-10 14:02:01 +00:00
// --------------------------------------------------------------------
// Sizers
// -----------------------------
2008-12-08 05:25:12 +00:00
sPage [ i ] = new wxGridBagSizer ( 0 , 0 );
sPage [ i ] -> SetFlexibleDirection ( wxBOTH );
sPage [ i ] -> SetNonFlexibleGrowMode ( wxFLEX_GROWMODE_SPECIFIED );
2009-02-10 14:02:01 +00:00
sPage [ i ] -> Add ( sDevice [ i ], wxGBPosition ( 0 , 0 ), wxGBSpan ( 1 , 5 ), wxEXPAND | wxALL , 1 );
2008-12-08 05:25:12 +00:00
sPage [ i ] -> Add ( sButtons [ i ], wxGBPosition ( 1 , 0 ), wxGBSpan ( 2 , 1 ), wxALL , 1 );
sPage [ i ] -> Add ( sTriggers [ i ], wxGBPosition ( 1 , 1 ), wxGBSpan ( 1 , 1 ), wxEXPAND | wxALL , 1 );
sPage [ i ] -> Add ( sModifiers [ i ], wxGBPosition ( 2 , 1 ), wxGBSpan ( 1 , 1 ), wxALL , 1 );
sPage [ i ] -> Add ( sStick [ i ], wxGBPosition ( 1 , 2 ), wxGBSpan ( 2 , 1 ), wxALL , 1 );
sPage [ i ] -> Add ( sDPad [ i ], wxGBPosition ( 1 , 3 ), wxGBSpan ( 2 , 1 ), wxALL , 1 );
sPage [ i ] -> Add ( sCStick [ i ], wxGBPosition ( 1 , 4 ), wxGBSpan ( 2 , 1 ), wxALL , 1 );
m_Controller [ i ] -> SetSizer ( sPage [ i ]);
sPage [ i ] -> Layout ();
}
}
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: OnClose ( wxCloseEvent & event )
2008-12-08 05:25:12 +00:00
{
#ifdef _WIN32
m_dinput . Free ();
#endif
EndModal ( 0 );
}
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: OnKeyDown ( wxKeyEvent & event )
2008-12-08 05:25:12 +00:00
{
2009-06-14 10:01:01 +00:00
char keyStr [ 10 ] = { 0 };
2009-02-15 18:23:42 +00:00
if ( ClickedButton != NULL )
2008-12-08 05:25:12 +00:00
{
2009-02-15 18:23:42 +00:00
// Get the selected notebook page
2008-12-08 05:25:12 +00:00
int page = m_Notebook -> GetSelection ();
#ifdef _WIN32
m_dinput . Read ();
for ( int i = 0 ; i < 255 ; i ++ )
{
if ( m_dinput . diks [ i ])
{
2009-02-15 18:23:42 +00:00
// Save the mapped key, the wxButtons have the Id 0 to 21
pad [ page ]. keyForControl [ ClickedButton -> GetId ()] = i ;
// Get the key name
2008-12-08 05:25:12 +00:00
DInput :: DIKToString ( i , keyStr );
2009-02-15 18:23:42 +00:00
ClickedButton -> SetLabel ( wxString :: FromAscii ( keyStr ));
2008-12-08 05:25:12 +00:00
break ;
}
}
2009-01-13 00:34:36 +00:00
#elif defined(HAVE_X11) && HAVE_X11
2009-07-09 06:50:22 +00:00
pad [ page ]. keyForControl [ ClickedButton -> GetId ()] = InputCommon :: wxCharCodeWXToX ( event . GetKeyCode ());
2009-06-14 10:01:01 +00:00
2009-07-09 06:50:22 +00:00
InputCommon :: XKeyToString ( pad [ page ]. keyForControl [ ClickedButton -> GetId ()], keyStr );
2009-06-14 10:01:01 +00:00
ClickedButton -> SetLabel ( wxString :: FromAscii ( keyStr ));
2008-12-08 05:25:12 +00:00
#endif
2009-02-15 18:23:42 +00:00
ClickedButton -> Disconnect ();
2008-12-08 05:25:12 +00:00
}
2009-02-15 18:23:42 +00:00
// Reset
ClickedButton = NULL ;
2009-06-14 10:01:01 +00:00
//event.Skip();
2008-12-08 05:25:12 +00:00
}
2009-02-15 18:23:42 +00:00
// We have clicked a button
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: OnButtonClick ( wxCommandEvent & event )
2009-02-15 18:23:42 +00:00
{
2009-02-15 19:25:23 +00:00
// Check if the Space key was set, to solve the problem that the Space key calls this function
#ifdef _WIN32
if ( m_dinput . diks [ DIK_SPACE ]) { m_dinput . diks [ DIK_SPACE ] = 0 ; return ; }
#endif
2009-02-15 18:23:42 +00:00
// If we come here again before any key was set
if ( ClickedButton ) ClickedButton -> SetLabel ( oldLabel );
// Save the old button label so we can reapply it if necessary
ClickedButton = ( wxButton * ) event . GetEventObject ();
oldLabel = ClickedButton -> GetLabel ();
ClickedButton -> SetLabel ( _ ( "Press Key" ));
2009-06-13 11:59:58 +00:00
ClickedButton -> SetWindowStyle ( wxWANTS_CHARS );
2009-02-15 18:23:42 +00:00
}
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: OnCloseClick ( wxCommandEvent & event )
2008-12-08 05:25:12 +00:00
{
Close ();
}
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: ControllerSettingsChanged ( wxCommandEvent & event )
2008-12-08 05:25:12 +00:00
{
int page = m_Notebook -> GetSelection ();
switch ( event . GetId ())
{
2009-02-10 14:02:01 +00:00
// General settings
case ID_DISABLE :
pad [ page ]. bDisable = m_Disable [ page ] -> GetValue ();
break ;
// XInput
2008-12-08 05:25:12 +00:00
case ID_X360PAD :
pad [ page ]. bEnableXPad = event . IsChecked ();
m_Rumble [ page ] -> Enable ( event . IsChecked ());
m_X360PadC [ page ] -> Enable ( event . IsChecked ());
break ;
case ID_X360PAD_CHOICE :
pad [ page ]. XPadPlayer = event . GetSelection ();
break ;
case ID_RUMBLE :
pad [ page ]. bRumble = m_Rumble [ page ] -> GetValue ();
break ;
2009-02-10 14:02:01 +00:00
2009-02-16 06:18:18 +00:00
// Input recording
#ifdef RERECORDING
case ID_RECORDING :
pad [ page ]. bRecording = m_CheckRecording [ page ] -> GetValue ();
// Turn off the other option
pad [ page ]. bPlayback = false ; m_CheckPlayback [ page ] -> SetValue ( false );
break ;
case ID_PLAYBACK :
pad [ page ]. bPlayback = m_CheckPlayback [ page ] -> GetValue ();
// Turn off the other option
pad [ page ]. bRecording = false ; m_CheckRecording [ page ] -> SetValue ( false );
break ;
case ID_SAVE_RECORDING :
// Double check again that we are still running a game
if ( g_EmulatorRunning ) SaveRecord ();
break ;
#endif
2008-12-08 05:25:12 +00:00
}
}
2009-07-02 19:00:27 +00:00
void PADConfigDialogSimple :: DllAbout ( wxCommandEvent & event )
2008-12-08 05:25:12 +00:00
{
wxString message ;
#ifdef _WIN32
message = _ ( "A simple keyboard and XInput plugin for dolphin." );
#else
message = _ ( "A simple keyboard plugin for dolphin." );
#endif
wxMessageBox ( _T ( "Dolphin PadSimple Plugin \n By ector and F|RES \n\n " + message ),
_T ( "Dolphin PadSimple" ), wxOK , this );
}