ソースを参照

Support for mouse keys 4 & 5

Thomas Buck 10年前
コミット
f97ebd7a0b
6個のファイルの変更24行の追加7行の削除
  1. 1
    0
      ChangeLog.md
  2. 1
    1
      include/global.h
  3. 1
    0
      src/Console.cpp
  4. 11
    3
      src/WindowSDL.cpp
  5. 9
    1
      src/main.cpp
  6. 1
    2
      src/utils/pcx.cpp

+ 1
- 0
ChangeLog.md ファイルの表示

@@ -5,6 +5,7 @@
5 5
     [ 20140621 ]
6 6
     * Created StaticMesh class replacing model_mesh_t stuff
7 7
     * Simplified StaticMesh’s data storage
8
+    * Added support for fourth & fifth mouse keys
8 9
 
9 10
     [ 20140617 ]
10 11
     * Finally fixed SkeletalModel bugs introduced a month ago

+ 1
- 1
include/global.h ファイルの表示

@@ -94,7 +94,7 @@ typedef enum {
94 94
     rightguiKey, rightbracketKey, rightshiftKey, scrolllockKey,
95 95
     semicolonKey, slashKey, spaceKey, tabKey,
96 96
     leftmouseKey, middlemouseKey, rightmouseKey,
97
-
97
+    fourthmouseKey, fifthmouseKey,
98 98
     unknownKey // Should always be at the end
99 99
 } KeyboardButton;
100 100
 

+ 1
- 0
src/Console.cpp ファイルの表示

@@ -237,6 +237,7 @@ void Console::handleText(char *text, bool notFinished) {
237 237
 }
238 238
 
239 239
 void Console::handleMouseScroll(int xrel, int yrel) {
240
+    assert((xrel != 0) || (yrel != 0));
240 241
     LINE_GEOMETRY(getWindow());
241 242
 
242 243
     if (mHistory.size() > lineCount) {

+ 11
- 3
src/WindowSDL.cpp ファイルの表示

@@ -156,18 +156,26 @@ void WindowSDL::eventHandling() {
156 156
                     button = leftmouseKey;
157 157
                 else if (event.button.button == SDL_BUTTON_RIGHT)
158 158
                     button = rightmouseKey;
159
-                else
159
+                else if (event.button.button == SDL_BUTTON_MIDDLE)
160 160
                     button = middlemouseKey;
161
+                else if (event.button.button == SDL_BUTTON_X1)
162
+                    button = fourthmouseKey;
163
+                else if (event.button.button == SDL_BUTTON_X2)
164
+                    button = fifthmouseKey;
165
+                else
166
+                    button = unknownKey;
161 167
                 getOpenRaider().handleMouseClick(event.button.x, event.button.y, button, (event.type == SDL_MOUSEBUTTONUP));
162 168
                 break;
163 169
 
164 170
             case SDL_MOUSEWHEEL:
165
-                getOpenRaider().handleMouseScroll(event.wheel.x, event.wheel.y);
171
+                if ((event.wheel.x != 0) || (event.wheel.y != 0))
172
+                    getOpenRaider().handleMouseScroll(event.wheel.x, event.wheel.y);
166 173
                 break;
167 174
 
168 175
             case SDL_TEXTINPUT:
169 176
             case SDL_TEXTEDITING:
170
-                getOpenRaider().handleText(event.text.text, (event.type == SDL_TEXTEDITING));
177
+                if (event.text.text != NULL)
178
+                    getOpenRaider().handleText(event.text.text, (event.type == SDL_TEXTEDITING));
171 179
                 break;
172 180
 
173 181
             case SDL_KEYDOWN:

+ 9
- 1
src/main.cpp ファイルの表示

@@ -138,7 +138,7 @@ int main(int argc, char *argv[]) {
138 138
     }
139 139
 
140 140
 #ifdef DEBUG
141
-    std::cout << "Initializing " << VERSION << std::endl;
141
+    getConsole().print("Initializing %s", VERSION);
142 142
 #endif
143 143
 
144 144
     atexit(cleanupHandler);
@@ -219,6 +219,7 @@ ActionEvents stringToActionEvent(const char *action) {
219 219
     } else if (strcmp(action, "walk") == 0) {
220 220
         return walkAction;
221 221
     } else {
222
+        getConsole().print("Unknown action: \"%s\"", action);
222 223
         return ActionEventCount;
223 224
     }
224 225
 }
@@ -393,10 +394,17 @@ KeyboardButton stringToKeyboardButton(const char *key) {
393 394
         } else if (strcmp(tmp, "rightmouse") == 0) {
394 395
             delete [] tmp;
395 396
             return rightmouseKey;
397
+        } else if (strcmp(tmp, "fourthmouse") == 0) {
398
+            delete [] tmp;
399
+            return fourthmouseKey;
400
+        } else if (strcmp(tmp, "fifthmouse") == 0) {
401
+            delete [] tmp;
402
+            return fifthmouseKey;
396 403
         }
397 404
         delete [] tmp;
398 405
     }
399 406
 
407
+    getConsole().print("Unknown key: %s", key);
400 408
     return unknownKey;
401 409
 }
402 410
 

+ 1
- 2
src/utils/pcx.cpp ファイルの表示

@@ -13,9 +13,8 @@
13 13
 #include "global.h"
14 14
 #include "utils/pcx.h"
15 15
 
16
-#include "Console.h"
17
-
18 16
 #ifdef DEBUG
17
+#include "Console.h"
19 18
 #define pcxPrint getConsole().print
20 19
 #else
21 20
 void pcxPrint(...) { }

読み込み中…
キャンセル
保存