Re: [hatari-devel] Keyboard shortcut to toggle Atari borders?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 07/20/2017 06:16 PM, Matthias Arndt wrote:
Am Wed, 19 Jul 2017 22:27:55 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
On 07/19/2017 08:42 PM, Matthias Arndt wrote:
I noticed that I tend to toggle Atari border emulation more often
since I exchanged my monitor for a more recent 16:9 one.

Would it be possible to add a keyboard shortcut for this?

Hm.  At least AltGr + B shortcut combination is still free...

Sounds reasonable.


Can you propose a patch?

Hardly as I don't know where to add which hooks in order not to break
anything.

I am not fully fluent in the current Hatari code base.

Attached is patch implementing Borders shortcut, could you try it?

Note that Hatari supports borders only for ST/STE & Falcon,
not for TT or VDI mode.

If everything works fine and nobody complains, I'll document
and commit it.


	- Eero
diff -r 6f5bb2fa5270 src/configuration.c
--- a/src/configuration.c	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/configuration.c	Sun Nov 19 13:21:30 2017 +0200
@@ -272,6 +272,7 @@
 {
 	{ "keyOptions",    Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
 	{ "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
+	{ "keyBorders",    Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_BORDERS] },
 	{ "keyMouseMode",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] },
 	{ "keyColdReset",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
 	{ "keyWarmReset",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
@@ -300,6 +301,7 @@
 {
 	{ "keyOptions",    Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
 	{ "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
+	{ "keyBorders",    Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_BORDERS] },
 	{ "keyMouseMode",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEGRAB] },
 	{ "keyColdReset",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
 	{ "keyWarmReset",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
@@ -329,6 +331,7 @@
 {
 	{ "kOptions",    Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
 	{ "kFullScreen", Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
+	{ "kBorders",    Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_BORDERS] },
 	{ "kMouseMode",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] },
 	{ "kColdReset",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
 	{ "kWarmReset",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
@@ -357,6 +360,7 @@
 {
 	{ "kOptions",    Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
 	{ "kFullScreen", Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
+	{ "kBorders",    Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_BORDERS] },
 	{ "kMouseMode",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEGRAB] },
 	{ "kColdReset",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
 	{ "kWarmReset",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
@@ -692,6 +696,7 @@
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG] = SDLK_PAUSE;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] = SDLK_o;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] = SDLK_f;
+	ConfigureParams.Shortcut.withModifier[SHORTCUT_BORDERS] = SDLK_b;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] = SDLK_m;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] = SDLK_c;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] = SDLK_r;
diff -r 6f5bb2fa5270 src/includes/configuration.h
--- a/src/includes/configuration.h	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/includes/configuration.h	Sun Nov 19 13:21:30 2017 +0200
@@ -88,6 +88,7 @@
 typedef enum {
   SHORTCUT_OPTIONS,
   SHORTCUT_FULLSCREEN,
+  SHORTCUT_BORDERS,
   SHORTCUT_MOUSEGRAB,
   SHORTCUT_COLDRESET,
   SHORTCUT_WARMRESET,
diff -r 6f5bb2fa5270 src/shortcut.c
--- a/src/shortcut.c	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/shortcut.c	Sun Nov 19 13:21:30 2017 +0200
@@ -50,6 +50,15 @@
 	}
 }
 
+/*-----------------------------------------------------------------------*/
+/**
+ * Shortcut to toggle borders
+ */
+static void ShortCut_Borders(void)
+{
+	ConfigureParams.Screen.bAllowOverscan = !ConfigureParams.Screen.bAllowOverscan;
+	Screen_ModeChanged(false);  /* false: re-create window only if size changed */
+}
 
 /*-----------------------------------------------------------------------*/
 /**
@@ -281,6 +290,9 @@
 	 case SHORTCUT_FULLSCREEN:
 		ShortCut_FullScreen();		/* Switch between fullscreen/windowed mode */
 		break;
+	 case SHORTCUT_BORDERS:
+		ShortCut_Borders();		/* Toggle Atari borders */
+		break;
 	 case SHORTCUT_MOUSEGRAB:
 		ShortCut_MouseGrab();		/* Toggle mouse grab */
 		break;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/