Ver Fonte

Partial Gamepad changes.

Ramprasad Madhavan há 14 anos atrás
pai
commit
c0929f12e3

+ 1 - 1
gameplay/gameplay.vcxproj

@@ -294,4 +294,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 1 - 1
gameplay/gameplay.vcxproj.filters

@@ -508,4 +508,4 @@
       <Filter>src</Filter>
     </None>
   </ItemGroup>
-</Project>
+</Project>

+ 0 - 0
gameplay/src/Gamepad.cpp


+ 17 - 0
gameplay/src/Input.h

@@ -1,6 +1,8 @@
 #ifndef INPUT_H_
 #define INPUT_H_
 
+#include "Gamepad.h"
+
 namespace gameplay
 {
 
@@ -207,6 +209,21 @@ public:
      */
     static void getAccelerometerPitchAndRoll(float* pitch, float* roll);
 
+    /**
+     * Indicates if the game device supports a gamepad.
+     * 
+     * @return true if the gamepad is supported; false otherwise.
+     */
+    static bool isGamepadSupported();
+
+    /**
+     * Gets a gamepad associaed with the specified integer Id.
+     *
+     * @ returns an instance of gamepad if Id is valid; NULL otherwise.
+     */
+    static Gamepad* getGamepad(unsigned int index);
+
+
 private:
 
     /**

+ 78 - 0
gameplay/src/gamepad.h

@@ -0,0 +1,78 @@
+/*
+ * Gamepad.h
+ */
+
+#ifndef GAMEPAD_H_
+#define GAMEPAD_H_
+
+#include "Vector3.h"
+
+namespace gameplay
+{
+
+/*
+ * Defines a class for accessing gamepad controls.
+ */
+class Gamepad
+{
+public:
+
+    /*
+     * Represents the maximum number of buttons supported on a gamepad.
+     */
+    static const int MAX_BUTTONS = 32;
+
+    /*
+     * Represents the maximum number of joysticks supported on a gamepad.
+     */
+    static const int MAX_JOYSTICKS = 2;
+
+    /*
+     * Represents the maximum number of dpads supported on a gamepad.
+     */
+    static const int MAX_DPADS = 2;
+
+private:
+
+    /*
+     * Creates an instance of the gamepad with the input .gamepad file.
+     * 
+     * @param filepath Path of the .gamepad file
+     * @return instance of Gamepad.
+     */
+
+    Gamepad* createGamepad(std::string filepath);
+    
+    /* 
+     * Defines a gamepad button.
+     */
+    class Button
+    {
+        bool pressed;
+    };
+
+    /*
+     * Defines a gamepad joystick.
+     */
+    class Joystick
+    {
+        Vector3 direction;
+    };
+
+    /*
+     * Defines a gamepad dpad.
+     */
+    class Dpad
+    {
+        // TODO.
+    };
+
+    Button _buttons[MAX_BUTTONS];
+    Joystick _joysticks[MAX_JOYSTICKS];
+    Dpad _dpads[MAX_DPADS];
+
+};
+
+}
+
+#endif