mirror of
https://github.com/overte-org/overte.git
synced 2025-08-03 23:43:30 +02:00
Fine tunning on windows
This commit is contained in:
parent
8e65ce34d1
commit
b7bacccce7
3 changed files with 32 additions and 101 deletions
|
@ -1114,11 +1114,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_E:
|
||||
case Qt::Key_PageUp:
|
||||
// _myAvatar->setDriveKeys(UP, 1.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_F: {
|
||||
_physicsEngine.dumpNextStats();
|
||||
break;
|
||||
|
@ -1128,16 +1123,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
Menu::getInstance()->triggerOption(MenuOption::Stars);
|
||||
break;
|
||||
|
||||
case Qt::Key_C:
|
||||
case Qt::Key_PageDown:
|
||||
// _myAvatar->setDriveKeys(DOWN, 1.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_W:
|
||||
if (isOption && !isShifted && !isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::Wireframe);
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(FWD, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1148,8 +1136,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
Menu::getInstance()->triggerOption(MenuOption::ScriptEditor);
|
||||
} else if (!isOption && !isShifted && isMeta) {
|
||||
takeSnapshot();
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(BACK, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1160,14 +1146,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_A:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
|
||||
} else if (!isMeta) {
|
||||
// _myAvatar->setDriveKeys(ROT_LEFT, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_D:
|
||||
if (!isMeta) {
|
||||
// _myAvatar->setDriveKeys(ROT_RIGHT, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1182,8 +1160,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
} else {
|
||||
_raiseMirror += 0.05f;
|
||||
}
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1194,24 +1170,18 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
} else {
|
||||
_raiseMirror -= 0.05f;
|
||||
}
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_rotateMirror += PI / 20.0f;
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Right:
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_rotateMirror -= PI / 20.0f;
|
||||
} else {
|
||||
// _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1357,57 +1327,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
_keyboardMouseDevice.keyReleaseEvent(event);
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_E:
|
||||
case Qt::Key_PageUp:
|
||||
// _myAvatar->setDriveKeys(UP, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_C:
|
||||
case Qt::Key_PageDown:
|
||||
// _myAvatar->setDriveKeys(DOWN, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_W:
|
||||
// _myAvatar->setDriveKeys(FWD, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_S:
|
||||
// _myAvatar->setDriveKeys(BACK, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_A:
|
||||
// _myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_D:
|
||||
// _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
// _myAvatar->setDriveKeys(FWD, 0.0f);
|
||||
// _myAvatar->setDriveKeys(UP, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_Down:
|
||||
// _myAvatar->setDriveKeys(BACK, 0.0f);
|
||||
// _myAvatar->setDriveKeys(DOWN, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
// _myAvatar->setDriveKeys(LEFT, 0.0f);
|
||||
// _myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
|
||||
break;
|
||||
|
||||
case Qt::Key_Right:
|
||||
// _myAvatar->setDriveKeys(RIGHT, 0.0f);
|
||||
// _myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
|
||||
break;
|
||||
case Qt::Key_Control:
|
||||
case Qt::Key_Shift:
|
||||
case Qt::Key_Meta:
|
||||
case Qt::Key_Alt:
|
||||
// _myAvatar->clearDriveKeys();
|
||||
break;
|
||||
case Qt::Key_Space: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this ends the HFActionEvent
|
||||
|
@ -1433,6 +1352,8 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
}
|
||||
|
||||
void Application::focusOutEvent(QFocusEvent* event) {
|
||||
_keyboardMouseDevice.focusOutEvent(event);
|
||||
|
||||
// synthesize events for keys currently pressed, since we may not get their release events
|
||||
foreach (int key, _keysPressed) {
|
||||
QKeyEvent event(QEvent::KeyRelease, key, Qt::NoModifier);
|
||||
|
|
|
@ -27,6 +27,10 @@ void KeyboardMouseDevice::update() {
|
|||
}
|
||||
}
|
||||
|
||||
void KeyboardMouseDevice::focusOutEvent(QFocusEvent* event) {
|
||||
_buttonPressedMap.clear();
|
||||
};
|
||||
|
||||
void KeyboardMouseDevice::keyPressEvent(QKeyEvent* event) {
|
||||
auto input = makeInput((Qt::Key) event->key());
|
||||
auto result = _buttonPressedMap.insert(input.getChannel());
|
||||
|
@ -114,35 +118,38 @@ void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) {
|
|||
}
|
||||
|
||||
UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::Key code) {
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, code & KEYBOARD_MASK, UserInputMapper::ChannelType::BUTTON);
|
||||
return UserInputMapper::Input(_deviceID, code & KEYBOARD_MASK, UserInputMapper::ChannelType::BUTTON);
|
||||
}
|
||||
UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::MouseButton code) {
|
||||
switch (code) {
|
||||
case Qt::LeftButton:
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_LEFT, UserInputMapper::ChannelType::BUTTON);
|
||||
return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_LEFT, UserInputMapper::ChannelType::BUTTON);
|
||||
case Qt::RightButton:
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_RIGHT, UserInputMapper::ChannelType::BUTTON);
|
||||
return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_RIGHT, UserInputMapper::ChannelType::BUTTON);
|
||||
case Qt::MiddleButton:
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_MIDDLE, UserInputMapper::ChannelType::BUTTON);
|
||||
return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_MIDDLE, UserInputMapper::ChannelType::BUTTON);
|
||||
default:
|
||||
return UserInputMapper::Input();
|
||||
};
|
||||
}
|
||||
UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::MouseAxisChannel axis) {
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, axis, UserInputMapper::ChannelType::AXIS);
|
||||
return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS);
|
||||
}
|
||||
UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchAxisChannel axis) {
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, axis, UserInputMapper::ChannelType::AXIS);
|
||||
return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS);
|
||||
}
|
||||
UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchButtonChannel button) {
|
||||
return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, button, UserInputMapper::ChannelType::BUTTON);
|
||||
return UserInputMapper::Input(_deviceID, button, UserInputMapper::ChannelType::BUTTON);
|
||||
}
|
||||
|
||||
void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {
|
||||
// Grab the current free device ID
|
||||
_deviceID = mapper.getFreeDeviceID();
|
||||
|
||||
auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy());
|
||||
proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input._channel); };
|
||||
proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input._channel); };
|
||||
mapper.registerDevice(DEFAULT_DESKTOP_DEVICE, proxy); // HARDCODED!, the KeyboardMouseDevice always take the DeviceID = 1
|
||||
mapper.registerDevice(_deviceID, proxy);
|
||||
}
|
||||
|
||||
void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
|
||||
|
@ -206,8 +213,8 @@ void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
|
|||
mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);
|
||||
|
||||
// Wheel move
|
||||
mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);
|
||||
mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
|
||||
//mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);
|
||||
//mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
|
||||
mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(MOUSE_AXIS_WHEEL_X_NEG), BUTTON_YAW_SPEED);
|
||||
mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(MOUSE_AXIS_WHEEL_X_POS), BUTTON_YAW_SPEED);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
typedef std::function<float (const Input& input, int timestamp)> AxisGetter;
|
||||
typedef std::function<JointValue (const Input& input, int timestamp)> JointGetter;
|
||||
|
||||
class DeviceProxy {
|
||||
class DeviceProxy {
|
||||
public:
|
||||
DeviceProxy() {}
|
||||
|
||||
|
@ -94,6 +94,8 @@ public:
|
|||
|
||||
typedef std::shared_ptr<DeviceProxy> Pointer;
|
||||
};
|
||||
// GetFreeDeviceID should be called before registering a device to use an ID not used by a different device.
|
||||
uint16 getFreeDeviceID() { return _nextFreeDeviceID++; }
|
||||
bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device);
|
||||
DeviceProxy::Pointer getDeviceProxy(const Input& input);
|
||||
|
||||
|
@ -163,7 +165,8 @@ public:
|
|||
protected:
|
||||
typedef std::map<int, DeviceProxy::Pointer> DevicesMap;
|
||||
DevicesMap _registeredDevices;
|
||||
|
||||
uint16 _nextFreeDeviceID = 1;
|
||||
|
||||
typedef std::map<int, Modifiers> InputToMoModifiersMap;
|
||||
InputToMoModifiersMap _inputToModifiersMap;
|
||||
|
||||
|
@ -215,6 +218,8 @@ public:
|
|||
typedef std::unordered_set<int> ButtonPressedMap;
|
||||
typedef std::map<int, float> AxisStateMap; // 8 axes
|
||||
|
||||
void focusOutEvent(QFocusEvent* event);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
|
@ -232,15 +237,12 @@ public:
|
|||
float getButton(int channel) const;
|
||||
float getAxis(int channel) const;
|
||||
|
||||
// Reserverd device ID for the standard keyboard and mouse
|
||||
const static UserInputMapper::uint16 DEFAULT_DESKTOP_DEVICE = 1;
|
||||
|
||||
// Let's make it easy for Qt because we assume we love Qt forever
|
||||
static UserInputMapper::Input makeInput(Qt::Key code);
|
||||
static UserInputMapper::Input makeInput(Qt::MouseButton code);
|
||||
static UserInputMapper::Input makeInput(KeyboardMouseDevice::MouseAxisChannel axis);
|
||||
static UserInputMapper::Input makeInput(KeyboardMouseDevice::TouchAxisChannel axis);
|
||||
static UserInputMapper::Input makeInput(KeyboardMouseDevice::TouchButtonChannel button);
|
||||
UserInputMapper::Input makeInput(Qt::Key code);
|
||||
UserInputMapper::Input makeInput(Qt::MouseButton code);
|
||||
UserInputMapper::Input makeInput(KeyboardMouseDevice::MouseAxisChannel axis);
|
||||
UserInputMapper::Input makeInput(KeyboardMouseDevice::TouchAxisChannel axis);
|
||||
UserInputMapper::Input makeInput(KeyboardMouseDevice::TouchButtonChannel button);
|
||||
|
||||
KeyboardMouseDevice() {}
|
||||
|
||||
|
@ -255,6 +257,7 @@ protected:
|
|||
ButtonPressedMap _buttonPressedMap;
|
||||
AxisStateMap _axisStateMap;
|
||||
|
||||
int _deviceID = 0;
|
||||
QPoint _lastCursor;
|
||||
glm::vec2 _lastTouch;
|
||||
bool _isTouching = false;
|
||||
|
|
Loading…
Reference in a new issue