InputMapping.bindNew

Bind an input stroke to an input action.

Does not replace any existing mappings, even in case of collision. Previously created mappings will have higher higher priority than this mapping.

  1. void bindNew(InputActionID action, InputEventCode[] codes)
    struct InputMapping
    void
    bindNew
    in (codes.length >= 1)
  2. void bindNew(InputEventCode[] codes)

Parameters

action InputActionID

Input action the stroke should trigger

codes InputEventCode[]

Sequence of event codes that triggers the event.

Examples

Add a number of bindings to an empty map.

import fluid.io.keyboard;

auto map = InputMapping();
map.bindNew!(FluidInputAction.press)    (KeyboardIO.codes.enter);
map.bindNew!(FluidInputAction.focusNext)(KeyboardIO.codes.tab);
map.bindNew!(FluidInputAction.submit)   (KeyboardIO.codes.leftControl, KeyboardIO.codes.enter);
map.bindNew!(FluidInputAction.copy)     (KeyboardIO.codes.leftControl, KeyboardIO.codes.c);

// The above creates equivalent layers
assert(map.layers == [
    Layer([KeyboardIO.codes.leftControl], [
        Trigger(inputActionID!(FluidInputAction.submit), KeyboardIO.codes.enter),
        Trigger(inputActionID!(FluidInputAction.copy),   KeyboardIO.codes.c),
    ]),
    Layer([], [
        Trigger(inputActionID!(FluidInputAction.press),     KeyboardIO.codes.enter),
        Trigger(inputActionID!(FluidInputAction.focusNext), KeyboardIO.codes.tab),
    ]),
]);

Meta