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
27 }27 }
28}28}
29 29
30void KeyboardMouseDevice::focusOutEvent(QFocusEvent* event) {
31 _buttonPressedMap.clear();
32};
33
30void KeyboardMouseDevice::keyPressEvent(QKeyEvent* event) {34void KeyboardMouseDevice::keyPressEvent(QKeyEvent* event) {
31 auto input = makeInput((Qt::Key) event->key());35 auto input = makeInput((Qt::Key) event->key());
32 auto result = _buttonPressedMap.insert(input.getChannel());36 auto result = _buttonPressedMap.insert(input.getChannel());
@@ -114,35 +118,38 @@ void KeyboardMouseDevice::touchUpdateEvent(const QTouchEvent* event) { · 81 unmodified lines
114}118}
115 119
116UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::Key code) {120UserInputMapper::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);
118}122}
119UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::MouseButton code) {123UserInputMapper::Input KeyboardMouseDevice::makeInput(Qt::MouseButton code) {
120 switch (code) {124 switch (code) {
121 case Qt::LeftButton:125 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);
123 case Qt::RightButton:127 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);
125 case Qt::MiddleButton:129 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);
127 default:131 default:
128 return UserInputMapper::Input();132 return UserInputMapper::Input();
129 };133 };
130}134}
131UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::MouseAxisChannel axis) {135UserInputMapper::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);
133}137}
134UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchAxisChannel axis) {138UserInputMapper::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);
136}140}
137UserInputMapper::Input KeyboardMouseDevice::makeInput(KeyboardMouseDevice::TouchButtonChannel button) {141UserInputMapper::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);
139}143}
140 144
141void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {145void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {
146 // Grab the current free device ID
147 _deviceID = mapper.getFreeDeviceID();
148
142 auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy());149 auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy());
143 proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input._channel); };150 proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input._channel); };
144 proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input._channel); };151 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 = 1152 mapper.registerDevice(_deviceID, proxy);
146}153}
147 154
148void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {155void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
@@ -206,8 +213,8 @@ void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) { · 57 unmodified lines
206 mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);213 mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);
207 214
208 // Wheel move215 // Wheel move
209 mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);216 //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);217 //mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
211 mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(MOUSE_AXIS_WHEEL_X_NEG), BUTTON_YAW_SPEED);218 mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(MOUSE_AXIS_WHEEL_X_NEG), BUTTON_YAW_SPEED);
212 mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(MOUSE_AXIS_WHEEL_X_POS), BUTTON_YAW_SPEED);219 mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(MOUSE_AXIS_WHEEL_X_POS), BUTTON_YAW_SPEED);
213 220

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