瀏覽代碼

Ignore first mouse event

Thomas Buck 11 年之前
父節點
當前提交
d325c492ef
共有 3 個文件被更改,包括 11 次插入1 次删除
  1. 4
    0
      ChangeLog
  2. 6
    1
      src/SDLSystem.cpp
  3. 1
    0
      src/SDLSystem.h

+ 4
- 0
ChangeLog 查看文件

@@ -6,6 +6,10 @@
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8 8
 	[ 20140101 ]
9
+	* Added bool mFirstMouseEvent to SDLSystem used to ignore
10
+	  the first received mouse event, because its faulty, thanks
11
+	  to an SDL bug:
12
+	  http://gamedev.stackexchange.com/questions/33519/trap-mouse-in-sdl#comment56642_33554
9 13
 	* Fixed incredibly slow mouse/camera movements
10 14
 	* Fixed mouse grabbing in fullscreen mode. Also make mouse
11 15
 	  invisible and grab it in windowed mode

+ 6
- 1
src/SDLSystem.cpp 查看文件

@@ -130,6 +130,7 @@ SDLSystem::SDLSystem() : System()
130 130
 	mWindow = 0x0;
131 131
 	gWidth = &m_width;
132 132
 	gHeight = &m_height;
133
+    mFirstMouseEvent = false;
133 134
 }
134 135
 
135 136
 
@@ -340,7 +341,11 @@ void SDLSystem::runGame()
340 341
 				break;
341 342
 			case SDL_MOUSEMOTION:
342 343
 				// Wrap motion
343
-				handleMouseMotionEvent(event.motion.xrel/2, -event.motion.yrel/2);
344
+                if (!mFirstMouseEvent) {
345
+                    mFirstMouseEvent = true;
346
+                } else {
347
+                    handleMouseMotionEvent(event.motion.xrel/2, event.motion.yrel/2);
348
+                }
344 349
 				break;
345 350
 			case SDL_MOUSEBUTTONDOWN:
346 351
 			case SDL_MOUSEBUTTONUP:

+ 1
- 0
src/SDLSystem.h 查看文件

@@ -223,6 +223,7 @@ class SDLSystem : public System
223 223
  protected:
224 224
     int m_old_width;
225 225
     int m_old_height;
226
+    bool mFirstMouseEvent; // Filter first mouse event (SDL bug)
226 227
 
227 228
  private:
228 229
 

Loading…
取消
儲存