GRIM: Ignore the sticky modifiers when checking alt+enter.

This commit is contained in:
Giulio Camuffo 2012-03-09 12:09:37 +01:00
parent 0b620ac31e
commit 52bc1d948a
3 changed files with 17 additions and 17 deletions

View File

@ -39,7 +39,6 @@
#include "common/archive.h"
#include "common/debug-channels.h"
#include "common/events.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/config-manager.h"
@ -678,11 +677,11 @@ void GrimEngine::mainLoop() {
handlePause();
break;
} else {
handleChars(type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
handleChars(type, event.kbd);
}
}
handleControls(type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
handleControls(type, event.kbd);
// Allow lua to react to the event.
// Without this lua_update switching the entries in the menu is slow because

View File

@ -27,6 +27,7 @@
#include "common/str-array.h"
#include "common/hashmap.h"
#include "common/events.h"
#include "engines/advancedDetector.h"
@ -175,8 +176,8 @@ public:
TextObjectDefaults _sayLineDefaults, _printLineDefaults, _blastTextDefaults;
private:
void handleControls(int operation, int key, int keyModifier, uint16 ascii);
void handleChars(int operation, int key, int keyModifier, uint16 ascii);
void handleControls(Common::EventType type, const Common::KeyState &key);
void handleChars(Common::EventType type, const Common::KeyState &key);
void handleExit();
void handlePause();
void handleUserPaint();

View File

@ -271,34 +271,34 @@ const ControlDescriptor controls[] = {
// a "character" handler or a "button" handler
#define CHAR_KEY(k) ((k >= 'a' && k <= 'z') || (k >= 'A' && k <= 'Z') || (k >= '0' && k <= '9') || k == ' ')
void GrimEngine::handleChars(int operation, int key, int /*keyModifier*/, uint16 ascii) {
if (!CHAR_KEY(ascii))
void GrimEngine::handleChars(Common::EventType operation, const Common::KeyState &key) {
if (!CHAR_KEY(key.ascii))
return;
char keychar[2];
keychar[0] = ascii;
keychar[0] = key.ascii;
keychar[1] = 0;
LuaObjects objects;
objects.add(keychar);
if (!LuaBase::instance()->callback("characterHandler", objects)) {
error("handleChars: invalid handler");
}
}
void GrimEngine::handleControls(int operation, int key, int keyModifier, uint16 ascii) {
void GrimEngine::handleControls(Common::EventType operation, const Common::KeyState &key) {
// Might also want to support keypad-enter?
if (keyModifier == Common::KBD_ALT && key == Common::KEYCODE_RETURN && operation == Common::EVENT_KEYDOWN) {
if (key.hasFlags(Common::KBD_ALT) && key.keycode == Common::KEYCODE_RETURN && operation == Common::EVENT_KEYDOWN) {
_changeFullscreenState = true;
}
// If we're not supposed to handle the key then don't
if (!_controlsEnabled[key])
// If we're not supposed to handle the key then don't
if (!_controlsEnabled[key.keycode])
return;
LuaObjects objects;
objects.add(key);
objects.add(key.keycode);
if (operation == Common::EVENT_KEYDOWN) {
objects.add(1);
objects.add(1);
@ -315,9 +315,9 @@ void GrimEngine::handleControls(int operation, int key, int keyModifier, uint16
// }
if (operation == Common::EVENT_KEYDOWN)
_controlsState[key] = true;
_controlsState[key.keycode] = true;
else if (operation == Common::EVENT_KEYUP)
_controlsState[key] = false;
_controlsState[key.keycode] = false;
}
} // end of namespace Grim