config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 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"
	GyroX        Action = "gyro_x"
	GyroY        Action = "gyro_y"
	GyroZ        Action = "gyro_z"
	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

	GyroHold   GyroMode = "hold"
	GyroToggle GyroMode = "toggle"
)

Variables

View Source
var SupportedGyroActivationTypes = map[GyroMode]bool{
	GyroHold:   true,
	GyroToggle: true,
}
View Source
var SupportedGyroMappingTypes = map[MappingType]bool{
	AnalogPitchBend: true,
	AnalogCC:        true,
}
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

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
}

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
	Deadzone      Deadzone
	Gyro          map[evdev.EvCode][]GyroDesc
	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 Deadzone

type Deadzone struct {
	Deadzones map[evdev.EvCode]float64
	Default   float64
}

type Defaults

type Defaults struct {
	Octave, Semitone, Channel, Mapping 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 GyroDesc

type GyroDesc struct {
	Axis                int // 0-2 (x, y, z)
	Type                MappingType
	CC                  int
	ActivationMode      GyroMode
	ResetOnDeactivation bool
	FlipAxis            bool
	ValueMultiplier     float64
}

func (GyroDesc) String

func (g GyroDesc) String() string

type GyroDescToml

type GyroDescToml struct {
	Axis                string  `toml:"axis"`
	Type                string  `toml:"type"`
	CC                  int     `toml:"cc"`
	ActivationKey       string  `toml:"activation_key"`
	ActivationMode      string  `toml:"activation_mode"`
	ResetOnDeactivation bool    `toml:"reset_on_deactivation"`
	FlipAxis            bool    `toml:"flip_axis"`
	ValueMultiplier     float64 `toml:"value_multiplier"`
}

type GyroMode

type GyroMode string

type Key added in v1.1.0

type Key struct {
	Note          byte
	ChannelOffset byte
}

type KeyMapping

type KeyMapping struct {
	Name   string
	Midi   map[evdev.EvCode]Key
	Analog map[evdev.EvCode]Analog
}

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"`
	} `toml:"defaults"`

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

	Gyro []GyroDescToml `toml:"gyro"`

	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"`

	Deadzone struct {
		Default   float64            `toml:"default"`
		Deadzones map[string]float64 `toml:"deadzones"`
	} `toml:"deadzone,omitempty"`

	KeyMappings []struct {
		Name          string            `toml:"name"`
		KeyMapping    map[string]string `toml:"keys"`
		AnalogMapping 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"`
		} `toml:"analog,omitempty"`
	} `toml:"mapping"`
}

type YamlCustomMapping

type YamlCustomMapping struct {
	MappingType    string `yaml:"type"`
	CC             string `yaml:"cc"`
	CCNegative     string `yaml:"cc_negative"`
	Note           string `yaml:"note"`
	NoteNegative   string `yaml:"note_negative"`
	Action         string `yaml:"action"`
	ActionNegative string `yaml:"action_negative"`
	FlipAxis       bool   `yaml:"flip_axis"`
}

type YamlDeviceConfig

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

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

	CollisionMode   string                         `yaml:"collision_mode"`
	Deadzones       map[string]float64             `yaml:"deadzones"`
	DefaultDeadzone float64                        `yaml:"default_deadzone"`
	ActionMapping   map[string]string              `yaml:"action_mapping"`
	KeyMappings     []map[string]map[string]string `yaml:"midi_mappings"`
	ExitSequence    []string                       `yaml:"exit_sequence"`

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

Jump to

Keyboard shortcuts

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