bool OSystem_SDL::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONUP; fillMouseEvent(event, _km.x, _km.y); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONUP; fillMouseEvent(event, _km.x, _km.y); } else { event.type = Common::EVENT_KEYUP; switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); break; case JOY_BUT_PERIOD: event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); break; case JOY_BUT_SPACE: event.kbd.keycode = Common::KEYCODE_SPACE; event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); break; case JOY_BUT_F5: event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); break; } } return true; }
bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { event.kbd.flags = 0; switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONUP; processMouseEvent(event, _km.x, _km.y); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONUP; processMouseEvent(event, _km.x, _km.y); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); break; case BTN_SELECT: // Virtual keyboard // Handled in key down break; case BTN_SQUARE: // Escape event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); break; } return true; }
bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONDOWN; processMouseEvent(event, _km.x, _km.y); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONDOWN; processMouseEvent(event, _km.x, _km.y); } else { event.type = Common::EVENT_KEYDOWN; switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_PERIOD: event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_SPACE: event.kbd.keycode = Common::KEYCODE_SPACE; event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_F5: event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0); break; } } return true; }
void OPRijVij::eventUpdate(const System& sysEvent, const NEventData& SDat, const double&) { BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges) process2PED(rvdotacc[mapKey(sysEvent.getType(), getClassKey(sysEvent))], pDat); }
void OPRijVij::eventUpdate(const LocalEvent& localEvent, const NEventData& SDat) { BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges) process2PED(rvdotacc[mapKey(localEvent.getType(), getClassKey(localEvent))], pDat); }
static LRESULT process_key(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { int key; lastUserInputTick = GetTickCount(); switch (key = mapKey(wp, lp)) { case KEYMAP_KEY_INVALID: break; default: pMidpEventResult->type = MIDP_KEY_EVENT; pMidpEventResult->CHR = key; if (msg == WM_KEYUP) { pMidpEventResult->ACTION = KEYMAP_STATE_RELEASED; } else if (lp & 0x40000000) { pMidpEventResult->ACTION = KEYMAP_STATE_REPEATED; } else { pMidpEventResult->ACTION = KEYMAP_STATE_PRESSED; } pSignalResult->waitingFor = UI_SIGNAL; pMidpEventResult->DISPLAY = gForegroundDisplayId; sendMidpKeyEvent(pMidpEventResult, sizeof(*pMidpEventResult)); } return 0; }
bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) { SDLModToOSystemKeyFlags(SDL_GetModState(), event); // Handle scroll lock as a key modifier if (ev.key.keysym.sym == SDLK_SCROLLOCK) _scrollLock = !_scrollLock; if (_scrollLock) event.kbd.flags |= Common::KBD_SCRL; // Ctrl-m toggles mouse capture if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') { toggleMouseGrab(); return false; } #if defined(MACOSX) // On Macintosh, Cmd-Q quits if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') { event.type = Common::EVENT_QUIT; return true; } #elif defined(POSIX) // On other *nix systems, Control-Q quits if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') { event.type = Common::EVENT_QUIT; return true; } #else // Ctrl-z and Alt-X quit if ((event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'z') || (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 'x')) { event.type = Common::EVENT_QUIT; return true; } #ifdef WIN32 // On Windows, also use the default Alt-F4 quit combination if ((ev.key.keysym.mod & KMOD_ALT) && ev.key.keysym.sym == SDLK_F4) { event.type = Common::EVENT_QUIT; return true; } #endif #endif // Ctrl-u toggles mute if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'u') { event.type = Common::EVENT_MUTE; return true; } if (remapKey(ev, event)) return true; event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = SDLToOSystemKeycode(ev.key.keysym.sym); event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode); return true; }
void OPRijVij::eventUpdate(const IntEvent& iEvent, const PairEventData& pDat) { process2PED(rvdotacc[mapKey(iEvent.getType(), getClassKey(iEvent))], pDat); }
void AI::updateWallMap() { wallMap.clear(); for (int j = 0; j < walls.size(); j++) { wallMap[mapKey(walls[j].x(), walls[j].y())] = j; } }
void Window::keyReleaseEvent( QKeyEvent * event ) { if ( !event->isAutoRepeat() ) { int key = mapKey( event->key() ); if ( key > 0 ) controller->keyup( key ); } }
void Window::keyPressEvent( QKeyEvent * event ) { if ( !event->isAutoRepeat() ) { int key = mapKey( event->key() ); if ( key > 0 ) controller->keydown( key ); } }
void UDPServer::handleDataRequest(QString data) { qDebug() << "UDPServer::handleDataRequest called with data:" << data; QString cmd = data.section(';',1,1).toLower(); switch (COMMANDS.indexOf(cmd.section(' ',0,0))) { case 0: // Help command (help) qDebug() << "help command called"; sendHelp(); break; case 1: // List devices command (lsdvs) qDebug() << "List devices command called"; sendDeviceList(); break; case 2: // Select device command (sldvc) qDebug() << "Select device command called"; selectDevice(cmd); break; case 3: // Deselect device command (dsdvc) qDebug() << "Deselect device command called"; deselectDevice(); break; case 4: // List buttons command (lsbts) qDebug() << "List buttons command called"; listButtons(); break; case 5: // Keymap command (kmap) qDebug() << "Keymap command called"; mapKey(cmd); break; case 6: // Undo keymap command (umap) qDebug() << "Undo keymap command called"; unmapKey(cmd); break; case 7: // Supported devices command (supdvs) qDebug() << "Supported devices command called"; supportedDevices(cmd); break; case 8: // Axis Format Map (afmap) qDebug() << "Axis Format Map command called"; axisFormatMap(cmd); break; case 9: // Axis Key Map (akmap) qDebug() << "Axis Key Map command called"; axisKeyMap(cmd); break; default: qDebug() << "Command not recognised"; QString reply = "10;"; reply += "\'" + cmd.section(' ',0,0) + "\'"; reply += " is not recognized as a command, use the \'help\' command for more information"; sendDatagram(reply.toLatin1()); break; } emit dataAvailable(data); }
int AI::getWall(int x, int y) { std::map<int, int>::iterator iter; int index = -1; iter = wallMap.find(mapKey(x, y)); if (iter != wallMap.end()) index = iter->second; return index; }
void CKeyState::fakeKeyRepeat( KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button) { button &= kButtonMask; // if we haven't seen this button go down then ignore it KeyButton oldLocalID = m_serverKeyMap[button]; if (oldLocalID == 0) { return; } // get the sequence of keys to simulate key repeat and the final // modifier state. Keystrokes keys; KeyButton localID = (KeyButton)(mapKey(keys, id, mask, true) & kButtonMask); if (localID == 0) { LOG((CLOG_DEBUG2 "cannot map key 0x%08x", id)); return; } if (keys.empty()) { // do nothing if there are no associated keys return; } // if the keycode for the auto-repeat is not the same as for the // initial press then mark the initial key as released and the new // key as pressed. this can happen when we auto-repeat after a // dead key. for example, a dead accent followed by 'a' will // generate an 'a with accent' followed by a repeating 'a'. the // keycodes for the two keysyms might be different. if (localID != oldLocalID) { // replace key up with previous key id but leave key down // alone so it uses the new keycode. for (Keystrokes::iterator index = keys.begin(); index != keys.end(); ++index) { if (index->m_key == localID) { index->m_key = oldLocalID; break; } } // note that old key is now up m_keys[oldLocalID] &= ~kDown; // map server key to new key m_serverKeyMap[button] = localID; // note that new key is now down m_keys[localID] |= kDown; } // generate key events fakeKeyEvents(keys, count); }
void ChameleonMScreen::keyPressEvent(QKeyEvent *key) { seen_key_press = KNI_TRUE; #if ENABLE_MULTIPLE_ISOLATES if (key->key() == Qt::Key_F12|| key->key() == Qt::Key_Home) { /* F12 to display the foreground selector */ if (!key->isAutoRepeat()) { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = SELECT_FOREGROUND_EVENT; evt.intParam1 = 0; midpStoreEventAndSignalAms(evt); } #ifdef QT_KEYPAD_MODE } else if (key->key() == Qt::Key_Flip) { #else } else if (key->key() == Qt::Key_F4) { #endif if (!key->isAutoRepeat()) { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = SELECT_FOREGROUND_EVENT; evt.intParam1 = 1; midpStoreEventAndSignalAms(evt); } } #else /* F12 pause or activate all Java apps */ if ((key->key() == Qt::Key_F12 || key->key() == Qt::Key_Home) && !key->isAutoRepeat()) { pauseAll(); } #endif else { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); if ((evt.CHR = mapKey(key)) != KEYMAP_KEY_INVALID) { if (evt.CHR == KEYMAP_KEY_SCREEN_ROT) { evt.type = ROTATION_EVENT; } else { evt.type = MIDP_KEY_EVENT; } evt.ACTION = key->isAutoRepeat() ? KEYMAP_STATE_REPEATED : KEYMAP_STATE_PRESSED; midpStoreEventAndSignalForeground(evt); } } }
bool GP2XSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) { SDLModToOSystemKeyFlags(SDL_GetModState(), event); if (remapKey(ev, event)) return true; event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); return true; }
bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) { if (remapKey(ev, event)) return true; SDLMod mod = SDL_GetModState(); // Check if this is an event handled by handleKeyDown(), and stop if it is // Check if the Ctrl key is down, so that we can trap cases where the // user has the Ctrl key down, and has just released a special key if (mod & KMOD_CTRL) { if (ev.key.keysym.sym == 'm' || // Ctrl-m toggles mouse capture #if defined(MACOSX) // Meta - Q, handled below #elif defined(POSIX) ev.key.keysym.sym == 'q' || // On other *nix systems, Control-Q quits #else ev.key.keysym.sym == 'z' || // Ctrl-z quit #endif ev.key.keysym.sym == 'u') // Ctrl-u toggles mute return false; } // Same for other keys (Meta and Alt) #if defined(MACOSX) if ((mod & KMOD_META) && ev.key.keysym.sym == 'q') return false; // On Macintosh, Cmd-Q quits #elif defined(POSIX) // Control Q has already been handled above #else if ((mod & KMOD_ALT) && ev.key.keysym.sym == 'x') return false; // Alt-x quit #endif // If we reached here, this isn't an event handled by handleKeyDown(), thus // continue normally event.type = Common::EVENT_KEYUP; event.kbd.keycode = SDLToOSystemKeycode(ev.key.keysym.sym); event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode); // Ctrl-Alt-<key> will change the GFX mode SDLModToOSystemKeyFlags(mod, event); // Set the scroll lock sticky flag if (_scrollLock) event.kbd.flags |= Common::KBD_SCRL; return true; }
bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { event.kbd.flags = 0; switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONDOWN; processMouseEvent(event, _km.x, _km.y); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONDOWN; processMouseEvent(event, _km.x, _km.y); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); break; case BTN_SELECT: // Virtual keyboard #ifdef ENABLE_VKEYBD event.type = Common::EVENT_VIRTUAL_KEYBOARD; #endif break; case BTN_SQUARE: // Escape event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); break; case BTN_L1: // Predictive input dialog event.type = Common::EVENT_PREDICTIVE_DIALOG; break; case BTN_START: // ScummVM in game menu event.type = Common::EVENT_MAINMENU; break; } return true; }
void OPCubeComp::eventUpdate(const IntEvent& iEvent, const PairEventData& pDat) { mapdata& ref = angles[mapKey(iEvent.getType(), getClassKey(iEvent))]; std::vector<double> vals(NDIM, 0); for (size_t i(0); i < NDIM; ++i) vals[i] = pDat.rij[i] * pDat.rij[i] / Sim->dynamics.units().unitArea(); std::sort(vals.begin(), vals.end()); for (size_t i(0); i < NDIM; ++i) ref.angles[i].addVal(vals[i]); }
void ConfigManager::getBindingMap (LUA& lua, std::map<int, std::string>* map, const char *key, BindingType type) { if (type == CONTROLLER) return; lua.getGlobalKeyValue(key); while (lua.getNextKeyValue()) { const std::string id = lua.getKey(); if (id.empty()) { lua.pop(); continue; } lua_pushnil(lua.getState()); std::map<std::string, std::string> strMap; while (lua_next(lua.getState(), -2) != 0) { const char *_key = lua_tostring(lua.getState(), -2); assert(_key); std::string _value; if (lua_isstring(lua.getState(), -1)) { _value = lua_tostring(lua.getState(), -1); } else if (lua_isnumber(lua.getState(), -1)) { _value = string::toString(lua_tonumber(lua.getState(), -1)); } else if (lua_isboolean(lua.getState(), -1)) { _value = lua_toboolean(lua.getState(), -1) ? "true" : "false"; } strMap[_key] = _value; lua_pop(lua.getState(), 1); } BindingSpace bindingSpace = BINDINGS_UI; if (id == "map") bindingSpace = BINDINGS_MAP; for (std::map<std::string, std::string>::const_iterator i = strMap.begin(); i != strMap.end(); ++i) { if (type == KEYBOARD) { map[bindingSpace][mapKey(i->first)] = i->second; } else if (type == JOYSTICK) { const std::string index = i->first.substr(3); map[bindingSpace][string::toInt(index)] = i->second; } } lua_pop(lua.getState(), 1); } }
bool AndroidSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { if (false) {} if (ev.key.keysym.sym == SDLK_F13) { event.type = Common::EVENT_MAINMENU; return true; } else { // Let the events fall through if we didn't change them, this may not be the best way to // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. // and yes i have an huge terminal size so i dont wrap soon enough. event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); } return false; }
bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) { if (remapKey(ev, event)) return true; event.type = Common::EVENT_KEYUP; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); // Ctrl-Alt-<key> will change the GFX mode byte b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { // Swallow these key up events return false; } return true; }
void OPCubeComp::eventUpdate(const GlobalEvent& globEvent, const NEventData& SDat) { BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges) { mapdata& ref = angles[mapKey(globEvent.getType(), getClassKey(globEvent))]; std::vector<double> vals(NDIM, 0); for (size_t i(0); i < NDIM; ++i) vals[i] = pDat.rij[i] * pDat.rij[i] / Sim->dynamics.units().unitArea(); std::sort(vals.begin(), vals.end()); for (size_t i(0); i < NDIM; ++i) ref.angles[i].addVal(vals[i]); } }
void ChameleonMScreen::keyReleaseEvent(QKeyEvent *key) { if (!seen_key_press || key->isAutoRepeat()) { /* * We may have a left-over keyReleaseEvent from a previous * invocation of the VM! */ return; } MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); if ((evt.CHR = mapKey(key)) != KEYMAP_KEY_INVALID) { evt.type = MIDP_KEY_EVENT; evt.ACTION = KEYMAP_STATE_RELEASED; midpStoreEventAndSignalForeground(evt); } }
void CKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button) { // get the sequence of keys to simulate key press and the final // modifier state. Keystrokes keys; KeyButton localID = (KeyButton)(mapKey(keys, id, mask, false) & kButtonMask); if (keys.empty()) { // do nothing if there are no associated keys LOG((CLOG_DEBUG2 "cannot map key 0x%08x", id)); return; } // generate key events fakeKeyEvents(keys, 1); // note that key is down updateKeyState((KeyButton)(button & kButtonMask), localID, true, true); }
void ConfigManager::getBindingMap (LUA& lua, std::map<int, std::string>* map, const char *key, BindingType type) { if (type == CONTROLLER) return; if (!lua.getGlobalKeyValue(key)) return; while (lua.getNextKeyValue()) { const std::string id = lua.getKey(); if (id.empty()) { lua.pop(); continue; } lua_pushnil(lua.getState()); std::map<std::string, std::string> strMap; while (lua.getNextKeyValue()) { const std::string& _key = lua.getLuaValue(-2); const std::string& _value = lua.getLuaValue(-1); strMap[_key] = _value; lua.pop(); } BindingSpace bindingSpace = BINDINGS_UI; if (id == "map") bindingSpace = BINDINGS_MAP; for (std::map<std::string, std::string>::const_iterator i = strMap.begin(); i != strMap.end(); ++i) { if (type == KEYBOARD) { map[bindingSpace][mapKey(i->first)] = i->second; } } lua_pop(lua.getState(), 1); } }
bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { // Motorol A1200/E6/A1600 remapkey by Lubomyr #ifdef MOTOEZX // Quit on MOD+Camera Key on A1200 if (ev.key.keysym.sym == SDLK_e) { event.type = Common::EVENT_QUIT; return true; } // '1' Bypass security protection - MOD+Call key if (ev.key.keysym.sym == SDLK_f) { ev.key.keysym.sym = SDLK_1; } // F5 Game Menu - Call key else if (ev.key.keysym.sym == SDLK_SPACE) { ev.key.keysym.sym = SDLK_F5; } // VirtualKeyboard - Camera key else if (ev.key.keysym.sym == SDLK_PAUSE) { ev.key.keysym.sym = SDLK_F7; } // Enter - mod+fire key else if (ev.key.keysym.sym == SDLK_b) { ev.key.keysym.sym = SDLK_RETURN; } // '3' - mod+up key else if (ev.key.keysym.sym == SDLK_j) { ev.key.keysym.sym = SDLK_3; } // '6' - mod+up key else if (ev.key.keysym.sym == SDLK_i) { ev.key.keysym.sym = SDLK_6; } // 'y' - mod+right key else if (ev.key.keysym.sym == SDLK_g) { ev.key.keysym.sym = SDLK_y; } // 'n' - mod+right key else if (ev.key.keysym.sym == SDLK_h) { ev.key.keysym.sym = SDLK_n; } // mod+vol'+' -> volume'+' else if (ev.key.keysym.sym == SDLK_c) { ev.key.keysym.sym = SDLK_RIGHTBRACKET; } // mod+vol'-' -> volume'-' else if (ev.key.keysym.sym == SDLK_d) { ev.key.keysym.sym = SDLK_LEFTBRACKET; } #endif // Motorola Z6/V8 remapkey by Ant-On #ifdef MOTOMAGX // Quit on cancel if (ev.key.keysym.sym == SDLK_ESCAPE) { event.type = Common::EVENT_QUIT; return true; } // F5 Game Menu - Slide Select if (ev.key.keysym.sym == SDLK_SPACE) { ev.key.keysym.sym = SDLK_F5; } // Escape - Dial key else if (ev.key.keysym.sym == SDLK_TAB) { ev.key.keysym.sym = SDLK_ESCAPE; } // Space - Virtual keyboard else if (ev.key.keysym.sym == SDLK_PAUSE) { ev.key.keysym.sym = SDLK_F7; } // 'y' - Left soft else if (ev.key.keysym.sym == SDLK_F9) { ev.key.keysym.sym = SDLK_y; } // 'n' - Rigth soft else if (ev.key.keysym.sym == SDLK_F11) { ev.key.keysym.sym = SDLK_n; } // # -> volume'+' else if (ev.key.keysym.sym == SDLK_HASH) { ev.key.keysym.sym = SDLK_RIGHTBRACKET; } // * -> volume'-' else if (ev.key.keysym.sym == SDLK_WORLD_55) { ev.key.keysym.sym = SDLK_LEFTBRACKET; } #endif // Joystick to Mouse else if (ev.key.keysym.sym == SDLK_LEFT) { if (ev.type == SDL_KEYDOWN) { _km.x_vel = -1; _km.x_down_count = 1; } else { _km.x_vel = 0; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_RIGHT) { if (ev.type == SDL_KEYDOWN) { _km.x_vel = 1; _km.x_down_count = 1; } else { _km.x_vel = 0; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_DOWN) { if (ev.type == SDL_KEYDOWN) { _km.y_vel = 1; _km.y_down_count = 1; } else { _km.y_vel = 0; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_UP) { if (ev.type == SDL_KEYDOWN) { _km.y_vel = -1; _km.y_down_count = 1; } else { _km.y_vel = 0; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_RETURN) { // Joystick center to pressing Left Mouse if (ev.key.type == SDL_KEYDOWN) { event.type = Common::EVENT_LBUTTONDOWN; } else { event.type = Common::EVENT_LBUTTONUP; } fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_PLUS) { // Volume Up to pressing Right Mouse if (ev.key.type == SDL_KEYDOWN ) { event.type = Common::EVENT_RBUTTONDOWN; } else { event.type = Common::EVENT_RBUTTONUP; } fillMouseEvent(event, _km.x, _km.y); return true; } else if (ev.key.keysym.sym == SDLK_MINUS) { // Volume Down to pressing Left Mouse if (ev.key.type == SDL_KEYDOWN) { event.type = Common::EVENT_LBUTTONDOWN; } else { event.type = Common::EVENT_LBUTTONUP; } fillMouseEvent(event, _km.x, _km.y); return true; } else { // Let the events fall through if we didn't change them, this may not be the best way to // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. // and yes i have an huge terminal size so i dont wrap soon enough. event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); } return false; }
bool GP2XSdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { _stickBtn[ev.jbutton.button] = 1; event.kbd.flags = 0; switch (ev.jbutton.button) { case BUTTON_UP: case BUTTON_UPLEFT: case BUTTON_LEFT: case BUTTON_DOWNLEFT: case BUTTON_DOWN: case BUTTON_DOWNRIGHT: case BUTTON_RIGHT: case BUTTON_UPRIGHT: moveStick(); event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); break; case BUTTON_B: case BUTTON_CLICK: if (BUTTON_STATE_L == true) { ((GP2XSdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->toggleZoomOnMouse(); fillMouseEvent(event, _km.x, _km.y); } else { event.type = Common::EVENT_LBUTTONDOWN; fillMouseEvent(event, _km.x, _km.y); } break; case BUTTON_X: event.type = Common::EVENT_RBUTTONDOWN; fillMouseEvent(event, _km.x, _km.y); break; case BUTTON_L: BUTTON_STATE_L = true; break; case BUTTON_R: event.type = Common::EVENT_KEYDOWN; if (BUTTON_STATE_L == true) { #ifdef ENABLE_VKEYBD event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0); #else event.kbd.keycode = Common::KEYCODE_0; event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); #endif } else { event.kbd.keycode = Common::KEYCODE_RETURN; event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); } break; case BUTTON_SELECT: case BUTTON_HOME: event.type = Common::EVENT_KEYDOWN; if (BUTTON_STATE_L == true) { event.type = Common::EVENT_QUIT; } else { event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); } break; case BUTTON_A: event.type = Common::EVENT_KEYDOWN; if (BUTTON_STATE_L == true) { event.type = Common::EVENT_PREDICTIVE_DIALOG; } else { event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); } break; case BUTTON_Y: event.type = Common::EVENT_KEYDOWN; if (BUTTON_STATE_L == true) { GPH::ToggleTapMode(); if (GPH::tapmodeLevel == TAPMODE_LEFT) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click"); } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click"); } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)"); } } else { event.kbd.keycode = Common::KEYCODE_SPACE; event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); } break; case BUTTON_MENU: case BUTTON_HELP: event.type = Common::EVENT_KEYDOWN; if (BUTTON_STATE_L == true) { event.type = Common::EVENT_MAINMENU; } else { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); } break; case BUTTON_VOLUP: GP2X_HW::mixerMoveVolume(2); if (GP2X_HW::volumeLevel == 100) { g_system->displayMessageOnOSD("Maximum Volume"); } else { g_system->displayMessageOnOSD("Increasing Volume"); } break; case BUTTON_VOLDOWN: GP2X_HW::mixerMoveVolume(1); if (GP2X_HW::volumeLevel == 0) { g_system->displayMessageOnOSD("Minimal Volume"); } else { g_system->displayMessageOnOSD("Decreasing Volume"); } break; case BUTTON_HOLD: event.type = Common::EVENT_QUIT; break; case BUTTON_HELP2: GPH::ToggleTapMode(); if (GPH::tapmodeLevel == TAPMODE_LEFT) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click"); } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click"); } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)"); } break; } return true; }
void KPSdl2UserInterface::MainLoop() { // This is the event loop auto done = false; unsigned char key; while (! done) { SDL_Event event; memset(&event, 0, sizeof(event)); Idle(); while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: Reshape(event.window.data1, event.window.data2); break; } break; case SDL_USEREVENT: if (event.user.code == REQUEST_FOR_CLOSE) { done = true; } break; case SDL_QUIT: done = true; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: MouseClick(event.button.button, event.button.state, event.button.x, event.button.y); break; case SDL_KEYDOWN: if (mapKey(event.key.keysym.mod, event.key.keysym.sym, &key)) { int xm, ym; SDL_GetMouseState(&xm, &ym); KeyPressed(key, xm, ym); } break; } // switch } // event loop Display(); PostWindowRedisplay(); SDL_Delay(10); } // main loop }
bool GP2XSdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { _stickBtn[ev.jbutton.button] = 0; event.kbd.flags = 0; switch (ev.jbutton.button) { case BUTTON_UP: case BUTTON_UPLEFT: case BUTTON_LEFT: case BUTTON_DOWNLEFT: case BUTTON_DOWN: case BUTTON_DOWNRIGHT: case BUTTON_RIGHT: case BUTTON_UPRIGHT: moveStick(); event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); break; case BUTTON_B: case BUTTON_CLICK: if (BUTTON_STATE_L == true) { break; } else { event.type = Common::EVENT_LBUTTONUP; fillMouseEvent(event, _km.x, _km.y); } break; case BUTTON_X: event.type = Common::EVENT_RBUTTONUP; fillMouseEvent(event, _km.x, _km.y); break; case BUTTON_L: BUTTON_STATE_L = false; break; case BUTTON_SELECT: case BUTTON_HOME: event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); break; case BUTTON_A: event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); break; case BUTTON_Y: event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_SPACE; event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); break; case BUTTON_MENU: case BUTTON_HELP: event.type = Common::EVENT_KEYUP; if (BUTTON_STATE_L == true) { event.type = Common::EVENT_MAINMENU; } else { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); } break; case BUTTON_R: event.type = Common::EVENT_KEYUP; if (BUTTON_STATE_L == true) { #ifdef ENABLE_VKEYBD event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0); #else event.kbd.keycode = Common::KEYCODE_0; event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); #endif } else { event.kbd.keycode = Common::KEYCODE_RETURN; event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); } break; case BUTTON_VOLUP: break; case BUTTON_VOLDOWN: break; case BUTTON_HOLD: break; case BUTTON_HELP2: break; } return true; }