actions

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

The actions module implements actions that nanokongo can trigger in response to MIDI control change messages.

Index

Constants

This section is empty.

Variables

Functions

func RegisterAction

func RegisterAction(name string, constructor ActionConstructor)

RegisterAction associates an Action constructor with the specified name.

func RegisterActions

func RegisterActions()

Types

type Action

type Action interface {
	Act(int, int) error
}

func NewCommandAction

func NewCommandAction(args yaml.Node) (Action, error)

func NewSendKeysAction

func NewSendKeysAction(args yaml.Node) (Action, error)

func NewSendMidiAction

func NewSendMidiAction(args yaml.Node) (Action, error)

func NewSendMouseAction

func NewSendMouseAction(args yaml.Node) (Action, error)

type ActionConstructor

type ActionConstructor func(args yaml.Node) (Action, error)

func LookupAction

func LookupAction(want string) ActionConstructor

LookUpAction looks for a named action in the list of registered actions and returns the appropriate constructor.

type CommandAction

type CommandAction struct {
	Args []string
}

The command action allows you to execute commands in response to MIDI events.

A command is specified as a list of strings. Any occurrences of {value} will be replaced by the value of the MIDI control change message that triggered the event.

Example configuration:

controls:
  0:
    type: knob
    scaleRange: [0, 100]
    onChange:
      - command: [amixer, set, Master, '{value}%']

func (CommandAction) Act

func (action CommandAction) Act(value, lastvalue int) error

type ControlChangeSpec

type ControlChangeSpec struct {
	Control uint8
	Value   *uint8
}

type SendKeysAction

type SendKeysAction struct {
	Keys  []string
	Delay int
}

The sendKeys action allows you to send keystrokes in response to MIDI control change events.

See https://github.com/bendahl/uinput/blob/master/keycodes.go for a list of valid keycodes. Remove the "Key" part of the name, and convert the rest to lower case, so "KeyA" -> "a", and "KeyLeftshift" -> "leftshift".

Example configuration:

	controls:
	  41:
	    type: button
	    onRelease:
	      - sendKeys:
	          keys: [leftshift+o, o, d, d, b, i, t]
               delay: 100

func (SendKeysAction) Act

func (action SendKeysAction) Act(value, lastvalue int) error

type SendMidiAction

type SendMidiAction struct {
	DeviceName    string    `yaml:"device"`
	ChannelNumber uint8     `yaml:"channel"`
	Port          *midi.Out `yaml:"-"`
	Messages      []ControlChangeSpec
}

The sendMidi actions lets you send MIDI control change messages in response to midi control change events.

Example configuration:

controls:
  48:
    type: button
    onRelease:
      - sendMidi:
          device: nanoKONTROL2
          channel: 0
          messages:
          - control: 0x30
            value: 0x7f

func (SendMidiAction) Act

func (action SendMidiAction) Act(value, lastvalue int) error

type SendMouseAction

type SendMouseAction struct {
	Click   string
	Press   string
	Release string
	X       int
	Y       int
	WheelX  int
	WheelY  int
}

The sendMouse action lets you send mouse inputs in reaction to MIDI control change messages.

Supported attributes are:

- click: name of a button to click (one of "left", "right") - press: name of a button to press - release: name of a button to release - x: relative x movement - y: relative y movement - wheelx: relative horizontal wheel movement - wheely: relative vertical wheel movement

Example config:

controls:
  58:
    type: button
    onRelease:
      - sendMouse:
          click: left

func (SendMouseAction) Act

func (action SendMouseAction) Act(value, lastvalue int) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL