diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 3dee04936..33578c95f 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -8318,14 +8318,30 @@ EM_BOOL Emscripten_on_resize(int eventType, const EmscriptenUiEvent* e, void* us } EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreenChangeEvent* e, void* userData) { - RGFW_UNUSED(eventType); RGFW_UNUSED(userData); + static bool fullscreen = false; + static RGFW_rect ogRect; + + if (fullscreen == false) { + ogRect = RGFW_root->r; + } + fullscreen = !fullscreen; + + RGFW_UNUSED(eventType); RGFW_UNUSED(userData); + RGFW_events[RGFW_eventLen].type = RGFW_windowResized; RGFW_eventLen++; RGFW_root->r = RGFW_RECT(0, 0, e->elementWidth, e->elementHeight); + + if (fullscreen == false) { + emscripten_set_canvas_element_size("#canvas", ogRect.w, ogRect.h); + RGFW_root->r = RGFW_RECT(0, 0, ogRect.w, ogRect.h); + } + + RGFW_windowResizeCallback(RGFW_root, RGFW_root->r); - return EM_TRUE; + return EM_TRUE; } EM_BOOL Emscripten_on_focusin(int eventType, const EmscriptenFocusEvent* e, void* userData) { @@ -8736,9 +8752,9 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { } for (int j = 0; (j < gamepadState.numAxes) && (j < 4); j += 2) { - win->event.axisesCount = gamepadState.numAxes; - if (win->event.axis[j].x != (i8)(gamepadState.axis[j] * 100.0f) || - win->event.axis[j].y != (i8)(gamepadState.axis[j + 1] * 100.0f) + win->event.axisesCount = gamepadState.numAxes / 2; + if (win->event.axis[j / 2].x != (i8)(gamepadState.axis[j] * 100.0f) || + win->event.axis[j / 2].y != (i8)(gamepadState.axis[j + 1] * 100.0f) ) { win->event.axis[j / 2].x = (i8)(gamepadState.axis[j] * 100.0f); win->event.axis[j / 2].y = (i8)(gamepadState.axis[j + 1] * 100.0f); diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 891644a8f..6d5dc2e52 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -1166,50 +1166,35 @@ void PollInputEvents(void) switch(event->whichAxis) { case 0: { - if (abs(event->axis[0].x) > abs(event->axis[0].y)) - { - axis = GAMEPAD_AXIS_LEFT_X; - value = event->axis[0].x; - break; - } - - value = event->axis[0].y; - axis = GAMEPAD_AXIS_LEFT_Y; + #ifndef __linux__ + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f; + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f; + #else + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 32767.0f; + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 32767.0f; + #endif } break; case 1: { - if (abs(event->axis[1].x) > abs(event->axis[1].y)) - { - axis = GAMEPAD_AXIS_RIGHT_X; - value = event->axis[1].x; - break; - } - - value = event->axis[1].y; - axis = GAMEPAD_AXIS_RIGHT_Y; + #ifndef __linux__ + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f; + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f; + #else + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 32767.0f; + CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 32767.0f; + #endif } break; - case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; break; - case 3: axis = GAMEPAD_AXIS_RIGHT_TRIGGER; break; + case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; + case 3: { if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER; + int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; + int pressed = (value > 0.1f); + CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed; + + if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; + else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; + } default: break; } - - #ifdef __linux__ - value = (float)(value)/32767.0f; - #else - value = ((float)value / 100.0f); - #endif - CORE.Input.Gamepad.axisState[event->joystick][axis] = value; - - // Register button state for triggers in addition to their axes - if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER)) - { - int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; - int pressed = (value > 0.1f); - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed; - - if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; - else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; - } } break; default: break; }