aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReece Mackie <20544390+Rover656@users.noreply.github.com>2019-04-28 15:59:39 +0100
committerReece Mackie <20544390+Rover656@users.noreply.github.com>2019-04-28 15:59:39 +0100
commit7ca856f9b76e7e9eac49120d145f89c2fc639c38 (patch)
tree488721521734e698b2a24a25042051579a57c962 /src
parentf8c6226826b03a4b624e5b2cc96d488e3975894f (diff)
downloadraylib-7ca856f9b76e7e9eac49120d145f89c2fc639c38.tar.gz
raylib-7ca856f9b76e7e9eac49120d145f89c2fc639c38.zip
Formatting changes
Diffstat (limited to 'src')
-rw-r--r--src/core.c35
-rw-r--r--src/raylib.h19
2 files changed, 16 insertions, 38 deletions
diff --git a/src/core.c b/src/core.c
index ec7586df..4bb1e76f 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3110,34 +3110,11 @@ static GamepadButton GetGamepadButton(int button)
#endif
#if defined(PLATFORM_UWP)
- /*switch(button)
- {
- case 4: b = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
- case 8: b = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
- case 16: b = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break;
- case 32: b = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
-
- case 128: b = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break;
- case 256: b = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break;
- case 512: b = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
- case 64: b = GAMEPAD_BUTTON_LEFT_FACE_UP; break;
-
- case 1024: b = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break;
- case 2048: b = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break;
-
- case 4096: b = GAMEPAD_BUTTON_LEFT_THUMB; break;
- case 8192: b = GAMEPAD_BUTTON_RIGHT_THUMB; break;
-
- case 2: b = GAMEPAD_BUTTON_MIDDLE_LEFT;
- case 1: b = GAMEPAD_BUTTON_MIDDLE_RIGHT;
- }*/
- //Above might not be most efficient, so not doing it for now
b = button;
#endif
#if defined(PLATFORM_WEB)
- //TODO: TEST
- //https://www.w3.org/TR/gamepad/#gamepad-interface
+ // https://www.w3.org/TR/gamepad/#gamepad-interface
switch (button)
{
case 0: b = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
@@ -3178,11 +3155,11 @@ static GamepadAxis GetGamepadAxis(int axis)
#endif
#if defined(PLATFORM_UWP)
- a = axis; //UWP will provide the correct axis
+ a = axis; // UWP will provide the correct axis
#endif
#if defined(PLATFORM_WEB)
- //TODO: TEST
+ // https://www.w3.org/TR/gamepad/#gamepad-interface
switch(axis)
{
case 0: a = GAMEPAD_AXIS_LEFT_X;
@@ -3430,9 +3407,9 @@ static void PollInputEvents(void)
// Get current gamepad state
// NOTE: There is no callback available, so we get it manually
- //Get remapped buttons
+ // Get remapped buttons
GLFWgamepadstate state;
- glfwGetGamepadState(i, &state); //This remapps all gamepads so they work the same
+ glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
const unsigned char *buttons = state.buttons;
for (int k = 0; (buttons != NULL) && (k < GLFW_GAMEPAD_BUTTON_DPAD_LEFT + 1) && (k < MAX_GAMEPAD_BUTTONS); k++)
@@ -3456,7 +3433,7 @@ static void PollInputEvents(void)
gamepadAxisState[i][axis] = axes[k];
}
- //Register buttons for 2nd triggers
+ // Register buttons for 2nd triggers (because GLFW doesn't count these as buttons but rather axis)
currentGamepadState[i][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(gamepadAxisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1);
currentGamepadState[i][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(gamepadAxisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1);
diff --git a/src/raylib.h b/src/raylib.h
index cf8543a2..3fb4ee6d 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -622,50 +622,51 @@ typedef enum {
// Gamepad Buttons
typedef enum
{
- //This is here just for error checking
+ // This is here just for error checking
GAMEPAD_BUTTON_UNKNOWN = 0,
- //This is normally ABXY/Circle, Triangle, Square, Cross. No support for 6 button controllers though..
+ // This is normally ABXY/Circle, Triangle, Square, Cross. No support for 6 button controllers though..
GAMEPAD_BUTTON_LEFT_FACE_UP,
GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
GAMEPAD_BUTTON_LEFT_FACE_DOWN,
GAMEPAD_BUTTON_LEFT_FACE_LEFT,
- //This is normally a DPAD
+ // This is normally a DPAD
GAMEPAD_BUTTON_RIGHT_FACE_UP,
GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
- //Triggers
+ // Triggers
GAMEPAD_BUTTON_LEFT_TRIGGER_1,
GAMEPAD_BUTTON_LEFT_TRIGGER_2,
GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
- //These are buttons in the center of the gamepad
+ // These are buttons in the center of the gamepad
GAMEPAD_BUTTON_MIDDLE_LEFT, //PS3 Select
GAMEPAD_BUTTON_MIDDLE, //PS Button/XBOX Button
GAMEPAD_BUTTON_MIDDLE_RIGHT, //PS3 Start
- //These are the joystick press in buttons
+ // These are the joystick press in buttons
GAMEPAD_BUTTON_LEFT_THUMB,
GAMEPAD_BUTTON_RIGHT_THUMB
} GamepadButton;
typedef enum
{
+ // This is here just for error checking
GAMEPAD_AXIS_UNKNOWN = 0,
- //Left stick
+ // Left stick
GAMEPAD_AXIS_LEFT_X,
GAMEPAD_AXIS_LEFT_Y,
- //Right stick
+ // Right stick
GAMEPAD_AXIS_RIGHT_X,
GAMEPAD_AXIS_RIGHT_Y,
- //Pressure levels
+ // Pressure levels for the back triggers
GAMEPAD_AXIS_LEFT_TRIGGER, // [1..-1] (pressure-level)
GAMEPAD_AXIS_RIGHT_TRIGGER // [1..-1] (pressure-level)
} GamepadAxis;