- [NEW] Dialeg per a configurar els joysticks

This commit is contained in:
2025-08-16 10:09:42 +02:00
parent 864c6b929d
commit 8201d51668
9 changed files with 170 additions and 38 deletions

72
zx_dialog_joystick.cpp Normal file
View File

@@ -0,0 +1,72 @@
#include "zx_dialog_joystick.h"
#include "ui.h"
#include "z80debug.h"
#include "gamepad.h"
namespace dialogs
{
namespace joysticks
{
int32_t selected = 0;
void init(int32_t index)
{
if (index != -1) selected = index;
ui::setDialog(dialogs::joysticks::show);
z80debug::pause();
}
void show()
{
uint8_t back_color = COLOR_DARK;
uint8_t front_color = COLOR_WHITE;
ui::setoffset(0,0);
ui::printrect(36, 15, 46, 12, COLOR_DARK);
ui::panel(36,15,46,12,"CONFIGURE JOYSTICKS:");
if (ui::mouseInside(34,9,7,1)) {
back_color = COLOR_WHITE;
front_color = COLOR_BLACK;
if (ui::getClicked()) { ui::setDialog(nullptr); z80debug::cont(); }
}
ui::printrect(34, 9, 7, 1, back_color);
ui::printtxt(35,9,"CLOSE", front_color);
ui::panel(38,17,20,8,"JOYSTICKS:");
const int num_gamepads = gamepad::getNumGamepads();
for (int i=0; i<num_gamepads; ++i)
{
char name[] = "JOYSTICK 0";
name[9] = 48+i;
if (selected==i) {
ui::printrect(0,i,18,1, COLOR_WHITE);
ui::printtxt(0,i,name, COLOR_BLACK);
} else {
ui::printtxt(0,i,name, COLOR_WHITE);
}
}
ui::panel(60,17,20,8,"TYPE:");
const int selected_type = gamepad::getGamepadType(selected);
const char* types[5] = {"SINCLAIR 1", "SINCLAIR 2", "KEMPSTON", "FULLER", "CUSTOM"};
for (int i=0;i<5;++i)
{
back_color = COLOR_DARK;
front_color = COLOR_WHITE;
if (ui::mouseInside(0,i,18,1)) {
back_color = COLOR_BLACK;
if (ui::getClicked()) {
gamepad::setGamepadType(selected, i+1);
}
}
if (i==selected_type-1) {
back_color = COLOR_WHITE;
front_color = COLOR_BLACK;
}
ui::printrect(0,i,18,1, back_color);
ui::printtxt(0,i,types[i],front_color);
}
}
}
}