More hotkey fixes

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2416 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-01-08 23:33:15 +00:00
parent e8cb837db5
commit bee1bde1b3
10 changed files with 109 additions and 79 deletions

View File

@ -16,6 +16,7 @@
#pragma once
#include <list>
#include "Threading.h"
class wxCommandEvent;
@ -85,6 +86,8 @@ protected:
// Translation: The dispatcher uses this copy instead, to avoid iterator invalidation.
ListenerList m_cache_copy;
bool m_cache_valid;
Threading::Mutex m_listeners_lock;
public:
EventSource() : m_cache_valid( false )
@ -93,34 +96,12 @@ public:
virtual ~EventSource() throw() {}
virtual void Remove( const ListenerType& listener )
{
m_cache_valid = false;
m_listeners.remove( listener );
}
virtual void Remove( const ListenerType& listener );
virtual void Remove( const Handle& listenerHandle );
virtual void Remove( const Handle& listenerHandle )
{
m_cache_valid = false;
m_listeners.erase( listenerHandle );
}
virtual Handle AddFast( const ListenerType& listener )
{
m_cache_valid = false;
m_listeners.push_front( listener );
return m_listeners.begin();
}
void Add( void* objhandle, typename ListenerType::FuncType* fnptr )
{
Add( ListenerType( objhandle, fnptr ) );
}
void Remove( void* objhandle, typename ListenerType::FuncType* fnptr )
{
Remove( ListenerType( objhandle, fnptr ) );
}
Handle AddFast( const ListenerType& listener );
void Add( void* objhandle, typename ListenerType::FuncType* fnptr );
void Remove( void* objhandle, typename ListenerType::FuncType* fnptr );
// Checks for duplicates before adding the event.
virtual void Add( const ListenerType& listener );
@ -128,6 +109,7 @@ public:
void Dispatch( EvtType& evt );
protected:
virtual Handle _AddFast_without_lock( const ListenerType& listener );
inline void _DispatchRaw( ConstIterator iter, const ConstIterator& iend, EvtType& evt );
};
@ -150,10 +132,10 @@ protected:
bool m_attached;
public:
EventListenerBinding( EventSource<EvtType>& source, const ListenerHandle& listener, bool autoAttach=true ) :
m_source( source )
, m_listener( listener )
, m_attached( false )
EventListenerBinding( EventSource<EvtType>& source, const ListenerHandle& listener, bool autoAttach=true )
: m_source( source )
, m_listener( listener )
, m_attached( false )
{
// If you want to assert on null pointers, you'll need to do the check yourself. There's
// too many cases where silently ignoring null pointers is the desired behavior.
@ -185,8 +167,4 @@ typedef EventSource<wxCommandEvent> CmdEvt_Source;
typedef EventListener<wxCommandEvent> CmdEvt_Listener;
typedef EventListenerBinding<wxCommandEvent> CmdEvt_ListenerBinding;
#define EventSource_ImplementType( tname ) \
template void EventSource<tname>::Add(const EventSource<tname>::ListenerType &listener); \
template void EventSource<tname>::RemoveObject(const void* object); \
template void EventSource<tname>::Dispatch(tname& evt); \
template void EventSource<tname>::_DispatchRaw( EventSource<tname>::ConstIterator iter, const EventSource<tname>::ConstIterator& iend, tname& evt );
#define EventSource_ImplementType( tname ) template class EventSource<tname>

View File

@ -15,20 +15,7 @@
#pragma once
// Checks for duplicates before adding the event.
template< typename EvtType >
void EventSource<EvtType>::Add( const ListenerType& listener )
{
if( !pxAssertDev( listener.OnEvent != NULL, "NULL listener callback function." ) ) return;
Handle iter = m_listeners.begin();
while( iter != m_listeners.end() )
{
if( *iter == listener ) return;
++iter;
}
AddFast( listener );
}
using Threading::ScopedLock;
template< typename EvtType >
class PredicatesAreTheThingsOfNightmares
@ -47,6 +34,67 @@ public:
}
};
// Checks for duplicates before adding the event.
template< typename EvtType >
void EventSource<EvtType>::Add( const ListenerType& listener )
{
ScopedLock locker( m_listeners_lock );
if( !pxAssertDev( listener.OnEvent != NULL, "NULL listener callback function." ) ) return;
Handle iter = m_listeners.begin();
while( iter != m_listeners.end() )
{
if( *iter == listener ) return;
++iter;
}
_AddFast_without_lock( listener );
}
template< typename EvtType >
void EventSource<EvtType>::Remove( const ListenerType& listener )
{
ScopedLock locker( m_listeners_lock );
m_cache_valid = false;
m_listeners.remove( listener );
}
template< typename EvtType >
void EventSource<EvtType>::Remove( const Handle& listenerHandle )
{
ScopedLock locker( m_listeners_lock );
m_cache_valid = false;
m_listeners.erase( listenerHandle );
}
template< typename EvtType >
typename EventSource<EvtType>::Handle EventSource<EvtType>::AddFast( const ListenerType& listener )
{
ScopedLock locker( m_listeners_lock );
return _AddFast_without_lock( listener );
}
template< typename EvtType >
typename EventSource<EvtType>::Handle EventSource<EvtType>::_AddFast_without_lock( const ListenerType& listener )
{
m_cache_valid = false;
m_listeners.push_front( listener );
return m_listeners.begin();
}
template< typename EvtType >
void EventSource<EvtType>::Add( void* objhandle, typename ListenerType::FuncType* fnptr )
{
Add( ListenerType( objhandle, fnptr ) );
}
template< typename EvtType >
void EventSource<EvtType>::Remove( void* objhandle, typename ListenerType::FuncType* fnptr )
{
Remove( ListenerType( objhandle, fnptr ) );
}
// removes all listeners which reference the given object. Use for assuring object deletion.
template< typename EvtType >
void EventSource<EvtType>::RemoveObject( const void* object )

