shithub: ft²

Download patch

ref: 80f1c7105ef27ec2426e02cb660d9d95a8706a65
parent: 6e71350b6a996d27229ca18ac386f83c6e4ad58b
author: Olav Sørensen <olav.sorensen@live.no>
date: Mon Sep 7 07:40:08 EDT 2020

Some changes to keybindings

1) Right Shift is now "Record Pattern" instead of "Record Song" (was wrong)
2) For Mac keyboards: Left Command key can now be used for "Play Pattern" (since some Mac keyboards don't have a Right Alt key)

--- a/src/ft2_keyboard.c
+++ b/src/ft2_keyboard.c
@@ -60,16 +60,12 @@
 
 void readKeyModifiers(void)
 {
-	SDL_Keymod modState;
+	const SDL_Keymod modState = SDL_GetModState();
 
-	modState = SDL_GetModState();
-
-	keyb.ctrlPressed = (modState & (KMOD_LCTRL | KMOD_RCTRL)) ? true : false;
 	keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false;
 	keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false;
 	keyb.leftShiftPressed = (modState & KMOD_LSHIFT) ? true : false;
 #ifdef __APPLE__
-	keyb.commandPressed = (modState & (KMOD_LGUI | KMOD_RGUI)) ? true : false;
 	keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false;
 #endif
 	keyb.keyModifierDown = (modState & (KMOD_LSHIFT | KMOD_LCTRL | KMOD_LALT | KMOD_LGUI)) ? true : false;
@@ -360,13 +356,13 @@
 		}
 		break;
 
-		// This is maybe not ideal to implement...
+		// This is maybe not an ideal key for this anymore...
 		//case SDLK_PRINTSCREEN: togglePatternEditorExtended(); break;
 
 		// EDIT/PLAY KEYS
 
-		// record song
-		case SDLK_RSHIFT: startPlaying(PLAYMODE_RECSONG, 0); break;
+		// record pattern
+		case SDLK_RSHIFT: startPlaying(PLAYMODE_RECPATT, 0); break;
 
 		// play song
 #ifdef __APPLE__
@@ -377,6 +373,9 @@
 		break;
 
 		// play pattern
+#ifdef __APPLE__
+		case SDLK_LGUI: // fall-through for Apple keyboards
+#endif
 		case SDLK_RALT: startPlaying(PLAYMODE_PATT, 0); break;
 
 		case SDLK_SPACE:
@@ -755,7 +754,7 @@
 			break;
 
 		case SDLK_a:
-			if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
+			if (keyb.leftCtrlPressed)
 			{
 				if (ui.sampleEditorShown)
 					rangeAll();
@@ -805,7 +804,7 @@
 
 				return true;
 			}
-			else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
+			else if (keyb.leftCtrlPressed)
 			{
 				if (ui.sampleEditorShown)
 					sampCopy();
@@ -1038,7 +1037,7 @@
 
 				return true;
 			}
-			else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
+			else if (keyb.leftCtrlPressed)
 			{
 				if (ui.sampleEditorShown)
 					sampPaste();
@@ -1075,7 +1074,7 @@
 
 				return true;
 			}
-			else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
+			else if (keyb.leftCtrlPressed)
 			{
 				if (ui.extended)
 					exitPatternEditorExtended();
--- a/src/ft2_keyboard.h
+++ b/src/ft2_keyboard.h
@@ -8,8 +8,8 @@
 {
 	uint8_t keyRepeat, keyPressed;
 	bool ignoreCurrKeyUp, ignoreTextEditKey, numPadPlusPressed;
-	bool keyModifierDown, commandPressed, leftCommandPressed;
-	bool leftShiftPressed, leftCtrlPressed, ctrlPressed, leftAltPressed;
+	bool keyModifierDown, leftCommandPressed;
+	bool leftShiftPressed, leftCtrlPressed, leftAltPressed;
 } keyb_t;
 
 extern keyb_t keyb; // ft2_keyboard.c
--- a/src/ft2_textboxes.c
+++ b/src/ft2_textboxes.c
@@ -855,7 +855,7 @@
 		case SDLK_a:
 		{
 			// CTRL+A - mark all text
-			if (keyb.ctrlPressed || keyb.commandPressed)
+			if (keyb.leftCtrlPressed)
 			{
 				// count number of chars and get full text width
 				textWidth = 0;
@@ -883,7 +883,7 @@
 		case SDLK_x:
 		{
 			// CTRL+X - cut marked text
-			if (keyb.ctrlPressed || keyb.commandPressed)
+			if (keyb.leftCtrlPressed)
 				cutMarkedText(t);
 		}
 		break;
@@ -891,7 +891,7 @@
 		case SDLK_c:
 		{
 			// CTRL+C - copy marked text
-			if (keyb.ctrlPressed || keyb.commandPressed)
+			if (keyb.leftCtrlPressed)
 				copyMarkedText(t);
 		}
 		break;
@@ -899,7 +899,7 @@
 		case SDLK_v:
 		{
 			// CTRL+V - paste text
-			if (keyb.ctrlPressed || keyb.commandPressed)
+			if (keyb.leftCtrlPressed)
 				pasteText(t);
 		}
 		break;