diff --git a/src/cfgfile.cpp b/src/cfgfile.cpp index f4e660c5..a0f64381 100644 --- a/src/cfgfile.cpp +++ b/src/cfgfile.cpp @@ -29,6 +29,8 @@ #include "disk.h" #include "sd-pandora/sound.h" +#include "SDL_keysym.h" + static int config_newfilesystem; static struct strlist *temp_lines; static struct zfile *default_file; @@ -385,6 +387,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, _T("synchronize_clock"), p->tod_hack); cfgfile_dwrite_str (f, _T("absolute_mouse"), abspointers[p->input_tablet]); + cfgfile_write (f, _T("key_for_menu"), _T("%d"), p->key_for_menu); + cfgfile_write (f, _T("key_for_input_switching"), _T("%d"), p->key_for_input_switching); + cfgfile_write (f, _T("gfx_framerate"), _T("%d"), p->gfx_framerate); cfgfile_write (f, _T("gfx_width"), _T("%d"), p->gfx_size.width); cfgfile_write (f, _T("gfx_height"), _T("%d"), p->gfx_size.height); @@ -730,6 +735,13 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_strval (option, value, _T("gfx_lores"), &p->gfx_resolution, lorestype2, 0) || cfgfile_strval (option, value, _T("absolute_mouse"), &p->input_tablet, abspointers, 0)) return 1; + + + if (cfgfile_intval (option, value, "key_for_menu", &p->key_for_menu, 1) + || cfgfile_intval (option, value, "key_for_input_switching", &p->key_for_input_switching, 1)); + return 1; + + if(cfgfile_yesno (option, value, _T("show_leds"), &vb)) { p->leds_on_screen = vb; @@ -1818,6 +1830,9 @@ void default_prefs (struct uae_prefs *p, int type) p->input_tablet = TABLET_OFF; + p->key_for_menu = SDLK_F12; + p->key_for_input_switching = SDLK_F11; + target_default_options (p, type); inputdevice_default_prefs (p); diff --git a/src/include/options.h b/src/include/options.h index 397478a5..397bfc64 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -159,6 +159,9 @@ struct uae_prefs { int pandora_autofireButton1; int pandora_jump; + int key_for_menu; + int key_for_input_switching; + /* input */ int input_joymouse_multiplier; diff --git a/src/inputdevice.cpp b/src/inputdevice.cpp index d1770150..56a93f85 100644 --- a/src/inputdevice.cpp +++ b/src/inputdevice.cpp @@ -428,6 +428,9 @@ void inputdevice_copyconfig (struct uae_prefs *src, struct uae_prefs *dst) dst->pandora_autofireButton1 = src->pandora_autofireButton1; dst->pandora_jump = src->pandora_jump; + dst->key_for_menu = src->key_for_menu; + dst->key_for_input_switching = src->key_for_input_switching; + inputdevice_updateconfig (dst); } diff --git a/src/od-pandora/gui/PanelInput.cpp b/src/od-pandora/gui/PanelInput.cpp index cfeeb83c..f49ebd7c 100644 --- a/src/od-pandora/gui/PanelInput.cpp +++ b/src/od-pandora/gui/PanelInput.cpp @@ -61,6 +61,11 @@ static gcn::Label *lblLeft; static gcn::UaeDropDown* cboLeft; static gcn::Label *lblRight; static gcn::UaeDropDown* cboRight; +static gcn::Label *lblKeyForMenu; +static gcn::UaeDropDown* KeyForMenu; +static gcn::Label *lblKeyForSwitching; +static gcn::UaeDropDown* KeyForSwitching; + class StringListModel : public gcn::ListModel @@ -109,6 +114,12 @@ const char *dPADValues[] = { "Joystick", "Keyboard", "Custom" }; #endif StringListModel dPADList(dPADValues, 3); + +static const int ControlKey_SDLKeyValues[] = { SDLK_F11 , SDLK_F12, SDLK_LALT , SDLK_LCTRL }; + +const char *ControlKeyValues[] = { "F11", "F12", "LeftAlt", "LeftCtrl" }; +StringListModel ControlKeyList(ControlKeyValues, 4); + const char *mappingValues[] = { "Joystick Right", "Joystick Left", "Joystick Down", "Joystick Up", "Joystick fire but.2", "Joystick fire but.1", "Mouse right button", "Mouse left button", @@ -207,6 +218,13 @@ class InputActionListener : public gcn::ActionListener else if (actionEvent.getSource() == cboRight) changed_prefs.pandora_custom_right = cboRight->getSelected() - 8; + + else if (actionEvent.getSource() == KeyForMenu) + changed_prefs.key_for_menu = ControlKey_SDLKeyValues[KeyForMenu->getSelected()] ; + + else if (actionEvent.getSource() == KeyForSwitching) + changed_prefs.key_for_input_switching = ControlKey_SDLKeyValues[KeyForSwitching->getSelected()] ; + } }; static InputActionListener* inputActionListener; @@ -371,6 +389,26 @@ void InitPanelInput(const struct _ConfigCategory& category) cboRight->setId("cboRight"); cboRight->addActionListener(inputActionListener); + lblKeyForMenu = new gcn::Label("Key for Menu:"); + lblKeyForMenu->setSize(100, LABEL_HEIGHT); + lblKeyForMenu->setAlignment(gcn::Graphics::RIGHT); + KeyForMenu = new gcn::UaeDropDown(&ControlKeyList); + KeyForMenu->setSize(150, DROPDOWN_HEIGHT); + KeyForMenu->setBaseColor(gui_baseCol); + KeyForMenu->setId("CKeyMenu"); + KeyForMenu->addActionListener(inputActionListener); + + + lblKeyForSwitching = new gcn::Label("Mouse/joy sw:"); + lblKeyForSwitching->setSize(100, LABEL_HEIGHT); + lblKeyForSwitching->setAlignment(gcn::Graphics::RIGHT); + KeyForSwitching = new gcn::UaeDropDown(&ControlKeyList); + KeyForSwitching->setSize(150, DROPDOWN_HEIGHT); + KeyForSwitching->setBaseColor(gui_baseCol); + KeyForSwitching->setId("CKeySwitching"); + KeyForSwitching->addActionListener(inputActionListener); + + int posY = DISTANCE_BORDER; category.panel->add(lblCtrlConfig, DISTANCE_BORDER, posY); category.panel->add(cboCtrlConfig, DISTANCE_BORDER + lblCtrlConfig->getWidth() + 8, posY); @@ -421,8 +459,16 @@ void InitPanelInput(const struct _ConfigCategory& category) category.panel->add(cboLeft, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY); category.panel->add(lblRight, 300, posY); category.panel->add(cboRight, 300 + lblRight->getWidth() + 8, posY); - posY += cboLeft->getHeight() + 4; + posY += cboLeft->getHeight() + DISTANCE_NEXT_Y; + category.panel->add(lblKeyForMenu, DISTANCE_BORDER, posY); + category.panel->add(KeyForMenu, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY); + posY += KeyForMenu->getHeight() + 4; + + category.panel->add(lblKeyForSwitching, DISTANCE_BORDER, posY); + category.panel->add(KeyForSwitching, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY); + posY += KeyForSwitching->getHeight() + DISTANCE_NEXT_Y; + RefreshPanelInput(); } @@ -467,6 +513,12 @@ void ExitPanelInput(void) delete lblRight; delete cboRight; + delete lblKeyForMenu; + delete KeyForMenu; + delete lblKeyForSwitching; + delete KeyForSwitching; + + delete inputActionListener; } @@ -516,4 +568,21 @@ void RefreshPanelInput(void) cboDown->setSelected(changed_prefs.pandora_custom_down + 8); cboLeft->setSelected(changed_prefs.pandora_custom_left + 8); cboRight->setSelected(changed_prefs.pandora_custom_right + 8); + + for(i=0; i<4; ++i) + { + if(changed_prefs.key_for_menu == ControlKey_SDLKeyValues[i]) + { + KeyForMenu->setSelected(i); + break; + } + } + for(i=0; i<4; ++i) + { + if(changed_prefs.key_for_input_switching == ControlKey_SDLKeyValues[i]) + { + KeyForSwitching->setSelected(i); + break; + } + } } diff --git a/src/od-pandora/gui/main_window.cpp b/src/od-pandora/gui/main_window.cpp index d5544259..45cb9212 100644 --- a/src/od-pandora/gui/main_window.cpp +++ b/src/od-pandora/gui/main_window.cpp @@ -188,7 +188,26 @@ namespace sdl { gcn::FocusHandler* focusHdl; gcn::Widget* activeWidget; - + + + if (event.key.keysym.sym == currprefs.key_for_menu) + { + if(emulating && widgets::cmdStart->isEnabled()) + { + //------------------------------------------------ + // Continue emulation + //------------------------------------------------ + gui_running = false; + } + else + { + //------------------------------------------------ + // First start of emulator -> reset Amiga + //------------------------------------------------ + uae_reset(0); + gui_running = false; + } + } else switch(event.key.keysym.sym) { case SDLK_q: @@ -209,27 +228,9 @@ namespace sdl //------------------------------------------------- // Reset Amiga //------------------------------------------------- - uae_reset(1); - gui_running = false; - break; - - case SDLK_F12: - if(emulating && widgets::cmdStart->isEnabled()) - { - //------------------------------------------------ - // Continue emulation - //------------------------------------------------ - gui_running = false; - } - else - { - //------------------------------------------------ - // First start of emulator -> reset Amiga - //------------------------------------------------ - uae_reset(0); - gui_running = false; - } - break; + uae_reset(1); + gui_running = false; + break; case SDLK_PAGEDOWN: case SDLK_HOME: diff --git a/src/od-pandora/joystick.cpp b/src/od-pandora/joystick.cpp index 8557692d..787b3f9e 100644 --- a/src/od-pandora/joystick.cpp +++ b/src/od-pandora/joystick.cpp @@ -41,9 +41,10 @@ static int delay=0; #endif -static int nr_joysticks; +int nr_joysticks; +const char* JoystickName[4]; -static SDL_Joystick *uae4all_joy0, *uae4all_joy1; +static SDL_Joystick *uae4all_joy0 = 0, *uae4all_joy1 = 0 , *uae4all_joy2 = 0, *uae4all_joy3 = 0; void read_joystick(int nr, unsigned int *dir, int *button) { @@ -293,17 +294,32 @@ void init_joystick(void) if (nr_joysticks > 0) { uae4all_joy0 = SDL_JoystickOpen (0); - printf("Joystick0 : %s\n",SDL_JoystickName(0)); + JoystickName[0] = SDL_JoystickName(0); + printf("Joystick0 : %s\n",JoystickName[0]); printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy0),SDL_JoystickNumAxes(uae4all_joy0),SDL_JoystickNumHats(uae4all_joy0)); } if (nr_joysticks > 1) { uae4all_joy1 = SDL_JoystickOpen (1); - printf("Joystick1 : %s\n",SDL_JoystickName(1)); + JoystickName[1] = SDL_JoystickName(1); + printf("Joystick1 : %s\n",JoystickName[1]); printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy1),SDL_JoystickNumAxes(uae4all_joy1),SDL_JoystickNumHats(uae4all_joy1)); } - else - uae4all_joy1 = NULL; + if (nr_joysticks > 2) + { + uae4all_joy2 = SDL_JoystickOpen (2); + JoystickName[2] = SDL_JoystickName(2); + printf("Joystick2 : %s\n",JoystickName[2]); + printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy2),SDL_JoystickNumAxes(uae4all_joy2),SDL_JoystickNumHats(uae4all_joy2)); + } + if (nr_joysticks > 3) + { + uae4all_joy3 = SDL_JoystickOpen (3); + JoystickName[3] = SDL_JoystickName(3); + printf("Joystick3 : %s\n",JoystickName[3]); + printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy3),SDL_JoystickNumAxes(uae4all_joy3),SDL_JoystickNumHats(uae4all_joy3)); + } + } void close_joystick(void) @@ -312,4 +328,8 @@ void close_joystick(void) SDL_JoystickClose (uae4all_joy0); if (nr_joysticks > 1) SDL_JoystickClose (uae4all_joy1); + if (nr_joysticks > 2) + SDL_JoystickClose (uae4all_joy2); + if (nr_joysticks > 3) + SDL_JoystickClose (uae4all_joy3); } diff --git a/src/od-pandora/pandora.cpp b/src/od-pandora/pandora.cpp index 14e23022..4c554b3a 100644 --- a/src/od-pandora/pandora.cpp +++ b/src/od-pandora/pandora.cpp @@ -912,7 +912,7 @@ void handle_events (void) } } #endif - if (rEvent.key.keysym.sym==SDLK_F11) + if (rEvent.key.keysym.sym==currprefs.key_for_input_switching) { // state moves thus: // joystick mode @@ -1012,7 +1012,7 @@ void handle_events (void) buttonstate[2] = 0; } - if (rEvent.key.keysym.sym==SDLK_F11) + if (rEvent.key.keysym.sym==currprefs.key_for_input_switching) { show_inputmode = 0; } diff --git a/src/od-pandora/pandora_gui.cpp b/src/od-pandora/pandora_gui.cpp index 66253f85..0377c2de 100644 --- a/src/od-pandora/pandora_gui.cpp +++ b/src/od-pandora/pandora_gui.cpp @@ -608,7 +608,7 @@ void gui_handle_events (void) dpadRight = 1; else dpadRight = 0; #endif - if(keystate[SDLK_F12]) + if(keystate[currprefs.key_for_menu]) goMenu(); if(uae4all_keystate[AK_CTRL] && uae4all_keystate[AK_LAMI] && uae4all_keystate[AK_RAMI]) uae_reset(0);