mirror of
https://github.com/glfw/glfw.git
synced 2025-04-12 03:42:01 +00:00
Merge 4353b62251
into 7dfd84c458
This commit is contained in:
commit
d9583a45f9
26
deps/mingw/xinput.h
vendored
26
deps/mingw/xinput.h
vendored
@ -110,14 +110,17 @@
|
||||
* which are being used.
|
||||
*/
|
||||
|
||||
#define XINPUT_DEVTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
|
||||
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
|
||||
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
|
||||
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
|
||||
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
|
||||
#define XINPUT_DEVTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
|
||||
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
|
||||
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
|
||||
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 0x07
|
||||
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR_BASS 0x0b
|
||||
#define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
|
||||
|
||||
/*
|
||||
* These are used with the XInputGetCapabilities function to
|
||||
@ -156,6 +159,11 @@
|
||||
#define XUSER_MAX_COUNT 4
|
||||
#define XUSER_INDEX_ANY 0x000000FF
|
||||
|
||||
#define XINPUT_CAPS_FFB_SUPPORTED 0x0001
|
||||
#define XINPUT_CAPS_WIRELESS 0x0002
|
||||
#define XINPUT_CAPS_PMD_SUPPORTED 0x0008
|
||||
#define XINPUT_CAPS_NO_NAVIGATION 0x0010
|
||||
|
||||
/*
|
||||
* Defines the structure of an xbox 360 joystick.
|
||||
*/
|
||||
@ -232,6 +240,8 @@ DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
|
||||
DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
|
||||
DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
|
||||
|
||||
DWORD WINAPI XInputGetStateEx(DWORD, XINPUT_STATE*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
67
src/init.c
67
src/init.c
@ -244,26 +244,18 @@ int _glfw_max(int a, int b)
|
||||
|
||||
float _glfw_fminf(float a, float b)
|
||||
{
|
||||
if (a != a)
|
||||
return b;
|
||||
else if (b != b)
|
||||
if (b != b || a < b)
|
||||
return a;
|
||||
else if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
float _glfw_fmaxf(float a, float b)
|
||||
{
|
||||
if (a != a)
|
||||
return b;
|
||||
else if (b != b)
|
||||
if (b != b || a > b)
|
||||
return a;
|
||||
else if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void* _glfw_calloc(size_t count, size_t size)
|
||||
@ -343,36 +335,53 @@ void _glfwInputError(int code, const char* format, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code == GLFW_NOT_INITIALIZED)
|
||||
switch (code)
|
||||
{
|
||||
case GLFW_NOT_INITIALIZED:
|
||||
strcpy(description, "The GLFW library is not initialized");
|
||||
else if (code == GLFW_NO_CURRENT_CONTEXT)
|
||||
break;
|
||||
case GLFW_NO_CURRENT_CONTEXT:
|
||||
strcpy(description, "There is no current context");
|
||||
else if (code == GLFW_INVALID_ENUM)
|
||||
break;
|
||||
case GLFW_INVALID_ENUM:
|
||||
strcpy(description, "Invalid argument for enum parameter");
|
||||
else if (code == GLFW_INVALID_VALUE)
|
||||
break;
|
||||
case GLFW_INVALID_VALUE:
|
||||
strcpy(description, "Invalid value for parameter");
|
||||
else if (code == GLFW_OUT_OF_MEMORY)
|
||||
break;
|
||||
case GLFW_OUT_OF_MEMORY:
|
||||
strcpy(description, "Out of memory");
|
||||
else if (code == GLFW_API_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_API_UNAVAILABLE:
|
||||
strcpy(description, "The requested API is unavailable");
|
||||
else if (code == GLFW_VERSION_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_VERSION_UNAVAILABLE:
|
||||
strcpy(description, "The requested API version is unavailable");
|
||||
else if (code == GLFW_PLATFORM_ERROR)
|
||||
break;
|
||||
case GLFW_PLATFORM_ERROR:
|
||||
strcpy(description, "A platform-specific error occurred");
|
||||
else if (code == GLFW_FORMAT_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_FORMAT_UNAVAILABLE:
|
||||
strcpy(description, "The requested format is unavailable");
|
||||
else if (code == GLFW_NO_WINDOW_CONTEXT)
|
||||
break;
|
||||
case GLFW_NO_WINDOW_CONTEXT:
|
||||
strcpy(description, "The specified window has no context");
|
||||
else if (code == GLFW_CURSOR_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_CURSOR_UNAVAILABLE:
|
||||
strcpy(description, "The specified cursor shape is unavailable");
|
||||
else if (code == GLFW_FEATURE_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_FEATURE_UNAVAILABLE:
|
||||
strcpy(description, "The requested feature cannot be implemented for this platform");
|
||||
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
|
||||
break;
|
||||
case GLFW_FEATURE_UNIMPLEMENTED:
|
||||
strcpy(description, "The requested feature has not yet been implemented for this platform");
|
||||
else if (code == GLFW_PLATFORM_UNAVAILABLE)
|
||||
break;
|
||||
case GLFW_PLATFORM_UNAVAILABLE:
|
||||
strcpy(description, "The requested platform is unavailable");
|
||||
else
|
||||
break;
|
||||
default:
|
||||
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
if (_glfw.initialized)
|
||||
|
55
src/input.c
55
src/input.c
@ -202,14 +202,21 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
||||
c += 1;
|
||||
}
|
||||
|
||||
if (*c == 'a')
|
||||
switch (*c)
|
||||
{
|
||||
case 'a':
|
||||
e->type = _GLFW_JOYSTICK_AXIS;
|
||||
else if (*c == 'b')
|
||||
e->type = _GLFW_JOYSTICK_BUTTON;
|
||||
else if (*c == 'h')
|
||||
e->type = _GLFW_JOYSTICK_HATBIT;
|
||||
else
|
||||
break;
|
||||
case 'b':
|
||||
e->type = _GLFW_JOYSTICK_BUTTON;
|
||||
break;
|
||||
case 'h':
|
||||
e->type = _GLFW_JOYSTICK_HATBIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||
{
|
||||
@ -1331,7 +1338,9 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||
{
|
||||
const _GLFWmapelement* e = js->mapping->buttons + i;
|
||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||
switch (e->type)
|
||||
{
|
||||
case _GLFW_JOYSTICK_AXIS:
|
||||
{
|
||||
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
|
||||
// HACK: This should be baked into the value transform
|
||||
@ -1347,26 +1356,33 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||
state->buttons[i] = GLFW_PRESS;
|
||||
}
|
||||
}
|
||||
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||
break;
|
||||
case _GLFW_JOYSTICK_HATBIT:
|
||||
{
|
||||
const unsigned int hat = e->index >> 4;
|
||||
const unsigned int bit = e->index & 0xf;
|
||||
if (js->hats[hat] & bit)
|
||||
state->buttons[i] = GLFW_PRESS;
|
||||
const unsigned int hat = e->index >> 4;
|
||||
const unsigned int bit = e->index & 0xf;
|
||||
if (js->hats[hat] & bit)
|
||||
state->buttons[i] = GLFW_PRESS;
|
||||
break;
|
||||
}
|
||||
case _GLFW_JOYSTICK_BUTTON:
|
||||
state->buttons[i] = js->buttons[e->index];
|
||||
break;
|
||||
}
|
||||
else if (e->type == _GLFW_JOYSTICK_BUTTON)
|
||||
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;
|
||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||
switch (e->type)
|
||||
{
|
||||
case _GLFW_JOYSTICK_AXIS:
|
||||
{
|
||||
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
|
||||
state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
|
||||
}
|
||||
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||
break;
|
||||
case _GLFW_JOYSTICK_HATBIT:
|
||||
{
|
||||
const unsigned int hat = e->index >> 4;
|
||||
const unsigned int bit = e->index & 0xf;
|
||||
@ -1375,8 +1391,11 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||
else
|
||||
state->axes[i] = -1.f;
|
||||
}
|
||||
else if (e->type == _GLFW_JOYSTICK_BUTTON)
|
||||
break;
|
||||
case _GLFW_JOYSTICK_BUTTON:
|
||||
state->axes[i] = js->buttons[e->index] * 2.f - 1.f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user