mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
COMPOSER: Support keyboard shortcuts.
This commit is contained in:
parent
c2cb1019a6
commit
3e98c56377
@ -262,6 +262,33 @@ void ComposerEngine::onMouseMove(const Common::Point &pos) {
|
||||
void ComposerEngine::onKeyDown(uint16 keyCode) {
|
||||
runEvent(kEventKeyDown, keyCode, 0, 0);
|
||||
runEvent(kEventChar, keyCode, 0, 0);
|
||||
|
||||
for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) {
|
||||
for (Common::List<KeyboardHandler>::iterator j = i->_keyboardHandlers.begin(); j != i->_keyboardHandlers.end(); j++) {
|
||||
const KeyboardHandler &handler = *j;
|
||||
if (keyCode != handler.keyId)
|
||||
continue;
|
||||
|
||||
int modifiers = g_system->getEventManager()->getModifierState();
|
||||
switch (handler.modifierId) {
|
||||
case 0x10: // shift
|
||||
if (!(modifiers & Common::KBD_SHIFT))
|
||||
continue;
|
||||
break;
|
||||
case 0x11: // control
|
||||
if (!(modifiers & Common::KBD_CTRL))
|
||||
continue;
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
warning("unknown keyb modifier %d", handler.modifierId);
|
||||
continue;
|
||||
}
|
||||
|
||||
runScript(handler.scriptId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComposerEngine::setCursor(uint16 id, const Common::Point &offset) {
|
||||
@ -406,6 +433,16 @@ void ComposerEngine::loadLibrary(uint id) {
|
||||
newLib._buttons.insert(newLib._buttons.begin(), button);
|
||||
}
|
||||
|
||||
Common::Array<uint16> accelResources = library._archive->getResourceIDList(ID_ACEL);
|
||||
for (uint i = 0; i < accelResources.size(); i++) {
|
||||
Common::SeekableReadStream *stream = library._archive->getResource(ID_ACEL, accelResources[i]);
|
||||
KeyboardHandler handler;
|
||||
handler.keyId = stream->readUint16LE();
|
||||
handler.modifierId = stream->readUint16LE();
|
||||
handler.scriptId = stream->readUint16LE();
|
||||
newLib._keyboardHandlers.push_back(handler);
|
||||
}
|
||||
|
||||
// add background sprite, if it exists
|
||||
if (hasResource(ID_BMAP, 1000))
|
||||
setBackground(1000);
|
||||
|
@ -95,11 +95,18 @@ enum {
|
||||
kEventKeyUp = 7
|
||||
};
|
||||
|
||||
struct KeyboardHandler {
|
||||
uint16 keyId;
|
||||
uint16 modifierId;
|
||||
uint16 scriptId;
|
||||
};
|
||||
|
||||
struct Library {
|
||||
uint _id;
|
||||
Archive *_archive;
|
||||
|
||||
Common::List<Button> _buttons;
|
||||
Common::List<KeyboardHandler> _keyboardHandlers;
|
||||
};
|
||||
|
||||
struct QueuedScript {
|
||||
|
@ -35,6 +35,7 @@ struct Animation;
|
||||
|
||||
#define ID_LBRC MKTAG('L','B','R','C') // Main FourCC
|
||||
|
||||
#define ID_ACEL MKTAG('A','C','E','L') // Keyboard Accelerator (v1)
|
||||
#define ID_AMBI MKTAG('A','M','B','I') // Ambient (v1 sprite button)
|
||||
#define ID_ANIM MKTAG('A','N','I','M') // Animation
|
||||
#define ID_BMAP MKTAG('B','M','A','P') // Bitmap
|
||||
|
Loading…
Reference in New Issue
Block a user