From 3cb293e220f6767c7b41784829f351d3b36af84b Mon Sep 17 00:00:00 2001 From: "specialfred453@gmail.com" Date: Sun, 26 Jan 2025 00:48:54 -0500 Subject: [PATCH] fixed what I broke when I merged from master --- ui/xemu-input.c | 63 ++++++++++++++++---------------------------- ui/xui/gl-helpers.cc | 42 ++++++++++++++--------------- 2 files changed, 44 insertions(+), 61 deletions(-) diff --git a/ui/xemu-input.c b/ui/xemu-input.c index f62c7c3f53..54a2aefc3b 100644 --- a/ui/xemu-input.c +++ b/ui/xemu-input.c @@ -61,27 +61,27 @@ static void xemu_input_print_controller_state(ControllerState *state) "LTrig = %.3f, RTrig = %.3f\n" "LStickX = %.3f, RStickX = %.3f\n" "LStickY = %.3f, RStickY = %.3f\n\n", - !!(state->buttons & CONTROLLER_BUTTON_A), - !!(state->buttons & CONTROLLER_BUTTON_B), - !!(state->buttons & CONTROLLER_BUTTON_X), - !!(state->buttons & CONTROLLER_BUTTON_Y), - !!(state->buttons & CONTROLLER_BUTTON_DPAD_LEFT), - !!(state->buttons & CONTROLLER_BUTTON_DPAD_UP), - !!(state->buttons & CONTROLLER_BUTTON_DPAD_RIGHT), - !!(state->buttons & CONTROLLER_BUTTON_DPAD_DOWN), - !!(state->buttons & CONTROLLER_BUTTON_BACK), - !!(state->buttons & CONTROLLER_BUTTON_START), - !!(state->buttons & CONTROLLER_BUTTON_WHITE), - !!(state->buttons & CONTROLLER_BUTTON_BLACK), - !!(state->buttons & CONTROLLER_BUTTON_LSTICK), - !!(state->buttons & CONTROLLER_BUTTON_RSTICK), - !!(state->buttons & CONTROLLER_BUTTON_GUIDE), - state->axis[CONTROLLER_AXIS_LTRIG], - state->axis[CONTROLLER_AXIS_RTRIG], - state->axis[CONTROLLER_AXIS_LSTICK_X], - state->axis[CONTROLLER_AXIS_RSTICK_X], - state->axis[CONTROLLER_AXIS_LSTICK_Y], - state->axis[CONTROLLER_AXIS_RSTICK_Y] + !!(state->gp.buttons & CONTROLLER_BUTTON_A), + !!(state->gp.buttons & CONTROLLER_BUTTON_B), + !!(state->gp.buttons & CONTROLLER_BUTTON_X), + !!(state->gp.buttons & CONTROLLER_BUTTON_Y), + !!(state->gp.buttons & CONTROLLER_BUTTON_DPAD_LEFT), + !!(state->gp.buttons & CONTROLLER_BUTTON_DPAD_UP), + !!(state->gp.buttons & CONTROLLER_BUTTON_DPAD_RIGHT), + !!(state->gp.buttons & CONTROLLER_BUTTON_DPAD_DOWN), + !!(state->gp.buttons & CONTROLLER_BUTTON_BACK), + !!(state->gp.buttons & CONTROLLER_BUTTON_START), + !!(state->gp.buttons & CONTROLLER_BUTTON_WHITE), + !!(state->gp.buttons & CONTROLLER_BUTTON_BLACK), + !!(state->gp.buttons & CONTROLLER_BUTTON_LSTICK), + !!(state->gp.buttons & CONTROLLER_BUTTON_RSTICK), + !!(state->gp.buttons & CONTROLLER_BUTTON_GUIDE), + state->gp.axis[CONTROLLER_AXIS_LTRIG], + state->gp.axis[CONTROLLER_AXIS_RTRIG], + state->gp.axis[CONTROLLER_AXIS_LSTICK_X], + state->gp.axis[CONTROLLER_AXIS_RSTICK_X], + state->gp.axis[CONTROLLER_AXIS_LSTICK_Y], + state->gp.axis[CONTROLLER_AXIS_RSTICK_Y] ); } #endif @@ -146,27 +146,10 @@ static const char *get_bound_driver(int port) return DRIVER_DUKE; if (strcmp(driver, DRIVER_DUKE) == 0) return DRIVER_DUKE; - if (strcmp(driver, DRIVER_STEEL_BATTALION) == 0) - return DRIVER_STEEL_BATTALION; - - return DRIVER_DUKE; -} - -static const char *get_bound_driver(int port) -{ - assert(port >= 0 && port <= 3); - const char *driver = *port_index_to_driver_settings_key_map[port]; - - // If the driver in the config is NULL, empty, or unrecognized - // then default to DRIVER_DUKE - if (driver == NULL) - return DRIVER_DUKE; - if (strlen(driver) == 0) - return DRIVER_DUKE; - if (strcmp(driver, DRIVER_DUKE) == 0) - return DRIVER_DUKE; if (strcmp(driver, DRIVER_S) == 0) return DRIVER_S; + if (strcmp(driver, DRIVER_STEEL_BATTALION) == 0) + return DRIVER_STEEL_BATTALION; return DRIVER_DUKE; } diff --git a/ui/xui/gl-helpers.cc b/ui/xui/gl-helpers.cc index 1ad7132458..10a9524ba7 100644 --- a/ui/xui/gl-helpers.cc +++ b/ui/xui/gl-helpers.cc @@ -37,7 +37,7 @@ extern int viewport_coords[4]; Fbo *controller_fbo, *xmu_fbo, *logo_fbo; -GLuint g_controller_duke_tex, g_controller_s_tex, g_sb_controller_duke_tex, g_logo_tex, g_icon_tex, g_xmu_tex; +GLuint g_controller_duke_tex, g_controller_s_tex, g_sb_controller_tex, g_logo_tex, g_icon_tex, g_xmu_tex; enum class ShaderType { Blit, @@ -706,13 +706,13 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col // Check to see if the guide button is pressed const uint32_t animate_guide_button_duration = 2000; - if (state->buttons & CONTROLLER_BUTTON_GUIDE) { - state->animate_guide_button_end = + if (state->gp.buttons & CONTROLLER_BUTTON_GUIDE) { + state->gp.animate_guide_button_end = now + animate_guide_button_duration; } - if (now < state->animate_guide_button_end) { - t = 1.0f - (float)(state->animate_guide_button_end - now) / + if (now < state->gp.animate_guide_button_end) { + t = 1.0f - (float)(state->gp.animate_guide_button_end - now) / (float)animate_guide_button_duration; float sin_wav = (1 - sin(M_PI * t / 2.0f)); @@ -742,7 +742,7 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col // The controller has alpha cutouts where the buttons are. Draw a surface // behind the buttons if they are activated for (int i = 0; i < 12; i++) { - if (state->buttons & (1 << i)) { + if (state->gp.buttons & (1 << i)) { RenderDecal(g_decal_shader, frame_x + buttons[i].x, frame_y + buttons[i].y, buttons[i].w, buttons[i].h, 0, 0, 1, 1, 0, 0, primary_color + 0xff); @@ -756,15 +756,15 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col float h = tex_items[obj_lstick].h; float c_x = frame_x + lstick_ctr.x; float c_y = frame_y + lstick_ctr.y; - float lstick_x = (float)state->axis[CONTROLLER_AXIS_LSTICK_X] / 32768.0; - float lstick_y = (float)state->axis[CONTROLLER_AXIS_LSTICK_Y] / 32768.0; + float lstick_x = (float)state->gp.axis[CONTROLLER_AXIS_LSTICK_X] / 32768.0; + float lstick_y = (float)state->gp.axis[CONTROLLER_AXIS_LSTICK_Y] / 32768.0; RenderDecal( g_decal_shader, (int)(c_x - w / 2.0f + 10.0f * lstick_x), (int)(c_y - h / 2.0f + 10.0f * lstick_y), w, h, tex_items[obj_lstick].x, tex_items[obj_lstick].y, w, h, - (state->buttons & CONTROLLER_BUTTON_LSTICK) ? secondary_color : + (state->gp.buttons & CONTROLLER_BUTTON_LSTICK) ? secondary_color : primary_color, - (state->buttons & CONTROLLER_BUTTON_LSTICK) ? primary_color : + (state->gp.buttons & CONTROLLER_BUTTON_LSTICK) ? primary_color : secondary_color, 0); @@ -773,15 +773,15 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col h = tex_items[obj_rstick].h; c_x = frame_x + rstick_ctr.x; c_y = frame_y + rstick_ctr.y; - float rstick_x = (float)state->axis[CONTROLLER_AXIS_RSTICK_X] / 32768.0; - float rstick_y = (float)state->axis[CONTROLLER_AXIS_RSTICK_Y] / 32768.0; + float rstick_x = (float)state->gp.axis[CONTROLLER_AXIS_RSTICK_X] / 32768.0; + float rstick_y = (float)state->gp.axis[CONTROLLER_AXIS_RSTICK_Y] / 32768.0; RenderDecal( g_decal_shader, (int)(c_x - w / 2.0f + 10.0f * rstick_x), (int)(c_y - h / 2.0f + 10.0f * rstick_y), w, h, tex_items[obj_rstick].x, tex_items[obj_rstick].y, w, h, - (state->buttons & CONTROLLER_BUTTON_RSTICK) ? secondary_color : + (state->gp.buttons & CONTROLLER_BUTTON_RSTICK) ? secondary_color : primary_color, - (state->buttons & CONTROLLER_BUTTON_RSTICK) ? primary_color : + (state->gp.buttons & CONTROLLER_BUTTON_RSTICK) ? primary_color : secondary_color, 0); @@ -789,19 +789,19 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col GL_ZERO); // Don't blend, just overwrite values in buffer // Render trigger bars - float ltrig = state->axis[CONTROLLER_AXIS_LTRIG] / 32767.0; - float rtrig = state->axis[CONTROLLER_AXIS_RTRIG] / 32767.0; + float ltrig = state->gp.axis[CONTROLLER_AXIS_LTRIG] / 32767.0; + float rtrig = state->gp.axis[CONTROLLER_AXIS_RTRIG] / 32767.0; const uint32_t animate_trigger_duration = 1000; if ((ltrig > 0) || (rtrig > 0)) { - state->animate_trigger_end = now + animate_trigger_duration; + state->gp.animate_trigger_end = now + animate_trigger_duration; rumble_l = fmax(rumble_l, ltrig); rumble_r = fmax(rumble_r, rtrig); } // Animate trigger alpha down after a period of inactivity alpha = 0x80; - if (state->animate_trigger_end > now) { - t = 1.0f - (float)(state->animate_trigger_end - now) / + if (state->gp.animate_trigger_end > now) { + t = 1.0f - (float)(state->gp.animate_trigger_end - now) / (float)animate_trigger_duration; float sin_wav = (1 - sin(M_PI * t / 2.0f)); alpha += fmin(sin_wav * 0x40, 0x80); @@ -816,8 +816,8 @@ static void RenderControllerS(float frame_x, float frame_y, uint32_t primary_col rtrig, primary_color + alpha, primary_color + 0xff); // Apply rumble updates - state->rumble_l = (int)(rumble_l * (float)0xffff); - state->rumble_r = (int)(rumble_r * (float)0xffff); + state->gp.rumble_l = (int)(rumble_l * (float)0xffff); + state->gp.rumble_r = (int)(rumble_r * (float)0xffff); glBindVertexArray(0); glUseProgram(0);