config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MappingUp    Action = "mapping_up"
	MappingDown  Action = "mapping_down"
	Mapping      Action = "mapping" // given with mapping number
	OctaveUp     Action = "octave_up"
	OctaveDown   Action = "octave_down"
	SemitoneUp   Action = "semitone_up"
	SemitoneDown Action = "semitone_down"
	ChannelUp    Action = "channel_up"
	ChannelDown  Action = "channel_down"
	Channel      Action = "channel"   // given with number parameter 1-16
	Multinote    Action = "multinote" // holding this button and pressing midi keys sets multinote mode
	Panic        Action = "panic"
	Learning     Action = "cc_learning"
	Exit         Action = "exit"

	AnalogPitchBend MappingType = "pitch_bend"
	AnalogCC        MappingType = "cc"
	AnalogKeySim    MappingType = "key"
	AnalogActionSim MappingType = "action"

	CollisionOff       CollisionMode = "off"       // always emit note_on/off events
	CollisionNoRepeat  CollisionMode = "no_repeat" // emit note_on on first occurrence, note_off on last release
	CollisionInterrupt CollisionMode = "interrupt" // interrupt previous occurrence with note_off event first, note_off on last release
	CollisionRetrigger CollisionMode = "retrigger" // always emit note_on, note_off on last release
)

Variables

View Source
var (
	UnsupportedDeviceType = errors.New("unsupported device type")
)

Functions

func DetectDeviceConfigChanges

func DetectDeviceConfigChanges(ctx context.Context) <-chan bool

func NoteToOctave

func NoteToOctave(note byte) int

func NoteToPitch

func NoteToPitch(note byte) string

func StringToNote

func StringToNote(note string) (byte, error)

func StringToNoteUnsafe

func StringToNoteUnsafe(note string) byte

func TomlKeyToEvCode added in v1.2.0

func TomlKeyToEvCode(key string, lookupTable map[string]evdev.EvCode) (evdev.EvCode, error)

Types

type Action

type Action string

type Analog

type Analog struct {
	MappingType       MappingType
	CC, CCNeg         byte
	Note, NoteNeg     byte
	ChannelOffset     byte
	ChannelOffsetNeg  byte
	Action, ActionNeg Action
	FlipAxis          bool
	Bidirectional     bool
	DeadzoneAtCenter  bool
}

type AnalogMappingAction

type AnalogMappingAction struct {
	Action, ActionNeg Action
	FlipAxis          bool
	Bidirectional     bool
}

type AnalogMappingCC

type AnalogMappingCC struct {
	CC, CCNeg     byte
	FlipAxis      bool
	Bidirectional bool
}

type AnalogMappingNote

type AnalogMappingNote struct {
	Note, NoteNeg byte
	FlipAxis      bool
	Bidirectional bool
}

type CollisionMode

type CollisionMode string

type Colors

type Colors struct {
	White, Black, C openrgb.Color
	Unavailable     openrgb.Color
	Other           openrgb.Color
	Active          openrgb.Color
	ActiveExternal  openrgb.Color
}

type Config

type Config struct {
	ID            input.InputID
	Uniq          string
	KeyMappings   []KeyMapping
	ActionMapping map[evdev.EvCode]Action
	ExitSequence  []evdev.EvCode
	CollisionMode CollisionMode
	Defaults      Defaults
	OpenRGB       OpenRGB
}

func ParseData added in v1.1.0

func ParseData(data []byte) (Config, error)

type ConfigMap

type ConfigMap map[input.InputID]DeviceConfig

type Defaults

type Defaults struct {
	Octave, Semitone, Channel, Mapping, Velocity int
}

type DeviceConfig

type DeviceConfig struct {
	ConfigFile string
	ConfigType string // factory or user
	Config     Config
}

type DeviceConfigs

type DeviceConfigs struct {
	Factory struct {
		Keyboards ConfigMap
		Gamepads  ConfigMap
	}
	User struct {
		Keyboards ConfigMap
		Gamepads  ConfigMap
	}
}

func LoadDeviceConfigs

func LoadDeviceConfigs(ctx context.Context, wg *sync.WaitGroup) (DeviceConfigs, error)

func (*DeviceConfigs) FindConfig

func (c *DeviceConfigs) FindConfig(id input.InputID, devType input.DeviceType) (DeviceConfig, error)

type Key added in v1.1.0

type Key struct {
	Note          byte
	ChannelOffset byte
}

type KeyMapping

type KeyMapping struct {
	Name            string
	Midi            map[string]map[evdev.EvCode]Key     // main key: subhandler
	Analog          map[string]map[evdev.EvCode]Analog  // main key: subhandler
	Deadzones       map[string]map[evdev.EvCode]float64 // main key: subhandler
	DefaultDeadzone map[string]float64                  // main key: subhandler
}

type MappingType

type MappingType string

type OpenRGB

type OpenRGB struct {
	Colors Colors
}

type TOMLDeviceConfig

type TOMLDeviceConfig struct {
	CollisionMode string   `toml:"collision_mode"`
	ExitSequence  []string `toml:"exit_sequence"`

	Identifier struct {
		Bus     uint16 `toml:"bus"`
		Vendor  uint16 `toml:"vendor"`
		Product uint16 `toml:"product"`
		Version uint16 `toml:"version"`
		Uniq    string `toml:"uniq"`
	} `toml:"identifier"`

	Defaults struct {
		Octave   int    `toml:"octave"`
		Semitone int    `toml:"semitone"`
		Channel  int    `toml:"channel"`
		Mapping  string `toml:"mapping"`
		Velocity int    `toml:"velocity"`
	} `toml:"defaults"`

	ActionMapping map[string]string `toml:"action_mapping"`

	OpenRGB struct {
		White          int `toml:"white"`
		Black          int `toml:"black"`
		C              int `toml:"c"`
		Unavailable    int `toml:"unavailable"`
		Other          int `toml:"other"`
		Active         int `toml:"active"`
		ActiveExternal int `toml:"active_external"`
	} `toml:"open_rgb"`

	KeyMappings []struct {
		Name       string `toml:"name"`
		KeyMapping []struct {
			SubHandler string            `toml:"subhandler"`
			Map        map[string]string `toml:"map"`
		} `toml:"keys"`
		AnalogMapping []struct {
			SubHandler      string  `toml:"subhandler"`
			DefaultDeadzone float64 `toml:"default_deadzone,omitempty"`
			Map             map[string]struct {
				Type                  string  `toml:"type"`
				CC                    *int    `toml:"cc,omitempty"`
				CCNegative            *int    `toml:"cc_negative,omitempty"`
				Note                  *int    `toml:"note,omitempty"`
				NoteNegative          *int    `toml:"note_negative,omitempty"`
				ChannelOffset         int     `toml:"channel_offset"`
				ChannelOffsetNegative int     `toml:"channel_offset_negative"`
				Action                *string `toml:"action,omitempty"`
				ActionNegative        *string `toml:"action_negative,omitempty"`
				FlipAxis              bool    `toml:"flip_axis"`
				DeadzoneAtCenter      bool    `toml:"deadzone_at_center,omitempty"`
			} `toml:"map"`
			Deadzones map[string]float64 `toml:"deadzones,omitempty"`
		} `toml:"analog,omitempty"`
	} `toml:"mapping"`
}

Jump to

Keyboard shortcuts

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