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