GTK:
The keymap now uses a std::map instead of a glib map git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@666 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
930e637894
commit
b4ec3b9375
|
@ -57,8 +57,6 @@ u8 gbSoundRead( u16 address )
|
|||
|
||||
void gbSoundEvent(register u16 address, register int data)
|
||||
{
|
||||
int freq = 0;
|
||||
|
||||
gbMemory[address] = data;
|
||||
|
||||
if ( gb_apu && address >= NR10 && address <= 0xFF3F )
|
||||
|
|
|
@ -18,36 +18,25 @@
|
|||
|
||||
#include "input.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
namespace VBA
|
||||
{
|
||||
|
||||
Keymap::Keymap()
|
||||
{
|
||||
m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
if (m_pstTable == NULL)
|
||||
{
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
Keymap::~Keymap()
|
||||
{
|
||||
g_hash_table_destroy(m_pstTable);
|
||||
}
|
||||
|
||||
void Keymap::vRegister(guint _uiVal, EKey _eKey)
|
||||
void Keymap::vRegister(int _iVal, EKey _eKey)
|
||||
{
|
||||
g_hash_table_insert(m_pstTable,
|
||||
GUINT_TO_POINTER(_uiVal),
|
||||
GUINT_TO_POINTER(_eKey));
|
||||
m_oTable[_iVal] = _eKey;
|
||||
}
|
||||
|
||||
void Keymap::vClear()
|
||||
{
|
||||
g_hash_table_destroy(m_pstTable);
|
||||
m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
m_oTable.clear();
|
||||
}
|
||||
|
||||
} // namespace VBA
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef __VBA_INPUT_H__
|
||||
#define __VBA_INPUT_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <map>
|
||||
|
||||
namespace VBA
|
||||
{
|
||||
|
@ -68,22 +68,21 @@ class Keymap
|
|||
Keymap();
|
||||
~Keymap();
|
||||
|
||||
void vRegister(guint _uiVal, EKey _eKey);
|
||||
void vRegister(int _iVal, EKey _eKey);
|
||||
void vClear();
|
||||
inline EKey eGetKey(guint _uiVal);
|
||||
inline EKey eGetKey(int _iVal);
|
||||
|
||||
private:
|
||||
GHashTable * m_pstTable;
|
||||
std::map<int, EKey> m_oTable;
|
||||
|
||||
// noncopyable
|
||||
Keymap(const Keymap &);
|
||||
Keymap & operator=(const Keymap &);
|
||||
};
|
||||
|
||||
inline EKey Keymap::eGetKey(guint _uiVal)
|
||||
inline EKey Keymap::eGetKey(int _iVal)
|
||||
{
|
||||
return (EKey)GPOINTER_TO_UINT(g_hash_table_lookup(m_pstTable,
|
||||
GUINT_TO_POINTER(_uiVal)));
|
||||
return m_oTable[_iVal];
|
||||
}
|
||||
|
||||
} // namespace VBA
|
||||
|
|
Loading…
Reference in New Issue