New feature: Full Screen mode toggle (when running under X11), configurable button from Misc Panel.
Added Action Replay button, configurable from Misc Panel. Filtered out repeated key events, so they work as toggles properly now.
This commit is contained in:
parent
75f91db975
commit
cd3998cc4f
8 changed files with 170 additions and 21 deletions
|
@ -421,6 +421,8 @@ struct uae_prefs {
|
|||
|
||||
TCHAR open_gui[256];
|
||||
TCHAR quit_amiberry[256];
|
||||
TCHAR action_replay[256];
|
||||
TCHAR fullscreen_toggle[256];
|
||||
|
||||
/* input */
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "native2amiga_api.h"
|
||||
#include "sounddep/sound.h"
|
||||
#include "disk.h"
|
||||
#include "amiberry_gfx.h"
|
||||
|
||||
#define COMPA_RESERVED_FLAGS (ID_FLAG_INVERT)
|
||||
|
||||
|
@ -2646,6 +2647,9 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s)
|
|||
// screenshot(1, 1);
|
||||
// }
|
||||
// break;
|
||||
case AKS_TOGGLEWINDOWEDFULLSCREEN:
|
||||
toggle_fullscreen();
|
||||
break;
|
||||
#ifdef ACTION_REPLAY
|
||||
case AKS_FREEZEBUTTON:
|
||||
action_replay_freeze();
|
||||
|
@ -5704,6 +5708,8 @@ void inputdevice_copyconfig(struct uae_prefs *src, struct uae_prefs *dst)
|
|||
#ifdef AMIBERRY
|
||||
strcpy(dst->open_gui, src->open_gui);
|
||||
strcpy(dst->quit_amiberry, src->quit_amiberry);
|
||||
strcpy(dst->action_replay, src->action_replay);
|
||||
strcpy(dst->fullscreen_toggle, src->fullscreen_toggle);
|
||||
dst->use_retroarch_quit = src->use_retroarch_quit;
|
||||
dst->use_retroarch_menu = src->use_retroarch_menu;
|
||||
dst->use_retroarch_reset = src->use_retroarch_reset;
|
||||
|
|
|
@ -249,6 +249,8 @@ void target_default_options(struct uae_prefs* p, int type)
|
|||
|
||||
_tcscpy(p->open_gui, "F12");
|
||||
_tcscpy(p->quit_amiberry, "");
|
||||
_tcscpy(p->action_replay, "Pause");
|
||||
_tcscpy(p->fullscreen_toggle, "");
|
||||
|
||||
p->use_retroarch_quit = true;
|
||||
p->use_retroarch_menu = true;
|
||||
|
@ -317,6 +319,8 @@ void target_save_options(struct zfile* f, struct uae_prefs* p)
|
|||
|
||||
cfgfile_dwrite_str(f, _T("amiberry.open_gui"), p->open_gui);
|
||||
cfgfile_dwrite_str(f, _T("amiberry.quit_amiberry"), p->quit_amiberry);
|
||||
cfgfile_dwrite_str(f, _T("amiberry.action_replay"), p->action_replay);
|
||||
cfgfile_dwrite_str(f, _T("amiberry.fullscreen_toggle"), p->fullscreen_toggle);
|
||||
|
||||
cfgfile_write_bool(f, _T("amiberry.use_retroarch_quit"), p->use_retroarch_quit);
|
||||
cfgfile_write_bool(f, _T("amiberry.use_retroarch_menu"), p->use_retroarch_menu);
|
||||
|
@ -429,6 +433,10 @@ int target_parse_option(struct uae_prefs* p, const char* option, const char* val
|
|||
return 1;
|
||||
if (cfgfile_string(option, value, "quit_amiberry", p->quit_amiberry, sizeof p->quit_amiberry))
|
||||
return 1;
|
||||
if (cfgfile_string(option, value, "action_replay", p->action_replay, sizeof p->action_replay))
|
||||
return 1;
|
||||
if (cfgfile_string(option, value, "fullscreen_toggle", p->fullscreen_toggle, sizeof p->fullscreen_toggle))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -970,6 +978,24 @@ int handle_msgpump()
|
|||
#endif
|
||||
}
|
||||
|
||||
// The default value for Action Replay is Pause/Break
|
||||
int action_replay_button = SDLK_PAUSE;
|
||||
if (strncmp(currprefs.action_replay, "", 1) != 0)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
action_replay_button = SDL_GetKeyFromName(currprefs.action_replay);
|
||||
#endif
|
||||
}
|
||||
|
||||
// No default value for Full Screen toggle
|
||||
int fullscreen_key = 0;
|
||||
if (strncmp(currprefs.fullscreen_toggle, "", 1) != 0)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
fullscreen_key = SDL_GetKeyFromName(currprefs.fullscreen_toggle);
|
||||
#endif
|
||||
}
|
||||
|
||||
while (SDL_PollEvent(&rEvent))
|
||||
{
|
||||
got = 1;
|
||||
|
@ -986,19 +1012,31 @@ int handle_msgpump()
|
|||
|
||||
case SDL_KEYDOWN:
|
||||
// If the Enter GUI key was pressed, handle it
|
||||
if (enter_gui_key && rEvent.key.keysym.sym == enter_gui_key)
|
||||
if (enter_gui_key && rEvent.key.keysym.sym == enter_gui_key && rEvent.key.repeat == 0)
|
||||
{
|
||||
inputdevice_add_inputcode(AKS_ENTERGUI, 1, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
// If the Quit emulator key was pressed, handle it
|
||||
if (quit_key && rEvent.key.keysym.sym == quit_key)
|
||||
if (quit_key && rEvent.key.keysym.sym == quit_key && rEvent.key.repeat == 0)
|
||||
{
|
||||
inputdevice_add_inputcode(AKS_QUIT, 1, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (action_replay_button && rEvent.key.keysym.sym == action_replay_button && rEvent.key.repeat == 0)
|
||||
{
|
||||
inputdevice_add_inputcode(AKS_FREEZEBUTTON, 1, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (fullscreen_key && rEvent.key.keysym.sym == fullscreen_key && rEvent.key.repeat == 0)
|
||||
{
|
||||
inputdevice_add_inputcode(AKS_TOGGLEWINDOWEDFULLSCREEN, 1, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
// If the reset combination was pressed, handle it
|
||||
#ifdef USE_SDL1
|
||||
// Strangely in FBCON left window is seen as left alt ??
|
||||
|
@ -1026,7 +1064,7 @@ int handle_msgpump()
|
|||
rEvent.key.keysym.sym = SDLK_CAPSLOCK;
|
||||
#endif
|
||||
|
||||
if (rEvent.key.keysym.sym == SDLK_CAPSLOCK)
|
||||
if (rEvent.key.keysym.sym == SDLK_CAPSLOCK && rEvent.key.repeat == 0)
|
||||
{
|
||||
// Treat CAPSLOCK as a toggle. If on, set off and vice/versa
|
||||
ioctl(0, KDGKBLED, &kbd_flags);
|
||||
|
@ -1051,27 +1089,30 @@ int handle_msgpump()
|
|||
}
|
||||
|
||||
// Handle all other keys
|
||||
//translate_amiberry_keys(rEvent.key.keysym.sym, 1);
|
||||
if (rEvent.key.repeat == 0)
|
||||
{
|
||||
#ifdef USE_SDL1
|
||||
if (keyboard_type == KEYCODE_UNK)
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
|
||||
else
|
||||
if (keyboard_type == KEYCODE_UNK)
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
|
||||
else
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
||||
#elif USE_SDL2
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
||||
#elif USE_SDL2
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
//translate_amiberry_keys(rEvent.key.keysym.sym, 0);
|
||||
if (rEvent.key.repeat == 0)
|
||||
{
|
||||
#ifdef USE_SDL1
|
||||
if (keyboard_type == KEYCODE_UNK)
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
|
||||
else
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
||||
if (keyboard_type == KEYCODE_UNK)
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
|
||||
else
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
||||
#elif USE_SDL2
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
||||
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
|
|
@ -309,8 +309,9 @@ int graphics_setup(void)
|
|||
sdlWindow = SDL_CreateWindow("Amiberry",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
800,
|
||||
480,
|
||||
0,
|
||||
0,
|
||||
//SDL_WINDOW_FULLSCREEN);
|
||||
//SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
check_error_sdl(sdlWindow == nullptr, "Unable to create window");
|
||||
|
@ -356,6 +357,17 @@ int graphics_setup(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void toggle_fullscreen()
|
||||
{
|
||||
Uint32 FullscreenFlag = SDL_WINDOW_FULLSCREEN;
|
||||
if (sdlWindow)
|
||||
{
|
||||
bool IsFullscreen = SDL_GetWindowFlags(sdlWindow) & FullscreenFlag;
|
||||
SDL_SetWindowFullscreen(sdlWindow, IsFullscreen ? 0 : FullscreenFlag);
|
||||
SDL_ShowCursor(IsFullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_DISPMANX
|
||||
static void wait_for_display_thread(void)
|
||||
{
|
||||
|
@ -534,6 +546,17 @@ static void open_screen(struct uae_prefs* p)
|
|||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
if (sdlWindow)
|
||||
{
|
||||
if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0)
|
||||
{
|
||||
if (screen_is_picasso)
|
||||
SDL_SetWindowSize(sdlWindow, display_width, display_height);
|
||||
else
|
||||
SDL_SetWindowSize(sdlWindow, display_width, display_height * 2 >> p->gfx_vresolution);
|
||||
}
|
||||
}
|
||||
|
||||
screen = SDL_CreateRGBSurface(0, display_width, display_height, 16, 0, 0, 0, 0);
|
||||
check_error_sdl(screen == nullptr, "Unable to create a surface");
|
||||
|
||||
|
|
|
@ -17,4 +17,5 @@ extern SDL_DisplayMode sdlMode;
|
|||
#endif
|
||||
|
||||
extern bool can_have_linedouble;
|
||||
extern void check_error_sdl(bool check, const char* message);
|
||||
extern void check_error_sdl(bool check, const char* message);
|
||||
extern void toggle_fullscreen();
|
|
@ -50,6 +50,14 @@ static gcn::Label* lblKeyForQuit;
|
|||
static gcn::TextField* txtKeyForQuit;
|
||||
static gcn::Button* cmdKeyForQuit;
|
||||
|
||||
static gcn::Label* lblKeyActionReplay;
|
||||
static gcn::TextField* txtKeyActionReplay;
|
||||
static gcn::Button* cmdKeyActionReplay;
|
||||
|
||||
static gcn::Label* lblKeyFullScreen;
|
||||
static gcn::TextField* txtKeyFullScreen;
|
||||
static gcn::Button* cmdKeyFullScreen;
|
||||
|
||||
class StringListModel : public gcn::ListModel
|
||||
{
|
||||
vector<string> values;
|
||||
|
@ -136,6 +144,26 @@ public:
|
|||
strcpy(changed_prefs.quit_amiberry, key);
|
||||
}
|
||||
}
|
||||
|
||||
else if (actionEvent.getSource() == cmdKeyActionReplay)
|
||||
{
|
||||
const auto key = ShowMessageForInput("Press a key", "Press a key to map to Action Replay", "Cancel");
|
||||
if (key != nullptr)
|
||||
{
|
||||
txtKeyActionReplay->setText(key);
|
||||
strcpy(changed_prefs.action_replay, key);
|
||||
}
|
||||
}
|
||||
|
||||
else if (actionEvent.getSource() == cmdKeyFullScreen)
|
||||
{
|
||||
const auto key = ShowMessageForInput("Press a key", "Press a key to map to toggle FullScreen", "Cancel");
|
||||
if (key != nullptr)
|
||||
{
|
||||
txtKeyFullScreen->setText(key);
|
||||
strcpy(changed_prefs.fullscreen_toggle, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -222,6 +250,30 @@ void InitPanelMisc(const struct _ConfigCategory& category)
|
|||
cmdKeyForQuit->setBaseColor(gui_baseCol);
|
||||
cmdKeyForQuit->addActionListener(miscActionListener);
|
||||
|
||||
lblKeyActionReplay = new gcn::Label("Action Replay:");
|
||||
lblKeyActionReplay->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtKeyActionReplay = new gcn::TextField();
|
||||
txtKeyActionReplay->setEnabled(false);
|
||||
txtKeyActionReplay->setSize(85, TEXTFIELD_HEIGHT);
|
||||
txtKeyActionReplay->setBackgroundColor(colTextboxBackground);
|
||||
cmdKeyActionReplay = new gcn::Button("...");
|
||||
cmdKeyActionReplay->setId("KeyActionReplay");
|
||||
cmdKeyActionReplay->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
cmdKeyActionReplay->setBaseColor(gui_baseCol);
|
||||
cmdKeyActionReplay->addActionListener(miscActionListener);
|
||||
|
||||
lblKeyFullScreen = new gcn::Label("FullScreen toggle:");
|
||||
lblKeyFullScreen->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtKeyFullScreen = new gcn::TextField();
|
||||
txtKeyFullScreen->setEnabled(false);
|
||||
txtKeyFullScreen->setSize(85, TEXTFIELD_HEIGHT);
|
||||
txtKeyFullScreen->setBackgroundColor(colTextboxBackground);
|
||||
cmdKeyFullScreen = new gcn::Button("...");
|
||||
cmdKeyFullScreen->setId("KeyFullScreen");
|
||||
cmdKeyFullScreen->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
cmdKeyFullScreen->setBaseColor(gui_baseCol);
|
||||
cmdKeyFullScreen->addActionListener(miscActionListener);
|
||||
|
||||
auto posY = DISTANCE_BORDER;
|
||||
category.panel->add(chkStatusLine, DISTANCE_BORDER, posY);
|
||||
posY += chkStatusLine->getHeight() + DISTANCE_NEXT_Y;
|
||||
|
@ -262,6 +314,16 @@ void InitPanelMisc(const struct _ConfigCategory& category)
|
|||
category.panel->add(txtKeyForQuit, lblKeyForQuit->getX() + lblKeyForQuit->getWidth() + 8, posY);
|
||||
category.panel->add(cmdKeyForQuit, txtKeyForQuit->getX() + txtKeyForQuit->getWidth() + 8, posY);
|
||||
|
||||
posY += cmdOpenGUI->getHeight() + DISTANCE_NEXT_Y;
|
||||
|
||||
category.panel->add(lblKeyActionReplay, DISTANCE_BORDER, posY);
|
||||
category.panel->add(txtKeyActionReplay, lblKeyActionReplay->getX() + lblKeyActionReplay->getWidth() + 8, posY);
|
||||
category.panel->add(cmdKeyActionReplay, txtKeyActionReplay->getX() + txtKeyActionReplay->getWidth() + 8, posY);
|
||||
|
||||
category.panel->add(lblKeyFullScreen, cmdKeyActionReplay->getX() + cmdKeyActionReplay->getWidth() + DISTANCE_NEXT_X * 2, posY);
|
||||
category.panel->add(txtKeyFullScreen, lblKeyFullScreen->getX() + lblKeyFullScreen->getWidth() + 8, posY);
|
||||
category.panel->add(cmdKeyFullScreen, txtKeyFullScreen->getX() + txtKeyFullScreen->getWidth() + 8, posY);
|
||||
|
||||
RefreshPanelMisc();
|
||||
}
|
||||
|
||||
|
@ -292,6 +354,14 @@ void ExitPanelMisc()
|
|||
delete txtKeyForQuit;
|
||||
delete cmdKeyForQuit;
|
||||
|
||||
delete lblKeyActionReplay;
|
||||
delete txtKeyActionReplay;
|
||||
delete cmdKeyActionReplay;
|
||||
|
||||
delete lblKeyFullScreen;
|
||||
delete txtKeyFullScreen;
|
||||
delete cmdKeyFullScreen;
|
||||
|
||||
delete miscActionListener;
|
||||
}
|
||||
|
||||
|
@ -314,7 +384,8 @@ void RefreshPanelMisc()
|
|||
|
||||
txtOpenGUI->setText(strncmp(changed_prefs.open_gui, "", 1) != 0 ? changed_prefs.open_gui : "Click to map");
|
||||
txtKeyForQuit->setText(strncmp(changed_prefs.quit_amiberry, "", 1) != 0 ? changed_prefs.quit_amiberry : "Click to map");
|
||||
|
||||
txtKeyActionReplay->setText(strncmp(changed_prefs.action_replay, "", 1) != 0 ? changed_prefs.action_replay : "Click to map");
|
||||
txtKeyFullScreen->setText(strncmp(changed_prefs.fullscreen_toggle, "", 1) != 0 ? changed_prefs.fullscreen_toggle : "Click to map");
|
||||
}
|
||||
|
||||
bool HelpPanelMisc(std::vector<std::string> &helptext)
|
||||
|
|
|
@ -296,6 +296,11 @@ namespace sdl
|
|||
#ifndef TINKER
|
||||
setup_cursor();
|
||||
#endif
|
||||
if (sdlWindow)
|
||||
{
|
||||
if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0)
|
||||
SDL_SetWindowSize(sdlWindow, GUI_WIDTH, GUI_HEIGHT);
|
||||
}
|
||||
|
||||
// make the scaled rendering look smoother (linear scaling).
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||
|
|
|
@ -510,7 +510,7 @@ static struct uae_input_device_kbr_default keytrans_amiga[] = {
|
|||
|
||||
{ SDL_SCANCODE_END, INPUTEVENT_SPC_QUALIFIER_SPECIAL },
|
||||
{ SDL_SCANCODE_NONUSBACKSLASH, INPUTEVENT_KEY_30 },
|
||||
{ SDL_SCANCODE_PAUSE, INPUTEVENT_SPC_FREEZEBUTTON },
|
||||
//{ SDL_SCANCODE_PAUSE, INPUTEVENT_SPC_FREEZEBUTTON },
|
||||
|
||||
// This is configurable, so let's not hardcode it here
|
||||
//{SDL_SCANCODE_F12, INPUTEVENT_SPC_ENTERGUI },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue