Misc code reviews
This commit is contained in:
parent
0bd64b7975
commit
913ef1d56f
1 changed files with 16 additions and 8 deletions
24
src/core.c
24
src/core.c
|
@ -1949,6 +1949,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
|
|
||||||
if (fileExt != NULL)
|
if (fileExt != NULL)
|
||||||
{
|
{
|
||||||
|
#if defined(SUPPORT_TEXT_MANIPULATION)
|
||||||
int extCount = 0;
|
int extCount = 0;
|
||||||
const char **checkExts = TextSplit(ext, ';', &extCount);
|
const char **checkExts = TextSplit(ext, ';', &extCount);
|
||||||
|
|
||||||
|
@ -1963,6 +1964,9 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (strcmp(fileExt, ext) == 0) result = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -2509,8 +2513,8 @@ float GetGamepadAxisMovement(int gamepad, int axis)
|
||||||
|
|
||||||
#if !defined(PLATFORM_ANDROID)
|
#if !defined(PLATFORM_ANDROID)
|
||||||
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (axis < MAX_GAMEPAD_AXIS) &&
|
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (axis < MAX_GAMEPAD_AXIS) &&
|
||||||
(axis == GAMEPAD_AXIS_LEFT_TRIGGER || axis == GAMEPAD_AXIS_RIGHT_TRIGGER ||
|
((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER) ||
|
||||||
fabsf(CORE.Input.Gamepad.axisState[gamepad][axis]) >= 0.2f)) value = CORE.Input.Gamepad.axisState[gamepad][axis];
|
(fabsf(CORE.Input.Gamepad.axisState[gamepad][axis]) >= 0.2f))) value = CORE.Input.Gamepad.axisState[gamepad][axis];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -3486,8 +3490,11 @@ static void InitTimer(void)
|
||||||
static void Wait(float ms)
|
static void Wait(float ms)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
UWPGetSleepFunc()(ms / 1000);
|
UWPGetSleepFunc()(ms/1000);
|
||||||
#elif defined(SUPPORT_BUSY_WAIT_LOOP)
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||||
double prevTime = GetTime();
|
double prevTime = GetTime();
|
||||||
double nextTime = 0.0;
|
double nextTime = 0.0;
|
||||||
|
|
||||||
|
@ -3515,7 +3522,7 @@ static void Wait(float ms)
|
||||||
usleep(ms*1000.0f);
|
usleep(ms*1000.0f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)// && !defined(PLATFORM_UWP)
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)
|
||||||
while (GetTime() < destTime) { }
|
while (GetTime() < destTime) { }
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -3677,8 +3684,9 @@ static void PollInputEvents(void)
|
||||||
// Get current gamepad state
|
// Get current gamepad state
|
||||||
// NOTE: There is no callback available, so we get it manually
|
// NOTE: There is no callback available, so we get it manually
|
||||||
// Get remapped buttons
|
// Get remapped buttons
|
||||||
GLFWgamepadstate state;
|
GLFWgamepadstate state = { 0 };
|
||||||
glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
|
glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
|
||||||
|
|
||||||
const unsigned char *buttons = state.buttons;
|
const unsigned char *buttons = state.buttons;
|
||||||
|
|
||||||
for (int k = 0; (buttons != NULL) && (k < GLFW_GAMEPAD_BUTTON_DPAD_LEFT + 1) && (k < MAX_GAMEPAD_BUTTONS); k++)
|
for (int k = 0; (buttons != NULL) && (k < GLFW_GAMEPAD_BUTTON_DPAD_LEFT + 1) && (k < MAX_GAMEPAD_BUTTONS); k++)
|
||||||
|
@ -3705,7 +3713,7 @@ static void PollInputEvents(void)
|
||||||
CORE.Input.Gamepad.currentState[i][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1);
|
CORE.Input.Gamepad.currentState[i][GAMEPAD_BUTTON_LEFT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] > 0.1);
|
||||||
CORE.Input.Gamepad.currentState[i][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1);
|
CORE.Input.Gamepad.currentState[i][GAMEPAD_BUTTON_RIGHT_TRIGGER_2] = (char)(CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.1);
|
||||||
|
|
||||||
CORE.Input.Gamepad.axisCount = GLFW_GAMEPAD_AXIS_LAST + 1;
|
CORE.Input.Gamepad.axisCount = GLFW_GAMEPAD_AXIS_LAST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4294,7 +4302,7 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
|
||||||
// Register keyboard input events
|
// Register keyboard input events
|
||||||
static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
||||||
{
|
{
|
||||||
if ((eventType == EMSCRIPTEN_EVENT_KEYPRESS) && (keyEvent->key == 27)) // ESCAPE key
|
if ((eventType == EMSCRIPTEN_EVENT_KEYPRESS) && (keyEvent->keyCode == 27)) // ESCAPE key
|
||||||
{
|
{
|
||||||
emscripten_exit_pointerlock();
|
emscripten_exit_pointerlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue