Skip to content

Commit

Permalink
Brought in some improvements from the Controller S PR
Browse files Browse the repository at this point in the history
  • Loading branch information
faha223 committed Dec 6, 2024
1 parent 2e03e39 commit a072f4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
22 changes: 5 additions & 17 deletions ui/xemu-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,19 @@ static int sdl_sbc_kbd_scancode_map[56];
static const char *get_bound_driver(int port)
{
assert(port >= 0 && port <= 3);
const char *driver = NULL;
switch (port) {
case 0:
driver = g_config.input.bindings.port1_driver;
break;
case 1:
driver = g_config.input.bindings.port2_driver;
break;
case 2:
driver = g_config.input.bindings.port3_driver;
break;
case 3:
driver = g_config.input.bindings.port4_driver;
break;
}
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; // Shouldn't be possible
return DRIVER_DUKE;
if (strlen(driver) == 0)
return DRIVER_DUKE;
if (strcmp(driver, DRIVER_DUKE) == 0)
return DRIVER_DUKE;
if (strcmp(driver, DRIVER_STEEL_BATTALION) == 0)
return DRIVER_STEEL_BATTALION;

// Shouldn't be possible
return DRIVER_DUKE;
}

Expand Down
16 changes: 8 additions & 8 deletions ui/xui/gl-helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "ui/shader/xemu-logo-frag.h"

Fbo *controller_fbo, *xmu_fbo, *logo_fbo;
GLuint g_controller_tex, g_sb_controller_tex, g_logo_tex, g_icon_tex, g_xmu_tex;
GLuint g_controller_duke_tex, g_sb_controller_tex, g_logo_tex, g_icon_tex, g_xmu_tex;

enum class ShaderType {
Blit,
Expand Down Expand Up @@ -465,7 +465,7 @@ enum sb_tex_item_names {
void InitCustomRendering(void)
{
glActiveTexture(GL_TEXTURE0);
g_controller_tex =
g_controller_duke_tex =
LoadTextureFromMemory(controller_mask_data, controller_mask_size);
g_sb_controller_tex =
LoadTextureFromMemory(sb_controller_mask_data, sb_controller_mask_size);
Expand All @@ -492,7 +492,7 @@ static void RenderMeter(DecalShader *s, float x, float y, float width,
RenderDecal(s, x, y, width * p, height, 0, 0, 1, 1, 0, 0, color_fg);
}

static void RenderController_Duke(float frame_x, float frame_y, uint32_t primary_color,
static void RenderDukeController(float frame_x, float frame_y, uint32_t primary_color,
uint32_t secondary_color, ControllerState *state)
{
// Location within the controller texture of masked button locations,
Expand Down Expand Up @@ -522,7 +522,7 @@ static void RenderController_Duke(float frame_x, float frame_y, uint32_t primary
glUseProgram(g_decal_shader->prog);
glBindVertexArray(g_decal_shader->vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, g_controller_tex);
glBindTexture(GL_TEXTURE_2D, g_controller_duke_tex);

// Add a 5 pixel space around the controller so we can wiggle the controller
// around to visualize rumble in action
Expand Down Expand Up @@ -651,7 +651,7 @@ static void RenderController_Duke(float frame_x, float frame_y, uint32_t primary
glUseProgram(0);
}

void RenderController_SB(float frame_x, float frame_y, uint32_t primary_color,
void RenderSteelBattalionController(float frame_x, float frame_y, uint32_t primary_color,
uint32_t secondary_color, ControllerState *state)
{
// Location within the controller texture of masked button locations,
Expand Down Expand Up @@ -947,10 +947,10 @@ void RenderController(float frame_x, float frame_y, uint32_t primary_color,
uint32_t secondary_color, ControllerState *state)
{
if (strcmp(bound_drivers[state->bound], DRIVER_STEEL_BATTALION) == 0)
RenderController_SB(frame_x, frame_y, primary_color, secondary_color,
RenderSteelBattalionController(frame_x, frame_y, primary_color, secondary_color,
state);
else if (strcmp(bound_drivers[state->bound], DRIVER_DUKE) == 0)
RenderController_Duke(frame_x, frame_y, primary_color, secondary_color,
RenderDukeController(frame_x, frame_y, primary_color, secondary_color,
state);
}

Expand All @@ -960,7 +960,7 @@ void RenderControllerPort(float frame_x, float frame_y, int i,
glUseProgram(g_decal_shader->prog);
glBindVertexArray(g_decal_shader->vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, g_controller_tex);
glBindTexture(GL_TEXTURE_2D, g_controller_duke_tex);
glBlendFunc(GL_ONE, GL_ZERO);

// Render port socket
Expand Down

0 comments on commit a072f4d

Please sign in to comment.