BACKENDS: Simplify EventsBaseBackend
This commit is contained in:
parent
75852a786a
commit
7745ffdac1
12 changed files with 23 additions and 28 deletions
|
@ -40,12 +40,6 @@ void BaseBackend::displayMessageOnOSD(const char *msg) {
|
|||
}
|
||||
|
||||
void BaseBackend::initBackend() {
|
||||
// Init Event manager
|
||||
#ifndef DISABLE_DEFAULT_EVENT_MANAGER
|
||||
if (!_eventManager)
|
||||
_eventManager = new DefaultEventManager(getDefaultEventSource());
|
||||
#endif
|
||||
|
||||
// Init audio CD manager
|
||||
#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
|
||||
if (!_audiocdManager)
|
||||
|
@ -61,3 +55,13 @@ void BaseBackend::fillScreen(uint32 col) {
|
|||
screen->fillRect(Common::Rect(screen->w, screen->h), col);
|
||||
unlockScreen();
|
||||
}
|
||||
|
||||
void EventsBaseBackend::initBackend() {
|
||||
// Init Event manager
|
||||
#ifndef DISABLE_DEFAULT_EVENT_MANAGER
|
||||
if (!_eventManager)
|
||||
_eventManager = new DefaultEventManager(this);
|
||||
#endif
|
||||
|
||||
BaseBackend::initBackend();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "common/events.h"
|
||||
|
||||
class BaseBackend : public OSystem {
|
||||
protected:
|
||||
virtual Common::EventSource *getDefaultEventSource() = 0;
|
||||
public:
|
||||
virtual void initBackend();
|
||||
|
||||
|
@ -37,10 +35,9 @@ public:
|
|||
virtual void fillScreen(uint32 col);
|
||||
};
|
||||
|
||||
class EventsBaseBackend : public BaseBackend, Common::EventSource {
|
||||
protected:
|
||||
virtual Common::EventSource *getDefaultEventSource() { return this; }
|
||||
class EventsBaseBackend : virtual public BaseBackend, Common::EventSource {
|
||||
public:
|
||||
virtual void initBackend();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void loadConfig() {
|
|||
gspLcdExit();
|
||||
}
|
||||
|
||||
OSystem_3DS *osys = (OSystem_3DS *)g_system;
|
||||
OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
|
||||
osys->updateConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static bool hasAudio = false;
|
|||
|
||||
static void audioThreadFunc(void *arg) {
|
||||
Audio::MixerImpl *mixer = (Audio::MixerImpl *)arg;
|
||||
OSystem_3DS *osys = (OSystem_3DS *)g_system;
|
||||
OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
|
||||
|
||||
const int channel = 0;
|
||||
int bufferIndex = 0;
|
||||
|
|
|
@ -91,7 +91,7 @@ static void doJoyEvent(Common::Queue<Common::Event> *queue, u32 keysPressed, u32
|
|||
}
|
||||
|
||||
static void eventThreadFunc(void *arg) {
|
||||
OSystem_3DS *osys = (OSystem_3DS *)g_system;
|
||||
OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
|
||||
Common::Queue<Common::Event> *eventQueue = (Common::Queue<Common::Event> *)arg;
|
||||
|
||||
uint32 touchStartTime = osys->getMillis();
|
||||
|
@ -206,7 +206,7 @@ static void eventThreadFunc(void *arg) {
|
|||
}
|
||||
|
||||
static void aptHookFunc(APT_HookType hookType, void *param) {
|
||||
OSystem_3DS *osys = (OSystem_3DS *)g_system;
|
||||
OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
|
||||
|
||||
switch (hookType) {
|
||||
case APTHOOK_ONSUSPEND:
|
||||
|
|
|
@ -81,9 +81,6 @@ private:
|
|||
|
||||
Common::String getSystemProperty(const char *name) const;
|
||||
|
||||
protected:
|
||||
virtual Common::EventSource *getDefaultEventSource() { return this; }
|
||||
|
||||
public:
|
||||
OSystem_Android(int audio_sample_rate, int audio_buffer_size);
|
||||
virtual ~OSystem_Android();
|
||||
|
|
|
@ -104,7 +104,7 @@ bool findWordCompletions(const char *input) {
|
|||
if (wordBufferPtrPos == 0)
|
||||
return false;
|
||||
|
||||
OSystem_DS *system = (OSystem_DS *) g_system;
|
||||
OSystem_DS *system = dynamic_cast<OSystem_DS *>(g_system);
|
||||
system->clearAutoComplete();
|
||||
|
||||
int start = 0;
|
||||
|
|
|
@ -353,7 +353,7 @@ void OSystem_iOS7::addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
|
|||
}
|
||||
|
||||
bool iOS7_touchpadModeEnabled() {
|
||||
OSystem_iOS7 *sys = (OSystem_iOS7 *) g_system;
|
||||
OSystem_iOS7 *sys = dynamic_cast<OSystem_iOS7 *>(g_system);
|
||||
return sys && sys->touchpadModeEnabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "backends/timer/default/default-timer.h"
|
||||
|
||||
void checkTimers(void) {
|
||||
OSystem_N64 *osys = (OSystem_N64 *)g_system;
|
||||
OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
|
||||
|
||||
uint32 curTime = osys->getMillis();
|
||||
|
||||
|
@ -46,7 +46,7 @@ void disableAudioPlayback(void) {
|
|||
void enableAudioPlayback(void) {
|
||||
static bool _firstRun = true;
|
||||
|
||||
OSystem_N64 *osys = (OSystem_N64 *)g_system;
|
||||
OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
|
||||
Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer();
|
||||
|
||||
uint32 sampleBufferSize = 3072;
|
||||
|
@ -83,7 +83,7 @@ void vblCallback(void) {
|
|||
sndCallback();
|
||||
}
|
||||
|
||||
((OSystem_N64 *)g_system)->readControllerAnalogInput();
|
||||
dynamic_cast<OSystem_N64 *>(g_system)->readControllerAnalogInput();
|
||||
}
|
||||
|
||||
void sndCallback() {
|
||||
|
@ -95,7 +95,7 @@ void sndCallback() {
|
|||
void refillAudioBuffers(void) {
|
||||
if (!_audioEnabled) return;
|
||||
|
||||
OSystem_N64 *osys = (OSystem_N64 *)g_system;
|
||||
OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
|
||||
byte *sndBuf;
|
||||
Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer();
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ public:
|
|||
|
||||
virtual void initBackend();
|
||||
|
||||
virtual Common::EventSource *getDefaultEventSource() { return this; }
|
||||
virtual bool pollEvent(Common::Event &event);
|
||||
|
||||
virtual uint32 getMillis(bool skipRecord = false);
|
||||
|
|
|
@ -124,8 +124,6 @@ protected:
|
|||
*/
|
||||
SdlWindow *_window;
|
||||
|
||||
virtual Common::EventSource *getDefaultEventSource() override { return _eventSource; }
|
||||
|
||||
/**
|
||||
* Initialze the SDL library.
|
||||
*/
|
||||
|
|
|
@ -149,7 +149,7 @@ protected:
|
|||
|
||||
/**
|
||||
* No default value is provided for _eventManager by OSystem.
|
||||
* However, BaseBackend::initBackend() does set a default value
|
||||
* However, EventsBaseBackend::initBackend() does set a default value
|
||||
* if none has been set before.
|
||||
*
|
||||
* @note _eventManager is deleted by the OSystem destructor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue