[MOD/API] Hotkey API

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

[MOD/API] Hotkey API

Post by SirNukes » Mon, 25. Nov 19, 09:34

Download: https://github.com/bvbohnen/x4-projects/releases
Documentation: https://github.com/bvbohnen/x4-projects ... nctions.md


X4 Hotkey API

Adds support for capturing key presses in X4, to implement custom hotkeys.
An external Python server is used for the key capture and combo recognition, and interfaces with X4 using named pipes.

Requirements Usage

Extensions may define custom hotkey actions by registering a new action with the api, where an action has an id and callback cue. Actions are initially unbound to any input. Actions will appear in the standard controls menu for the player, under the General page. Each action may specify in which contexts it will be valid: when flying, when walking, in any menu, or in specifically named menus.

Example action registration:

Code: Select all

  <signal_cue_instantly 
    cue="md.Hotkey_API.Register_Action" 
    param="table[
      $id = 'kc_target_follow', 
      $cue = Target_Follow,
      $name = 'Follow Target', 
      $description = 'Turns on autopilot to follow the target'
    ]"/>
Optionally, a key or key combination may be directly assigned to the action from md script. When done this way, a wider variety of combinations are supported than possible through the standard options menu.

Example direct key mapping:

Code: Select all

  <cue name="Register_Keys" instantiate="true">
    <conditions>
      <event_cue_signalled cue="md.Hotkey_API.Reloaded" />
    </conditions>
    <actions>
      <signal_cue_instantly 
        cue="md.Hotkey_API.Register_Key" 
        param="table[$key='shift a', $id='kc_target_follow']"/>
    </actions>
  </cue>
Limitations:
  • The windows backend confuses numpad enter and numpad / with their non-numpad counterparts. If one of these keys is used, both the numpad and normal key will trigger the hotkey callback.
  • Currently only supports keyboard inputs.

Post Reply

Return to “X4: Foundations - Scripts and Modding”