I'm making an addon that has some remapping of the key configurations.
How would you guys edit the transform modal map trough code?
I want Y axis to be overriden by Space and ⇧ Shift + Space
These are the specific keys that I want to override:
def add_keymap_items(clear_existing=True):
if clear_existing:
clear_keymaps()
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
# Handling modal keymap changes
km_transform_modal = kc.keymaps.get('Transform Modal Map')
if km_transform_modal:
# Add a modal keymap item for Y axis constraint during translation
kmi = km_transform_modal.keymap_items.new_modal('CONFIRM', 'SPACE', 'PRESS')
kmi_props = kmi.properties
kmi_props.name = 'axis_y'
addon_keymaps.append((km_transform_modal, kmi))
else:
print("Modal keymap 'Transform Modal Map' not found")
km_edit_mode = kc.keymaps.new(name='Mesh', space_type='EMPTY')
# LOOP CUT
kmi = km_edit_mode.keymap_items.new(HP_OT_loopcut.bl_idname, type='R', value='PRESS', ctrl=True, shift=False)
addon_keymaps.append((km_edit_mode, kmi))
# SMART PUSH AND SLIDE
kmi = km_edit_mode.keymap_items.new(HP_OT_PushAndSlide.bl_idname, type='G', value='PRESS', ctrl=False, shift=True)
addon_keymaps.append((km_edit_mode, kmi))
kmi = km_edit_mode.keymap_items.new('mesh.select_prev_item', type='WHEELOUTMOUSE', value='PRESS', ctrl=False, shift=True)
addon_keymaps.append((km_edit_mode, kmi))
kmi = km_edit_mode.keymap_items.new('mesh.select_next_item', type='WHEELINMOUSE', value='PRESS', ctrl=False, shift=True)
addon_keymaps.append((km_edit_mode, kmi))
kmi = km_edit_mode.keymap_items.new('mesh.loop_select', type='LEFTMOUSE', value='PRESS', ctrl=False, shift=False, alt=True)
addon_keymaps.append((km_edit_mode, kmi))
kmi = km_edit_mode.keymap_items.new('mesh.edgering_select', type='LEFTMOUSE', value='DOUBLE_CLICK', ctrl=False, shift=False, alt=True)
addon_keymaps.append((km_edit_mode, kmi))