mode

package
v0.0.0-...-23a661a Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputType_None = iota // for always-on-trigger
	InputType_Button
	InputType_Stick
	InputType_Gyro
	InputType_Speech
)
View Source
const (
	Tag_Repeat    = "[repeat]"
	Tag_CaseCamel = "[camel]"
	Tag_CaseTitle = "[title]"
	Tag_CaseUpper = "[upper]"
	Tag_CaseSnake = "[snake]"
)

Variables

View Source
var Manager = &ModeManager{}

global variable

View Source
var ModeList []ModeConfig
View Source
var PhraseList map[string][]string
View Source
var WordMapping map[string][]string

Functions

func Parse

func Parse() ([]mode, []switch_, error)

Types

type ButtonCondition

type ButtonCondition struct {
	// contains filtered or unexported fields
}

If the *Input matches Up/Down event of specified key

func (*ButtonCondition) Satisfy

func (bc *ButtonCondition) Satisfy(in *Input) bool

type ButtonInput

type ButtonInput struct {
	Up, Down, Curr *joycon.ButtonState
}

type ButtonSwitch

type ButtonSwitch struct {
	Switch
}

A switch that is turned on On/Off by Button down/up

func NewButtonSwitch

func NewButtonSwitch(btnId joycon.ButtonID) *ButtonSwitch

type ButtonTrigger

type ButtonTrigger struct {
	Trigger
}

func NewButtonTrigger

func NewButtonTrigger(
	btnId joycon.ButtonID, whenDown bool, a action,
) *ButtonTrigger

type CursorBoost

type CursorBoost struct {
	Modifier
	// contains filtered or unexported fields
}

Boost cursor move speed or slow it down

func NewCursorBoost

func NewCursorBoost(multiplier float64) *CursorBoost

func (*CursorBoost) Modify

func (cb *CursorBoost) Modify(in *Input)

type EnableGyro

type EnableGyro struct {
	// contains filtered or unexported fields
}

func (*EnableGyro) Do

func (eg *EnableGyro) Do(in *Input)

type ExecSpeech

type ExecSpeech struct {
	// contains filtered or unexported fields
}

func NewExecSpeech

func NewExecSpeech(
	castNumber, noSpace, typing bool,
	mappings []string,
) (*ExecSpeech, error)

func (*ExecSpeech) Do

func (es *ExecSpeech) Do(in *Input)

type FlushVoice

type FlushVoice struct{}

`FlushVoice` forces speech engine stop waiting for further data and return the result immediately

func (*FlushVoice) Do

func (fv *FlushVoice) Do(*Input)

type Gyro

type Gyro struct {
	Frame *joycon.GyroFrame
}

type GyroCondition

type GyroCondition struct{}

return true if there is gyro signal

func (*GyroCondition) Satisfy

func (sc *GyroCondition) Satisfy(in *Input) bool

type GyroMode

type GyroMode struct {
	Mode
}

func NewGyroMode

func NewGyroMode(modeId string) *GyroMode

func (*GyroMode) OnEnter

func (g *GyroMode) OnEnter(in *Input) error

func (*GyroMode) OnExit

func (g *GyroMode) OnExit(in *Input) error

type GyroTrigger

type GyroTrigger struct {
	Trigger
}

func NewGyroTrigger

func NewGyroTrigger(
	a action,
) *GyroTrigger

type Hotkey

type Hotkey struct {
	// contains filtered or unexported fields
}

just use the `hotkey` of `word executor`

func NewHotkey

func NewHotkey(keys []string) *Hotkey

func (*Hotkey) Do

func (h *Hotkey) Do(*Input)

type IdleMode

type IdleMode struct {
	Mode
}

A mode that does nothing, used as default mode

func NewIdleMode

func NewIdleMode(modeId string) *IdleMode

type Input

type Input struct {
	Type InputType

	Jc joycon.Controller

	// button
	*ButtonInput

	// stick
	*StickInput

	// gyro
	*Gyro

	// text
	*SpeechInput
}

type InputType

type InputType int

type Mode

type Mode struct {
	// contains filtered or unexported fields
}

`Mode` is a container of modifier switches and action triggers, it passes all Input events to them

func (*Mode) Handle

func (m *Mode) Handle(in *Input)

func (*Mode) Id

func (m *Mode) Id() string

func (*Mode) OnEnter

func (m *Mode) OnEnter(*Input) error

func (*Mode) OnExit

func (m *Mode) OnExit(*Input) error

func (*Mode) SetActions

func (m *Mode) SetActions(t []trigger)

func (*Mode) SetSwitches

func (m *Mode) SetSwitches(sw map[switch_]modifier)

type ModeConfig

type ModeConfig struct {
	Mode  string   ``
	Rules []string `toml:"Rules,multiline"`
}

type ModeManager

type ModeManager struct {
	// contains filtered or unexported fields
}

func (*ModeManager) CurrentMode

func (l *ModeManager) CurrentMode() mode

func (*ModeManager) DefaultMode

func (l *ModeManager) DefaultMode() mode

func (*ModeManager) Handle

func (l *ModeManager) Handle(in *Input)

func (*ModeManager) SetModes

func (l *ModeManager) SetModes(list []mode, modeSwitches []switch_) error

Set modes from configuration file, the first is set as default mode

type Modifier

type Modifier struct {
}

A convenient class for default members

func (*Modifier) Reset

func (m *Modifier) Reset()

type MouseClick

type MouseClick struct {
	// contains filtered or unexported fields
}

func NewMouseClick

func NewMouseClick(button string, isDouble bool) *MouseClick

func (*MouseClick) Do

func (mc *MouseClick) Do(*Input)

type MouseToggle

type MouseToggle struct {
	// contains filtered or unexported fields
}

func NewMouseDown

func NewMouseDown(button string) *MouseToggle

func NewMouseToggle

func NewMouseToggle(button, downUp string) *MouseToggle

func NewMouseUp

func NewMouseUp(button string) *MouseToggle

func (*MouseToggle) Do

func (md *MouseToggle) Do(*Input)

type MoveCursor

type MoveCursor struct {
	// contains filtered or unexported fields
}

Cursor movement JoyCon's packet push inerval is 15ms `robotgo.MoveRelative` takes < 2ms

func NewMoveCursor

func NewMoveCursor(speed float64) *MoveCursor

func (*MoveCursor) Do

func (mc *MoveCursor) Do(in *Input)

type Repeat

type Repeat struct {
}

func (*Repeat) Do

func (r *Repeat) Do(*Input)

type RestoreMode

type RestoreMode struct{}

Restore to default mode

func (*RestoreMode) Do

func (rm *RestoreMode) Do(in *Input)

type Speak

type Speak struct {
	// contains filtered or unexported fields
}

`Speak` simulate a speech, throw it to the word executor, normally used for complex macro that cannot be done with a simple action. For example, if we want to: win+R -> delay-1-second -> type"calc.exe" -> enter -> delay-1-second -> type"1+1=" this can only be done with word executors, hence a [speech] trigger must be set in that mode.

func (*Speak) Do

func (s *Speak) Do(*Input)

type SpeechCondition

type SpeechCondition struct{}

return true if there is speech signal

func (*SpeechCondition) Satisfy

func (sc *SpeechCondition) Satisfy(in *Input) bool

type SpeechInput

type SpeechInput struct {
	Text string
}

type SpeechMode

type SpeechMode struct {
	Mode
	// contains filtered or unexported fields
}

func NewSpeechMode

func NewSpeechMode(
	modeId, engine, host string,
	phraseIds []string,
	flushOnExit bool,
) (*SpeechMode, error)

func (*SpeechMode) OnEnter

func (sp *SpeechMode) OnEnter(*Input) error

Start monitoring microphone input and send captured voice data to recognition engine.

func (*SpeechMode) OnExit

func (sp *SpeechMode) OnExit(*Input) error

type SpeechTrigger

type SpeechTrigger struct {
	Trigger
}

func NewSpeechTrigger

func NewSpeechTrigger(
	a action,
) *SpeechTrigger

type StickDirectionCondition

type StickDirectionCondition struct {
	// contains filtered or unexported fields
}

5 enter and 5 leave events for: U D L R Center

func (*StickDirectionCondition) Satisfy

func (sc *StickDirectionCondition) Satisfy(in *Input) bool

type StickDirectionSwitch

type StickDirectionSwitch struct {
	Switch
	// contains filtered or unexported fields
}

A switch that is turned on On/Off by spinning stick to the specified direction

func NewStickDirectionSwitch

func NewStickDirectionSwitch(side joycon.JoyConSide, dir joycon.SpinDirection) *StickDirectionSwitch

type StickDirectionTrigger

type StickDirectionTrigger struct {
	Trigger
}

func NewStickDirectionTrigger

func NewStickDirectionTrigger(
	side joycon.JoyConSide, dir joycon.SpinDirection, a action,
) *StickDirectionTrigger

type StickInput

type StickInput struct {
	Side      joycon.JoyConSide
	Ratio     *joycon.Ratio
	Direction joycon.SpinDirection
}

type StickMoveCondition

type StickMoveCondition struct {
	// contains filtered or unexported fields
}

check if there is specified stick movement event

func (*StickMoveCondition) Satisfy

func (sc *StickMoveCondition) Satisfy(in *Input) bool

type StickMoveTrigger

type StickMoveTrigger struct {
	Trigger
}

func NewStickMoveTrigger

func NewStickMoveTrigger(
	side joycon.JoyConSide, a action,
) *StickMoveTrigger

type Switch

type Switch struct {
	// contains filtered or unexported fields
}

A convenient class for default members

func (*Switch) GetOffTrigger

func (s *Switch) GetOffTrigger() trigger

func (*Switch) GetOnTrigger

func (s *Switch) GetOnTrigger() trigger

func (*Switch) Handle

func (s *Switch) Handle(
	in *Input,
) SwitchResult

func (*Switch) IsOn

func (s *Switch) IsOn() bool

func (*Switch) Reset

func (s *Switch) Reset()

func (*Switch) SetOffTrigger

func (s *Switch) SetOffTrigger(t trigger)

func (*Switch) SetOnTrigger

func (s *Switch) SetOnTrigger(t trigger)

type SwitchMode

type SwitchMode struct {
	// contains filtered or unexported fields
}

Mode Switcher

func NewSwitchMode

func NewSwitchMode(modeId string) *SwitchMode

func (*SwitchMode) Do

func (sm *SwitchMode) Do(in *Input)

type SwitchResult

type SwitchResult int
const (
	SwitchedOn SwitchResult = iota
	SwitchedOff
	SwitchNotChange
)

type SysNotify

type SysNotify struct {
	// contains filtered or unexported fields
}

Popup a system notification with specified Title/Text/Icon

func NewSysNotify

func NewSysNotify(title, text, icon string) *SysNotify

func (*SysNotify) Do

func (sn *SysNotify) Do(in *Input)

type TextPrefix

type TextPrefix struct {
	Modifier
	// contains filtered or unexported fields
}

func (*TextPrefix) Modify

func (tp *TextPrefix) Modify(in *Input)

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

A convenient class for default members

func (*Trigger) GetAction

func (t *Trigger) GetAction() action

func (*Trigger) GetCondition

func (t *Trigger) GetCondition() condition

func (*Trigger) Handle

func (t *Trigger) Handle(in *Input) TriggerResult

func (*Trigger) SetAction

func (t *Trigger) SetAction(a action)

func (*Trigger) SetCondition

func (t *Trigger) SetCondition(c condition)

type TriggerResult

type TriggerResult int
const (
	Triggered TriggerResult = iota
	NotTriggered
)

Jump to

Keyboard shortcuts

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