浏览代码

On Mac OSX there are spurious hat events at program start, so skip these

Sam Lantinga 5 年之前
父节点
当前提交
0a7fe18fe6
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      test/controllermap.c

+ 5 - 0
test/controllermap.c

@@ -415,6 +415,11 @@ WatchJoystick(SDL_Joystick * joystick)
     s_nNumAxes = SDL_JoystickNumAxes(joystick);
     s_arrAxisState = (AxisState *)SDL_calloc(s_nNumAxes, sizeof(*s_arrAxisState));
 
+	/* Skip any spurious events at start */
+	while (SDL_PollEvent(&event) > 0) {
+		continue;
+	}
+
     /* Loop, getting joystick events! */
     while (!done && !s_bBindingComplete) {
         int iElement = s_arrBindingOrder[s_iCurrentBinding];