History

Fine tunning on windows

Sam Gateau committed 11 years ago

Commit b7baccc1 parent 8e65ce33 files · +32 −101Browse files

Showing the changes to interface/src/ui/UserInputMapper.cpp (1 of 3 files). Show all

Unified · Split

interface/src/ui/UserInputMapper.cpp+17−10
@@ -27,6 +27,10 @@ void KeyboardMouseDevice::update() { · 26 unmodified lines
2727 }
2828 }
2929
30+void KeyboardMouseDevice::focusOutEvent(QFocusEvent* event) {
31+ _buttonPressedMap.clear();
32+};
33+
3034 void KeyboardMouseDevice::keyPressEvent(QKeyEvent* event) {
3135 auto input = makeInput((Qt::Key) event->key());
3236 auto result = _buttonPressedMap.insert(input.getChannel());
@@ -114,35 +118,38 @@ void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) { · 81 unmodified lines
114118 }
115119
116120 UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::Key code) {
117− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, code & KEYBOARD_MASK, UserInputMapper::ChannelType::BUTTON);
121+ return UserInputMapper::Input(_deviceID, code & KEYBOARD_MASK, UserInputMapper::ChannelType::BUTTON);
118122 }
119123 UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::MouseButton code) {
120124 switch (code) {
121125 case Qt::LeftButton:
122− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_LEFT, UserInputMapper::ChannelType::BUTTON);
126+ return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_LEFT, UserInputMapper::ChannelType::BUTTON);
123127 case Qt::RightButton:
124− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_RIGHT, UserInputMapper::ChannelType::BUTTON);
128+ return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_RIGHT, UserInputMapper::ChannelType::BUTTON);
125129 case Qt::MiddleButton:
126− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, MOUSE_BUTTON_MIDDLE, UserInputMapper::ChannelType::BUTTON);
130+ return UserInputMapper::Input(_deviceID, MOUSE_BUTTON_MIDDLE, UserInputMapper::ChannelType::BUTTON);
127131 default:
128132 return UserInputMapper::Input();
129133 };
130134 }
131135 UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::MouseAxisChannel axis) {
132− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, axis, UserInputMapper::ChannelType::AXIS);
136+ return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS);
133137 }
134138 UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchAxisChannel axis) {
135− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, axis, UserInputMapper::ChannelType::AXIS);
139+ return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS);
136140 }
137141 UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchButtonChannel button) {
138− return UserInputMapper::Input(DEFAULT_DESKTOP_DEVICE, button, UserInputMapper::ChannelType::BUTTON);
142+ return UserInputMapper::Input(_deviceID, button, UserInputMapper::ChannelType::BUTTON);
139143 }
140144
141145 void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {
146+ // Grab the current free device ID
147+ _deviceID = mapper.getFreeDeviceID();
148+
142149 auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy());
143150 proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input._channel); };
144151 proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input._channel); };
145− mapper.registerDevice(DEFAULT_DESKTOP_DEVICE, proxy); // HARDCODED!, the KeyboardMouseDevice always take the DeviceID = 1
152+ mapper.registerDevice(_deviceID, proxy);
146153 }
147154
148155 void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
@@ -206,8 +213,8 @@ void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) { · 57 unmodified lines
206213 mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);
207214
208215 // Wheel move
209− mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);
210− mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
216+ //mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);
217+ //mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
211218 mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(MOUSE_AXIS_WHEEL_X_NEG), BUTTON_YAW_SPEED);
212219 mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(MOUSE_AXIS_WHEEL_X_POS), BUTTON_YAW_SPEED);
213220

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t