View Issue Details

IDProjectCategoryView StatusLast Update
0003092FSSCPlocalizationpublic2014-08-14 11:00
ReporterYarn Assigned ToYarn  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Platformx64OSWindows 7 
Product Version3.7.1 
Target Version3.7.2 
Summary0003092: Certain key strings not parsed correctly if language is set to German or French
DescriptionCertain SEXPs like key-pressed use strings like "Shift-T" to refer to controls by their default key mappings. Messages and directives can also use the same strings by surrounding them with dollar signs. For parsing reasons, it is very important that the game expect the same strings regardless of the current language. However, in both FSO and retail FS2, this is not the case. The specific problems are listed below:

(All functions mentioned here are found in controlsconfigcommon.cpp. Also, the problems described here happen only if the game is set to the respective language.)

German: In control_config_common_init(), if the language is set to German, the game changes the default mappings of certain controls in a mistaken attempt to accomodate the German QWERTZ layout, where the Y and Z keys are switched. Because of this, if the player is supposed to press the key that's mapped to (for example) Reverse Thrust, they would instead have to press the key that's mapped to Target Ship in Reticle. If a key string containing Y or Z is used in a message or a directive, this also causes the wrong key name to be displayed.

French: In translate_key_to_index() (which converts a key string to a control index), normally the game converts a string to a "shifted" scan code if the string begins with "Shift". However, if the language is set to French, then the function expects such strings to start with "Maj." (the French translation) instead. This means that, if an event requires the player to use a control whose default binding includes the Shift key, then that event can never return true. If such strings are used in messages or directives, then the key strings are not converted at all.

The attached patch fixes both of these problems.
Steps To ReproduceTo verify that the patch works, you can use the attached mission while using the default key mapping (important!). In it, the directives will tell you to press the following keys in the following order: Y, Z, Shift-T. Press each key when ordered and make sure that doing so completes the directives. (The German key labels are based on the German layout, which switches Y and Z, so to help avoid confusion, the directives will tell you where the keys actually are.)
TagsNo tags attached.

Activities

Yarn

2014-08-12 00:05

developer  

KeypressTest.fs2 (4,119 bytes)

Yarn

2014-08-12 00:06

developer  

mantis3092.patch (1,678 bytes)   
Index: code/controlconfig/controlsconfigcommon.cpp
===================================================================
--- code/controlconfig/controlsconfigcommon.cpp	(revision 10988)
+++ code/controlconfig/controlsconfigcommon.cpp	(working copy)
@@ -386,13 +386,7 @@
 {
 	int i, index = -1, alt = 0, shift = 0, max_scan_codes;
 
-	if (Lcl_gr) {
-		max_scan_codes = sizeof(Scan_code_text_german) / sizeof(char *);
-	} else if (Lcl_fr) {
-		max_scan_codes = sizeof(Scan_code_text_french) / sizeof(char *);
-	} else {
-		max_scan_codes = sizeof(Scan_code_text_english) / sizeof(char *);
-	}
+	max_scan_codes = sizeof(Scan_code_text_english) / sizeof(char *);
 
 	// look for modifiers
 	Assert(key);
@@ -403,17 +397,7 @@
 			key++;
 	}
 
-	char *translated_shift;
-	
-	if(Lcl_gr){
-		translated_shift = "Shift";
-	} else if(Lcl_fr){	
-		translated_shift = "Maj.";
-	} else {	
-		translated_shift = "Shift";
-	}
-
-	if (!strnicmp(key, translated_shift, 5)) {
+	if (!strnicmp(key, "Shift", 5)) {
 		shift = 1;
 		key += 5;
 		if (*key)
@@ -561,13 +545,7 @@
 	control_config_common_load_overrides();
 	if(Lcl_gr){
 		Scan_code_text = Scan_code_text_german;
-		Joy_button_text = Joy_button_text_german;
-		
-		// swap init bindings for y and z keys
-		Control_config[TARGET_SHIP_IN_RETICLE].key_default = KEY_Z;
-		Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | KEY_Z;
-		Control_config[REVERSE_THRUST].key_default = KEY_Y;
-		Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | KEY_Y;		
+		Joy_button_text = Joy_button_text_german;		
 	} else if(Lcl_fr){
 		Scan_code_text = Scan_code_text_french;
 		Joy_button_text = Joy_button_text_french;
mantis3092.patch (1,678 bytes)   

niffiwan

2014-08-13 09:56

developer   ~0016212

Last edited: 2014-08-13 09:59

I've run some tests on this and unfortunately I don't think it's quite working as intended (or I'm not understanding this correctly).

Firstly, the changes for French seem fine.

For German, without the patch and using a new pilot, the directives have the wrong names (i.e. swapped) but the keypresses are correct (y then z). However, with the patch (and again creating a new pilot) I have the same behaviour. The only difference is that without the patch, the 2nd directive is "y or knopf 5" and with the patch, the 1st directive is "z or knopf 5".

Maybe SDL is cause of this issue, i.e. since it'll be handling input on my Linux PC as opposed to whatever method that Windows uses?

MageKing17

2014-08-13 11:01

developer   ~0016213

I get identical behavior to niffiwan in Windows.

niffiwan

2014-08-13 11:20

developer   ~0016214

Oops. So, per the conversation in IRC, this would actually seem to be working as expected. i.e. if someone wants to detect the "reverse thrust" or "target ship in reticle" keys when the language is German it now works correctly. The directive keys still look "wrong" on a QWERTY keyboard, but they'd be fine on a QWERTZ.

niffiwan

2014-08-14 11:00

developer   ~0016215

Fix committed to trunk@10995.

Related Changesets

fs2open: trunk r10995

2014-08-14 07:29

niffiwan


Ported: N/A

Details Diff
Fix mantis 3092 (from Yarn)

Fix certain key string parsing in German & French
Affected Issues
0003092
mod - /trunk/fs2_open/code/controlconfig/controlsconfigcommon.cpp Diff File

Issue History

Date Modified Username Field Change
2014-08-12 00:05 Yarn New Issue
2014-08-12 00:05 Yarn Status new => assigned
2014-08-12 00:05 Yarn Assigned To => Yarn
2014-08-12 00:05 Yarn File Added: KeypressTest.fs2
2014-08-12 00:06 Yarn File Added: mantis3092.patch
2014-08-12 00:06 Yarn Status assigned => code review
2014-08-13 09:56 niffiwan Note Added: 0016212
2014-08-13 09:59 niffiwan Note Edited: 0016212
2014-08-13 11:01 MageKing17 Note Added: 0016213
2014-08-13 11:20 niffiwan Note Added: 0016214
2014-08-14 11:00 niffiwan Changeset attached => fs2open trunk r10995
2014-08-14 11:00 niffiwan Note Added: 0016215
2014-08-14 11:00 niffiwan Status code review => resolved
2014-08-14 11:00 niffiwan Resolution open => fixed