View File

@ -19,5 +19,5 @@
#include <wx/event.h>
EventSource_ImplementType( wxCommandEvent );
EventSource_ImplementType( int );
template class EventSource< wxCommandEvent >;
template class EventSource< int >;

View File

@ -86,8 +86,8 @@ public:
}
protected:
_BaseStateThread( const char* name, FnType_OnThreadComplete* onFinished ) :
m_bind_OnExit( wxGetApp().Source_AppStatus(), EventListener<AppEventType>( this, StateThread_OnAppStatus ) )
_BaseStateThread( const char* name, FnType_OnThreadComplete* onFinished )
: m_bind_OnExit( wxGetApp().Source_AppStatus(), EventListener<AppEventType>( this, StateThread_OnAppStatus ) )
{
Callback_FreezeFinished = onFinished;
m_name = L"StateThread::" + fromUTF8(name);
@ -366,7 +366,7 @@ void StateCopy_LoadFromSlot( uint slot )
bool StateCopy_IsValid()
{
return !state_buffer.IsDisposed();
return !state_buffer.IsDisposed();
}
const SafeArray<u8>* StateCopy_GetBuffer()

View File

@ -22,7 +22,7 @@
#include "System/PageFaultSource.h"
#include "Utilities/EventSource.inl"
EventSource_ImplementType( PageFaultInfo );
template class EventSource< PageFaultInfo >;
SrcType_PageFault Source_PageFault;

View File

@ -250,7 +250,7 @@ void SysCoreThread::_reset_stuff_as_needed()
}
if( m_resetVsyncTimers )
{
{
UpdateVSyncRate();
frameLimitReset();
m_resetVsyncTimers = false;

View File

@ -322,11 +322,11 @@ protected:
EventSource<AppEventType> m_evtsrc_AppStatus;
public:
CmdEvt_Source& Source_CoreThreadStatus() { AffinityAssert_AllowFromMain(); return m_evtsrc_CoreThreadStatus; }
EventSource<int>& Source_SettingsApplied() { AffinityAssert_AllowFromMain(); return m_evtsrc_SettingsApplied; }
EventSource<AppEventType>& Source_AppStatus() { AffinityAssert_AllowFromMain(); return m_evtsrc_AppStatus; }
EventSource<PluginEventType>& Source_CorePluginStatus() { AffinityAssert_AllowFromMain(); return m_evtsrc_CorePluginStatus; }
EventSource<IniInterface>& Source_SettingsLoadSave() { AffinityAssert_AllowFromMain(); return m_evtsrc_SettingsLoadSave; }
CmdEvt_Source& Source_CoreThreadStatus() { return m_evtsrc_CoreThreadStatus; }
EventSource<int>& Source_SettingsApplied() { return m_evtsrc_SettingsApplied; }
EventSource<AppEventType>& Source_AppStatus() { return m_evtsrc_AppStatus; }
EventSource<PluginEventType>& Source_CorePluginStatus() { return m_evtsrc_CorePluginStatus; }
EventSource<IniInterface>& Source_SettingsLoadSave() { return m_evtsrc_SettingsLoadSave; }
// ----------------------------------------------------------------------------
public:

View File

@ -45,9 +45,9 @@ DEFINE_EVENT_TYPE( pxEvt_InvokeMethod );
DEFINE_EVENT_TYPE( pxEvt_LogicalVsync );
#include "Utilities/EventSource.inl"
EventSource_ImplementType( IniInterface );
EventSource_ImplementType( AppEventType );
EventSource_ImplementType( PluginEventType );
template class EventSource< IniInterface >;
template class EventSource< AppEventType >;
template class EventSource< PluginEventType >;
bool UseAdminMode = false;
wxDirName SettingsFolder;
@ -202,7 +202,7 @@ void Pcsx2App::PadKeyDispatch( const keyEvent& ev )
// times a second if not (ok, not quite, but you get the idea... I hope.)
void Pcsx2App::LogicalVsync()
{
if( !SelfMethodPost( &Pcsx2App::LogicalVsync ) ) return;
if( SelfMethodPost( &Pcsx2App::LogicalVsync ) ) return;
if( !SysHasValidState() || g_plugins == NULL ) return;

View File

@ -30,7 +30,7 @@ struct Component_FileMcd;
# include "svnrev.h"
#endif
#include <wx/file.h>
#include <wx/ffile.h>
static const int MCD_SIZE = 1024 * 8 * 16;
static const int MC2_SIZE = 1024 * 528 * 16;
@ -43,13 +43,13 @@ static const int MC2_SIZE = 1024 * 528 * 16;
class FileMemoryCard
{
protected:
wxFile m_file[2][4];
wxFFile m_file[2][4];
u8 m_effeffs[528*16];
SafeArray<u8> m_currentdata;
public:
FileMemoryCard();
virtual ~FileMemoryCard() {}
virtual ~FileMemoryCard() throw() {}
void Lock();
void Unlock();
@ -61,7 +61,7 @@ public:
u64 GetCRC( uint port, uint slot );
protected:
bool Seek( wxFile& f, u32 adr );
bool Seek( wxFFile& f, u32 adr );
bool Create( const wxString& mcdFile );
wxString GetDisabledMessage( uint port, uint slot ) const
@ -104,7 +104,7 @@ FileMemoryCard::FileMemoryCard()
NTFS_CompressFile( str, g_Conf->McdEnableNTFS );
if( !m_file[port][slot].Open( str.c_str(), wxFile::read_write ) )
if( !m_file[port][slot].Open( str.c_str(), L"r+b" ) )
{
// Translation note: detailed description should mention that the memory card will be disabled
// for the duration of this session.
@ -118,7 +118,7 @@ FileMemoryCard::FileMemoryCard()
}
// Returns FALSE if the seek failed (is outside the bounds of the file).
bool FileMemoryCard::Seek( wxFile& f, u32 adr )
bool FileMemoryCard::Seek( wxFFile& f, u32 adr )
{
const u32 size = f.Length();
@ -137,7 +137,7 @@ bool FileMemoryCard::Seek( wxFile& f, u32 adr )
// perform sanity checks here?
}
return wxInvalidOffset != f.Seek( adr + offset );
return f.Seek( adr + offset );
}
// returns FALSE if an error occurred (either permission denied or disk full)
@ -145,7 +145,7 @@ bool FileMemoryCard::Create( const wxString& mcdFile )
{
//int enc[16] = {0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0,0,0,0};
wxFile fp( mcdFile, wxFile::write );
wxFFile fp( mcdFile, L"wb" );
if( !fp.IsOpened() ) return false;
for( uint i=0; i<MC2_SIZE/sizeof(m_effeffs); i++ )
@ -163,7 +163,7 @@ s32 FileMemoryCard::IsPresent( uint port, uint slot )
s32 FileMemoryCard::Read( uint port, uint slot, u8 *dest, u32 adr, int size )
{
wxFile& mcfp( m_file[port][slot] );
wxFFile& mcfp( m_file[port][slot] );
if( !mcfp.IsOpened() )
{
DevCon.Error( "MemoryCard: Ignoring attempted read from disabled card." );
@ -176,7 +176,7 @@ s32 FileMemoryCard::Read( uint port, uint slot, u8 *dest, u32 adr, int size )
s32 FileMemoryCard::Save( uint port, uint slot, const u8 *src, u32 adr, int size )
{
wxFile& mcfp( m_file[port][slot] );
wxFFile& mcfp( m_file[port][slot] );
if( !mcfp.IsOpened() )
{
@ -201,7 +201,7 @@ s32 FileMemoryCard::Save( uint port, uint slot, const u8 *src, u32 adr, int size
s32 FileMemoryCard::EraseBlock( uint port, uint slot, u32 adr )
{
wxFile& mcfp( m_file[port][slot] );
wxFFile& mcfp( m_file[port][slot] );
if( !mcfp.IsOpened() )
{
@ -215,7 +215,7 @@ s32 FileMemoryCard::EraseBlock( uint port, uint slot, u32 adr )
u64 FileMemoryCard::GetCRC( uint port, uint slot )
{
wxFile& mcfp( m_file[port][slot] );
wxFFile& mcfp( m_file[port][slot] );
if( !mcfp.IsOpened() ) return 0;
if( !Seek( mcfp, 0 ) ) return 0;
@ -272,6 +272,8 @@ static u64 PS2E_CALLBACK FileMcd_GetCRC( PS2E_THISPTR thisptr, uint port, uint s
Component_FileMcd::Component_FileMcd()
{
memzero( api );
api.McdIsPresent = FileMcd_IsPresent;
api.McdRead = FileMcd_Read;
api.McdSave = FileMcd_Save;

View File

@ -237,6 +237,9 @@ protected:
wxString m_Stacktrace;
public:
virtual ~pxAssertionEvent() throw() { }
virtual pxAssertionEvent *Clone() const { return new pxAssertionEvent(*this); }
pxAssertionEvent();
pxAssertionEvent( MsgboxEventResult& instdata, const wxString& content, const wxString& trace );
pxAssertionEvent( const wxString& content, const wxString& trace );
@ -244,7 +247,6 @@ public:
pxAssertionEvent& SetInstData( MsgboxEventResult& instdata );
pxAssertionEvent& SetStacktrace( const wxString& trace );
~pxAssertionEvent() throw() { }
protected:
virtual int _DoDialog() const;