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