diff --git a/CMakeLists.txt b/CMakeLists.txt index eadfa1f7..d0276959 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,7 +194,6 @@ SET(SRC_HQ_ASM SET(SRC_GTK src/gtk/configfile.cpp - src/gtk/input.cpp src/gtk/main.cpp src/gtk/system.cpp src/gtk/windowcallbacks.cpp diff --git a/src/gtk/input.cpp b/src/gtk/input.cpp deleted file mode 100644 index 5beb4073..00000000 --- a/src/gtk/input.cpp +++ /dev/null @@ -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 diff --git a/src/gtk/input.h b/src/gtk/input.h index 948fd705..ea029dd7 100644 --- a/src/gtk/input.h +++ b/src/gtk/input.h @@ -62,28 +62,7 @@ enum EKeyFlag KeyFlagCapture = 1 << 11, }; -class Keymap -{ - public: - Keymap(); - ~Keymap(); - - void vRegister(int _iVal, EKey _eKey); - void vClear(); - inline EKey eGetKey(int _iVal); - - private: - std::map m_oTable; - - // noncopyable - Keymap(const Keymap &); - Keymap & operator=(const Keymap &); -}; - -inline EKey Keymap::eGetKey(int _iVal) -{ - return m_oTable[_iVal]; -} +typedef std::map Keymap; } // namespace VBA diff --git a/src/gtk/joypadconfig.cpp b/src/gtk/joypadconfig.cpp index 56202232..97043c4a 100644 --- a/src/gtk/joypadconfig.cpp +++ b/src/gtk/joypadconfig.cpp @@ -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 ); - poKeymap->vRegister(m_uiDown, KeyDown ); - poKeymap->vRegister(m_uiLeft, KeyLeft ); - poKeymap->vRegister(m_uiRight, KeyRight ); - poKeymap->vRegister(m_uiA, KeyA ); - poKeymap->vRegister(m_uiB, KeyB ); - poKeymap->vRegister(m_uiL, KeyL ); - poKeymap->vRegister(m_uiR, KeyR ); - poKeymap->vRegister(m_uiSelect, KeySelect ); - poKeymap->vRegister(m_uiStart, KeyStart ); - poKeymap->vRegister(m_uiSpeed, KeySpeed ); - poKeymap->vRegister(m_uiCapture, KeyCapture ); + oKeymap[m_uiUp] = KeyUp; + oKeymap[m_uiDown] = KeyDown; + oKeymap[m_uiLeft] = KeyLeft; + oKeymap[m_uiRight] = KeyRight; + oKeymap[m_uiA] = KeyA; + oKeymap[m_uiB] = KeyB; + oKeymap[m_uiL] = KeyL; + oKeymap[m_uiR] = KeyR; + oKeymap[m_uiSelect] = KeySelect; + oKeymap[m_uiStart] = KeyStart; + oKeymap[m_uiSpeed] = KeySpeed; + oKeymap[m_uiCapture] = KeyCapture; - return poKeymap; + return oKeymap; } JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog, diff --git a/src/gtk/joypadconfig.h b/src/gtk/joypadconfig.h index 8fb860c6..404a98b1 100644 --- a/src/gtk/joypadconfig.h +++ b/src/gtk/joypadconfig.h @@ -49,7 +49,7 @@ public: guint * puiAt(int _iIndex); int iFind(guint _uiKeycode); void vSetDefault(); - Keymap * poCreateKeymap() const; + Keymap oCreateKeymap() const; }; class JoypadConfigDialog : public Gtk::Dialog diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 931890fd..67da40e0 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -101,7 +101,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : m_eCartridge = CartridgeNone; m_uiJoypadState = 0; m_uiAutofireState = 0; - m_poKeymap = NULL; vInitSDL(); vInitSystem(); @@ -799,11 +798,6 @@ Window::~Window() delete m_poFileOpenDialog; } - if (m_poKeymap != NULL) - { - delete m_poKeymap; - } - m_poInstance = NULL; } diff --git a/src/gtk/window.h b/src/gtk/window.h index 4b11a883..a5cb4b57 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -252,7 +252,7 @@ private: sigc::connection m_oEmuSig; std::vector m_oJoypads; - Keymap * m_poKeymap; + Keymap m_oKeymap; int m_bFullscreen; int m_iScreenWidth; diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 1767de62..7823c16d 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -871,11 +871,7 @@ void Window::vOnJoypadConfigure(int _iJoypad) m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig(); if (_iJoypad == m_poInputConfig->oGetKey("active_joypad")) { - if (m_poKeymap != NULL) - { - delete m_poKeymap; - } - m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap(); + m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap(); } } @@ -889,11 +885,7 @@ void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad) return; } - if (m_poKeymap != NULL) - { - delete m_poKeymap; - } - m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap(); + m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap(); 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()) - || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone) + || (eKey = m_oKeymap[_pstEvent->hardware_keycode]) == KeyNone) { return Gtk::Window::on_key_press_event(_pstEvent); } @@ -1239,7 +1231,7 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent) EKey eKey; 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); }