input: add AZERTY (Z/Q) mappings alongside QWERTY; drop LFS lockable
This commit is contained in:
1 parent
ebbbfe845f
commit
438b0f2154
7 files changed
+88
-11
No files matched your search
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
# Unreal assets (binary, lockable)
|
# Unreal assets (binary)
|
||||||
*.uasset filter=lfs diff=lfs merge=lfs -text lockable
|
*.uasset filter=lfs diff=lfs merge=lfs -text
|
||||||
*.umap filter=lfs diff=lfs merge=lfs -text lockable
|
*.umap filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|
||||||
# Source art / audio / video
|
# Source art / audio / video
|
||||||
*.fbx filter=lfs diff=lfs merge=lfs -text
|
*.fbx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,70 @@
|
|||||||
|
"""Add AZERTY key mappings next to the QWERTY ones in every Input Mapping Context.
|
||||||
|
|
||||||
|
W -> also Z (forward), A -> also Q (left). Idempotent: skips keys already mapped.
|
||||||
|
Run headless (editor closed):
|
||||||
|
UnrealEditor pogo.uproject -run=pythonscript -script=Scripts/azerty_mappings.py -nullrhi -unattended -FullStdOutLogOutput
|
||||||
|
"""
|
||||||
|
import unreal
|
||||||
|
|
||||||
|
CONTEXTS = [
|
||||||
|
"/Game/Input/IMC_Default",
|
||||||
|
"/Game/Variant_Platforming/Input/IMC_Platforming",
|
||||||
|
"/Game/Variant_Combat/Input/IMC_Combat",
|
||||||
|
"/Game/Variant_SideScrolling/Input/IMC_SideScroller",
|
||||||
|
]
|
||||||
|
EXTRA_KEYS = {"W": "Z", "A": "Q"}
|
||||||
|
|
||||||
|
# Properties copied when cloning instanced modifiers/triggers.
|
||||||
|
COPY_PROPS = ["order", "x", "y", "z", "lower_threshold", "upper_threshold", "type",
|
||||||
|
"scalar", "actuation_threshold"]
|
||||||
|
|
||||||
|
|
||||||
|
def clone_instanced(obj, outer):
|
||||||
|
new = unreal.new_object(type(obj), outer=outer)
|
||||||
|
for prop in COPY_PROPS:
|
||||||
|
try:
|
||||||
|
new.set_editor_property(prop, obj.get_editor_property(prop))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return new
|
||||||
|
|
||||||
|
|
||||||
|
def log(msg):
|
||||||
|
unreal.log(f"POGO_AZERTY {msg}")
|
||||||
|
|
||||||
|
|
||||||
|
for path in CONTEXTS:
|
||||||
|
imc = unreal.load_asset(path)
|
||||||
|
if imc is None:
|
||||||
|
log(f"MISSING {path}")
|
||||||
|
continue
|
||||||
|
data = imc.get_editor_property("default_key_mappings")
|
||||||
|
mappings = list(data.get_editor_property("mappings"))
|
||||||
|
existing = {(m.get_editor_property("action").get_name(),
|
||||||
|
str(m.get_editor_property("key").get_editor_property("key_name")))
|
||||||
|
for m in mappings}
|
||||||
|
added = 0
|
||||||
|
for m in list(mappings):
|
||||||
|
action = m.get_editor_property("action")
|
||||||
|
src_key = str(m.get_editor_property("key").get_editor_property("key_name"))
|
||||||
|
dst_key = EXTRA_KEYS.get(src_key)
|
||||||
|
if not dst_key or (action.get_name(), dst_key) in existing:
|
||||||
|
continue
|
||||||
|
new = unreal.EnhancedActionKeyMapping()
|
||||||
|
new.set_editor_property("action", action)
|
||||||
|
key = unreal.Key()
|
||||||
|
key.set_editor_property("key_name", dst_key)
|
||||||
|
new.set_editor_property("key", key)
|
||||||
|
new.set_editor_property("modifiers", [clone_instanced(x, imc) for x in m.get_editor_property("modifiers")])
|
||||||
|
new.set_editor_property("triggers", [clone_instanced(x, imc) for x in m.get_editor_property("triggers")])
|
||||||
|
mappings.append(new)
|
||||||
|
existing.add((action.get_name(), dst_key))
|
||||||
|
added += 1
|
||||||
|
log(f"{path}: {action.get_name()} {src_key} -> +{dst_key}")
|
||||||
|
if added:
|
||||||
|
data.set_editor_property("mappings", mappings)
|
||||||
|
imc.set_editor_property("default_key_mappings", data)
|
||||||
|
ok = unreal.EditorAssetLibrary.save_loaded_asset(imc, only_if_is_dirty=False)
|
||||||
|
log(f"SAVED {path} added={added} ok={ok}")
|
||||||
|
else:
|
||||||
|
log(f"UNCHANGED {path}")
|
||||||
@@ -30,6 +30,13 @@
|
|||||||
{
|
{
|
||||||
"Name": "GameplayStateTree",
|
"Name": "GameplayStateTree",
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "PythonScriptPlugin",
|
||||||
|
"Enabled": true,
|
||||||
|
"TargetAllowList": [
|
||||||
|
"Editor"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user