- [NEW] Es pot accedir al dialeg de configuracio dels joysticks des del menú
This commit is contained in:
18
main.cpp
18
main.cpp
@@ -36,6 +36,11 @@ namespace actions
|
||||
zxscreen::refresh(dt);
|
||||
}
|
||||
|
||||
void exitButNotContinue()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
int fastload(int value)
|
||||
{
|
||||
zx_tape::toggleOption(ZXTAPE_OPTION_FAST_LOAD);
|
||||
@@ -107,6 +112,13 @@ namespace actions
|
||||
zx_system::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int configureJoysticks(int value)
|
||||
{
|
||||
ui::setDialog(dialogs::joysticks::show);
|
||||
ui::menu::exitButNotContinue();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void init_menu()
|
||||
@@ -144,6 +156,8 @@ void init_menu()
|
||||
menu = ui::menu::addsubmenu("EMULATION");
|
||||
ui::menu::addbooloption(menu, "STOP ON INVALID OP", z80::getOption(Z80_OPTION_STOP_ON_INVALID), actions::decZoom);
|
||||
ui::menu::addoption(menu, "SHOW ANALYZER", actions::showAnalyzer);
|
||||
ui::menu::addoption(menu, "CONFIGURE JOYSTICKS", actions::configureJoysticks);
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -178,9 +192,7 @@ int main(int argc, char *argv[])
|
||||
if (e.type == SDL_JOYDEVICEADDED) {
|
||||
const uint8_t index = gamepad::add(e.jdevice.which, GAMEPAD_TYPE_ANY);
|
||||
printf("JOYSTICK CONECTAT: %i\n", e.jdevice.which);
|
||||
//if (!first_time)
|
||||
dialogs::joysticks::init(index);
|
||||
// [TODO] Mostrar dialeg de triar tipus de joystick
|
||||
if (!first_time) dialogs::joysticks::init(index);
|
||||
}
|
||||
if (e.type == SDL_JOYDEVICEREMOVED) {
|
||||
gamepad::remove(e.jdevice.which);
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace ui
|
||||
std::vector<menu_t> menus;
|
||||
int visible_menu = -1;
|
||||
int menu_x = 0;
|
||||
bool do_not_exit = false;
|
||||
|
||||
void init()
|
||||
{
|
||||
@@ -81,7 +82,8 @@ namespace ui
|
||||
if (ui::getClicked())
|
||||
{
|
||||
if (option.callback) option.value = option.callback(option.value);
|
||||
if (exit_callback) exit_callback();
|
||||
if (exit_callback && !do_not_exit) exit_callback();
|
||||
do_not_exit = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -103,6 +105,11 @@ namespace ui
|
||||
exit_callback = callback;
|
||||
}
|
||||
|
||||
void exitButNotContinue()
|
||||
{
|
||||
do_not_exit = true;
|
||||
}
|
||||
|
||||
const int addsubmenu(const char *label)
|
||||
{
|
||||
menu_t m;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ui
|
||||
void init();
|
||||
void show();
|
||||
void setexitcallback(void(*callback)(void));
|
||||
void exitButNotContinue();
|
||||
const int addsubmenu(const char *label);
|
||||
void addoption(int menu, const char *label, int(*callback)(int));
|
||||
void addbooloption(int menu, const char *label, bool default_value, int(*callback)(int));
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace dialogs
|
||||
|
||||
ui::panel(38,17,20,8,"JOYSTICKS:");
|
||||
const int num_gamepads = gamepad::getNumGamepads();
|
||||
if (selected>=num_gamepads) selected = 0;
|
||||
for (int i=0; i<num_gamepads; ++i)
|
||||
{
|
||||
char name[] = "JOYSTICK 0";
|
||||
|
||||
Reference in New Issue
Block a user