Gamepad Support
This commit is contained in:
parent
6aaa479361
commit
29e94ef039
1 changed files with 70 additions and 39 deletions
44
src/core.c
44
src/core.c
|
|
@ -3094,6 +3094,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;
|
||||
|
|
@ -4591,12 +4599,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;
|
||||
|
|
@ -4666,23 +4676,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
|
||||
|
|
|
|||
Loading…
Reference in a new issue