diff options
Diffstat (limited to 'backends/events/default/default-events.cpp')
| -rw-r--r-- | backends/events/default/default-events.cpp | 74 | 
1 files changed, 71 insertions, 3 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 0caba25792..c503e6a536 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -93,7 +93,8 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) :  	_boss(boss),  	_buttonState(0),  	_modifierState(0), -	_shouldQuit(false) { +	_shouldQuit(false), +	_shouldRTL(false) {  	assert(_boss); @@ -200,6 +201,9 @@ DefaultEventManager::~DefaultEventManager() {  	_boss->unlockMutex(_timeMutex);  	_boss->unlockMutex(_recorderMutex); +	if (!artificialEventQueue.empty()) +		artificialEventQueue.clear(); +  	if (_playbackFile != NULL) {  		delete _playbackFile;  	} @@ -349,7 +353,11 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  	uint32 time = _boss->getMillis();  	bool result; -	result = _boss->pollEvent(event); +	if (!artificialEventQueue.empty()) { +		event = artificialEventQueue.pop(); +		result = true; +	} else 	 +		result = _boss->pollEvent(event);  	if (_recordMode != kPassthrough)  { @@ -375,7 +383,6 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  		switch (event.type) {  		case Common::EVENT_KEYDOWN:  			_modifierState = event.kbd.flags; -  			// init continuous event stream  			// not done on PalmOS because keyboard is emulated and keyup is not generated  #if !defined(PALMOS_MODE) @@ -384,7 +391,41 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  			_currentKeyDown.flags = event.kbd.flags;  			_keyRepeatTime = time + kKeyRepeatInitialDelay;  #endif +			// Global Main Menu +			// FIXME: F6 is not the best trigger, it conflicts with some games!!! +			if (event.kbd.keycode == Common::KEYCODE_F6) { +				if (g_engine && !g_engine->isPaused()) { +					Common::Event menuEvent; +					menuEvent.type = Common::EVENT_MAINMENU; +					 +					// FIXME: GSoC RTL branch passes the F6 key event to the +					// engine, and also enqueues a EVENT_MAINMENU. For now, +					// we just drop the key event and return an EVENT_MAINMENU +					// instead. This way, we don't have to add special cases +					// to engines (like it was the case for LURE in the RTL branch). +					// +					// However, this has other consequences, possibly negative ones. +					// Like, what happens with key repeat for the trigger key? +					 +					//pushEvent(menuEvent); +					event = menuEvent; + +					// FIXME: Since now we do not push another MAINMENU event onto +					// our event stack, the GMM would never open, so we have to do +					// that here. Of course when the engine would handle MAINMENU +					// as an event now and open up the GMM itself it would open the +					// menu twice. +					if (g_engine && !g_engine->isPaused()) +						g_engine->mainMenuDialog(); + +					if (_shouldQuit) +						event.type = Common::EVENT_QUIT; +					else if (_shouldRTL) +						event.type = Common::EVENT_RTL; +				} +			}  			break; +  		case Common::EVENT_KEYUP:  			_modifierState = event.kbd.flags;  			if (event.kbd.keycode == _currentKeyDown.keycode) { @@ -401,6 +442,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  			_mousePos = event.mouse;  			_buttonState |= LBUTTON;  			break; +  		case Common::EVENT_LBUTTONUP:  			_mousePos = event.mouse;  			_buttonState &= ~LBUTTON; @@ -410,11 +452,26 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  			_mousePos = event.mouse;  			_buttonState |= RBUTTON;  			break; +  		case Common::EVENT_RBUTTONUP:  			_mousePos = event.mouse;  			_buttonState &= ~RBUTTON;  			break; +		case Common::EVENT_MAINMENU: +			if (g_engine && !g_engine->isPaused()) +				g_engine->mainMenuDialog(); + +			if (_shouldQuit) +				event.type = Common::EVENT_QUIT; +			else if (_shouldRTL) +				event.type = Common::EVENT_RTL; +			break; + +		case Common::EVENT_RTL: +			_shouldRTL = true; +			break; +  		case Common::EVENT_QUIT:  			if (ConfMan.getBool("confirm_exit")) {  				if (g_engine) @@ -425,6 +482,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  					g_engine->pauseEngine(false);  			} else  				_shouldQuit = true; +  			break;  		default: @@ -447,4 +505,14 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {  	return result;  } +void DefaultEventManager::pushEvent(Common::Event event) { + +	// If already received an EVENT_QUIT, don't add another one +	if (event.type == Common::EVENT_QUIT) { +		if (!_shouldQuit) +			artificialEventQueue.push(event); +	} else  +		artificialEventQueue.push(event);	 +} +  #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER)  | 
