//----------------------------------------------------------------------------- // key typed void SeaOfMemes::appKeyChar( int keyCode, int modifiers) { // if UI open, give it character if (m_helpUI != NULL && m_helpUI->hasKeyFocus()) { m_helpUI->getTop()->surfaceKeyChar(keyCode, modifiers); return; } switch (keyCode) { case 'L': setLandingMode(!m_landingMode); break; case 'K': setUnits(!m_unitsMetric); break; case '=': case '+': { m_avatarSpeed = m_avatarSpeed * 2.0; m_avatarSpeed = min(MAX_AVATAR_SPEED, m_avatarSpeed); if (m_speedUI != NULL) m_speedUI->setSpeed(m_avatarSpeed); /* if (m_landingMode) m_avatarSpeed = min(MAX_LAND_SPEED, m_avatarSpeed); else m_avatarSpeed = min(MAX_SPACE_SPEED, m_avatarSpeed); showSpeed(); */ break; } case '-': { m_avatarSpeed = m_avatarSpeed / 2.0; m_avatarSpeed = max(MIN_AVATAR_SPEED, m_avatarSpeed); if (m_speedUI != NULL) m_speedUI->setSpeed(m_avatarSpeed); /* if (m_landingMode) m_avatarSpeed = max(MIN_LAND_SPEED, m_avatarSpeed); else m_avatarSpeed = max(MIN_SPACE_SPEED, m_avatarSpeed); showSpeed(); */ break; } } }
//----------------------------------------------------------------------------- // key press void SeaOfMemes::appKeyDown( int keyCode, int modifiers) { switch (keyCode) { case MG_EVENT_KEY_ESCAPE: setDeskMode(!m_deskMode); break; case MG_EVENT_KEY_F1: if (m_helpUI != NULL) m_helpUI->toggleHelp(); break; case MG_EVENT_KEY_F6: { mgDebug("debug"); break; } case 'W': case MG_EVENT_KEY_UP: // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_forwardSince == INVALID_TIME) m_forwardSince = mgOSGetTime(); break; case 'S': case MG_EVENT_KEY_DOWN: // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_backwardSince == INVALID_TIME) m_backwardSince = mgOSGetTime(); break; case 'A': // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_leftSince == INVALID_TIME) m_leftSince = mgOSGetTime(); break; case 'D': // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_rightSince == INVALID_TIME) m_rightSince = mgOSGetTime(); break; case MG_EVENT_KEY_PAGEUP: case ' ': // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_upSince == INVALID_TIME) m_upSince = mgOSGetTime(); break; case MG_EVENT_KEY_PAGEDN: case 'X': // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_downSince == INVALID_TIME) m_downSince = mgOSGetTime(); break; case MG_EVENT_KEY_LEFT: // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_turnLeftSince == INVALID_TIME) m_turnLeftSince = mgOSGetTime(); break; case MG_EVENT_KEY_RIGHT: // ignore autorepeat keys if ((modifiers & MG_EVENT_KEYREPEAT) != 0) return; if (m_turnRightSince == INVALID_TIME) m_turnRightSince = mgOSGetTime(); break; case 'L': setLandingMode(!m_landingMode); break; case 'K': setUnits(!m_unitsMetric); break; case '=': case '+': { m_avatarSpeed = m_avatarSpeed * 2.0; m_avatarSpeed = min(MAX_AVATAR_SPEED, m_avatarSpeed); if (m_speedUI != NULL) m_speedUI->setSpeed(m_avatarSpeed); /* if (m_landingMode) m_avatarSpeed = min(MAX_LAND_SPEED, m_avatarSpeed); else m_avatarSpeed = min(MAX_SPACE_SPEED, m_avatarSpeed); showSpeed(); */ break; } case '-': { m_avatarSpeed = m_avatarSpeed / 2.0; m_avatarSpeed = max(MIN_AVATAR_SPEED, m_avatarSpeed); if (m_speedUI != NULL) m_speedUI->setSpeed(m_avatarSpeed); /* if (m_landingMode) m_avatarSpeed = max(MIN_LAND_SPEED, m_avatarSpeed); else m_avatarSpeed = max(MIN_SPACE_SPEED, m_avatarSpeed); showSpeed(); */ break; } } }