Skip to content

Commit 5a7a8a7

Browse files
committed
rg_gui: Changed rg_keyboard_map_t to match #220
1 parent 1cb23a3 commit 5a7a8a7

5 files changed

Lines changed: 20 additions & 24 deletions

File tree

components/retro-go/rg_gui.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ char *rg_gui_input_str(const char *title, const char *message, const char *defau
10541054
return default_value ? strdup(default_value) : NULL;
10551055
}
10561056

1057-
void rg_gui_draw_keyboard(const rg_keyboard_map_t *map, size_t cursor)
1057+
void rg_gui_draw_keyboard(const rg_keyboard_layout_t *map, size_t cursor)
10581058
{
10591059
RG_ASSERT_ARG(map);
10601060

@@ -1072,9 +1072,9 @@ void rg_gui_draw_keyboard(const rg_keyboard_map_t *map, size_t cursor)
10721072
{
10731073
int x = x_pos + 8 + (i % map->columns) * 16;
10741074
int y = y_pos + 8 + (i / map->columns) * 16;
1075-
if (!map->data[i])
1075+
if (!map->layout[i])
10761076
continue;
1077-
buf[0] = map->data[i];
1077+
buf[0] = map->layout[i];
10781078
rg_gui_draw_text(x + 1, y + 1, 14, buf, C_BLACK, i == cursor ? C_CYAN : C_IVORY, RG_TEXT_ALIGN_CENTER);
10791079
}
10801080
}

components/retro-go/rg_gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void rg_gui_draw_dialog(const char *header, const rg_gui_option_t *options, int
122122
void rg_gui_draw_image(int x_pos, int y_pos, int width, int height, bool resample, const rg_image_t *img);
123123
void rg_gui_draw_hourglass(void); // This should be moved to system or display...
124124
void rg_gui_draw_status_bars(void);
125-
void rg_gui_draw_keyboard(const rg_keyboard_map_t *map, size_t cursor);
125+
void rg_gui_draw_keyboard(const rg_keyboard_layout_t *map, size_t cursor);
126126
void rg_gui_draw_message(const char *format, ...);
127127

128128
intptr_t rg_gui_dialog(const char *title, const rg_gui_option_t *options, int selected_index);

components/retro-go/rg_input.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,16 @@ const char *rg_input_get_key_mapping(rg_key_t key)
432432
return NULL;
433433
}
434434

435-
const rg_keyboard_map_t virtual_map1 = {
435+
const rg_keyboard_layout_t virtual_map1 = {
436+
.layout = "0123456789"
437+
"ABCDEFGHIJ"
438+
"KLMNOPQRST"
439+
"UVWXYZ ,. ",
436440
.columns = 10,
437441
.rows = 4,
438-
.data = {
439-
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
440-
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
441-
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
442-
'U', 'V', 'W', 'X', 'Y', 'Z', ' ', ',', '.', ' ',
443-
}
444442
};
445443

446-
int rg_input_read_keyboard(const rg_keyboard_map_t *map)
444+
int rg_input_read_keyboard(const rg_keyboard_layout_t *map)
447445
{
448446
int cursor = -1;
449447
int count = map->columns * map->rows;
@@ -459,7 +457,7 @@ int rg_input_read_keyboard(const rg_keyboard_map_t *map)
459457
int prev_cursor = cursor;
460458

461459
if (joystick & RG_KEY_A)
462-
return map->data[cursor];
460+
return map->layout[cursor];
463461
if (joystick & RG_KEY_B)
464462
break;
465463

components/retro-go/rg_input.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ typedef struct
9090

9191
typedef struct
9292
{
93-
size_t columns, rows;
94-
char data[];
95-
} rg_keyboard_map_t;
93+
const char *layout;
94+
size_t columns;
95+
size_t rows;
96+
bool is_upper;
97+
bool is_symbols;
98+
} rg_keyboard_layout_t;
9699

97100
void rg_input_init(void);
98101
void rg_input_deinit(void);
@@ -101,7 +104,7 @@ bool rg_input_wait_for_key(rg_key_t mask, bool pressed, int timeout_ms);
101104
const char *rg_input_get_key_name(rg_key_t key);
102105
const char *rg_input_get_key_mapping(rg_key_t key);
103106
uint32_t rg_input_read_gamepad(void);
104-
int rg_input_read_keyboard(const rg_keyboard_map_t *map);
107+
int rg_input_read_keyboard(const rg_keyboard_layout_t *map);
105108
rg_battery_t rg_input_read_battery(void);
106109
bool rg_input_read_gamepad_raw(uint32_t *out);
107110
bool rg_input_read_keyboard_raw(int *out);

retro-core/main/main_sms.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ static rg_app_t *app;
66
static rg_surface_t *updates[2];
77
static rg_surface_t *currentUpdate;
88

9-
const rg_keyboard_map_t coleco_keyboard = {
9+
const rg_keyboard_layout_t coleco_keyboard = {
10+
.layout = "123" "456" "789" "*0#",
1011
.columns = 3,
1112
.rows = 4,
12-
.data = {
13-
'1', '2', '3',
14-
'4', '5', '6',
15-
'7', '8', '9',
16-
'*', '0', '#',
17-
},
1813
};
1914

2015
static const char *SETTING_PALETTE = "palette";

0 commit comments

Comments
 (0)