GTK : The joypad config dialog can now be used to configure the 4 joypads.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@695 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
bgk 2008-09-03 20:36:29 +00:00
parent 1c55e89f7c
commit c31ada1146
5 changed files with 21 additions and 20 deletions

View File

@ -43,7 +43,8 @@ const EKey JoypadConfigDialog::m_aeKeys[] =
JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog,
const Glib::RefPtr<Gnome::Glade::Xml> & _poXml) :
Gtk::Dialog(_pstDialog)
Gtk::Dialog(_pstDialog),
m_ePad(PAD_MAIN)
{
m_poOkButton = dynamic_cast<Gtk::Button *>(_poXml->get_widget("JoypadOkButton"));
@ -70,16 +71,20 @@ JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog,
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
}
vUpdateEntries();
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
vEmptyEventQueue();
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
m_oConfigSig = Glib::signal_idle().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
Glib::PRIORITY_DEFAULT_IDLE);
}
void JoypadConfigDialog::vInitDialog(EPad _ePad)
{
m_ePad = _ePad;
vUpdateEntries();
}
JoypadConfigDialog::~JoypadConfigDialog()
{
m_oConfigSig.disconnect();
@ -91,7 +96,7 @@ void JoypadConfigDialog::vUpdateEntries()
{
const char * csName = 0;
guint uiKeyval = inputGetKeymap(PAD_MAIN, m_aeKeys[i]);
guint uiKeyval = inputGetKeymap(m_ePad, m_aeKeys[i]);
int dev = uiKeyval >> 16;
if (dev == 0)
{
@ -177,7 +182,7 @@ void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event)
}
int code = inputGetEventCode(event);
inputSetKeymap(PAD_MAIN, m_aeKeys[m_iCurrentEntry], code);
inputSetKeymap(m_ePad, m_aeKeys[m_iCurrentEntry], code);
vUpdateEntries();
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size())

View File

@ -37,6 +37,7 @@ public:
const Glib::RefPtr<Gnome::Glade::Xml> & _poXml);
virtual ~JoypadConfigDialog();
void vInitDialog(EPad _ePad);
protected:
bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry);
bool bOnEntryFocusOut(GdkEventFocus * _pstEvent);
@ -51,6 +52,7 @@ private:
static const EKey m_aeKeys[];
sigc::connection m_oConfigSig;
SDL_Event m_oPreviousEvent;
EPad m_ePad;
void vUpdateEntries();
bool bOnConfigIdle();

View File

@ -698,19 +698,19 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
//
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure1"));
poMI->signal_activate().connect(sigc::bind(
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 1));
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_1));
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure2"));
poMI->signal_activate().connect(sigc::bind(
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 2));
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_2));
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure3"));
poMI->signal_activate().connect(sigc::bind(
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 3));
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_3));
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure4"));
poMI->signal_activate().connect(sigc::bind(
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 4));
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_4));
int iDefaultJoypad = m_poInputConfig->oGetKey<int>("active_joypad");
for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)

View File

@ -164,7 +164,7 @@ protected:
virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType);
virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
virtual void vOnJoypadConfigure(int _iJoypad);
virtual void vOnJoypadConfigure(EPad _eJoypad);
virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad);
virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag);
#ifndef NO_DEBUGGER

View File

@ -860,7 +860,7 @@ void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB)
m_poDisplayConfig->vSetKey("filterIB", _iFilterIB);
}
void Window::vOnJoypadConfigure(int _iJoypad)
void Window::vOnJoypadConfigure(EPad _eJoypad)
{
Glib::RefPtr<Xml> poXml;
poXml = Xml::create(PKGDATADIR "/vba.glade", "JoypadConfigDialog");
@ -868,15 +868,9 @@ void Window::vOnJoypadConfigure(int _iJoypad)
JoypadConfigDialog * poDialog = NULL;
poXml->get_widget_derived<JoypadConfigDialog>("JoypadConfigDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vInitDialog(_eJoypad);
if (poDialog->run() == Gtk::RESPONSE_OK)
{
/*m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig();
if (_iJoypad == m_poInputConfig->oGetKey<int>("active_joypad"))
{
m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap();
}*/
}
poDialog->run();
delete poDialog;
}