Gamepad Support
This commit is contained in:
parent
108f02e279
commit
19cdcbe7a0
2 changed files with 70 additions and 39 deletions
44
src/core.c
44
src/core.c
|
|
@ -3096,6 +3096,14 @@ static void PollInputEvents(void)
|
|||
// Register previous keys states
|
||||
for (int i = 0; i < 512; i++) previousKeyState[i] = currentKeyState[i];
|
||||
|
||||
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||
{
|
||||
if (gamepadReady[i])
|
||||
{
|
||||
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) previousGamepadState[i][k] = currentGamepadState[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
// Register previous mouse states
|
||||
previousMouseWheelY = currentMouseWheelY;
|
||||
currentMouseWheelY = 0;
|
||||
|
|
@ -4593,12 +4601,14 @@ static void *GamepadThread(void *arg)
|
|||
|
||||
#if defined(PLATFORM_UWP)
|
||||
|
||||
void UWPRegisterKey(int key, char action) {
|
||||
void UWPRegisterKey(int key, char action)
|
||||
{
|
||||
//Convert from virtualKey
|
||||
|
||||
int actualKey = -1;
|
||||
|
||||
switch (key) {
|
||||
switch (key)
|
||||
{
|
||||
case 0x08: actualKey = KEY_BACKSPACE; break;
|
||||
case 0x20: actualKey = KEY_SPACE; break;
|
||||
case 0x1B: actualKey = KEY_ESCAPE; break;
|
||||
|
|
@ -4668,23 +4678,45 @@ void UWPRegisterKey(int key, char action) {
|
|||
currentKeyState[actualKey] = action;
|
||||
}
|
||||
|
||||
void UWPRegisterClick(int btn, char action) {
|
||||
void UWPRegisterClick(int btn, char action)
|
||||
{
|
||||
currentMouseState[btn] = action;
|
||||
}
|
||||
|
||||
void UWPScrollWheel(int delta) {
|
||||
void UWPScrollWheel(int delta)
|
||||
{
|
||||
currentMouseWheelY += delta;
|
||||
}
|
||||
|
||||
void UWPMousePosition(float x, float y) {
|
||||
void UWPMousePosition(float x, float y)
|
||||
{
|
||||
mousePosition.x = x;
|
||||
mousePosition.y = y;
|
||||
}
|
||||
|
||||
void UWPMarkCursor(bool hidden) {
|
||||
void UWPMarkCursor(bool hidden)
|
||||
{
|
||||
cursorHidden = hidden;
|
||||
}
|
||||
|
||||
void UWPGamepadActive(int gamepad, bool active)
|
||||
{
|
||||
if (gamepad < MAX_GAMEPADS)
|
||||
gamepadReady[gamepad] = active;
|
||||
}
|
||||
|
||||
void UWPGamepadButton(int gamepad, int button, char action)
|
||||
{
|
||||
if (gamepad < MAX_GAMEPADS && button < MAX_GAMEPAD_BUTTONS)
|
||||
currentGamepadState[gamepad][button] = action;
|
||||
}
|
||||
|
||||
void UWPGamepadAxis(int gamepad, int axis, float value)
|
||||
{
|
||||
if (gamepad < MAX_GAMEPADS && axis < MAX_GAMEPAD_AXIS)
|
||||
gamepadAxisState[gamepad][axis] = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Plays raylib logo appearing animation
|
||||
|
|
|
|||
|
|
@ -921,9 +921,11 @@ RLAPI void UWPRegisterClick(int btn, char action);
|
|||
RLAPI void UWPScrollWheel(int delta);
|
||||
RLAPI void UWPMousePosition(float x, float y);
|
||||
RLAPI void UWPMarkCursor(bool hidden);
|
||||
RLAPI void UWPGamepadActive(int gamepad, bool active);
|
||||
RLAPI void UWPGamepadButton(int gamepad, int button, char action);
|
||||
RLAPI void UWPGamepadAxis(int gamepad, int axis, float value);
|
||||
|
||||
//Get task/input for allowing C to call UWP/cursor functions
|
||||
//Gamepad functionality?
|
||||
//Get task/input for allowing C to call UWP/cursor functions
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue