فهرست منبع

Merge branch 'next' of https://github.com/blackberry/GamePlay into next

Adam Blake 13 سال پیش
والد
کامیت
5489f40f37
2فایلهای تغییر یافته به همراه41 افزوده شده و 90 حذف شده
  1. 2 2
      gameplay/CMakeLists.txt
  2. 39 88
      gameplay/src/PlatformLinux.cpp

+ 2 - 2
gameplay/CMakeLists.txt

@@ -333,8 +333,8 @@ set(GAMEPLAY_LUA
     src/lua/lua_GameClearFlags.h
     src/lua/lua_Gamepad.cpp
     src/lua/lua_Gamepad.h
-    src/lua/lua_GamepadButtonState.cpp
-    src/lua/lua_GamepadButtonState.h
+    src/lua/lua_GamepadButtonMapping.cpp
+    src/lua/lua_GamepadButtonMapping.h
     src/lua/lua_GamepadGamepadEvent.cpp
     src/lua/lua_GamepadGamepadEvent.h
     src/lua/lua_GameState.cpp

+ 39 - 88
gameplay/src/PlatformLinux.cpp

@@ -24,9 +24,9 @@ static double __timeAbsolute;
 static bool __vsync = WINDOW_VSYNC;
 static float __pitch;
 static float __roll;
-static bool __mouseCaptured = false;
-static float __mouseCapturePointX = 0;
-static float __mouseCapturePointY = 0;
+static bool __mouseCaptured = false;
+static float __mouseCapturePointX = 0;
+static float __mouseCapturePointY = 0;
 static bool __cursorVisible = true;
 static Display* __display;
 static Window   __window;
@@ -563,6 +563,8 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
     glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");
     glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int *value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib");
+    glXSwapIntervalEXT = (void(*)(Display* dpy, GLXDrawable drawable, int interval))glXGetProcAddressARB((GLubyte*)"glXSwapIntervalEXT");
+    glXSwapIntervalMESA = (int(*)(unsigned int interval))glXGetProcAddressARB((GLubyte*)"glXSwapIntervalMESA");
 
     // Get the configs
     int configAttribs[] = 
@@ -661,8 +663,10 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     printf("GL version: %d.%d\n", versionGL[0], versionGL[1]);
 
     // TODO: Get this workings
-    //if (GLXEW_EXT_swap_control)
-    //    glXSwapIntervalEXT(__display, glXGetCurrentDrawable(), __vsync ? 1 : 0);
+    if (glXSwapIntervalEXT)
+        glXSwapIntervalEXT(__display, __window, __vsync ? 1 : 0);
+    else if(glXSwapIntervalMESA)
+        glXSwapIntervalMESA(__vsync ? 1 : 0);
  
     return platform;
 }
@@ -872,16 +876,16 @@ int Platform::enterMessagePump()
                     {
                         if (x == __mouseCapturePointX && y == __mouseCapturePointY)
                         {
-                            // Discard the first MotionNotify following capture
-                            // since it contains bogus x,y data.
+                            // Discard the first MotionNotify following capture
+                            // since it contains bogus x,y data.
                             break;
                         }
 
-                        // Convert to deltas
+                        // Convert to deltas
                         x -= __mouseCapturePointX;
                         y -= __mouseCapturePointY;
 
-                        // Warp mouse back to center of screen.
+                        // Warp mouse back to center of screen.
                         XWarpPointer(__display, None, __window, 0, 0, 0, 0, __mouseCapturePointX, __mouseCapturePointY);
                     }
 
@@ -973,9 +977,11 @@ bool Platform::isVsync()
 
 void Platform::setVsync(bool enable)
 {
-    // TODO: Get this working
-    //if (GLXEW_EXT_swap_control)
-    //    glXSwapIntervalEXT(__display, glXGetCurrentDrawable(), __vsync ? 1 : 0);
+    if (glXSwapIntervalEXT)
+        glXSwapIntervalEXT(__display, __window, __vsync ? 1 : 0);
+    else if(glXSwapIntervalMESA)
+        glXSwapIntervalMESA(__vsync ? 1 : 0);
+
     __vsync = enable;
 }
 
@@ -1015,26 +1021,26 @@ bool Platform::hasMouse()
 
 void Platform::setMouseCaptured(bool captured)
 {
-    if (captured != __mouseCaptured)
-    {
-        if (captured)
-        {
-            // Hide the cursor and warp it to the center of the screen
-            __mouseCapturePointX = getDisplayWidth() / 2;
-            __mouseCapturePointY = getDisplayHeight() / 2;
-
-            setCursorVisible(false);
-            XWarpPointer(__display, None, __window, 0, 0, 0, 0, __mouseCapturePointX, __mouseCapturePointY);
-        }
-        else
-        {
-            // Restore cursor
-            XWarpPointer(__display, None, __window, 0, 0, 0, 0, __mouseCapturePointX, __mouseCapturePointY);
-            setCursorVisible(true);
-        }
-
-        __mouseCaptured = captured;
-    }
+    if (captured != __mouseCaptured)
+    {
+        if (captured)
+        {
+            // Hide the cursor and warp it to the center of the screen
+            __mouseCapturePointX = getDisplayWidth() / 2;
+            __mouseCapturePointY = getDisplayHeight() / 2;
+
+            setCursorVisible(false);
+            XWarpPointer(__display, None, __window, 0, 0, 0, 0, __mouseCapturePointX, __mouseCapturePointY);
+        }
+        else
+        {
+            // Restore cursor
+            XWarpPointer(__display, None, __window, 0, 0, 0, 0, __mouseCapturePointX, __mouseCapturePointY);
+            setCursorVisible(true);
+        }
+
+        __mouseCaptured = captured;
+    }
 }
 
 bool Platform::isMouseCaptured()
@@ -1131,63 +1137,8 @@ bool Platform::isGestureRegistered(Gesture::GestureEvent evt)
     return false;
 }
 
-unsigned int Platform::getGamepadsConnected()
-{
-    return 0;
-}
-
-bool Platform::isGamepadConnected(unsigned int gamepadHandle)
-{
-    return false;
-}
-
-const char* Platform::getGamepadId(unsigned int gamepadHandle)
-{
-    return NULL;
-}
-
-unsigned int Platform::getGamepadButtonCount(unsigned int gamepadHandle)
-{
-    return 0;
-}
-
-bool Platform::getGamepadButtonState(unsigned int gamepadHandle, unsigned int buttonIndex)
-{
-    return false;
-}
-
-unsigned int Platform::getGamepadJoystickCount(unsigned int gamepadHandle)
-{
-    return 0;
-}
-
-bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int joystickIndex)
-{
-    return false;
-}
-
-float Platform::getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex)
-{
-    return 0.0f;
-}
-
-float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
-{
-    return 0.0f;
-}
-
-void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue)
-{
-}
-
-unsigned int Platform::getGamepadTriggerCount(unsigned int gamepadHandle)
-{
-    return 0;
-}
-
-float Platform::getGamepadTriggerValue(unsigned int gamepadHandle, unsigned int triggerIndex)
+void Platform::pollGamepadState(Gamepad* gamepad)
 {
-    return 0.0f;
 }
 
 bool Platform::launchURL(const char* url)