Squashed commit of the following:

commit cdfb6f8bd07e1e44850167dcfe4bbe393d6d40bf
Author: itsmattkc <[email protected]>
Date:   Sun Dec 28 10:36:34 2025 -0800

    add user setting for swapping AB/XY

commit b230c8e86baae91f733e67f97494ee18dbcb85d0
Author: itsmattkc <[email protected]>
Date:   Sun Dec 28 10:25:34 2025 -0800

    start impl
This commit is contained in:
itsmattkc
2025-12-28 10:44:10 -08:00
parent b116d6cabc
commit a73632aca6
6 changed files with 57 additions and 17 deletions
+16 -11
View File
@@ -41,16 +41,16 @@ void vpi_config_save()
}
char buf[0x100];
xmlTextWriterStartDocument(writer, 0, 0, 0);
xmlTextWriterSetIndent(writer, 1);
xmlTextWriterSetIndentString(writer, BAD_CAST "\t");
xmlTextWriterStartElement(writer, BAD_CAST "vanilla");
xmlTextWriterStartElement(writer, BAD_CAST "consoles");
for (uint8_t i = 0; i < vpi_config.connected_console_count; i++) {
vpi_console_entry_t *entry = &vpi_config.connected_console_entries[i];
xmlTextWriterStartElement(writer, BAD_CAST "console");
@@ -65,17 +65,20 @@ void vpi_config_save()
sprintf(buf, "%X", vpi_config.server_address);
xmlTextWriterWriteElement(writer, BAD_CAST "server", BAD_CAST buf);
xmlTextWriterWriteElement(writer, BAD_CAST "wireless", BAD_CAST vpi_config.wireless_interface);
sprintf(buf, "%i", vpi_config.connection_setup);
xmlTextWriterWriteElement(writer, BAD_CAST "connectionsetup", BAD_CAST buf);
sprintf(buf, "%i", vpi_config.region);
xmlTextWriterWriteElement(writer, BAD_CAST "region", BAD_CAST buf);
sprintf(buf, "%i", vpi_config.swap_abxy);
xmlTextWriterWriteElement(writer, BAD_CAST "swapabxy", BAD_CAST buf);
xmlTextWriterEndElement(writer); // vanilla
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
@@ -87,7 +90,7 @@ void vpi_config_init()
// Set defaults
memset(&vpi_config, 0, sizeof(vpi_config));
vpi_config.server_address = VANILLA_ADDRESS_LOCAL;
vpi_config.region = VANILLA_REGION_AMERICA;
@@ -144,12 +147,14 @@ void vpi_config_init()
vpi_config.connection_setup = atoi((const char *) child->children->content);
} else if (!strcmp((const char *) child->name, "region")) {
vpi_config.region = atoi((const char *) child->children->content);
} else if (!strcmp((const char *) child->name, "swapabxy")) {
vpi_config.swap_abxy = atoi((const char *) child->children->content);
}
}
child = child->next;
}
}
xmlFreeDoc(doc);
}
}
@@ -177,7 +182,7 @@ int vpi_config_add_console(vpi_console_entry_t *entry)
vpi_config.connected_console_count++;
if (old_entries)
free(old_entries);
vpi_config_save();
return index;
@@ -200,14 +205,14 @@ void vpi_config_remove_console(uint8_t index)
if (vpi_config.connected_console_count != 1) {
vpi_config.connected_console_entries = malloc((vpi_config.connected_console_count - 1) * sizeof(vpi_console_entry_t));
// Copy first half
memcpy(vpi_config.connected_console_entries, old_entries, index * sizeof(vpi_console_entry_t));
// Copy second half
memcpy(vpi_config.connected_console_entries + index, old_entries + index + 1, (vpi_config.connected_console_count - index - 1) * sizeof(vpi_console_entry_t));
}
vpi_config.connected_console_count--;
free(old_entries);
+1
View File
@@ -19,6 +19,7 @@ typedef struct {
char wireless_interface[VPI_CONSOLE_MAX_NAME];
int connection_setup;
int region;
int swap_abxy;
} vpi_config_t;
extern vpi_config_t vpi_config;
+2 -1
View File
@@ -51,7 +51,8 @@ static const char *lang_str[__VPI_LANG_T_COUNT] = {
"This option will install a Polkit rule that will allow Vanilla's backend to run as root without password entry.\n\nThere are inherent risks to bypassing security systems. Only enable this if you are willing to accept those risks.\n\nNOTE: If you are using the Steam Deck, this will also disable read-only access to your system partition.",
"I acknowledge",
"Enable Root Password Skip",
"Disable Root Password Skip"
"Disable Root Password Skip",
"Swap AB/XY buttons",
};
const char *lang(vpi_lang_t id)
+1
View File
@@ -53,6 +53,7 @@ typedef enum {
VPI_LANG_AUTH_WARNING_ACKNOWLEDGE,
VPI_LANG_ENABLE_PASSWORD_SKIP,
VPI_LANG_DISABLE_PASSWORD_SKIP,
VPI_LANG_SWAP_ABXY_BUTTONS,
__VPI_LANG_T_COUNT
} vpi_lang_t;
+26 -5
View File
@@ -1,16 +1,27 @@
#include "menu_gamepad.h"
#include "config.h"
#include "lang.h"
#include "menu/menu_common.h"
#include "menu/menu_settings.h"
#include "ui/ui_anim.h"
#define MAIN_MENU_ENTRIES 3
static void return_to_settings(vui_context_t *vui, int btn, void *v)
{
int layer = (intptr_t) v;
vui_transition_fade_layer_out(vui, layer, vpi_menu_settings, 0);
}
void vpi_menu_toggle_swap_abxy(vui_context_t *vui, int btn, void *v)
{
vpi_config.swap_abxy = !vpi_config.swap_abxy;
vpi_config_save();
vui_button_update_checked(vui, btn, vpi_config.swap_abxy);
}
void vpi_menu_gamepad(vui_context_t *vui, void *v)
{
vui_reset(vui);
@@ -20,11 +31,21 @@ void vpi_menu_gamepad(vui_context_t *vui, void *v)
int scrw, scrh;
vui_get_screen_size(vui, &scrw, &scrh);
int img_w = scrw / 2;
int img_h = scrh / 2;
vui_image_create(vui, scrw/2-img_w/2, scrh/2-img_h/2 + 50, img_w, img_h, "gamepad.svg", layer);
// int img_w = scrw / 2;
// int img_h = scrh / 2;
// vui_image_create(vui, scrw/2-img_w/2, scrh/2-img_h/2 + 50, img_w, img_h, "gamepad.svg", layer);
int tmp_lbl = vui_label_create(vui, scrw/4, scrh/8, scrw/2, scrh, "Controller remapping is not yet implemented in this version, please come back soon...", vui_color_create(0.25f,0.25f,0.25f,1), VUI_FONT_SIZE_SMALL, layer);
// int tmp_lbl = vui_label_create(vui, scrw/4, scrh/8, scrw/2, scrh, "Controller remapping is not yet implemented in this version, please come back soon...", vui_color_create(0.25f,0.25f,0.25f,1), VUI_FONT_SIZE_SMALL, layer);
int SCREEN_WIDTH, SCREEN_HEIGHT;
vui_get_screen_size(vui, &SCREEN_WIDTH, &SCREEN_HEIGHT);
int list_item_width = SCREEN_WIDTH - BTN_SZ - BTN_SZ;
int list_item_height = (SCREEN_HEIGHT - BTN_SZ - BTN_SZ) / MAIN_MENU_ENTRIES;
int swap_abxy_button = vui_button_create(vui, BTN_SZ, BTN_SZ + list_item_height * 0, list_item_width, list_item_height, lang(VPI_LANG_SWAP_ABXY_BUTTONS), NULL, VUI_BUTTON_STYLE_LIST, layer, vpi_menu_toggle_swap_abxy, 0);
vui_button_update_checkable(vui, swap_abxy_button, 1);
vui_button_update_checked(vui, swap_abxy_button, vpi_config.swap_abxy);
// Back button
vpi_menu_create_back_button(vui, layer, return_to_settings, (void *) (intptr_t) layer);
@@ -33,4 +54,4 @@ void vpi_menu_gamepad(vui_context_t *vui, void *v)
// vui_button_create(vui, scrw-BTN_SZ, 0, BTN_SZ, BTN_SZ, lang(VPI_LANG_MORE), 0, VUI_BUTTON_STYLE_CORNER, layer, return_to_settings, (void *) (intptr_t) layer);
vui_transition_fade_layer_in(vui, layer, 0, 0);
}
}
+11
View File
@@ -24,6 +24,7 @@
#include "ui_sdl_drm.h"
#endif
#include "config.h"
#include "menu/menu.h"
#include "menu/menu_game.h"
#include "platform.h"
@@ -418,6 +419,16 @@ int vui_sdl_event_thread(void *data)
if (ev.type == SDL_CONTROLLERBUTTONDOWN)
vpi_menu_action(vui, (vpi_extra_action_t) vanilla_btn);
} else if (vanilla_btn != -1) {
// Handle ABXY swap
if (vpi_config.swap_abxy) {
switch (vanilla_btn) {
case VANILLA_BTN_A: vanilla_btn = VANILLA_BTN_B; break;
case VANILLA_BTN_B: vanilla_btn = VANILLA_BTN_A; break;
case VANILLA_BTN_X: vanilla_btn = VANILLA_BTN_Y; break;
case VANILLA_BTN_Y: vanilla_btn = VANILLA_BTN_X; break;
}
}
if (vui->game_mode) {
vanilla_set_button(vanilla_btn, ev.type == SDL_CONTROLLERBUTTONDOWN ? INT16_MAX : 0);
} else if (ev.type == SDL_CONTROLLERBUTTONDOWN) {