GTK:
Removed the Keymap class git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@668 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
a3d7fa464e
commit
093be7d2cf
|
@ -194,7 +194,6 @@ SET(SRC_HQ_ASM
|
||||||
|
|
||||||
SET(SRC_GTK
|
SET(SRC_GTK
|
||||||
src/gtk/configfile.cpp
|
src/gtk/configfile.cpp
|
||||||
src/gtk/input.cpp
|
|
||||||
src/gtk/main.cpp
|
src/gtk/main.cpp
|
||||||
src/gtk/system.cpp
|
src/gtk/system.cpp
|
||||||
src/gtk/windowcallbacks.cpp
|
src/gtk/windowcallbacks.cpp
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
|
||||||
// Copyright (C) 1999-2003 Forgotten
|
|
||||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
|
||||||
|
|
||||||
// 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; either version 2, or(at your option)
|
|
||||||
// any later version.
|
|
||||||
//
|
|
||||||
// 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 for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
|
||||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
#include "input.h"
|
|
||||||
|
|
||||||
namespace VBA
|
|
||||||
{
|
|
||||||
|
|
||||||
Keymap::Keymap()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Keymap::~Keymap()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keymap::vRegister(int _iVal, EKey _eKey)
|
|
||||||
{
|
|
||||||
m_oTable[_iVal] = _eKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keymap::vClear()
|
|
||||||
{
|
|
||||||
m_oTable.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace VBA
|
|
|
@ -62,28 +62,7 @@ enum EKeyFlag
|
||||||
KeyFlagCapture = 1 << 11,
|
KeyFlagCapture = 1 << 11,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Keymap
|
typedef std::map<int, EKey> Keymap;
|
||||||
{
|
|
||||||
public:
|
|
||||||
Keymap();
|
|
||||||
~Keymap();
|
|
||||||
|
|
||||||
void vRegister(int _iVal, EKey _eKey);
|
|
||||||
void vClear();
|
|
||||||
inline EKey eGetKey(int _iVal);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<int, EKey> m_oTable;
|
|
||||||
|
|
||||||
// noncopyable
|
|
||||||
Keymap(const Keymap &);
|
|
||||||
Keymap & operator=(const Keymap &);
|
|
||||||
};
|
|
||||||
|
|
||||||
inline EKey Keymap::eGetKey(int _iVal)
|
|
||||||
{
|
|
||||||
return m_oTable[_iVal];
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
||||||
|
|
|
@ -117,24 +117,24 @@ void JoypadConfig::vSetDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keymap * JoypadConfig::poCreateKeymap() const
|
Keymap JoypadConfig::oCreateKeymap() const
|
||||||
{
|
{
|
||||||
Keymap * poKeymap = new Keymap();
|
Keymap oKeymap;
|
||||||
|
|
||||||
poKeymap->vRegister(m_uiUp, KeyUp );
|
oKeymap[m_uiUp] = KeyUp;
|
||||||
poKeymap->vRegister(m_uiDown, KeyDown );
|
oKeymap[m_uiDown] = KeyDown;
|
||||||
poKeymap->vRegister(m_uiLeft, KeyLeft );
|
oKeymap[m_uiLeft] = KeyLeft;
|
||||||
poKeymap->vRegister(m_uiRight, KeyRight );
|
oKeymap[m_uiRight] = KeyRight;
|
||||||
poKeymap->vRegister(m_uiA, KeyA );
|
oKeymap[m_uiA] = KeyA;
|
||||||
poKeymap->vRegister(m_uiB, KeyB );
|
oKeymap[m_uiB] = KeyB;
|
||||||
poKeymap->vRegister(m_uiL, KeyL );
|
oKeymap[m_uiL] = KeyL;
|
||||||
poKeymap->vRegister(m_uiR, KeyR );
|
oKeymap[m_uiR] = KeyR;
|
||||||
poKeymap->vRegister(m_uiSelect, KeySelect );
|
oKeymap[m_uiSelect] = KeySelect;
|
||||||
poKeymap->vRegister(m_uiStart, KeyStart );
|
oKeymap[m_uiStart] = KeyStart;
|
||||||
poKeymap->vRegister(m_uiSpeed, KeySpeed );
|
oKeymap[m_uiSpeed] = KeySpeed;
|
||||||
poKeymap->vRegister(m_uiCapture, KeyCapture );
|
oKeymap[m_uiCapture] = KeyCapture;
|
||||||
|
|
||||||
return poKeymap;
|
return oKeymap;
|
||||||
}
|
}
|
||||||
|
|
||||||
JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog,
|
JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog,
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
guint * puiAt(int _iIndex);
|
guint * puiAt(int _iIndex);
|
||||||
int iFind(guint _uiKeycode);
|
int iFind(guint _uiKeycode);
|
||||||
void vSetDefault();
|
void vSetDefault();
|
||||||
Keymap * poCreateKeymap() const;
|
Keymap oCreateKeymap() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class JoypadConfigDialog : public Gtk::Dialog
|
class JoypadConfigDialog : public Gtk::Dialog
|
||||||
|
|
|
@ -101,7 +101,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
|
||||||
m_eCartridge = CartridgeNone;
|
m_eCartridge = CartridgeNone;
|
||||||
m_uiJoypadState = 0;
|
m_uiJoypadState = 0;
|
||||||
m_uiAutofireState = 0;
|
m_uiAutofireState = 0;
|
||||||
m_poKeymap = NULL;
|
|
||||||
|
|
||||||
vInitSDL();
|
vInitSDL();
|
||||||
vInitSystem();
|
vInitSystem();
|
||||||
|
@ -799,11 +798,6 @@ Window::~Window()
|
||||||
delete m_poFileOpenDialog;
|
delete m_poFileOpenDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_poKeymap != NULL)
|
|
||||||
{
|
|
||||||
delete m_poKeymap;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_poInstance = NULL;
|
m_poInstance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ private:
|
||||||
sigc::connection m_oEmuSig;
|
sigc::connection m_oEmuSig;
|
||||||
|
|
||||||
std::vector<JoypadConfig> m_oJoypads;
|
std::vector<JoypadConfig> m_oJoypads;
|
||||||
Keymap * m_poKeymap;
|
Keymap m_oKeymap;
|
||||||
|
|
||||||
int m_bFullscreen;
|
int m_bFullscreen;
|
||||||
int m_iScreenWidth;
|
int m_iScreenWidth;
|
||||||
|
|
|
@ -871,11 +871,7 @@ void Window::vOnJoypadConfigure(int _iJoypad)
|
||||||
m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig();
|
m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig();
|
||||||
if (_iJoypad == m_poInputConfig->oGetKey<int>("active_joypad"))
|
if (_iJoypad == m_poInputConfig->oGetKey<int>("active_joypad"))
|
||||||
{
|
{
|
||||||
if (m_poKeymap != NULL)
|
m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap();
|
||||||
{
|
|
||||||
delete m_poKeymap;
|
|
||||||
}
|
|
||||||
m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,11 +885,7 @@ void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_poKeymap != NULL)
|
m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap();
|
||||||
{
|
|
||||||
delete m_poKeymap;
|
|
||||||
}
|
|
||||||
m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
|
|
||||||
|
|
||||||
m_poInputConfig->vSetKey("active_joypad", _iJoypad);
|
m_poInputConfig->vSetKey("active_joypad", _iJoypad);
|
||||||
}
|
}
|
||||||
|
@ -1181,7 +1173,7 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
||||||
|| (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
|
|| (eKey = m_oKeymap[_pstEvent->hardware_keycode]) == KeyNone)
|
||||||
{
|
{
|
||||||
return Gtk::Window::on_key_press_event(_pstEvent);
|
return Gtk::Window::on_key_press_event(_pstEvent);
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1231,7 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
||||||
EKey eKey;
|
EKey eKey;
|
||||||
|
|
||||||
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
||||||
|| (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
|
|| (eKey = m_oKeymap[_pstEvent->hardware_keycode]) == KeyNone)
|
||||||
{
|
{
|
||||||
return Gtk::Window::on_key_release_event(_pstEvent);
|
return Gtk::Window::on_key_release_event(_pstEvent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue