mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Update input.c
This commit is contained in:
parent
ed65906282
commit
6cd8a73064
317
src/input.c
317
src/input.c
@ -38,14 +38,14 @@
|
||||
#define _GLFW_STICK 3
|
||||
|
||||
// Internal constants for gamepad mapping source types
|
||||
#define _GLFW_JOYSTICK_AXIS 1
|
||||
#define _GLFW_JOYSTICK_BUTTON 2
|
||||
#define _GLFW_JOYSTICK_HATBIT 3
|
||||
#define _GLFW_JOYSTICK_AXIS 1
|
||||
#define _GLFW_JOYSTICK_BUTTON 2
|
||||
#define _GLFW_JOYSTICK_HATBIT 3
|
||||
|
||||
#define GLFW_MOD_MASK (GLFW_MOD_SHIFT | \
|
||||
GLFW_MOD_CONTROL | \
|
||||
GLFW_MOD_ALT | \
|
||||
GLFW_MOD_SUPER | \
|
||||
#define GLFW_MOD_MASK (GLFW_MOD_SHIFT | \
|
||||
GLFW_MOD_CONTROL | \
|
||||
GLFW_MOD_ALT | \
|
||||
GLFW_MOD_SUPER | \
|
||||
GLFW_MOD_CAPS_LOCK | \
|
||||
GLFW_MOD_NUM_LOCK)
|
||||
|
||||
@ -67,11 +67,11 @@ static GLFWbool initJoysticks(void)
|
||||
|
||||
// Finds a mapping based on joystick GUID
|
||||
//
|
||||
static _GLFWmapping *findMapping(const char *guid)
|
||||
static _GLFWmapping* findMapping(const char* guid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _glfw.mappingCount; i++)
|
||||
for (i = 0; i < _glfw.mappingCount; i++)
|
||||
{
|
||||
if (strcmp(_glfw.mappings[i].guid, guid) == 0)
|
||||
return _glfw.mappings + i;
|
||||
@ -82,8 +82,8 @@ static _GLFWmapping *findMapping(const char *guid)
|
||||
|
||||
// Checks whether a gamepad mapping element is present in the hardware
|
||||
//
|
||||
static GLFWbool isValidElementForJoystick(const _GLFWmapelement *e,
|
||||
const _GLFWjoystick *js)
|
||||
static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
|
||||
const _GLFWjoystick* js)
|
||||
{
|
||||
if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
|
||||
return GLFW_FALSE;
|
||||
@ -97,20 +97,20 @@ static GLFWbool isValidElementForJoystick(const _GLFWmapelement *e,
|
||||
|
||||
// Finds a mapping based on joystick GUID and verifies element indices
|
||||
//
|
||||
static _GLFWmapping *findValidMapping(const _GLFWjoystick *js)
|
||||
static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
|
||||
{
|
||||
_GLFWmapping *mapping = findMapping(js->guid);
|
||||
_GLFWmapping* mapping = findMapping(js->guid);
|
||||
if (mapping)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||
{
|
||||
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||
{
|
||||
if (!isValidElementForJoystick(mapping->axes + i, js))
|
||||
return NULL;
|
||||
@ -122,38 +122,39 @@ static _GLFWmapping *findValidMapping(const _GLFWjoystick *js)
|
||||
|
||||
// Parses an SDL_GameControllerDB line and adds it to the mapping list
|
||||
//
|
||||
static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
||||
{
|
||||
const char *c = string;
|
||||
const char* c = string;
|
||||
size_t i, length;
|
||||
struct
|
||||
{
|
||||
const char *name;
|
||||
_GLFWmapelement *element;
|
||||
const char* name;
|
||||
_GLFWmapelement* element;
|
||||
} fields[] =
|
||||
{
|
||||
{"platform", NULL},
|
||||
{"a", mapping->buttons + GLFW_GAMEPAD_BUTTON_A},
|
||||
{"b", mapping->buttons + GLFW_GAMEPAD_BUTTON_B},
|
||||
{"x", mapping->buttons + GLFW_GAMEPAD_BUTTON_X},
|
||||
{"y", mapping->buttons + GLFW_GAMEPAD_BUTTON_Y},
|
||||
{"back", mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK},
|
||||
{"start", mapping->buttons + GLFW_GAMEPAD_BUTTON_START},
|
||||
{"guide", mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE},
|
||||
{"leftshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER},
|
||||
{"rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER},
|
||||
{"leftstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB},
|
||||
{"rightstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB},
|
||||
{"dpup", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP},
|
||||
{"dpright", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT},
|
||||
{"dpdown", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN},
|
||||
{"dpleft", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT},
|
||||
{"lefttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER},
|
||||
{"righttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER},
|
||||
{"leftx", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X},
|
||||
{"lefty", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y},
|
||||
{"rightx", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X},
|
||||
{"righty", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y}};
|
||||
{
|
||||
{ "platform", NULL },
|
||||
{ "a", mapping->buttons + GLFW_GAMEPAD_BUTTON_A },
|
||||
{ "b", mapping->buttons + GLFW_GAMEPAD_BUTTON_B },
|
||||
{ "x", mapping->buttons + GLFW_GAMEPAD_BUTTON_X },
|
||||
{ "y", mapping->buttons + GLFW_GAMEPAD_BUTTON_Y },
|
||||
{ "back", mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK },
|
||||
{ "start", mapping->buttons + GLFW_GAMEPAD_BUTTON_START },
|
||||
{ "guide", mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE },
|
||||
{ "leftshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
|
||||
{ "rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER },
|
||||
{ "leftstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB },
|
||||
{ "rightstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB },
|
||||
{ "dpup", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP },
|
||||
{ "dpright", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT },
|
||||
{ "dpdown", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN },
|
||||
{ "dpleft", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT },
|
||||
{ "lefttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
|
||||
{ "righttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
|
||||
{ "leftx", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X },
|
||||
{ "lefty", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y },
|
||||
{ "rightx", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X },
|
||||
{ "righty", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y }
|
||||
};
|
||||
|
||||
length = strcspn(c, ",");
|
||||
if (length != 32 || c[length] != ',')
|
||||
@ -181,7 +182,7 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
if (*c == '+' || *c == '-')
|
||||
return GLFW_FALSE;
|
||||
|
||||
for (i = 0; i < sizeof(fields) / sizeof(fields[0]); i++)
|
||||
for (i = 0; i < sizeof(fields) / sizeof(fields[0]); i++)
|
||||
{
|
||||
length = strlen(fields[i].name);
|
||||
if (strncmp(c, fields[i].name, length) != 0 || c[length] != ':')
|
||||
@ -191,7 +192,7 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
|
||||
if (fields[i].element)
|
||||
{
|
||||
_GLFWmapelement *e = fields[i].element;
|
||||
_GLFWmapelement* e = fields[i].element;
|
||||
int8_t minimum = -1;
|
||||
int8_t maximum = 1;
|
||||
|
||||
@ -217,12 +218,12 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
|
||||
if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||
{
|
||||
const unsigned long hat = strtoul(c + 1, (char **)&c, 10);
|
||||
const unsigned long bit = strtoul(c + 1, (char **)&c, 10);
|
||||
e->index = (uint8_t)((hat << 4) | bit);
|
||||
const unsigned long hat = strtoul(c + 1, (char**) &c, 10);
|
||||
const unsigned long bit = strtoul(c + 1, (char**) &c, 10);
|
||||
e->index = (uint8_t) ((hat << 4) | bit);
|
||||
}
|
||||
else
|
||||
e->index = (uint8_t)strtoul(c + 1, (char **)&c, 10);
|
||||
e->index = (uint8_t) strtoul(c + 1, (char**) &c, 10);
|
||||
|
||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||
{
|
||||
@ -238,7 +239,7 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *name = _glfw.platform.getMappingName();
|
||||
const char* name = _glfw.platform.getMappingName();
|
||||
length = strlen(name);
|
||||
if (strncmp(c, name, length) != 0)
|
||||
return GLFW_FALSE;
|
||||
@ -251,7 +252,7 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
c += strspn(c, ",");
|
||||
}
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (mapping->guid[i] >= 'A' && mapping->guid[i] <= 'F')
|
||||
mapping->guid[i] += 'a' - 'A';
|
||||
@ -261,13 +262,14 @@ static GLFWbool parseMapping(_GLFWmapping *mapping, const char *string)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW event API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Notifies shared code of a physical key event
|
||||
//
|
||||
void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(key >= 0 || key == GLFW_KEY_UNKNOWN);
|
||||
@ -288,7 +290,7 @@ void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, int m
|
||||
if (action == GLFW_RELEASE && window->stickyKeys)
|
||||
window->keys[key] = _GLFW_STICK;
|
||||
else
|
||||
window->keys[key] = (char)action;
|
||||
window->keys[key] = (char) action;
|
||||
|
||||
if (repeated)
|
||||
action = GLFW_REPEAT;
|
||||
@ -298,13 +300,13 @@ void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, int m
|
||||
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||
|
||||
if (window->callbacks.key)
|
||||
window->callbacks.key((GLFWwindow *)window, key, scancode, action, mods);
|
||||
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
||||
}
|
||||
|
||||
// Notifies shared code of a Unicode codepoint input event
|
||||
// The 'plain' parameter determines whether to emit a regular character event
|
||||
//
|
||||
void _glfwInputChar(_GLFWwindow *window, uint32_t codepoint, int mods, GLFWbool plain)
|
||||
void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(mods == (mods & GLFW_MOD_MASK));
|
||||
@ -317,18 +319,18 @@ void _glfwInputChar(_GLFWwindow *window, uint32_t codepoint, int mods, GLFWbool
|
||||
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||
|
||||
if (window->callbacks.charmods)
|
||||
window->callbacks.charmods((GLFWwindow *)window, codepoint, mods);
|
||||
window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
|
||||
|
||||
if (plain)
|
||||
{
|
||||
if (window->callbacks.character)
|
||||
window->callbacks.character((GLFWwindow *)window, codepoint);
|
||||
window->callbacks.character((GLFWwindow*) window, codepoint);
|
||||
}
|
||||
}
|
||||
|
||||
// Notifies shared code of a scroll event
|
||||
//
|
||||
void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset)
|
||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(xoffset > -FLT_MAX);
|
||||
@ -337,12 +339,12 @@ void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset)
|
||||
assert(yoffset < FLT_MAX);
|
||||
|
||||
if (window->callbacks.scroll)
|
||||
window->callbacks.scroll((GLFWwindow *)window, xoffset, yoffset);
|
||||
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
|
||||
}
|
||||
|
||||
// Notifies shared code of a mouse button click event
|
||||
//
|
||||
void _glfwInputMouseClick(_GLFWwindow *window, int button, int action, int mods)
|
||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(button >= 0);
|
||||
@ -364,13 +366,13 @@ void _glfwInputMouseClick(_GLFWwindow *window, int button, int action, int mods)
|
||||
}
|
||||
|
||||
if (window->callbacks.mouseButton)
|
||||
window->callbacks.mouseButton((GLFWwindow *)window, button, action, mods);
|
||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||
}
|
||||
|
||||
// Notifies shared code of a cursor motion event
|
||||
// The position is specified in content area relative screen coordinates
|
||||
//
|
||||
void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos)
|
||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(xpos > -FLT_MAX);
|
||||
@ -385,30 +387,30 @@ void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos)
|
||||
window->virtualCursorPosY = ypos;
|
||||
|
||||
if (window->callbacks.cursorPos)
|
||||
window->callbacks.cursorPos((GLFWwindow *)window, xpos, ypos);
|
||||
window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
|
||||
}
|
||||
|
||||
// Notifies shared code of a cursor enter/leave event
|
||||
//
|
||||
void _glfwInputCursorEnter(_GLFWwindow *window, GLFWbool entered)
|
||||
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(entered == GLFW_TRUE || entered == GLFW_FALSE);
|
||||
|
||||
if (window->callbacks.cursorEnter)
|
||||
window->callbacks.cursorEnter((GLFWwindow *)window, entered);
|
||||
window->callbacks.cursorEnter((GLFWwindow*) window, entered);
|
||||
}
|
||||
|
||||
// Notifies shared code of files or directories dropped on a window
|
||||
//
|
||||
void _glfwInputDrop(_GLFWwindow *window, int count, const char **paths)
|
||||
void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(count > 0);
|
||||
assert(paths != NULL);
|
||||
|
||||
if (window->callbacks.drop)
|
||||
window->callbacks.drop((GLFWwindow *)window, count, paths);
|
||||
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
||||
}
|
||||
|
||||
// Notifies shared code of a change in the gamepad state.
|
||||
@ -434,7 +436,7 @@ void _glfwInputGamepad(_GLFWjoystick *js)
|
||||
|
||||
// Notifies shared code of a joystick connection or disconnection
|
||||
//
|
||||
void _glfwInputJoystick(_GLFWjoystick *js, int event)
|
||||
void _glfwInputJoystick(_GLFWjoystick* js, int event)
|
||||
{
|
||||
assert(js != NULL);
|
||||
assert(event == GLFW_CONNECTED || event == GLFW_DISCONNECTED);
|
||||
@ -445,12 +447,12 @@ void _glfwInputJoystick(_GLFWjoystick *js, int event)
|
||||
js->connected = GLFW_FALSE;
|
||||
|
||||
if (_glfw.callbacks.joystick)
|
||||
_glfw.callbacks.joystick((int)(js - _glfw.joysticks), event);
|
||||
_glfw.callbacks.joystick((int) (js - _glfw.joysticks), event);
|
||||
}
|
||||
|
||||
// Notifies shared code of the new value of a joystick axis
|
||||
//
|
||||
void _glfwInputJoystickAxis(_GLFWjoystick *js, int axis, float value)
|
||||
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
||||
{
|
||||
assert(js != NULL);
|
||||
assert(axis >= 0);
|
||||
@ -465,13 +467,13 @@ void _glfwInputJoystickAxis(_GLFWjoystick *js, int axis, float value)
|
||||
_glfw.callbacks.joystick_axis(jid, axis, value);
|
||||
_glfwInputGamepad(js);
|
||||
} else {
|
||||
js->axes[axis] = value;
|
||||
js->axes[axis] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Notifies shared code of the new value of a joystick button
|
||||
//
|
||||
void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value)
|
||||
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
|
||||
{
|
||||
assert(js != NULL);
|
||||
assert(button >= 0);
|
||||
@ -481,8 +483,8 @@ void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value)
|
||||
if (js->buttons[button] != value) {
|
||||
const int jid = (int)(js - _glfw.joysticks);
|
||||
|
||||
js->buttons[button] = value;
|
||||
if (_glfw.callbacks.joystick_button)
|
||||
js->buttons[button] = value;
|
||||
if (_glfw.callbacks.joystick_button)
|
||||
_glfw.callbacks.joystick_button(jid, button, value);
|
||||
_glfwInputGamepad(js);
|
||||
} else {
|
||||
@ -492,7 +494,7 @@ void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value)
|
||||
|
||||
// Notifies shared code of the new value of a joystick hat
|
||||
//
|
||||
void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value)
|
||||
void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
||||
{
|
||||
int base;
|
||||
|
||||
@ -512,13 +514,12 @@ void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value)
|
||||
js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
|
||||
js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
|
||||
js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
|
||||
|
||||
if (js->hats[hat] != value)
|
||||
{
|
||||
const int jid = (int)(js - _glfw.joysticks);
|
||||
|
||||
js->hats[hat] = value;
|
||||
if (_glfw.callbacks.joystick_hat)
|
||||
js->hats[hat] = value;
|
||||
if (_glfw.callbacks.joystick_hat)
|
||||
_glfw.callbacks.joystick_hat(jid, hat, value);
|
||||
_glfwInputGamepad(js);
|
||||
}
|
||||
@ -533,10 +534,10 @@ void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value)
|
||||
void _glfwInitGamepadMappings(void)
|
||||
{
|
||||
size_t i;
|
||||
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char *);
|
||||
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
|
||||
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
|
||||
_glfw.mappingCount++;
|
||||
@ -545,16 +546,16 @@ void _glfwInitGamepadMappings(void)
|
||||
|
||||
// Returns an available joystick object with arrays and name allocated
|
||||
//
|
||||
_GLFWjoystick *_glfwAllocJoystick(const char *name,
|
||||
const char *guid,
|
||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||
const char* guid,
|
||||
int axisCount,
|
||||
int buttonCount,
|
||||
int hatCount)
|
||||
{
|
||||
int jid;
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
{
|
||||
if (!_glfw.joysticks[jid].allocated)
|
||||
break;
|
||||
@ -564,13 +565,13 @@ _GLFWjoystick *_glfwAllocJoystick(const char *name,
|
||||
return NULL;
|
||||
|
||||
js = _glfw.joysticks + jid;
|
||||
js->allocated = GLFW_TRUE;
|
||||
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||
js->buttons = _glfw_calloc(buttonCount + (size_t)hatCount * 4, 1);
|
||||
js->hats = _glfw_calloc(hatCount, 1);
|
||||
js->axisCount = axisCount;
|
||||
js->allocated = GLFW_TRUE;
|
||||
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
||||
js->hats = _glfw_calloc(hatCount, 1);
|
||||
js->axisCount = axisCount;
|
||||
js->buttonCount = buttonCount;
|
||||
js->hatCount = hatCount;
|
||||
js->hatCount = hatCount;
|
||||
|
||||
strncpy(js->name, name, sizeof(js->name) - 1);
|
||||
strncpy(js->guid, guid, sizeof(js->guid) - 1);
|
||||
@ -581,7 +582,7 @@ _GLFWjoystick *_glfwAllocJoystick(const char *name,
|
||||
|
||||
// Frees arrays and name and flags the joystick object as unused
|
||||
//
|
||||
void _glfwFreeJoystick(_GLFWjoystick *js)
|
||||
void _glfwFreeJoystick(_GLFWjoystick* js)
|
||||
{
|
||||
_glfw_free(js->axes);
|
||||
_glfw_free(js->buttons);
|
||||
@ -591,7 +592,7 @@ void _glfwFreeJoystick(_GLFWjoystick *js)
|
||||
|
||||
// Center the cursor in the content area of the specified window
|
||||
//
|
||||
void _glfwCenterCursorInContentArea(_GLFWwindow *window)
|
||||
void _glfwCenterCursorInContentArea(_GLFWwindow* window)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
@ -617,7 +618,7 @@ void _glfwPollAllJoysticks()
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI int glfwGetInputMode(GLFWwindow *handle, int mode)
|
||||
GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||
|
||||
@ -644,7 +645,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow *handle, int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetInputMode(GLFWwindow *handle, int mode, int value)
|
||||
GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
@ -689,7 +690,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow *handle, int mode, int value)
|
||||
int i;
|
||||
|
||||
// Release all sticky keys
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||
{
|
||||
if (window->keys[i] == _GLFW_STICK)
|
||||
window->keys[i] = GLFW_RELEASE;
|
||||
@ -711,7 +712,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow *handle, int mode, int value)
|
||||
int i;
|
||||
|
||||
// Release all sticky mouse buttons
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||
{
|
||||
if (window->mouseButtons[i] == _GLFW_STICK)
|
||||
window->mouseButtons[i] = GLFW_RELEASE;
|
||||
@ -762,7 +763,7 @@ GLFWAPI int glfwRawMouseMotionSupported(void)
|
||||
return _glfw.platform.rawMouseMotionSupported();
|
||||
}
|
||||
|
||||
GLFWAPI const char *glfwGetKeyName(int key, int scancode)
|
||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -800,7 +801,7 @@ GLFWAPI int glfwGetKeyScancode(int key)
|
||||
return _glfw.platform.getKeyScancode(key);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetKey(GLFWwindow *handle, int key)
|
||||
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
@ -820,10 +821,10 @@ GLFWAPI int glfwGetKey(GLFWwindow *handle, int key)
|
||||
return GLFW_PRESS;
|
||||
}
|
||||
|
||||
return (int)window->keys[key];
|
||||
return (int) window->keys[key];
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetMouseButton(GLFWwindow *handle, int button)
|
||||
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
@ -843,10 +844,10 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow *handle, int button)
|
||||
return GLFW_PRESS;
|
||||
}
|
||||
|
||||
return (int)window->mouseButtons[button];
|
||||
return (int) window->mouseButtons[button];
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetCursorPos(GLFWwindow *handle, double *xpos, double *ypos)
|
||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
@ -869,7 +870,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow *handle, double *xpos, double *ypos)
|
||||
_glfw.platform.getCursorPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetCursorPos(GLFWwindow *handle, double xpos, double ypos)
|
||||
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
@ -901,9 +902,9 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow *handle, double xpos, double ypos)
|
||||
}
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursor *glfwCreateCursor(const GLFWimage *image, int xhot, int yhot)
|
||||
GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||
{
|
||||
_GLFWcursor *cursor;
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
assert(image != NULL);
|
||||
assert(image->pixels != NULL);
|
||||
@ -922,16 +923,16 @@ GLFWAPI GLFWcursor *glfwCreateCursor(const GLFWimage *image, int xhot, int yhot)
|
||||
|
||||
if (!_glfw.platform.createCursor(cursor, image, xhot, yhot))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor *)cursor);
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (GLFWcursor *)cursor;
|
||||
return (GLFWcursor*) cursor;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursor *glfwCreateStandardCursor(int shape)
|
||||
GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
|
||||
{
|
||||
_GLFWcursor *cursor;
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -956,14 +957,14 @@ GLFWAPI GLFWcursor *glfwCreateStandardCursor(int shape)
|
||||
|
||||
if (!_glfw.platform.createStandardCursor(cursor, shape))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor *)cursor);
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (GLFWcursor *)cursor;
|
||||
return (GLFWcursor*) cursor;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwDestroyCursor(GLFWcursor *handle)
|
||||
GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
@ -974,12 +975,12 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor *handle)
|
||||
|
||||
// Make sure the cursor is not being used by any window
|
||||
{
|
||||
_GLFWwindow *window;
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
{
|
||||
if (window->cursor == cursor)
|
||||
glfwSetCursor((GLFWwindow *)window, NULL);
|
||||
glfwSetCursor((GLFWwindow*) window, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,7 +988,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor *handle)
|
||||
|
||||
// Unlink cursor from global linked list
|
||||
{
|
||||
_GLFWcursor **prev = &_glfw.cursorListHead;
|
||||
_GLFWcursor** prev = &_glfw.cursorListHead;
|
||||
|
||||
while (*prev != cursor)
|
||||
prev = &((*prev)->next);
|
||||
@ -998,7 +999,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor *handle)
|
||||
_glfw_free(cursor);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetCursor(GLFWwindow *windowHandle, GLFWcursor *cursorHandle)
|
||||
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
@ -1011,7 +1012,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow *windowHandle, GLFWcursor *cursorHandle)
|
||||
_glfw.platform.setCursor(window, cursor);
|
||||
}
|
||||
|
||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow *handle, GLFWkeyfun cbfun)
|
||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -1022,7 +1023,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow *handle, GLFWkeyfun cbfun)
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow *handle, GLFWcharfun cbfun)
|
||||
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -1033,7 +1034,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow *handle, GLFWcharfun cbfun)
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow *handle, GLFWcharmodsfun cbfun)
|
||||
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -1044,7 +1045,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow *handle, GLFWcharmods
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow *handle,
|
||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||
GLFWmousebuttonfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
@ -1056,7 +1057,7 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow *handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *handle,
|
||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||
GLFWcursorposfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
@ -1068,7 +1069,7 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow *handle,
|
||||
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
||||
GLFWcursorenterfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
@ -1080,7 +1081,7 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow *handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *handle,
|
||||
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
||||
GLFWscrollfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
@ -1092,7 +1093,7 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow *handle, GLFWdropfun cbfun)
|
||||
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
@ -1105,7 +1106,7 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow *handle, GLFWdropfun cbfun)
|
||||
|
||||
GLFWAPI int glfwJoystickPresent(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1128,9 +1129,9 @@ GLFWAPI int glfwJoystickPresent(int jid)
|
||||
return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||
}
|
||||
|
||||
GLFWAPI const float *glfwGetJoystickAxes(int jid, int *count)
|
||||
GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1160,9 +1161,9 @@ GLFWAPI const float *glfwGetJoystickAxes(int jid, int *count)
|
||||
return js->axes;
|
||||
}
|
||||
|
||||
GLFWAPI const unsigned char *glfwGetJoystickButtons(int jid, int *count)
|
||||
GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1196,9 +1197,9 @@ GLFWAPI const unsigned char *glfwGetJoystickButtons(int jid, int *count)
|
||||
return js->buttons;
|
||||
}
|
||||
|
||||
GLFWAPI const unsigned char *glfwGetJoystickHats(int jid, int *count)
|
||||
GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1228,9 +1229,9 @@ GLFWAPI const unsigned char *glfwGetJoystickHats(int jid, int *count)
|
||||
return js->hats;
|
||||
}
|
||||
|
||||
GLFWAPI const char *glfwGetJoystickName(int jid)
|
||||
GLFWAPI const char* glfwGetJoystickName(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1256,9 +1257,9 @@ GLFWAPI const char *glfwGetJoystickName(int jid)
|
||||
return js->name;
|
||||
}
|
||||
|
||||
GLFWAPI const char *glfwGetJoystickGUID(int jid)
|
||||
GLFWAPI const char* glfwGetJoystickGUID(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1284,9 +1285,9 @@ GLFWAPI const char *glfwGetJoystickGUID(int jid)
|
||||
return js->guid;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetJoystickUserPointer(int jid, void *pointer)
|
||||
GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1300,9 +1301,9 @@ GLFWAPI void glfwSetJoystickUserPointer(int jid, void *pointer)
|
||||
js->userPointer = pointer;
|
||||
}
|
||||
|
||||
GLFWAPI void *glfwGetJoystickUserPointer(int jid)
|
||||
GLFWAPI void* glfwGetJoystickUserPointer(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1355,10 +1356,10 @@ GLFWAPI GLFWjoystickhatfun glfwSetJoystickHatCallback(GLFWjoystickhatfun cbfun)
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwUpdateGamepadMappings(const char *string)
|
||||
GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
||||
{
|
||||
int jid;
|
||||
const char *c = string;
|
||||
const char* c = string;
|
||||
|
||||
assert(string != NULL);
|
||||
|
||||
@ -1382,7 +1383,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char *string)
|
||||
|
||||
if (parseMapping(&mapping, line))
|
||||
{
|
||||
_GLFWmapping *previous = findMapping(mapping.guid);
|
||||
_GLFWmapping* previous = findMapping(mapping.guid);
|
||||
if (previous)
|
||||
*previous = mapping;
|
||||
else
|
||||
@ -1405,9 +1406,9 @@ GLFWAPI int glfwUpdateGamepadMappings(const char *string)
|
||||
}
|
||||
}
|
||||
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
{
|
||||
_GLFWjoystick *js = _glfw.joysticks + jid;
|
||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||
if (js->connected)
|
||||
js->mapping = findValidMapping(js);
|
||||
}
|
||||
@ -1417,7 +1418,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char *string)
|
||||
|
||||
GLFWAPI int glfwJoystickIsGamepad(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1443,9 +1444,9 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
|
||||
return js->mapping != NULL;
|
||||
}
|
||||
|
||||
GLFWAPI const char *glfwGetGamepadName(int jid)
|
||||
GLFWAPI const char* glfwGetGamepadName(int jid)
|
||||
{
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1474,10 +1475,10 @@ GLFWAPI const char *glfwGetGamepadName(int jid)
|
||||
return js->mapping->name;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate *state)
|
||||
GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||
{
|
||||
int i;
|
||||
_GLFWjoystick *js;
|
||||
_GLFWjoystick* js;
|
||||
|
||||
assert(jid >= GLFW_JOYSTICK_1);
|
||||
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||
@ -1506,9 +1507,9 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate *state)
|
||||
if (!js->mapping)
|
||||
return GLFW_FALSE;
|
||||
|
||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||
{
|
||||
const _GLFWmapelement *e = js->mapping->buttons + i;
|
||||
const _GLFWmapelement* e = js->mapping->buttons + i;
|
||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||
{
|
||||
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
|
||||
@ -1536,9 +1537,9 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate *state)
|
||||
state->buttons[i] = js->buttons[e->index];
|
||||
}
|
||||
|
||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||
{
|
||||
const _GLFWmapelement *e = js->mapping->axes + i;
|
||||
const _GLFWmapelement* e = js->mapping->axes + i;
|
||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||
{
|
||||
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
|
||||
@ -1560,7 +1561,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate *state)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetClipboardString(GLFWwindow *handle, const char *string)
|
||||
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
|
||||
{
|
||||
assert(string != NULL);
|
||||
|
||||
@ -1568,7 +1569,7 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow *handle, const char *string)
|
||||
_glfw.platform.setClipboardString(string);
|
||||
}
|
||||
|
||||
GLFWAPI const char *glfwGetClipboardString(GLFWwindow *handle)
|
||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return _glfw.platform.getClipboardString();
|
||||
@ -1577,8 +1578,8 @@ GLFWAPI const char *glfwGetClipboardString(GLFWwindow *handle)
|
||||
GLFWAPI double glfwGetTime(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
|
||||
return (double)(_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
|
||||
_glfwPlatformGetTimerFrequency();
|
||||
return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
|
||||
_glfwPlatformGetTimerFrequency();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetTime(double time)
|
||||
@ -1592,7 +1593,7 @@ GLFWAPI void glfwSetTime(double time)
|
||||
}
|
||||
|
||||
_glfw.timer.offset = _glfwPlatformGetTimerValue() -
|
||||
(uint64_t)(time * _glfwPlatformGetTimerFrequency());
|
||||
(uint64_t) (time * _glfwPlatformGetTimerFrequency());
|
||||
}
|
||||
|
||||
GLFWAPI uint64_t glfwGetTimerValue(void)
|
||||
|
Loading…
Reference in New Issue
Block a user