本文整理汇总了C++中common::EventManager::getModifierState方法的典型用法代码示例。如果您正苦于以下问题:C++ EventManager::getModifierState方法的具体用法?C++ EventManager::getModifierState怎么用?C++ EventManager::getModifierState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::EventManager
的用法示例。
在下文中一共展示了EventManager::getModifierState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getScummVMEvent
SciEvent EventManager::getScummVMEvent() {
SciEvent input = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) };
SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) };
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
// Don't generate events for mouse movement
while (found && ev.type == Common::EVENT_MOUSEMOVE)
found = em->pollEvent(ev);
// Save the mouse position
//
// We call getMousePos of the event manager here, since we also want to
// store the mouse position in case of keyboard events, which do not feature
// any mouse position information itself.
// This should be safe, since the mouse position in the event manager should
// only be updated when a mouse related event has been taken from the queue
// via pollEvent.
// We also adjust the position based on the scaling of the screen.
Common::Point mousePos = em->getMousePos();
g_sci->_gfxScreen->adjustBackUpscaledCoordinates(mousePos.y, mousePos.x);
noEvent.mousePos = input.mousePos = mousePos;
if (!found || ev.type == Common::EVENT_MOUSEMOVE) {
int modifiers = em->getModifierState();
noEvent.modifiers =
((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0);
return noEvent;
}
if (ev.type == Common::EVENT_QUIT) {
input.type = SCI_EVENT_QUIT;
return input;
}
// Handle mouse events
for (int i = 0; i < ARRAYSIZE(mouseEventMappings); i++) {
if (mouseEventMappings[i].commonType == ev.type) {
input.type = mouseEventMappings[i].sciType;
input.data = mouseEventMappings[i].data;
return input;
}
}
// If we reached here, make sure that it's a keydown event
if (ev.type != Common::EVENT_KEYDOWN)
return noEvent;
// Check for Control-D (debug console)
if (ev.kbd.hasFlags(Common::KBD_CTRL | Common::KBD_SHIFT) && ev.kbd.keycode == Common::KEYCODE_d) {
// Open debug console
Console *con = g_sci->getSciDebugger();
con->attach();
return noEvent;
}
// Process keyboard events
int modifiers = em->getModifierState();
bool numlockOn = (ev.kbd.flags & Common::KBD_NUM);
input.data = ev.kbd.keycode;
input.character = ev.kbd.ascii;
input.type = SCI_EVENT_KEYBOARD;
input.modifiers =
((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0);
// Caps lock and Scroll lock have been removed, cause we already handle upper
// case keys ad Scroll lock doesn't seem to be used anywhere
//((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
//((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
if ((input.character) && (input.character <= 0xFF)) {
// Directly accept most common keys without conversion
if ((input.character >= 0x80) && (input.character <= 0xFF)) {
// If there is no extended font, we will just clear the
// current event.
// Sierra SCI actually accepted those characters, but
// didn't display them inside text edit controls because
// the characters were missing inside the font(s).
// We filter them out for non-multilingual games because
// of that.
if (!_fontIsExtended)
return noEvent;
// Convert 8859-1 characters to DOS (cp850/437) for
// multilingual SCI01 games
input.character = codepagemap_88591toDOS[input.character & 0x7f];
}
if (input.data == Common::KEYCODE_TAB) {
input.character = input.data = SCI_KEY_TAB;
if (modifiers & Common::KBD_SHIFT)
//.........这里部分代码省略.........
示例2: if
static sci_event_t
scummvm_get_event(struct _gfx_driver *drv)
{
sci_event_t input;
input.type = SCI_EVT_NONE;
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
Common::Point p = ev.mouse;
// Don't generate events for mouse movement
while (found && ev.type == Common::EVENT_MOUSEMOVE) {
found = em->pollEvent(ev);
p = ev.mouse;
drv->pointer_x = p.x;
drv->pointer_y = p.y;
S->update_mouse = true;
}
// Update the screen here, since it's called very often
if (S->update_mouse)
g_system->warpMouse(drv->pointer_x, drv->pointer_y);
if (S->update_screen || S->update_mouse) {
g_system->updateScreen();
S->update_screen = false;
S->update_mouse = false;
}
if (found && !ev.synthetic && ev.type != Common::EVENT_MOUSEMOVE) {
int modifiers;
if (ev.type == Common::EVENT_KEYDOWN)
modifiers = ev.kbd.flags;
else
modifiers = em->getModifierState();
input.buckybits =
((modifiers & Common::KBD_ALT) ? SCI_EVM_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_EVM_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_EVM_LSHIFT | SCI_EVM_RSHIFT : 0);
//TODO: SCI_EVM_SCRLOCK SCI_EVM_NUMLOCK SCI_EVM_CAPSLOCK SCI_EVM_INSERT
switch (ev.type) {
// Keyboard events
case Common::EVENT_KEYDOWN:
input.data = ev.kbd.keycode;
input.character = ev.kbd.ascii;
if (!(input.data & 0xFF00)) {
// Directly accept most common keys without conversion
input.type = SCI_EVT_KEYBOARD;
if (input.data == Common::KEYCODE_TAB) {
// Tab
input.type = SCI_EVT_KEYBOARD;
input.data = SCI_K_TAB;
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = SCI_K_SHIFT_TAB;
else
input.character = SCI_K_TAB;
}
} else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
// F1-F10
input.type = SCI_EVT_KEYBOARD;
// SCI_K_F1 == 59 << 8
// SCI_K_SHIFT_F1 == 84 << 8
input.data = (input.data - Common::KEYCODE_F1 + SCI_K_F1) << 8;
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = input.data + ((SCI_K_SHIFT_F1 - SCI_K_F1) << 8);
else
input.character = input.data;
} else {
// Special keys that need conversion
input.type = SCI_EVT_KEYBOARD;
switch (ev.kbd.keycode) {
case Common::KEYCODE_UP:
input.data = SCI_K_UP;
break;
case Common::KEYCODE_DOWN:
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_RIGHT:
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_LEFT:
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_INSERT:
input.data = SCI_K_INSERT;
break;
case Common::KEYCODE_HOME:
input.data = SCI_K_HOME;
break;
case Common::KEYCODE_END:
input.data = SCI_K_END;
break;
case Common::KEYCODE_PAGEUP:
input.data = SCI_K_PGUP;
break;
case Common::KEYCODE_PAGEDOWN:
//.........这里部分代码省略.........
示例3: getScummVMEvent
SciEvent EventManager::getScummVMEvent() {
#ifdef ENABLE_SCI32
SciEvent input = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point() };
SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point() };
#else
SciEvent input = { SCI_EVENT_NONE, 0, 0, Common::Point() };
SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, Common::Point() };
#endif
Common::EventManager *em = g_system->getEventManager();
Common::Event ev;
bool found = em->pollEvent(ev);
// Don't generate events for mouse movement
while (found && ev.type == Common::EVENT_MOUSEMOVE)
found = em->pollEvent(ev);
// Save the mouse position
//
// We call getMousePos of the event manager here, since we also want to
// store the mouse position in case of keyboard events, which do not feature
// any mouse position information itself.
// This should be safe, since the mouse position in the event manager should
// only be updated when a mouse related event has been taken from the queue
// via pollEvent.
// We also adjust the position based on the scaling of the screen.
Common::Point mousePos = em->getMousePos();
#if ENABLE_SCI32
if (getSciVersion() >= SCI_VERSION_2) {
Buffer &screen = g_sci->_gfxFrameout->getCurrentBuffer();
Common::Point mousePosSci = mousePos;
mulru(mousePosSci, Ratio(screen.scriptWidth, screen.screenWidth), Ratio(screen.scriptHeight, screen.screenHeight));
noEvent.mousePosSci = input.mousePosSci = mousePosSci;
} else {
#endif
g_sci->_gfxScreen->adjustBackUpscaledCoordinates(mousePos.y, mousePos.x);
#if ENABLE_SCI32
}
#endif
noEvent.mousePos = input.mousePos = mousePos;
if (!found || ev.type == Common::EVENT_MOUSEMOVE) {
int modifiers = em->getModifierState();
noEvent.modifiers =
((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0);
return noEvent;
}
if (ev.type == Common::EVENT_QUIT) {
input.type = SCI_EVENT_QUIT;
return input;
}
int scummVMKeyFlags;
switch (ev.type) {
case Common::EVENT_KEYDOWN:
case Common::EVENT_KEYUP:
// Use keyboard modifiers directly in case this is a keyboard event
scummVMKeyFlags = ev.kbd.flags;
break;
default:
// Otherwise get them from EventManager
scummVMKeyFlags = em->getModifierState();
break;
}
input.modifiers =
((scummVMKeyFlags & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
((scummVMKeyFlags & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
((scummVMKeyFlags & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0);
// Caps lock and Scroll lock have been removed, cause we already handle upper
// case keys and Scroll lock doesn't seem to be used anywhere
//((ourModifiers & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
//((ourModifiers & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
// Handle mouse events
for (int i = 0; i < ARRAYSIZE(mouseEventMappings); i++) {
if (mouseEventMappings[i].commonType == ev.type) {
input.type = mouseEventMappings[i].sciType;
// Sierra passed keyboard modifiers for mouse events, too.
// Sierra also set certain modifiers within their mouse interrupt handler
// This whole thing was probably meant for people using a mouse, that only featured 1 button
// So the user was able to press Ctrl and click the mouse button to create a right click.
switch (ev.type) {
case Common::EVENT_RBUTTONDOWN: // right button
case Common::EVENT_RBUTTONUP:
input.modifiers |= (SCI_KEYMOD_RSHIFT | SCI_KEYMOD_LSHIFT); // this value was hardcoded in the mouse interrupt handler
break;
case Common::EVENT_MBUTTONDOWN: // middle button
case Common::EVENT_MBUTTONUP:
input.modifiers |= SCI_KEYMOD_CTRL; // this value was hardcoded in the mouse interrupt handler
break;
//.........这里部分代码省略.........