1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

'Corrects' but disables SDL logical keyboard entry.

I'm just not sure that SDL supports what I want.
This commit is contained in:
Thomas Harte 2020-03-01 23:11:14 -05:00
parent b2c07b3110
commit 2db30a91c6
3 changed files with 20 additions and 7 deletions

View File

@ -31,7 +31,7 @@
</Testables> </Testables>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Release" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
disableMainThreadChecker = "YES" disableMainThreadChecker = "YES"
@ -58,6 +58,14 @@
</CommandLineArgument> </CommandLineArgument>
<CommandLineArgument <CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Desktop/Soft/Master System/R-Type (NTSC).sms&quot;" argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Desktop/Soft/Master System/R-Type (NTSC).sms&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--logical-keyboard"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Desktop/Soft/Amstrad CPC/Amstrad CPC [TOSEC]/Amstrad CPC - Applications - [DSK] (TOSEC-v2011-08-31_CM)/Tasword (1984)(Tasman Software).dsk&quot;"
isEnabled = "YES"> isEnabled = "YES">
</CommandLineArgument> </CommandLineArgument>
<CommandLineArgument <CommandLineArgument

View File

@ -67,7 +67,7 @@
</Testables> </Testables>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES" enableASanStackUseAfterReturn = "YES"

View File

@ -469,7 +469,7 @@ int main(int argc, char *argv[]) {
ParsedArguments arguments = parse_arguments(argc, argv); ParsedArguments arguments = parse_arguments(argc, argv);
// This may be printed either as // This may be printed either as
const std::string usage_suffix = " [file] [OPTIONS] [--rompath={path to ROMs}] [--speed={speed multiplier, e.g. 1.5}] [--logical-keyboard]"; const std::string usage_suffix = " [file] [OPTIONS] [--rompath={path to ROMs}] [--speed={speed multiplier, e.g. 1.5}]"; /* [--logical-keyboard] */
// Print a help message if requested. // Print a help message if requested.
if(arguments.selections.find("help") != arguments.selections.end() || arguments.selections.find("h") != arguments.selections.end()) { if(arguments.selections.find("help") != arguments.selections.end() || arguments.selections.find("h") != arguments.selections.end()) {
@ -611,7 +611,10 @@ int main(int argc, char *argv[]) {
} }
// Check whether a 'logical' keyboard has been requested. // Check whether a 'logical' keyboard has been requested.
const bool logical_keyboard = arguments.selections.find("logical_keyboard") != arguments.selections.end(); constexpr bool logical_keyboard = false; //arguments.selections.find("logical-keyboard") != arguments.selections.end();
/* Logical keyboard entry is currently disabled; the attempt below to get logical input via SDL_GetKeyName is
too flawed all letters are always capitals, shifted symbols are reported correctly on their first
press only, etc. I need to see whether other options are available. If not then SDL may not allow this feature.*/
// Wire up the best-effort updater, its delegate, and the speaker delegate. // Wire up the best-effort updater, its delegate, and the speaker delegate.
machine_runner.machine = machine.get(); machine_runner.machine = machine.get();
@ -896,12 +899,14 @@ int main(int argc, char *argv[]) {
// Grab the key's symbol. // Grab the key's symbol.
char key_value = '\0'; char key_value = '\0';
const char *key_name = SDL_GetKeyName(event.key.keysym.sym); const char *key_name = SDL_GetKeyName(event.key.keysym.sym);
if(key_name[0] >= 0) key_value = key_name[0]; if(key_name[0] >= 0 && key_name[1] == 0) key_value = key_name[0];
// If a logical mapping was selected and a symbol was found, type it. // If a logical mapping was selected and a symbol was found, type it.
if(logical_keyboard && key_value != '\0' && keyboard_machine->can_type(key_value)) { if(logical_keyboard && key_value != '\0' && keyboard_machine->can_type(key_value)) {
char string[] = { key_value, 0 }; if(is_pressed) {
keyboard_machine->type_string(string); char string[] = { key_value, 0 };
keyboard_machine->type_string(string);
}
break; break;
} }