diff --git a/fcore/core-key.sml b/fcore/core-key.sml index cf4c90d..16de3e0 100644 --- a/fcore/core-key.sml +++ b/fcore/core-key.sml @@ -139,6 +139,7 @@ sig val keyFromString: string -> key_code option val keyToString: key_code -> string + val userKeysToString: user_key -> string val containsKey: key_code * key_code list -> bool val containsAttack: user_key * key_code list -> bool @@ -531,6 +532,28 @@ struct | KEY_RIGHT_SUPER => "KEY_RIGHT_SUPER" | KEY_MENU => "KEY_MENU" + fun userKeysToString {left, right, up, down, jump, attack, escape = _} = + String.concat + [ "ACTION_LEFT:" + , keyToString left + , "\n" + , "ACTION_RIGHT:" + , keyToString right + , "\n" + , "ACTION_UP:" + , keyToString up + , "\n" + , "ACTION_DOWN:" + , keyToString down + , "\n" + , "ACTION_JUMP:" + , keyToString jump + , "\n" + , "ACTION_ATTACK:" + , keyToString attack + , "\n" + ] + fun containsKey (searchKey, lst) = case lst of hd :: tl => hd = searchKey orelse containsKey (searchKey, tl) diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index 6001db0..33ca740 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -287,8 +287,15 @@ struct end fun saveKeys game = - let val () = InputState.setControls (#userKeys game) - in () + let + val newKeys = #userKeys game + val () = InputState.setControls newKeys + + val io = TextIO.openOut "controls.config" + val () = TextIO.output (io, CoreKey.userKeysToString newKeys) + val () = TextIO.closeOut io + in + () end fun runEffects game =