@@ -46,7 +46,7 @@ void SdlInputManager::vibrationThreadFunc() {
46
46
}
47
47
48
48
void SdlInputManager::onVibrationEvent (Event::Controller::Vibration e) {
49
- // Vibration output is choosen by DPAD_UP mapped game controller
49
+ // Vibration output is chosen by DPAD_UP mapped game controller
50
50
std::string keyName = config.controller [e.port - 1 ].keys [" dpad_up" ];
51
51
Key key (keyName);
52
52
@@ -62,6 +62,18 @@ void SdlInputManager::onVibrationEvent(Event::Controller::Vibration e) {
62
62
}
63
63
}
64
64
65
+ bool SdlInputManager::isMouseBound () {
66
+ // Check if mouse axis is bound anywhere
67
+ for (auto & c : config.controller ) {
68
+ for (auto & k : c.keys ) {
69
+ if (k.second .rfind (" mouse" , 0 ) == 0 ) {
70
+ return true ;
71
+ }
72
+ }
73
+ }
74
+ return false ;
75
+ }
76
+
65
77
bool SdlInputManager::handleKey (Key key, AnalogValue value) {
66
78
if (waitingForKeyPress) {
67
79
waitingForKeyPress = false ;
@@ -104,6 +116,12 @@ void SdlInputManager::newFrame() {
104
116
mouseX = 0 ;
105
117
mouseY = 0 ;
106
118
119
+ #ifdef ANDROID
120
+ shouldCaptureMouse = false ;
121
+ #else
122
+ shouldCaptureMouse = isMouseBound ();
123
+ #endif
124
+
107
125
if (waitingForKeyPress) return ;
108
126
109
127
Key key;
@@ -126,10 +144,8 @@ bool SdlInputManager::handleEvent(SDL_Event& event) {
126
144
auto type = event.type ;
127
145
128
146
if ((!mouseCaptured || waitingForKeyPress) && event.type == SDL_MOUSEBUTTONDOWN && event.button .button == SDL_BUTTON_LEFT
129
- && event.button .clicks == 2 ) {
130
- #ifndef ANDROID
147
+ && event.button .clicks == 2 && shouldCaptureMouse) {
131
148
mouseLocked = true ;
132
- #endif
133
149
return true ;
134
150
}
135
151
@@ -235,4 +251,4 @@ bool SdlInputManager::handleEvent(SDL_Event& event) {
235
251
}
236
252
237
253
return false ;
238
- }
254
+ }
0 commit comments