Kaynağa Gözat

Support for mouse keys 4 & 5

Thomas Buck 11 yıl önce
ebeveyn
işleme
f97ebd7a0b
6 değiştirilmiş dosya ile 24 ekleme ve 7 silme
  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 Dosyayı Görüntüle

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

+ 1
- 1
include/global.h Dosyayı Görüntüle

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

+ 1
- 0
src/Console.cpp Dosyayı Görüntüle

237
 }
237
 }
238
 
238
 
239
 void Console::handleMouseScroll(int xrel, int yrel) {
239
 void Console::handleMouseScroll(int xrel, int yrel) {
240
+    assert((xrel != 0) || (yrel != 0));
240
     LINE_GEOMETRY(getWindow());
241
     LINE_GEOMETRY(getWindow());
241
 
242
 
242
     if (mHistory.size() > lineCount) {
243
     if (mHistory.size() > lineCount) {

+ 11
- 3
src/WindowSDL.cpp Dosyayı Görüntüle

156
                     button = leftmouseKey;
156
                     button = leftmouseKey;
157
                 else if (event.button.button == SDL_BUTTON_RIGHT)
157
                 else if (event.button.button == SDL_BUTTON_RIGHT)
158
                     button = rightmouseKey;
158
                     button = rightmouseKey;
159
-                else
159
+                else if (event.button.button == SDL_BUTTON_MIDDLE)
160
                     button = middlemouseKey;
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
                 getOpenRaider().handleMouseClick(event.button.x, event.button.y, button, (event.type == SDL_MOUSEBUTTONUP));
167
                 getOpenRaider().handleMouseClick(event.button.x, event.button.y, button, (event.type == SDL_MOUSEBUTTONUP));
162
                 break;
168
                 break;
163
 
169
 
164
             case SDL_MOUSEWHEEL:
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
                 break;
173
                 break;
167
 
174
 
168
             case SDL_TEXTINPUT:
175
             case SDL_TEXTINPUT:
169
             case SDL_TEXTEDITING:
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
                 break;
179
                 break;
172
 
180
 
173
             case SDL_KEYDOWN:
181
             case SDL_KEYDOWN:

+ 9
- 1
src/main.cpp Dosyayı Görüntüle

138
     }
138
     }
139
 
139
 
140
 #ifdef DEBUG
140
 #ifdef DEBUG
141
-    std::cout << "Initializing " << VERSION << std::endl;
141
+    getConsole().print("Initializing %s", VERSION);
142
 #endif
142
 #endif
143
 
143
 
144
     atexit(cleanupHandler);
144
     atexit(cleanupHandler);
219
     } else if (strcmp(action, "walk") == 0) {
219
     } else if (strcmp(action, "walk") == 0) {
220
         return walkAction;
220
         return walkAction;
221
     } else {
221
     } else {
222
+        getConsole().print("Unknown action: \"%s\"", action);
222
         return ActionEventCount;
223
         return ActionEventCount;
223
     }
224
     }
224
 }
225
 }
393
         } else if (strcmp(tmp, "rightmouse") == 0) {
394
         } else if (strcmp(tmp, "rightmouse") == 0) {
394
             delete [] tmp;
395
             delete [] tmp;
395
             return rightmouseKey;
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
         delete [] tmp;
404
         delete [] tmp;
398
     }
405
     }
399
 
406
 
407
+    getConsole().print("Unknown key: %s", key);
400
     return unknownKey;
408
     return unknownKey;
401
 }
409
 }
402
 
410
 

+ 1
- 2
src/utils/pcx.cpp Dosyayı Görüntüle

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

Loading…
İptal
Kaydet