Add support for button glyph display

This adds a function that converts an action (such as interacting
in-game) to the corresponding button text ("ENTER", "E") or button
glyph (PlayStation triangle, Steam Deck Y, etc). This function
currently only gives the existing ENTERs or Es, because I don't know
how best to detect controller usage, or whether the game is running on
a Steam Deck, or what buttons need to be displayed there. Still, it
should now be really easy to adapt the rendering of keyboard keys to
consoles, controllers, or rebound keys.

To identify the actions that currently need to be displayed, this
commit also adds the initial enums for action sets as described by
Ethan in a comment in #834 (Jan 18, 2022).
This commit is contained in:
Dav999-v
2023-03-18 22:30:16 +01:00
committed by Misa Elizabeth Kai
parent 5180e430a2
commit 3354a1a352
10 changed files with 332 additions and 39 deletions

View File

@@ -43,7 +43,7 @@
* The valid types are:
* - int Signed integer
* - str const char*
* - but Controller button icon
* - but Controller button icon: vformat_button(actionset, action)
*
* Special case: if an argument name is a single underscore (_), it matches
* any name not found earlier in the list. This should normally not be needed.
@@ -75,6 +75,8 @@
#include <stdarg.h>
#include <stddef.h>
#include "ActionSets.h"
#ifdef __cplusplus
extern "C"
{
@@ -83,6 +85,9 @@ extern "C"
typedef void (*format_callback)(void* userdata, const char* string, size_t bytes);
int vformat_button(ActionSet actionset, int action);
void vformat_cb_valist(
format_callback callback,
void* userdata,