From fca945333929ce1f3054340315a65f08a8bf1236 Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sat, 24 Jan 2026 01:10:48 -0300 Subject: [PATCH 1/7] Added trigger integration and gradient led --- pkg/commands/leds.go | 59 ++- pkg/commands/trigger.go | 429 +++++++++++++++++ pkg/dbus/pb/convert.go | 120 +++++ pkg/dbus/pb/flydigi.pb.go | 898 ++++++++++++++++++++++++------------ pkg/dbus/pb/flydigi.proto | 43 ++ pkg/flydigi/config/beans.go | 190 ++++++++ 6 files changed, 1451 insertions(+), 288 deletions(-) create mode 100644 pkg/commands/trigger.go diff --git a/pkg/commands/leds.go b/pkg/commands/leds.go index 8eab343..410077d 100644 --- a/pkg/commands/leds.go +++ b/pkg/commands/leds.go @@ -30,7 +30,20 @@ var ledsCommand = &cobra.Command{ case *pb.LedsConfiguration_Streamlined: fmt.Printf("Streamlined, speed %.0f%%\n", leds.Streamlined.Speed*100) - } + + case *pb.LedsConfiguration_Gradient: + fmt.Printf("Gradient, speed %.0f%%\n", leds.Gradient.Speed*100) + + for i, c := range leds.Gradient.Colors { + r, g, b := c.RGB() + fmt.Printf(" %d: #%02X%02X%02X (%d, %d, %d)\n", + i, + r, g, b, + r, g, b, + ) + } + + } return nil }) @@ -75,13 +88,57 @@ var ledsStreamlinedCommand = &cobra.Command{ }, } +var gradientSpeed float32 +var ledsGradientCommand = &cobra.Command{ + Use: "gradient [color3 ... color9]", + Short: "Sets LEDs to a gradient effect", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 2 { + return fmt.Errorf("gradient requires at least 2 colors") + } + if len(args) > 9 { + return fmt.Errorf("gradient supports at most 9 colors") + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + return useConnection(func() error { + colors := make([]*pb.Color, 0, len(args)) + + for _, hex := range args { + color, ok := pb.ColorFromName(hex) + if !ok { + color, ok = pb.ColorFromHex(hex) + if !ok { + return errInvalidColor + } + } + colors = append(colors, color) + } + + return modifyLEDConfiguration(func(conf *pb.LedsConfiguration) { + conf.Brightness = ledsBrightness + conf.Leds = &pb.LedsConfiguration_Gradient{ + Gradient: &pb.LedsGradient{ + Speed: gradientSpeed, + Colors: colors, + }, + } + }) + }) + }, +} + + func init() { rootCmd.AddCommand(ledsCommand) ledsCommand.AddCommand(ledsSteadyCommand) ledsCommand.AddCommand(ledsStreamlinedCommand) + ledsCommand.AddCommand(ledsGradientCommand) ledsCommand.PersistentFlags().Float32VarP(&ledsBrightness, "brightness", "b", 1, "led brightness (0.0-1.0)") ledsStreamlinedCommand.Flags().Float32VarP(&streamlinedSpeed, "speed", "s", 0.5, "speed for the effect (0.0-1.0)") + ledsGradientCommand.Flags().Float32VarP(&gradientSpeed, "speed", "s", 0.5, "speed for the effect (0.0-1.0)") } diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go new file mode 100644 index 0000000..5ebaa01 --- /dev/null +++ b/pkg/commands/trigger.go @@ -0,0 +1,429 @@ +package commands + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + "github.com/pipe01/flydigictl/pkg/dbus/pb" + "github.com/spf13/cobra" +) + +type triggerSide string + +type TriggerMotorSetJson *struct { + Type *int32 `json:"Type"` + Min *int32 `json:"Min"` + Max *int32 `json:"Max"` + Filter *int32 `json:"Filter"` + VibrLimit *int32 `json:"VibrLimit"` + Scale *int32 `json:"Scale"` + TimeLimit *int32 `json:"TimeLimit"` +} + +type TriggerJSON struct { + AutoTrigger *struct { + Mode *int32 `json:"Mode"` + + VibrationBind *struct { + Type *int32 `json:"Type"` + MinFilter *int32 `json:"MinFilter"` + Scale *int32 `json:"Scale"` + TriggerParams []int32 `json:"TriggerParams"` + } `json:"VibrationBind"` + + MixedBorder *int32 `json:"MixedBorder"` + MixedParams []int32 `json:"MixedParams"` + } `json:"AutoTrigger"` + + TriggerMotor *struct { + LineGear TriggerMotorSetJson `json:"LineGear"` + MicrGear TriggerMotorSetJson `json:"MicrGear"` + } `json:"TriggerMotor"` +} + +const ( + triggerLeft triggerSide = "left" + triggerRight triggerSide = "right" +) + +func (s triggerSide) GetBean(b *pb.GamepadConfiguration) *pb.TriggerConfiguration { + switch s { + case triggerLeft: + return b.LeftTrigger + case triggerRight: + return b.RightTrigger + } + panic("invalid trigger side") +} + +func triggerModeName(mode int32) string { + switch mode { + case 0: + return "default" + case 1: + return "race" + case 2: + return "recoil" + case 3: + return "sniper" + case 4: + return "lock" + case 5: + return "vibration" + default: + return fmt.Sprintf("unknown(%d)", mode) + } +} + +func loadTriggerJSON(path string) (*TriggerJSON, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, err + } + + var cfg TriggerJSON + if err := json.Unmarshal(data, &cfg); err != nil { + return nil, err + } + + return &cfg, nil +} + +func applyTriggerJSON(dst *pb.TriggerConfiguration, src *TriggerJSON) { + if src.AutoTrigger != nil { + at := dst.AutoTrigger + + if src.AutoTrigger.Mode != nil { + at.Mode = *src.AutoTrigger.Mode + } + + if src.AutoTrigger.VibrationBind != nil { + vb := at.VibrationBind + + if src.AutoTrigger.VibrationBind.Type != nil { + vb.Type = *src.AutoTrigger.VibrationBind.Type + } + if src.AutoTrigger.VibrationBind.MinFilter != nil { + vb.MinFilter = *src.AutoTrigger.VibrationBind.MinFilter + } + if src.AutoTrigger.VibrationBind.Scale != nil { + vb.Scale = *src.AutoTrigger.VibrationBind.Scale + } + if len(src.AutoTrigger.VibrationBind.TriggerParams) > 0 { + vb.TriggerParams = src.AutoTrigger.VibrationBind.TriggerParams + } + } + + if src.AutoTrigger.MixedBorder != nil { + at.MixedBorder = *src.AutoTrigger.MixedBorder + } + if len(src.AutoTrigger.MixedParams) > 0 { + at.MixedParams = src.AutoTrigger.MixedParams + } + } + + if src.TriggerMotor != nil { + if src.TriggerMotor.LineGear != nil { + lg := dst.TriggerMotor.LineGear + + if src.TriggerMotor.LineGear.Type != nil { + lg.Type = *src.TriggerMotor.LineGear.Type + } + if src.TriggerMotor.LineGear.Min != nil { + lg.Min = *src.TriggerMotor.LineGear.Min + } + if src.TriggerMotor.LineGear.Max != nil { + lg.Max = *src.TriggerMotor.LineGear.Max + } + if src.TriggerMotor.LineGear.Filter != nil { + lg.Filter = *src.TriggerMotor.LineGear.Filter + } + if src.TriggerMotor.LineGear.VibrLimit != nil { + lg.VibrLimit = *src.TriggerMotor.LineGear.VibrLimit + } + if src.TriggerMotor.LineGear.Scale != nil { + lg.Scale = *src.TriggerMotor.LineGear.Scale + } + if src.TriggerMotor.LineGear.TimeLimit != nil { + lg.TimeLimit = *src.TriggerMotor.LineGear.TimeLimit + } + } + if src.TriggerMotor.MicrGear != nil { + lg := dst.TriggerMotor.MicrGear + + if src.TriggerMotor.MicrGear.Type != nil { + lg.Type = *src.TriggerMotor.MicrGear.Type + } + if src.TriggerMotor.MicrGear.Min != nil { + lg.Min = *src.TriggerMotor.MicrGear.Min + } + if src.TriggerMotor.MicrGear.Max != nil { + lg.Max = *src.TriggerMotor.MicrGear.Max + } + if src.TriggerMotor.MicrGear.Filter != nil { + lg.Filter = *src.TriggerMotor.MicrGear.Filter + } + if src.TriggerMotor.MicrGear.VibrLimit != nil { + lg.VibrLimit = *src.TriggerMotor.MicrGear.VibrLimit + } + if src.TriggerMotor.MicrGear.Scale != nil { + lg.Scale = *src.TriggerMotor.MicrGear.Scale + } + if src.TriggerMotor.MicrGear.TimeLimit != nil { + lg.TimeLimit = *src.TriggerMotor.MicrGear.TimeLimit + } + } + } +} + +var triggerCommand = &cobra.Command{ + Use: "trigger", + Short: "Configure triggers (Apex 4)", +} + +func genTriggerCommand(side triggerSide) *cobra.Command { + cmd := &cobra.Command{ + Use: string(side), + Short: fmt.Sprintf("Manage %s trigger configuration", side), + RunE: func(cmd *cobra.Command, args []string) error { + mode, err := readConfiguration(func(conf *pb.GamepadConfiguration) int32 { + return int32(side.GetBean(conf).AutoTrigger.Mode) + }) + if err != nil { + return fmt.Errorf("get configuration: %w", err) + } + + modeName := triggerModeName(mode) + + if terseOutput { + fmt.Println(modeName) + } else { + fmt.Printf("%s trigger mode: %s\n", side, modeName) + } + return nil + }, + } + + cmd.AddCommand(&cobra.Command{ + Use: "default", + Short: "Set this trigger to default mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 0 + cfg.AutoTrigger.VibrationBind.TriggerParams = []int32{1, 10, 1, 90, 0} + + for i := range cfg.AutoTrigger.MixedParams { + cfg.AutoTrigger.MixedParams[i] = 0 + } + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "race", + Short: "Set this trigger to race mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 1 + cfg.AutoTrigger.VibrationBind.TriggerParams = []int32{100, 1, 255, 70, 0} + + for i := range cfg.AutoTrigger.MixedParams { + cfg.AutoTrigger.MixedParams[i] = 0 + } + cfg.AutoTrigger.MixedParams[1] = 30 + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 90 + lg.Max = 100 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 100 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "recoil", + Short: "Set this trigger to recoil mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 2 + cfg.AutoTrigger.VibrationBind.Type = 0 + cfg.AutoTrigger.VibrationBind.MinFilter = 10 + cfg.AutoTrigger.VibrationBind.Scale = 50 + cfg.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + cfg.AutoTrigger.MixedBorder = 0 + cfg.AutoTrigger.MixedParams = []int32{ + 0, 1, 50, 15, 1, + 0, 0, 0, 0, 0, + } + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "sniper", + Short: "Set this trigger to sniper mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 3 + cfg.AutoTrigger.VibrationBind.Type = 0 + cfg.AutoTrigger.VibrationBind.MinFilter = 10 + cfg.AutoTrigger.VibrationBind.Scale = 50 + cfg.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + cfg.AutoTrigger.MixedBorder = 0 + cfg.AutoTrigger.MixedParams = []int32{ + 50, 30, 1, 0, 1, + 0, 0, 0, 0, 0, + } + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "lock", + Short: "Set this trigger to lock mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 4 + cfg.AutoTrigger.VibrationBind.Type = 0 + cfg.AutoTrigger.VibrationBind.MinFilter = 10 + cfg.AutoTrigger.VibrationBind.Scale = 50 + cfg.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + cfg.AutoTrigger.MixedBorder = 0 + cfg.AutoTrigger.MixedParams = []int32{ + 40, 250, 1, 0, 0, + 0, 0, 0, 0, 0, + } + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "vibration", + Short: "Set this trigger to vibration mode", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 5 + cfg.AutoTrigger.VibrationBind.Type = 2 + cfg.AutoTrigger.VibrationBind.MinFilter = 10 + cfg.AutoTrigger.VibrationBind.Scale = 50 + cfg.AutoTrigger.VibrationBind.TriggerParams = + []int32{1, 1, 1, 90, 0} + + cfg.AutoTrigger.MixedBorder = 0 + cfg.AutoTrigger.MixedParams = []int32{ + 1, 1, 1, 90, 0, + 0, 0, 0, 0, 0, + } + + lg := cfg.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.VibrLimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 + }) + }, + }) + cmd.AddCommand(&cobra.Command{ + Use: "custom ", + Short: "Load custom trigger configuration from JSON file", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + path := args[0] + + info, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("file does not exist: %s", path) + } + return fmt.Errorf("cannot access file %s: %w", path, err) + } + + if info.IsDir() { + return fmt.Errorf("path is a directory, not a file: %s", path) + } + + if filepath.Ext(path) != ".json" { + return fmt.Errorf("expected a .json file: %s", path) + } + + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + jsonCfg, err := loadTriggerJSON(path) + if err != nil { + panic(err) + } + applyTriggerJSON(cfg, jsonCfg) + }) + }, + }) + + return cmd +} + +func init() { + var triggerLeftCommand = genTriggerCommand(triggerLeft) + var triggerRightCommand = genTriggerCommand(triggerRight) + + triggerCommand.AddCommand(triggerLeftCommand) + triggerCommand.AddCommand(triggerRightCommand) + + rootCmd.AddCommand(triggerCommand) +} diff --git a/pkg/dbus/pb/convert.go b/pkg/dbus/pb/convert.go index b1accc8..f7e5b57 100644 --- a/pkg/dbus/pb/convert.go +++ b/pkg/dbus/pb/convert.go @@ -49,12 +49,16 @@ func ConvertGamepadConfiguration(bean *config.AllConfigBean) *GamepadConfigurati return &GamepadConfiguration{ LeftJoystick: ConvertJoystickConfiguration(bean.JoyMapping.LeftJoystic), RightJoystick: ConvertJoystickConfiguration(bean.JoyMapping.RightJoystic), + LeftTrigger: ConvertTriggerConfiguration(bean.TriggerMapping.LeftTrigger), + RightTrigger: ConvertTriggerConfiguration(bean.TriggerMapping.RightTrigger), } } func (c *GamepadConfiguration) ApplyTo(bean *config.AllConfigBean) { c.LeftJoystick.ApplyTo(bean.JoyMapping.LeftJoystic) c.RightJoystick.ApplyTo(bean.JoyMapping.RightJoystic) + c.LeftTrigger.ApplyTo(bean.TriggerMapping.LeftTrigger) + c.RightTrigger.ApplyTo(bean.TriggerMapping.RightTrigger) } func ConvertJoystickConfiguration(bean *config.JoyStickBean) *JoystickConfiguration { @@ -67,6 +71,81 @@ func (c *JoystickConfiguration) ApplyTo(bean *config.JoyStickBean) { bean.Curve.Zero = c.Deadzone } +func ConvertTriggerConfiguration(bean *config.Trigger) *TriggerConfiguration { + return &TriggerConfiguration{ + AutoTrigger: &AutoTrigger{ + Mode: bean.AutoTrigger.Mode, + VibrationBind: &VibrationBind{ + Type: bean.AutoTrigger.VibrationBind.Type, + MinFilter: bean.AutoTrigger.VibrationBind.MinFilter, + Scale: bean.AutoTrigger.VibrationBind.Scale, + TriggerParams: bean.AutoTrigger.VibrationBind.TriggerParams, + }, + MixedBorder: bean.AutoTrigger.MixedBorder, + MixedParams: bean.AutoTrigger.MixedParams, + }, + TriggerMotor: &TriggerMotor{ + LineGear: &TriggerMotorSet{ + Type: bean.TriggerMotor.LineGear.Type, + Min: bean.TriggerMotor.LineGear.Min, + Max: bean.TriggerMotor.LineGear.Max, + Filter: bean.TriggerMotor.LineGear.Filter, + VibrLimit: bean.TriggerMotor.LineGear.Vibrlimit, + Scale: bean.TriggerMotor.LineGear.Scale, + TimeLimit: bean.TriggerMotor.LineGear.TimeLimit, + }, + MicrGear: &TriggerMotorSet{ + Type: bean.TriggerMotor.MicrGear.Type, + Min: bean.TriggerMotor.MicrGear.Min, + Max: bean.TriggerMotor.MicrGear.Max, + Filter: bean.TriggerMotor.MicrGear.Filter, + VibrLimit: bean.TriggerMotor.MicrGear.Vibrlimit, + Scale: bean.TriggerMotor.MicrGear.Scale, + TimeLimit: bean.TriggerMotor.MicrGear.TimeLimit, + }, + }, + } +} + +func (c *TriggerConfiguration) ApplyTo(bean *config.Trigger) { + if bean == nil { + return + } + + bean.Type = 0 + bean.AutoTrigger = &config.Autotrigger{ + Mode: c.AutoTrigger.Mode, + VibrationBind: &config.Vibrationbind{ + Type: c.AutoTrigger.VibrationBind.Type, + MinFilter: c.AutoTrigger.VibrationBind.MinFilter, + Scale: c.AutoTrigger.VibrationBind.Scale, + TriggerParams: c.AutoTrigger.VibrationBind.TriggerParams, + }, + MixedBorder: c.AutoTrigger.MixedBorder, + MixedParams: c.AutoTrigger.MixedParams, + } + bean.TriggerMotor = &config.TriggerMotor{ + LineGear: &config.TriggerMotorSet{ + Type: c.TriggerMotor.LineGear.Type, + Min: c.TriggerMotor.LineGear.Min, + Max: c.TriggerMotor.LineGear.Max, + Filter: c.TriggerMotor.LineGear.Filter, + Vibrlimit: c.TriggerMotor.LineGear.VibrLimit, + Scale: c.TriggerMotor.LineGear.Scale, + TimeLimit: c.TriggerMotor.LineGear.TimeLimit, + }, + MicrGear: &config.TriggerMotorSet{ + Type: c.TriggerMotor.MicrGear.Type, + Min: c.TriggerMotor.MicrGear.Min, + Max: c.TriggerMotor.MicrGear.Max, + Filter: c.TriggerMotor.MicrGear.Filter, + Vibrlimit: c.TriggerMotor.MicrGear.VibrLimit, + Scale: c.TriggerMotor.MicrGear.Scale, + TimeLimit: c.TriggerMotor.MicrGear.TimeLimit, + }, + } +} + func ConvertLEDConfiguration(bean *config.NewLedConfigBean) *LedsConfiguration { var leds isLedsConfiguration_Leds @@ -89,6 +168,30 @@ func ConvertLEDConfiguration(bean *config.NewLedConfigBean) *LedsConfiguration { Speed: float32(100-bean.Loop_time) / 100, }, } + case config.LedModeGradient: + colors := make([]*Color, 0) + + if bean.Rgb_num > 0 && len(bean.LedGroups) > 0 { + group := bean.LedGroups[0] + + for i := 0; i < int(bean.Rgb_num) && i < len(group.Units); i++ { + unit := group.Units[i] + if unit == nil { + continue + } + + colors = append(colors, &Color{ + Rgb: int32(unit.R)<<16 | int32(unit.G)<<8 | int32(unit.B), + }) + } + } + + leds = &LedsConfiguration_Gradient{ + Gradient: &LedsGradient{ + Speed: float32(100-bean.Loop_time) / 100, + Colors: colors, + }, + } default: panic("TODO: implement") @@ -111,5 +214,22 @@ func (c *LedsConfiguration) ApplyTo(bean *config.NewLedConfigBean) { case *LedsConfiguration_Streamlined: bean.SetStreamlined(leds.Streamlined.Speed) + + case *LedsConfiguration_Gradient: + g := leds.Gradient + + colors := make([]config.LedUnit, 0, len(g.Colors)) + for _, c := range g.Colors { + if c == nil { + continue + } + colors = append(colors, *c.LedUnit()) + } + + if len(colors) < 2 { + return + } + + bean.SetGradient(colors, g.Speed) } } diff --git a/pkg/dbus/pb/flydigi.pb.go b/pkg/dbus/pb/flydigi.pb.go index 64bf89f..71f0ccb 100644 --- a/pkg/dbus/pb/flydigi.pb.go +++ b/pkg/dbus/pb/flydigi.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v3.12.4 +// protoc-gen-go v1.36.11 +// protoc v6.33.1 // source: flydigi.proto package pb @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -70,24 +71,21 @@ func (ConnectionType) EnumDescriptor() ([]byte, []int) { } type GamepadInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - DeviceId int32 `protobuf:"varint,1,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` - BatteryPercent int32 `protobuf:"varint,2,opt,name=battery_percent,json=batteryPercent,proto3" json:"battery_percent,omitempty"` - ConnectionType ConnectionType `protobuf:"varint,3,opt,name=connection_type,json=connectionType,proto3,enum=flydigi.ConnectionType" json:"connection_type,omitempty"` - CpuType string `protobuf:"bytes,4,opt,name=cpu_type,json=cpuType,proto3" json:"cpu_type,omitempty"` - CpuName string `protobuf:"bytes,5,opt,name=cpu_name,json=cpuName,proto3" json:"cpu_name,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + DeviceId int32 `protobuf:"varint,1,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` + BatteryPercent int32 `protobuf:"varint,2,opt,name=battery_percent,json=batteryPercent,proto3" json:"battery_percent,omitempty"` + ConnectionType ConnectionType `protobuf:"varint,3,opt,name=connection_type,json=connectionType,proto3,enum=flydigi.ConnectionType" json:"connection_type,omitempty"` + CpuType string `protobuf:"bytes,4,opt,name=cpu_type,json=cpuType,proto3" json:"cpu_type,omitempty"` + CpuName string `protobuf:"bytes,5,opt,name=cpu_name,json=cpuName,proto3" json:"cpu_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GamepadInfo) Reset() { *x = GamepadInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GamepadInfo) String() string { @@ -98,7 +96,7 @@ func (*GamepadInfo) ProtoMessage() {} func (x *GamepadInfo) ProtoReflect() protoreflect.Message { mi := &file_flydigi_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -149,21 +147,20 @@ func (x *GamepadInfo) GetCpuName() string { } type GamepadConfiguration struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` LeftJoystick *JoystickConfiguration `protobuf:"bytes,1,opt,name=left_joystick,json=leftJoystick,proto3" json:"left_joystick,omitempty"` RightJoystick *JoystickConfiguration `protobuf:"bytes,2,opt,name=right_joystick,json=rightJoystick,proto3" json:"right_joystick,omitempty"` + LeftTrigger *TriggerConfiguration `protobuf:"bytes,3,opt,name=left_trigger,json=leftTrigger,proto3" json:"left_trigger,omitempty"` + RightTrigger *TriggerConfiguration `protobuf:"bytes,4,opt,name=right_trigger,json=rightTrigger,proto3" json:"right_trigger,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GamepadConfiguration) Reset() { *x = GamepadConfiguration{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GamepadConfiguration) String() string { @@ -174,7 +171,7 @@ func (*GamepadConfiguration) ProtoMessage() {} func (x *GamepadConfiguration) ProtoReflect() protoreflect.Message { mi := &file_flydigi_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -203,21 +200,32 @@ func (x *GamepadConfiguration) GetRightJoystick() *JoystickConfiguration { return nil } +func (x *GamepadConfiguration) GetLeftTrigger() *TriggerConfiguration { + if x != nil { + return x.LeftTrigger + } + return nil +} + +func (x *GamepadConfiguration) GetRightTrigger() *TriggerConfiguration { + if x != nil { + return x.RightTrigger + } + return nil +} + type JoystickConfiguration struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Deadzone int32 `protobuf:"varint,1,opt,name=deadzone,proto3" json:"deadzone,omitempty"` unknownFields protoimpl.UnknownFields - - Deadzone int32 `protobuf:"varint,1,opt,name=deadzone,proto3" json:"deadzone,omitempty"` + sizeCache protoimpl.SizeCache } func (x *JoystickConfiguration) Reset() { *x = JoystickConfiguration{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *JoystickConfiguration) String() string { @@ -228,7 +236,7 @@ func (*JoystickConfiguration) ProtoMessage() {} func (x *JoystickConfiguration) ProtoReflect() protoreflect.Message { mi := &file_flydigi_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -250,19 +258,349 @@ func (x *JoystickConfiguration) GetDeadzone() int32 { return 0 } -type LedsOff struct { - state protoimpl.MessageState +type VibrationBind struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + MinFilter int32 `protobuf:"varint,2,opt,name=minFilter,proto3" json:"minFilter,omitempty"` + Scale int32 `protobuf:"varint,3,opt,name=scale,proto3" json:"scale,omitempty"` + TriggerParams []int32 `protobuf:"varint,4,rep,packed,name=triggerParams,proto3" json:"triggerParams,omitempty"` + unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache +} + +func (x *VibrationBind) Reset() { + *x = VibrationBind{} + mi := &file_flydigi_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *VibrationBind) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VibrationBind) ProtoMessage() {} + +func (x *VibrationBind) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VibrationBind.ProtoReflect.Descriptor instead. +func (*VibrationBind) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{3} +} + +func (x *VibrationBind) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *VibrationBind) GetMinFilter() int32 { + if x != nil { + return x.MinFilter + } + return 0 +} + +func (x *VibrationBind) GetScale() int32 { + if x != nil { + return x.Scale + } + return 0 +} + +func (x *VibrationBind) GetTriggerParams() []int32 { + if x != nil { + return x.TriggerParams + } + return nil +} + +type TriggerConfiguration struct { + state protoimpl.MessageState `protogen:"open.v1"` + AutoTrigger *AutoTrigger `protobuf:"bytes,1,opt,name=autoTrigger,proto3" json:"autoTrigger,omitempty"` + TriggerMotor *TriggerMotor `protobuf:"bytes,2,opt,name=triggerMotor,proto3" json:"triggerMotor,omitempty"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *LedsOff) Reset() { - *x = LedsOff{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[3] +func (x *TriggerConfiguration) Reset() { + *x = TriggerConfiguration{} + mi := &file_flydigi_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerConfiguration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerConfiguration) ProtoMessage() {} + +func (x *TriggerConfiguration) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerConfiguration.ProtoReflect.Descriptor instead. +func (*TriggerConfiguration) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{4} +} + +func (x *TriggerConfiguration) GetAutoTrigger() *AutoTrigger { + if x != nil { + return x.AutoTrigger + } + return nil +} + +func (x *TriggerConfiguration) GetTriggerMotor() *TriggerMotor { + if x != nil { + return x.TriggerMotor + } + return nil +} + +type AutoTrigger struct { + state protoimpl.MessageState `protogen:"open.v1"` + Mode int32 `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"` + VibrationBind *VibrationBind `protobuf:"bytes,2,opt,name=vibrationBind,proto3" json:"vibrationBind,omitempty"` + MixedBorder int32 `protobuf:"varint,3,opt,name=mixedBorder,proto3" json:"mixedBorder,omitempty"` + MixedParams []int32 `protobuf:"varint,4,rep,packed,name=mixedParams,proto3" json:"mixedParams,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AutoTrigger) Reset() { + *x = AutoTrigger{} + mi := &file_flydigi_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AutoTrigger) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AutoTrigger) ProtoMessage() {} + +func (x *AutoTrigger) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AutoTrigger.ProtoReflect.Descriptor instead. +func (*AutoTrigger) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{5} +} + +func (x *AutoTrigger) GetMode() int32 { + if x != nil { + return x.Mode + } + return 0 +} + +func (x *AutoTrigger) GetVibrationBind() *VibrationBind { + if x != nil { + return x.VibrationBind + } + return nil +} + +func (x *AutoTrigger) GetMixedBorder() int32 { + if x != nil { + return x.MixedBorder + } + return 0 +} + +func (x *AutoTrigger) GetMixedParams() []int32 { + if x != nil { + return x.MixedParams + } + return nil +} + +type TriggerMotor struct { + state protoimpl.MessageState `protogen:"open.v1"` + LineGear *TriggerMotorSet `protobuf:"bytes,1,opt,name=lineGear,proto3" json:"lineGear,omitempty"` + MicrGear *TriggerMotorSet `protobuf:"bytes,2,opt,name=micrGear,proto3" json:"micrGear,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerMotor) Reset() { + *x = TriggerMotor{} + mi := &file_flydigi_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerMotor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerMotor) ProtoMessage() {} + +func (x *TriggerMotor) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[6] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerMotor.ProtoReflect.Descriptor instead. +func (*TriggerMotor) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{6} +} + +func (x *TriggerMotor) GetLineGear() *TriggerMotorSet { + if x != nil { + return x.LineGear + } + return nil +} + +func (x *TriggerMotor) GetMicrGear() *TriggerMotorSet { + if x != nil { + return x.MicrGear + } + return nil +} + +type TriggerMotorSet struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + Min int32 `protobuf:"varint,2,opt,name=min,proto3" json:"min,omitempty"` + Max int32 `protobuf:"varint,3,opt,name=max,proto3" json:"max,omitempty"` + Filter int32 `protobuf:"varint,4,opt,name=filter,proto3" json:"filter,omitempty"` + VibrLimit int32 `protobuf:"varint,5,opt,name=vibrLimit,proto3" json:"vibrLimit,omitempty"` + Scale int32 `protobuf:"varint,6,opt,name=scale,proto3" json:"scale,omitempty"` + TimeLimit int32 `protobuf:"varint,7,opt,name=timeLimit,proto3" json:"timeLimit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerMotorSet) Reset() { + *x = TriggerMotorSet{} + mi := &file_flydigi_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerMotorSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerMotorSet) ProtoMessage() {} + +func (x *TriggerMotorSet) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerMotorSet.ProtoReflect.Descriptor instead. +func (*TriggerMotorSet) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{7} +} + +func (x *TriggerMotorSet) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *TriggerMotorSet) GetMin() int32 { + if x != nil { + return x.Min + } + return 0 +} + +func (x *TriggerMotorSet) GetMax() int32 { + if x != nil { + return x.Max + } + return 0 +} + +func (x *TriggerMotorSet) GetFilter() int32 { + if x != nil { + return x.Filter + } + return 0 +} + +func (x *TriggerMotorSet) GetVibrLimit() int32 { + if x != nil { + return x.VibrLimit + } + return 0 +} + +func (x *TriggerMotorSet) GetScale() int32 { + if x != nil { + return x.Scale + } + return 0 +} + +func (x *TriggerMotorSet) GetTimeLimit() int32 { + if x != nil { + return x.TimeLimit + } + return 0 +} + +type LedsOff struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LedsOff) Reset() { + *x = LedsOff{} + mi := &file_flydigi_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsOff) String() string { @@ -272,8 +610,8 @@ func (x *LedsOff) String() string { func (*LedsOff) ProtoMessage() {} func (x *LedsOff) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_flydigi_proto_msgTypes[8] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -285,24 +623,21 @@ func (x *LedsOff) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsOff.ProtoReflect.Descriptor instead. func (*LedsOff) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{3} + return file_flydigi_proto_rawDescGZIP(), []int{8} } type LedsSteady struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Color *Color `protobuf:"bytes,1,opt,name=color,proto3" json:"color,omitempty"` unknownFields protoimpl.UnknownFields - - Color *Color `protobuf:"bytes,1,opt,name=color,proto3" json:"color,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LedsSteady) Reset() { *x = LedsSteady{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsSteady) String() string { @@ -312,8 +647,8 @@ func (x *LedsSteady) String() string { func (*LedsSteady) ProtoMessage() {} func (x *LedsSteady) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_flydigi_proto_msgTypes[9] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -325,7 +660,7 @@ func (x *LedsSteady) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsSteady.ProtoReflect.Descriptor instead. func (*LedsSteady) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{4} + return file_flydigi_proto_rawDescGZIP(), []int{9} } func (x *LedsSteady) GetColor() *Color { @@ -336,20 +671,17 @@ func (x *LedsSteady) GetColor() *Color { } type LedsStreamlined struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Speed float32 `protobuf:"fixed32,1,opt,name=speed,proto3" json:"speed,omitempty"` unknownFields protoimpl.UnknownFields - - Speed float32 `protobuf:"fixed32,1,opt,name=speed,proto3" json:"speed,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LedsStreamlined) Reset() { *x = LedsStreamlined{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsStreamlined) String() string { @@ -359,8 +691,8 @@ func (x *LedsStreamlined) String() string { func (*LedsStreamlined) ProtoMessage() {} func (x *LedsStreamlined) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_flydigi_proto_msgTypes[10] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -372,7 +704,7 @@ func (x *LedsStreamlined) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsStreamlined.ProtoReflect.Descriptor instead. func (*LedsStreamlined) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{5} + return file_flydigi_proto_rawDescGZIP(), []int{10} } func (x *LedsStreamlined) GetSpeed() float32 { @@ -382,27 +714,77 @@ func (x *LedsStreamlined) GetSpeed() float32 { return 0 } -type LedsConfiguration struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache +type LedsGradient struct { + state protoimpl.MessageState `protogen:"open.v1"` + Speed float32 `protobuf:"fixed32,1,opt,name=speed,proto3" json:"speed,omitempty"` + Colors []*Color `protobuf:"bytes,2,rep,name=colors,proto3" json:"colors,omitempty"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LedsGradient) Reset() { + *x = LedsGradient{} + mi := &file_flydigi_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LedsGradient) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LedsGradient) ProtoMessage() {} - Brightness float32 `protobuf:"fixed32,1,opt,name=brightness,proto3" json:"brightness,omitempty"` - // Types that are assignable to Leds: +func (x *LedsGradient) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LedsGradient.ProtoReflect.Descriptor instead. +func (*LedsGradient) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{11} +} + +func (x *LedsGradient) GetSpeed() float32 { + if x != nil { + return x.Speed + } + return 0 +} + +func (x *LedsGradient) GetColors() []*Color { + if x != nil { + return x.Colors + } + return nil +} + +type LedsConfiguration struct { + state protoimpl.MessageState `protogen:"open.v1"` + Brightness float32 `protobuf:"fixed32,1,opt,name=brightness,proto3" json:"brightness,omitempty"` + // Types that are valid to be assigned to Leds: // // *LedsConfiguration_Off // *LedsConfiguration_Steady // *LedsConfiguration_Streamlined - Leds isLedsConfiguration_Leds `protobuf_oneof:"leds"` + // *LedsConfiguration_Gradient + Leds isLedsConfiguration_Leds `protobuf_oneof:"leds"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *LedsConfiguration) Reset() { *x = LedsConfiguration{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsConfiguration) String() string { @@ -412,8 +794,8 @@ func (x *LedsConfiguration) String() string { func (*LedsConfiguration) ProtoMessage() {} func (x *LedsConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_flydigi_proto_msgTypes[12] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -425,7 +807,7 @@ func (x *LedsConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsConfiguration.ProtoReflect.Descriptor instead. func (*LedsConfiguration) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{6} + return file_flydigi_proto_rawDescGZIP(), []int{12} } func (x *LedsConfiguration) GetBrightness() float32 { @@ -435,30 +817,45 @@ func (x *LedsConfiguration) GetBrightness() float32 { return 0 } -func (m *LedsConfiguration) GetLeds() isLedsConfiguration_Leds { - if m != nil { - return m.Leds +func (x *LedsConfiguration) GetLeds() isLedsConfiguration_Leds { + if x != nil { + return x.Leds } return nil } func (x *LedsConfiguration) GetOff() *LedsOff { - if x, ok := x.GetLeds().(*LedsConfiguration_Off); ok { - return x.Off + if x != nil { + if x, ok := x.Leds.(*LedsConfiguration_Off); ok { + return x.Off + } } return nil } func (x *LedsConfiguration) GetSteady() *LedsSteady { - if x, ok := x.GetLeds().(*LedsConfiguration_Steady); ok { - return x.Steady + if x != nil { + if x, ok := x.Leds.(*LedsConfiguration_Steady); ok { + return x.Steady + } } return nil } func (x *LedsConfiguration) GetStreamlined() *LedsStreamlined { - if x, ok := x.GetLeds().(*LedsConfiguration_Streamlined); ok { - return x.Streamlined + if x != nil { + if x, ok := x.Leds.(*LedsConfiguration_Streamlined); ok { + return x.Streamlined + } + } + return nil +} + +func (x *LedsConfiguration) GetGradient() *LedsGradient { + if x != nil { + if x, ok := x.Leds.(*LedsConfiguration_Gradient); ok { + return x.Gradient + } } return nil } @@ -479,27 +876,30 @@ type LedsConfiguration_Streamlined struct { Streamlined *LedsStreamlined `protobuf:"bytes,13,opt,name=streamlined,proto3,oneof"` } +type LedsConfiguration_Gradient struct { + Gradient *LedsGradient `protobuf:"bytes,15,opt,name=gradient,proto3,oneof"` +} + func (*LedsConfiguration_Off) isLedsConfiguration_Leds() {} func (*LedsConfiguration_Steady) isLedsConfiguration_Leds() {} func (*LedsConfiguration_Streamlined) isLedsConfiguration_Leds() {} +func (*LedsConfiguration_Gradient) isLedsConfiguration_Leds() {} + type Color struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Rgb int32 `protobuf:"varint,1,opt,name=rgb,proto3" json:"rgb,omitempty"` unknownFields protoimpl.UnknownFields - - Rgb int32 `protobuf:"varint,1,opt,name=rgb,proto3" json:"rgb,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Color) Reset() { *x = Color{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_flydigi_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Color) String() string { @@ -509,8 +909,8 @@ func (x *Color) String() string { func (*Color) ProtoMessage() {} func (x *Color) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_flydigi_proto_msgTypes[13] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -522,7 +922,7 @@ func (x *Color) ProtoReflect() protoreflect.Message { // Deprecated: Use Color.ProtoReflect.Descriptor instead. func (*Color) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{7} + return file_flydigi_proto_rawDescGZIP(), []int{13} } func (x *Color) GetRgb() int32 { @@ -534,103 +934,125 @@ func (x *Color) GetRgb() int32 { var File_flydigi_proto protoreflect.FileDescriptor -var file_flydigi_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, 0x22, 0xcb, 0x01, 0x0a, 0x0b, 0x47, 0x61, 0x6d, - 0x65, 0x70, 0x61, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, - 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, - 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x40, - 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, - 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, - 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x19, 0x0a, 0x08, 0x63, 0x70, 0x75, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x63, 0x70, 0x75, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x63, - 0x70, 0x75, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, - 0x70, 0x75, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xa2, 0x01, 0x0a, 0x14, 0x47, 0x61, 0x6d, 0x65, 0x70, - 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x43, 0x0a, 0x0d, 0x6c, 0x65, 0x66, 0x74, 0x5f, 0x6a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, - 0x2e, 0x4a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x6c, 0x65, 0x66, 0x74, 0x4a, 0x6f, 0x79, 0x73, - 0x74, 0x69, 0x63, 0x6b, 0x12, 0x45, 0x0a, 0x0e, 0x72, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x6a, 0x6f, - 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x66, - 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, 0x2e, 0x4a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x72, 0x69, - 0x67, 0x68, 0x74, 0x4a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x22, 0x33, 0x0a, 0x15, 0x4a, - 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x7a, 0x6f, 0x6e, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x7a, 0x6f, 0x6e, 0x65, - 0x22, 0x09, 0x0a, 0x07, 0x4c, 0x65, 0x64, 0x73, 0x4f, 0x66, 0x66, 0x22, 0x32, 0x0a, 0x0a, 0x4c, - 0x65, 0x64, 0x73, 0x53, 0x74, 0x65, 0x61, 0x64, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x63, 0x6f, 0x6c, - 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x6c, 0x79, 0x64, 0x69, - 0x67, 0x69, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x22, - 0x27, 0x0a, 0x0f, 0x4c, 0x65, 0x64, 0x73, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x6c, 0x69, 0x6e, - 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x02, 0x52, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0xce, 0x01, 0x0a, 0x11, 0x4c, 0x65, 0x64, - 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, - 0x0a, 0x0a, 0x62, 0x72, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x02, 0x52, 0x0a, 0x62, 0x72, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x12, 0x24, - 0x0a, 0x03, 0x6f, 0x66, 0x66, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x66, 0x6c, - 0x79, 0x64, 0x69, 0x67, 0x69, 0x2e, 0x4c, 0x65, 0x64, 0x73, 0x4f, 0x66, 0x66, 0x48, 0x00, 0x52, - 0x03, 0x6f, 0x66, 0x66, 0x12, 0x2d, 0x0a, 0x06, 0x73, 0x74, 0x65, 0x61, 0x64, 0x79, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, 0x2e, 0x4c, - 0x65, 0x64, 0x73, 0x53, 0x74, 0x65, 0x61, 0x64, 0x79, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x65, - 0x61, 0x64, 0x79, 0x12, 0x3c, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x6c, 0x69, 0x6e, - 0x65, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x66, 0x6c, 0x79, 0x64, 0x69, - 0x67, 0x69, 0x2e, 0x4c, 0x65, 0x64, 0x73, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x6c, 0x69, 0x6e, - 0x65, 0x64, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x6c, 0x69, 0x6e, 0x65, - 0x64, 0x42, 0x06, 0x0a, 0x04, 0x6c, 0x65, 0x64, 0x73, 0x22, 0x19, 0x0a, 0x05, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x67, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x03, 0x72, 0x67, 0x62, 0x2a, 0x36, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x57, 0x49, 0x52, 0x45, 0x4c, 0x45, 0x53, 0x53, 0x10, - 0x01, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x49, 0x52, 0x45, 0x44, 0x10, 0x02, 0x42, 0x2a, 0x5a, 0x28, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x30, - 0x31, 0x2f, 0x66, 0x6c, 0x79, 0x64, 0x69, 0x67, 0x69, 0x63, 0x74, 0x6c, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x64, 0x62, 0x75, 0x73, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_flydigi_proto_rawDesc = "" + + "\n" + + "\rflydigi.proto\x12\aflydigi\"\xcb\x01\n" + + "\vGamepadInfo\x12\x1b\n" + + "\tdevice_id\x18\x01 \x01(\x05R\bdeviceId\x12'\n" + + "\x0fbattery_percent\x18\x02 \x01(\x05R\x0ebatteryPercent\x12@\n" + + "\x0fconnection_type\x18\x03 \x01(\x0e2\x17.flydigi.ConnectionTypeR\x0econnectionType\x12\x19\n" + + "\bcpu_type\x18\x04 \x01(\tR\acpuType\x12\x19\n" + + "\bcpu_name\x18\x05 \x01(\tR\acpuName\"\xa8\x02\n" + + "\x14GamepadConfiguration\x12C\n" + + "\rleft_joystick\x18\x01 \x01(\v2\x1e.flydigi.JoystickConfigurationR\fleftJoystick\x12E\n" + + "\x0eright_joystick\x18\x02 \x01(\v2\x1e.flydigi.JoystickConfigurationR\rrightJoystick\x12@\n" + + "\fleft_trigger\x18\x03 \x01(\v2\x1d.flydigi.TriggerConfigurationR\vleftTrigger\x12B\n" + + "\rright_trigger\x18\x04 \x01(\v2\x1d.flydigi.TriggerConfigurationR\frightTrigger\"3\n" + + "\x15JoystickConfiguration\x12\x1a\n" + + "\bdeadzone\x18\x01 \x01(\x05R\bdeadzone\"}\n" + + "\rVibrationBind\x12\x12\n" + + "\x04type\x18\x01 \x01(\x05R\x04type\x12\x1c\n" + + "\tminFilter\x18\x02 \x01(\x05R\tminFilter\x12\x14\n" + + "\x05scale\x18\x03 \x01(\x05R\x05scale\x12$\n" + + "\rtriggerParams\x18\x04 \x03(\x05R\rtriggerParams\"\x89\x01\n" + + "\x14TriggerConfiguration\x126\n" + + "\vautoTrigger\x18\x01 \x01(\v2\x14.flydigi.AutoTriggerR\vautoTrigger\x129\n" + + "\ftriggerMotor\x18\x02 \x01(\v2\x15.flydigi.TriggerMotorR\ftriggerMotor\"\xa3\x01\n" + + "\vAutoTrigger\x12\x12\n" + + "\x04mode\x18\x01 \x01(\x05R\x04mode\x12<\n" + + "\rvibrationBind\x18\x02 \x01(\v2\x16.flydigi.VibrationBindR\rvibrationBind\x12 \n" + + "\vmixedBorder\x18\x03 \x01(\x05R\vmixedBorder\x12 \n" + + "\vmixedParams\x18\x04 \x03(\x05R\vmixedParams\"z\n" + + "\fTriggerMotor\x124\n" + + "\blineGear\x18\x01 \x01(\v2\x18.flydigi.TriggerMotorSetR\blineGear\x124\n" + + "\bmicrGear\x18\x02 \x01(\v2\x18.flydigi.TriggerMotorSetR\bmicrGear\"\xb3\x01\n" + + "\x0fTriggerMotorSet\x12\x12\n" + + "\x04type\x18\x01 \x01(\x05R\x04type\x12\x10\n" + + "\x03min\x18\x02 \x01(\x05R\x03min\x12\x10\n" + + "\x03max\x18\x03 \x01(\x05R\x03max\x12\x16\n" + + "\x06filter\x18\x04 \x01(\x05R\x06filter\x12\x1c\n" + + "\tvibrLimit\x18\x05 \x01(\x05R\tvibrLimit\x12\x14\n" + + "\x05scale\x18\x06 \x01(\x05R\x05scale\x12\x1c\n" + + "\ttimeLimit\x18\a \x01(\x05R\ttimeLimit\"\t\n" + + "\aLedsOff\"2\n" + + "\n" + + "LedsSteady\x12$\n" + + "\x05color\x18\x01 \x01(\v2\x0e.flydigi.ColorR\x05color\"'\n" + + "\x0fLedsStreamlined\x12\x14\n" + + "\x05speed\x18\x01 \x01(\x02R\x05speed\"L\n" + + "\fLedsGradient\x12\x14\n" + + "\x05speed\x18\x01 \x01(\x02R\x05speed\x12&\n" + + "\x06colors\x18\x02 \x03(\v2\x0e.flydigi.ColorR\x06colors\"\x83\x02\n" + + "\x11LedsConfiguration\x12\x1e\n" + + "\n" + + "brightness\x18\x01 \x01(\x02R\n" + + "brightness\x12$\n" + + "\x03off\x18\n" + + " \x01(\v2\x10.flydigi.LedsOffH\x00R\x03off\x12-\n" + + "\x06steady\x18\f \x01(\v2\x13.flydigi.LedsSteadyH\x00R\x06steady\x12<\n" + + "\vstreamlined\x18\r \x01(\v2\x18.flydigi.LedsStreamlinedH\x00R\vstreamlined\x123\n" + + "\bgradient\x18\x0f \x01(\v2\x15.flydigi.LedsGradientH\x00R\bgradientB\x06\n" + + "\x04leds\"\x19\n" + + "\x05Color\x12\x10\n" + + "\x03rgb\x18\x01 \x01(\x05R\x03rgb*6\n" + + "\x0eConnectionType\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\f\n" + + "\bWIRELESS\x10\x01\x12\t\n" + + "\x05WIRED\x10\x02B*Z(github.com/pipe01/flydigictl/pkg/dbus/pbb\x06proto3" var ( file_flydigi_proto_rawDescOnce sync.Once - file_flydigi_proto_rawDescData = file_flydigi_proto_rawDesc + file_flydigi_proto_rawDescData []byte ) func file_flydigi_proto_rawDescGZIP() []byte { file_flydigi_proto_rawDescOnce.Do(func() { - file_flydigi_proto_rawDescData = protoimpl.X.CompressGZIP(file_flydigi_proto_rawDescData) + file_flydigi_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_flydigi_proto_rawDesc), len(file_flydigi_proto_rawDesc))) }) return file_flydigi_proto_rawDescData } var file_flydigi_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_flydigi_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_flydigi_proto_goTypes = []interface{}{ +var file_flydigi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_flydigi_proto_goTypes = []any{ (ConnectionType)(0), // 0: flydigi.ConnectionType (*GamepadInfo)(nil), // 1: flydigi.GamepadInfo (*GamepadConfiguration)(nil), // 2: flydigi.GamepadConfiguration (*JoystickConfiguration)(nil), // 3: flydigi.JoystickConfiguration - (*LedsOff)(nil), // 4: flydigi.LedsOff - (*LedsSteady)(nil), // 5: flydigi.LedsSteady - (*LedsStreamlined)(nil), // 6: flydigi.LedsStreamlined - (*LedsConfiguration)(nil), // 7: flydigi.LedsConfiguration - (*Color)(nil), // 8: flydigi.Color + (*VibrationBind)(nil), // 4: flydigi.VibrationBind + (*TriggerConfiguration)(nil), // 5: flydigi.TriggerConfiguration + (*AutoTrigger)(nil), // 6: flydigi.AutoTrigger + (*TriggerMotor)(nil), // 7: flydigi.TriggerMotor + (*TriggerMotorSet)(nil), // 8: flydigi.TriggerMotorSet + (*LedsOff)(nil), // 9: flydigi.LedsOff + (*LedsSteady)(nil), // 10: flydigi.LedsSteady + (*LedsStreamlined)(nil), // 11: flydigi.LedsStreamlined + (*LedsGradient)(nil), // 12: flydigi.LedsGradient + (*LedsConfiguration)(nil), // 13: flydigi.LedsConfiguration + (*Color)(nil), // 14: flydigi.Color } var file_flydigi_proto_depIdxs = []int32{ - 0, // 0: flydigi.GamepadInfo.connection_type:type_name -> flydigi.ConnectionType - 3, // 1: flydigi.GamepadConfiguration.left_joystick:type_name -> flydigi.JoystickConfiguration - 3, // 2: flydigi.GamepadConfiguration.right_joystick:type_name -> flydigi.JoystickConfiguration - 8, // 3: flydigi.LedsSteady.color:type_name -> flydigi.Color - 4, // 4: flydigi.LedsConfiguration.off:type_name -> flydigi.LedsOff - 5, // 5: flydigi.LedsConfiguration.steady:type_name -> flydigi.LedsSteady - 6, // 6: flydigi.LedsConfiguration.streamlined:type_name -> flydigi.LedsStreamlined - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 0, // 0: flydigi.GamepadInfo.connection_type:type_name -> flydigi.ConnectionType + 3, // 1: flydigi.GamepadConfiguration.left_joystick:type_name -> flydigi.JoystickConfiguration + 3, // 2: flydigi.GamepadConfiguration.right_joystick:type_name -> flydigi.JoystickConfiguration + 5, // 3: flydigi.GamepadConfiguration.left_trigger:type_name -> flydigi.TriggerConfiguration + 5, // 4: flydigi.GamepadConfiguration.right_trigger:type_name -> flydigi.TriggerConfiguration + 6, // 5: flydigi.TriggerConfiguration.autoTrigger:type_name -> flydigi.AutoTrigger + 7, // 6: flydigi.TriggerConfiguration.triggerMotor:type_name -> flydigi.TriggerMotor + 4, // 7: flydigi.AutoTrigger.vibrationBind:type_name -> flydigi.VibrationBind + 8, // 8: flydigi.TriggerMotor.lineGear:type_name -> flydigi.TriggerMotorSet + 8, // 9: flydigi.TriggerMotor.micrGear:type_name -> flydigi.TriggerMotorSet + 14, // 10: flydigi.LedsSteady.color:type_name -> flydigi.Color + 14, // 11: flydigi.LedsGradient.colors:type_name -> flydigi.Color + 9, // 12: flydigi.LedsConfiguration.off:type_name -> flydigi.LedsOff + 10, // 13: flydigi.LedsConfiguration.steady:type_name -> flydigi.LedsSteady + 11, // 14: flydigi.LedsConfiguration.streamlined:type_name -> flydigi.LedsStreamlined + 12, // 15: flydigi.LedsConfiguration.gradient:type_name -> flydigi.LedsGradient + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_flydigi_proto_init() } @@ -638,116 +1060,19 @@ func file_flydigi_proto_init() { if File_flydigi_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_flydigi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GamepadInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GamepadConfiguration); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JoystickConfiguration); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LedsOff); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LedsSteady); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LedsStreamlined); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LedsConfiguration); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_flydigi_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Color); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_flydigi_proto_msgTypes[6].OneofWrappers = []interface{}{ + file_flydigi_proto_msgTypes[12].OneofWrappers = []any{ (*LedsConfiguration_Off)(nil), (*LedsConfiguration_Steady)(nil), (*LedsConfiguration_Streamlined)(nil), + (*LedsConfiguration_Gradient)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_flydigi_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_flydigi_proto_rawDesc), len(file_flydigi_proto_rawDesc)), NumEnums: 1, - NumMessages: 8, + NumMessages: 14, NumExtensions: 0, NumServices: 0, }, @@ -757,7 +1082,6 @@ func file_flydigi_proto_init() { MessageInfos: file_flydigi_proto_msgTypes, }.Build() File_flydigi_proto = out.File - file_flydigi_proto_rawDesc = nil file_flydigi_proto_goTypes = nil file_flydigi_proto_depIdxs = nil } diff --git a/pkg/dbus/pb/flydigi.proto b/pkg/dbus/pb/flydigi.proto index fa6d769..0d298e1 100644 --- a/pkg/dbus/pb/flydigi.proto +++ b/pkg/dbus/pb/flydigi.proto @@ -20,12 +20,49 @@ message GamepadInfo { message GamepadConfiguration { JoystickConfiguration left_joystick = 1; JoystickConfiguration right_joystick = 2; + + TriggerConfiguration left_trigger = 3; + TriggerConfiguration right_trigger = 4; } message JoystickConfiguration { int32 deadzone = 1; } +message VibrationBind { + int32 type = 1; + int32 minFilter = 2; + int32 scale = 3; + repeated int32 triggerParams = 4; +} + +message TriggerConfiguration { + AutoTrigger autoTrigger = 1; + TriggerMotor triggerMotor = 2; +} + +message AutoTrigger { + int32 mode = 1; + VibrationBind vibrationBind = 2; + int32 mixedBorder = 3; + repeated int32 mixedParams = 4; +} + +message TriggerMotor { + TriggerMotorSet lineGear = 1; + TriggerMotorSet micrGear = 2; +} + +message TriggerMotorSet { + int32 type = 1; + int32 min = 2; + int32 max = 3; + int32 filter = 4; + int32 vibrLimit = 5; + int32 scale = 6; + int32 timeLimit = 7; +} + message LedsOff { } @@ -37,12 +74,18 @@ message LedsStreamlined { float speed = 1; } +message LedsGradient { + float speed = 1; + repeated Color colors = 2; +} + message LedsConfiguration { float brightness = 1; oneof leds { LedsOff off = 10; LedsSteady steady = 12; LedsStreamlined streamlined = 13; + LedsGradient gradient = 15; } } diff --git a/pkg/flydigi/config/beans.go b/pkg/flydigi/config/beans.go index 8760ca0..dad8bb5 100644 --- a/pkg/flydigi/config/beans.go +++ b/pkg/flydigi/config/beans.go @@ -95,6 +95,57 @@ func (b *NewLedConfigBean) SetStreamlined(speed float32) { b.LedGroups = getLedGroupList(0, 5) } +func interpolateGradient(colors []LedUnit, t float32) LedUnit { + if len(colors) == 0 { + return LedUnit{} + } + if len(colors) == 1 { + return colors[0] + } + + pos := t * float32(len(colors)-1) + i := int(pos) + f := pos - float32(i) + + c1 := colors[i] + c2 := colors[min(i+1, len(colors)-1)] + + return LedUnit{ + R: uint8(float32(c1.R)*(1-f) + float32(c2.R)*f), + G: uint8(float32(c1.G)*(1-f) + float32(c2.G)*f), + B: uint8(float32(c1.B)*(1-f) + float32(c2.B)*f), + } +} + +func (b *NewLedConfigBean) SetGradient(colors []LedUnit, speed float32) { + const ledCount = 10 + const groupCount = 16 + + b.LedMode = LedModeGradient + b.Loop_time = 100 - byte(speed*100) + b.Rgb_num = ledCount + b.Loop_End = ledCount - 1 + b.Type = 0 + + b.LedGroups = utils.RepeatFunc(func() *LedGroup { + return &LedGroup{ + Units: utils.RepeatFunc(func() *LedUnit { + return &LedUnit{} + }, ledCount), + } + }, groupCount) + + for i := 0; i < ledCount; i++ { + t := float32(i) / float32(ledCount-1) + + c := interpolateGradient(colors, t) + + for g := 0; g < groupCount; g++ { + b.LedGroups[g].Units[i] = &c + } + } +} + type LedGroup struct { Units []*LedUnit } @@ -239,6 +290,145 @@ type Trigger struct { TriggerMotor *TriggerMotor } +func (t *Trigger) ApplyDefaultTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 0 + t.AutoTrigger.VibrationBind.TriggerParams = []int32{1, 10, 1, 90, 0} + + for i := range t.AutoTrigger.MixedParams { + t.AutoTrigger.MixedParams[i] = 0 + } + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 +} + +func (t *Trigger) ApplyRaceTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 1 + t.AutoTrigger.VibrationBind.TriggerParams = []int32{100, 1, 255, 70, 0} + + for i := range t.AutoTrigger.MixedParams { + t.AutoTrigger.MixedParams[i] = 0 + } + t.AutoTrigger.MixedParams[1] = 30 + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 90 + lg.Max = 100 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 100 + lg.TimeLimit = 0 +} + +func (t *Trigger) ApplySniperTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 3 + t.AutoTrigger.VibrationBind.Type = 0 + t.AutoTrigger.VibrationBind.MinFilter = 10 + t.AutoTrigger.VibrationBind.Scale = 50 + t.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + t.AutoTrigger.MixedBorder = 0 + t.AutoTrigger.MixedParams = []int32{ + 50, 30, 1, 0, 1, + 0, 0, 0, 0, 0, + } + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 +} + +func (t *Trigger) ApplyRecoilTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 2 + t.AutoTrigger.VibrationBind.Type = 0 + t.AutoTrigger.VibrationBind.MinFilter = 10 + t.AutoTrigger.VibrationBind.Scale = 50 + t.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + t.AutoTrigger.MixedBorder = 0 + t.AutoTrigger.MixedParams = []int32{ + 0, 1, 50, 15, 1, + 0, 0, 0, 0, 0, + } + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 +} + +func (t *Trigger) ApplyLockTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 4 + t.AutoTrigger.VibrationBind.Type = 0 + t.AutoTrigger.VibrationBind.MinFilter = 10 + t.AutoTrigger.VibrationBind.Scale = 50 + t.AutoTrigger.VibrationBind.TriggerParams = + []int32{100, 1, 255, 70, 0} + + t.AutoTrigger.MixedBorder = 0 + t.AutoTrigger.MixedParams = []int32{ + 40, 250, 1, 0, 0, + 0, 0, 0, 0, 0, + } + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 +} + +func (t *Trigger) ApplyVibrationTrigger() { + t.Type = 0 + t.AutoTrigger.Mode = 5 + t.AutoTrigger.VibrationBind.Type = 2 + t.AutoTrigger.VibrationBind.MinFilter = 10 + t.AutoTrigger.VibrationBind.Scale = 50 + t.AutoTrigger.VibrationBind.TriggerParams = + []int32{1, 1, 1, 90, 0} + + t.AutoTrigger.MixedBorder = 0 + t.AutoTrigger.MixedParams = []int32{ + 1, 1, 1, 90, 0, + 0, 0, 0, 0, 0, + } + + lg := t.TriggerMotor.LineGear + lg.Type = 1 + lg.Min = 30 + lg.Max = 80 + lg.Filter = 5 + lg.Vibrlimit = 1 + lg.Scale = 50 + lg.TimeLimit = 0 +} + type Autotrigger struct { Mode int32 VibrationBind *Vibrationbind From 2cdf43ee4be6db68dbf005c2dc8f12cbd43188ec Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sat, 24 Jan 2026 02:57:46 -0300 Subject: [PATCH 2/7] start mapping params --- pkg/commands/trigger.go | 66 ++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go index 5ebaa01..8bbe11d 100644 --- a/pkg/commands/trigger.go +++ b/pkg/commands/trigger.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "github.com/pipe01/flydigictl/pkg/dbus/pb" "github.com/spf13/cobra" @@ -232,19 +233,47 @@ func genTriggerCommand(side triggerSide) *cobra.Command { }, }) cmd.AddCommand(&cobra.Command{ - Use: "race", + Use: "race ", Short: "Set this trigger to race mode", - Args: cobra.NoArgs, + Args: cobra.MaximumNArgs(2), RunE: func(cmd *cobra.Command, args []string) error { + + initialPos := 0 // 0-192 + pressure := 30 // 1-255 + + if len(args) >= 1 { + v, err := strconv.Atoi(args[0]) + if err != nil { + return fmt.Errorf("invalid start value: %q", args[0]) + } + if v < 0 || v > 192 { + return fmt.Errorf("start must be between 0 and 192") + } + initialPos = v + } + + if len(args) >= 2 { + v, err := strconv.Atoi(args[1]) + if err != nil { + return fmt.Errorf("invalid pressure value: %q", args[1]) + } + if v < 1 || v > 255 { + return fmt.Errorf("pressure must be between 1 and 255") + } + pressure = v + } + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) + cfg.AutoTrigger.Mode = 1 cfg.AutoTrigger.VibrationBind.TriggerParams = []int32{100, 1, 255, 70, 0} for i := range cfg.AutoTrigger.MixedParams { cfg.AutoTrigger.MixedParams[i] = 0 } - cfg.AutoTrigger.MixedParams[1] = 30 + cfg.AutoTrigger.MixedParams[0] = int32(initialPos) + cfg.AutoTrigger.MixedParams[1] = int32(pressure) lg := cfg.TriggerMotor.LineGear lg.Type = 1 @@ -262,6 +291,12 @@ func genTriggerCommand(side triggerSide) *cobra.Command { Short: "Set this trigger to recoil mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { + initialPos := 0 // 0-192 + initialStrength := 1 // 1-255 + intensity := 50 // 1-255 + frequency := 15 // 1-255 + onLeave := 1 // 0-1 + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) cfg.AutoTrigger.Mode = 2 @@ -273,7 +308,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cfg.AutoTrigger.MixedBorder = 0 cfg.AutoTrigger.MixedParams = []int32{ - 0, 1, 50, 15, 1, + int32(initialPos), int32(initialStrength), int32(intensity), int32(frequency), int32(onLeave), 0, 0, 0, 0, 0, } @@ -293,6 +328,11 @@ func genTriggerCommand(side triggerSide) *cobra.Command { Short: "Set this trigger to sniper mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { + initialPos := 50 // 0-192 + length := 30 // 1-255 + pressure := 1 // 1-255 + onLeave := 1 // 0-1 + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) cfg.AutoTrigger.Mode = 3 @@ -304,7 +344,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cfg.AutoTrigger.MixedBorder = 0 cfg.AutoTrigger.MixedParams = []int32{ - 50, 30, 1, 0, 1, + int32(initialPos), int32(length), int32(pressure), 0, int32(onLeave), 0, 0, 0, 0, 0, } @@ -320,10 +360,11 @@ func genTriggerCommand(side triggerSide) *cobra.Command { }, }) cmd.AddCommand(&cobra.Command{ - Use: "lock", + Use: "lock ", Short: "Set this trigger to lock mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { + initialPos := 40 // 20-200 return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) cfg.AutoTrigger.Mode = 4 @@ -335,7 +376,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cfg.AutoTrigger.MixedBorder = 0 cfg.AutoTrigger.MixedParams = []int32{ - 40, 250, 1, 0, 0, + int32(initialPos), 255, 1, 0, 0, 0, 0, 0, 0, 0, } @@ -355,14 +396,19 @@ func genTriggerCommand(side triggerSide) *cobra.Command { Short: "Set this trigger to vibration mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { + coefficient := 50 // 0 - 200 + threshold := 10 // 1 - 255 + travelRange := 20 // 0 - 200 + frequency := 90 // 0 - 200 + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) cfg.AutoTrigger.Mode = 5 cfg.AutoTrigger.VibrationBind.Type = 2 - cfg.AutoTrigger.VibrationBind.MinFilter = 10 - cfg.AutoTrigger.VibrationBind.Scale = 50 + cfg.AutoTrigger.VibrationBind.MinFilter = int32(threshold) + cfg.AutoTrigger.VibrationBind.Scale = int32(coefficient) cfg.AutoTrigger.VibrationBind.TriggerParams = - []int32{1, 1, 1, 90, 0} + []int32{int32(travelRange), 1, 1, int32(frequency), 0} cfg.AutoTrigger.MixedBorder = 0 cfg.AutoTrigger.MixedParams = []int32{ From 92080469561c9970e73ad08b30049b1536174f81 Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sat, 24 Jan 2026 14:43:51 -0300 Subject: [PATCH 3/7] refactor trigger proto --- pkg/commands/trigger.go | 649 +++++++++++++++++------------------- pkg/dbus/pb/convert.go | 128 +++---- pkg/dbus/pb/flydigi.pb.go | 584 +++++++++++++++++++++----------- pkg/dbus/pb/flydigi.proto | 59 ++-- pkg/flydigi/config/beans.go | 30 +- 5 files changed, 803 insertions(+), 647 deletions(-) diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go index 8bbe11d..6d5b962 100644 --- a/pkg/commands/trigger.go +++ b/pkg/commands/trigger.go @@ -1,49 +1,16 @@ package commands import ( - "encoding/json" "fmt" - "os" - "path/filepath" - "strconv" "github.com/pipe01/flydigictl/pkg/dbus/pb" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) type triggerSide string -type TriggerMotorSetJson *struct { - Type *int32 `json:"Type"` - Min *int32 `json:"Min"` - Max *int32 `json:"Max"` - Filter *int32 `json:"Filter"` - VibrLimit *int32 `json:"VibrLimit"` - Scale *int32 `json:"Scale"` - TimeLimit *int32 `json:"TimeLimit"` -} - -type TriggerJSON struct { - AutoTrigger *struct { - Mode *int32 `json:"Mode"` - - VibrationBind *struct { - Type *int32 `json:"Type"` - MinFilter *int32 `json:"MinFilter"` - Scale *int32 `json:"Scale"` - TriggerParams []int32 `json:"TriggerParams"` - } `json:"VibrationBind"` - - MixedBorder *int32 `json:"MixedBorder"` - MixedParams []int32 `json:"MixedParams"` - } `json:"AutoTrigger"` - - TriggerMotor *struct { - LineGear TriggerMotorSetJson `json:"LineGear"` - MicrGear TriggerMotorSetJson `json:"MicrGear"` - } `json:"TriggerMotor"` -} - const ( triggerLeft triggerSide = "left" triggerRight triggerSide = "right" @@ -59,129 +26,40 @@ func (s triggerSide) GetBean(b *pb.GamepadConfiguration) *pb.TriggerConfiguratio panic("invalid trigger side") } -func triggerModeName(mode int32) string { - switch mode { - case 0: - return "default" - case 1: - return "race" - case 2: - return "recoil" - case 3: - return "sniper" - case 4: - return "lock" - case 5: - return "vibration" - default: - return fmt.Sprintf("unknown(%d)", mode) - } +var triggerCommand = &cobra.Command{ + Use: "trigger", + Short: "Configure triggers (Apex 4)", } +var showDetails bool -func loadTriggerJSON(path string) (*TriggerJSON, error) { - data, err := os.ReadFile(path) - if err != nil { - return nil, err - } - - var cfg TriggerJSON - if err := json.Unmarshal(data, &cfg); err != nil { - return nil, err - } - - return &cfg, nil +var raceOptions struct { + InitialPos int + Pressure int +} +var recoilOptions struct { + InitialPos int + InitialStrength int + Intensity int + Frequency int + InputAfter bool } -func applyTriggerJSON(dst *pb.TriggerConfiguration, src *TriggerJSON) { - if src.AutoTrigger != nil { - at := dst.AutoTrigger - - if src.AutoTrigger.Mode != nil { - at.Mode = *src.AutoTrigger.Mode - } - - if src.AutoTrigger.VibrationBind != nil { - vb := at.VibrationBind - - if src.AutoTrigger.VibrationBind.Type != nil { - vb.Type = *src.AutoTrigger.VibrationBind.Type - } - if src.AutoTrigger.VibrationBind.MinFilter != nil { - vb.MinFilter = *src.AutoTrigger.VibrationBind.MinFilter - } - if src.AutoTrigger.VibrationBind.Scale != nil { - vb.Scale = *src.AutoTrigger.VibrationBind.Scale - } - if len(src.AutoTrigger.VibrationBind.TriggerParams) > 0 { - vb.TriggerParams = src.AutoTrigger.VibrationBind.TriggerParams - } - } - - if src.AutoTrigger.MixedBorder != nil { - at.MixedBorder = *src.AutoTrigger.MixedBorder - } - if len(src.AutoTrigger.MixedParams) > 0 { - at.MixedParams = src.AutoTrigger.MixedParams - } - } - - if src.TriggerMotor != nil { - if src.TriggerMotor.LineGear != nil { - lg := dst.TriggerMotor.LineGear - - if src.TriggerMotor.LineGear.Type != nil { - lg.Type = *src.TriggerMotor.LineGear.Type - } - if src.TriggerMotor.LineGear.Min != nil { - lg.Min = *src.TriggerMotor.LineGear.Min - } - if src.TriggerMotor.LineGear.Max != nil { - lg.Max = *src.TriggerMotor.LineGear.Max - } - if src.TriggerMotor.LineGear.Filter != nil { - lg.Filter = *src.TriggerMotor.LineGear.Filter - } - if src.TriggerMotor.LineGear.VibrLimit != nil { - lg.VibrLimit = *src.TriggerMotor.LineGear.VibrLimit - } - if src.TriggerMotor.LineGear.Scale != nil { - lg.Scale = *src.TriggerMotor.LineGear.Scale - } - if src.TriggerMotor.LineGear.TimeLimit != nil { - lg.TimeLimit = *src.TriggerMotor.LineGear.TimeLimit - } - } - if src.TriggerMotor.MicrGear != nil { - lg := dst.TriggerMotor.MicrGear +var sniperOptions struct { + InitialPos int + Length int + Pressure int + InputAfter bool +} - if src.TriggerMotor.MicrGear.Type != nil { - lg.Type = *src.TriggerMotor.MicrGear.Type - } - if src.TriggerMotor.MicrGear.Min != nil { - lg.Min = *src.TriggerMotor.MicrGear.Min - } - if src.TriggerMotor.MicrGear.Max != nil { - lg.Max = *src.TriggerMotor.MicrGear.Max - } - if src.TriggerMotor.MicrGear.Filter != nil { - lg.Filter = *src.TriggerMotor.MicrGear.Filter - } - if src.TriggerMotor.MicrGear.VibrLimit != nil { - lg.VibrLimit = *src.TriggerMotor.MicrGear.VibrLimit - } - if src.TriggerMotor.MicrGear.Scale != nil { - lg.Scale = *src.TriggerMotor.MicrGear.Scale - } - if src.TriggerMotor.MicrGear.TimeLimit != nil { - lg.TimeLimit = *src.TriggerMotor.MicrGear.TimeLimit - } - } - } +var lockOptions struct { + InitialPos int } -var triggerCommand = &cobra.Command{ - Use: "trigger", - Short: "Configure triggers (Apex 4)", +var vibrationOptions struct { + Coefficient int + Threshold int + TravelRange int + Frequency int } func genTriggerCommand(side triggerSide) *cobra.Command { @@ -189,20 +67,76 @@ func genTriggerCommand(side triggerSide) *cobra.Command { Use: string(side), Short: fmt.Sprintf("Manage %s trigger configuration", side), RunE: func(cmd *cobra.Command, args []string) error { - mode, err := readConfiguration(func(conf *pb.GamepadConfiguration) int32 { - return int32(side.GetBean(conf).AutoTrigger.Mode) + cfg, err := readConfiguration(func(conf *pb.GamepadConfiguration) *pb.TriggerConfiguration { + return side.GetBean(conf) }) if err != nil { return fmt.Errorf("get configuration: %w", err) } - modeName := triggerModeName(mode) + switch mode := cfg.Mode.(type) { + case *pb.TriggerConfiguration_Race: - if terseOutput { - fmt.Println(modeName) - } else { - fmt.Printf("%s trigger mode: %s\n", side, modeName) + if terseOutput { + fmt.Print("race") + return nil + } + + fmt.Printf("%s trigger mode: Race", side) + + if showDetails { + fmt.Printf(" %-22s : %v\n", "Initial position", mode.Race.InitialPos) + fmt.Printf(" %-22s : %v\n", "Pressure", mode.Race.Pressure) + } + case *pb.TriggerConfiguration_Recoil: + if terseOutput { + fmt.Println("recoil") + return nil + } + + fmt.Printf("%s trigger mode: Race\n", cases.Title(language.English, cases.NoLower).String(string(side))) + if showDetails { + fmt.Printf(" %-22s : %v\n", "Initial position", mode.Recoil.InitialPos) + fmt.Printf(" %-22s : %v\n", "Initial strength", mode.Recoil.InitialStrength) + fmt.Printf(" %-22s : %v\n", "Intensity", mode.Recoil.Intensity) + fmt.Printf(" %-22s : %v\n", "Frequency", mode.Recoil.Frequency) + fmt.Printf(" %-22s : %v\n", "Input After Trigger", mode.Recoil.InputAfter) + } + case *pb.TriggerConfiguration_Sniper: + if terseOutput { + fmt.Println("sniper") + return nil + } + fmt.Printf("%s trigger mode: Sniper\n", cases.Title(language.English, cases.NoLower).String(string(side))) + if showDetails { + fmt.Printf(" %-22s : %v\n", "Initial position", mode.Sniper.InitialPos) + fmt.Printf(" %-22s : %v\n", "Length", mode.Sniper.Length) + fmt.Printf(" %-22s : %v\n", "Pressure", mode.Sniper.Pressure) + fmt.Printf(" %-22s : %v\n", "Input After Trigger", mode.Sniper.InputAfter) + } + case *pb.TriggerConfiguration_Lock: + if terseOutput { + fmt.Println("lock") + return nil + } + fmt.Printf("%s trigger mode: Lock\n", cases.Title(language.English, cases.NoLower).String(string(side))) + if showDetails { + fmt.Printf(" %-22s : %v\n", "Initial position", mode.Lock.InitialPos) + } + case *pb.TriggerConfiguration_Vibration: + if terseOutput { + fmt.Println("vibration") + return nil + } + fmt.Printf("%s trigger mode: Vibration\n", cases.Title(language.English, cases.NoLower).String(string(side))) + if showDetails { + fmt.Printf(" %-22s : %v\n", "Coefficient", mode.Vibration.Coefficient) + fmt.Printf(" %-22s : %v\n", "Threshold", mode.Vibration.Threshold) + fmt.Printf(" %-22s : %v\n", "Travel range", mode.Vibration.TravelRange) + fmt.Printf(" %-22s : %v\n", "Frequency", mode.Vibration.Frequency) + } } + return nil }, } @@ -214,252 +148,252 @@ func genTriggerCommand(side triggerSide) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - cfg.AutoTrigger.Mode = 0 - cfg.AutoTrigger.VibrationBind.TriggerParams = []int32{1, 10, 1, 90, 0} - - for i := range cfg.AutoTrigger.MixedParams { - cfg.AutoTrigger.MixedParams[i] = 0 - } - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 30 - lg.Max = 80 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 50 - lg.TimeLimit = 0 + cfg.Mode = &pb.TriggerConfiguration_Default{} }) }, }) - cmd.AddCommand(&cobra.Command{ - Use: "race ", + + raceCmd := &cobra.Command{ + Use: "race", Short: "Set this trigger to race mode", - Args: cobra.MaximumNArgs(2), + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - - initialPos := 0 // 0-192 - pressure := 30 // 1-255 - - if len(args) >= 1 { - v, err := strconv.Atoi(args[0]) - if err != nil { - return fmt.Errorf("invalid start value: %q", args[0]) - } - if v < 0 || v > 192 { - return fmt.Errorf("start must be between 0 and 192") - } - initialPos = v + if raceOptions.InitialPos < 0 || raceOptions.InitialPos > 192 { + return fmt.Errorf("initial-pos must be between 0 and 192") } - - if len(args) >= 2 { - v, err := strconv.Atoi(args[1]) - if err != nil { - return fmt.Errorf("invalid pressure value: %q", args[1]) - } - if v < 1 || v > 255 { - return fmt.Errorf("pressure must be between 1 and 255") - } - pressure = v + if raceOptions.Pressure < 1 || raceOptions.Pressure > 255 { + return fmt.Errorf("pressure must be between 1 and 255") } - return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - - cfg.AutoTrigger.Mode = 1 - cfg.AutoTrigger.VibrationBind.TriggerParams = []int32{100, 1, 255, 70, 0} - - for i := range cfg.AutoTrigger.MixedParams { - cfg.AutoTrigger.MixedParams[i] = 0 + cfg.Mode = &pb.TriggerConfiguration_Race{ + Race: &pb.TriggerRace{ + InitialPos: int32(raceOptions.InitialPos), + Pressure: int32(raceOptions.Pressure), + }, } - cfg.AutoTrigger.MixedParams[0] = int32(initialPos) - cfg.AutoTrigger.MixedParams[1] = int32(pressure) - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 90 - lg.Max = 100 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 100 - lg.TimeLimit = 0 }) }, - }) - cmd.AddCommand(&cobra.Command{ + } + raceCmd.Flags().IntVar( + &raceOptions.InitialPos, + "initial-pos", + 0, + "Initial trigger position (0–192)", + ) + raceCmd.Flags().IntVar( + &raceOptions.Pressure, + "pressure", + 30, + "Trigger pressure (1–255)", + ) + raceCmd.Flags().SortFlags = false + cmd.AddCommand(raceCmd) + + recoilCmd := &cobra.Command{ Use: "recoil", Short: "Set this trigger to recoil mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - initialPos := 0 // 0-192 - initialStrength := 1 // 1-255 - intensity := 50 // 1-255 - frequency := 15 // 1-255 - onLeave := 1 // 0-1 + if recoilOptions.InitialPos < 0 || recoilOptions.InitialPos > 192 { + return fmt.Errorf("start-pos must be between 0 and 192") + } + if recoilOptions.InitialStrength < 1 || recoilOptions.InitialStrength > 255 { + return fmt.Errorf("initial-strength must be between 1 and 255") + } + if recoilOptions.Intensity < 1 || recoilOptions.Intensity > 255 { + return fmt.Errorf("intensity must be between 1 and 255") + } + if recoilOptions.Frequency < 1 || recoilOptions.Frequency > 255 { + return fmt.Errorf("frequency must be between 1 and 255") + } return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - cfg.AutoTrigger.Mode = 2 - cfg.AutoTrigger.VibrationBind.Type = 0 - cfg.AutoTrigger.VibrationBind.MinFilter = 10 - cfg.AutoTrigger.VibrationBind.Scale = 50 - cfg.AutoTrigger.VibrationBind.TriggerParams = - []int32{100, 1, 255, 70, 0} - - cfg.AutoTrigger.MixedBorder = 0 - cfg.AutoTrigger.MixedParams = []int32{ - int32(initialPos), int32(initialStrength), int32(intensity), int32(frequency), int32(onLeave), - 0, 0, 0, 0, 0, + cfg.Mode = &pb.TriggerConfiguration_Recoil{ + Recoil: &pb.TriggerRecoil{ + InitialPos: int32(recoilOptions.InitialPos), + InitialStrength: int32(recoilOptions.InitialStrength), + Intensity: int32(recoilOptions.Intensity), + Frequency: int32(recoilOptions.Frequency), + InputAfter: recoilOptions.InputAfter, + }, } - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 30 - lg.Max = 80 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 50 - lg.TimeLimit = 0 }) }, - }) - cmd.AddCommand(&cobra.Command{ + } + recoilCmd.Flags().IntVar( + &recoilOptions.InitialPos, + "start-pos", + 0, + "Vibration start position (0–192)", + ) + recoilCmd.Flags().IntVar( + &recoilOptions.InitialStrength, + "initial-strength", + 1, + "Initial recoil strength (1–255)", + ) + recoilCmd.Flags().IntVar( + &recoilOptions.Intensity, + "intensity", + 50, + "Recoil intensity (1–255). Force required to trigger vibration once the trigger reaches the start position", + ) + recoilCmd.Flags().IntVar( + &recoilOptions.Frequency, + "frequency", + 15, + "Recoil frequency (1–255)", + ) + recoilCmd.Flags().BoolVar( + &recoilOptions.InputAfter, + "input-after", + true, + "Only triggers the input after the start position", + ) + cmd.AddCommand(recoilCmd) + recoilCmd.Flags().SortFlags = false + + sniperCmd := &cobra.Command{ Use: "sniper", Short: "Set this trigger to sniper mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - initialPos := 50 // 0-192 - length := 30 // 1-255 - pressure := 1 // 1-255 - onLeave := 1 // 0-1 + if sniperOptions.InitialPos < 0 || sniperOptions.InitialPos > 192 { + return fmt.Errorf("initial-pos must be between 0 and 192") + } + if sniperOptions.Length < 1 || sniperOptions.Length > 255 { + return fmt.Errorf("length must be between 1 and 255") + } + if sniperOptions.Pressure < 1 || sniperOptions.Pressure > 255 { + return fmt.Errorf("pressure must be between 1 and 255") + } return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - cfg.AutoTrigger.Mode = 3 - cfg.AutoTrigger.VibrationBind.Type = 0 - cfg.AutoTrigger.VibrationBind.MinFilter = 10 - cfg.AutoTrigger.VibrationBind.Scale = 50 - cfg.AutoTrigger.VibrationBind.TriggerParams = - []int32{100, 1, 255, 70, 0} - - cfg.AutoTrigger.MixedBorder = 0 - cfg.AutoTrigger.MixedParams = []int32{ - int32(initialPos), int32(length), int32(pressure), 0, int32(onLeave), - 0, 0, 0, 0, 0, + cfg.Mode = &pb.TriggerConfiguration_Sniper{ + Sniper: &pb.TriggerSniper{ + InitialPos: int32(sniperOptions.InitialPos), + Length: int32(sniperOptions.Length), + Pressure: int32(sniperOptions.Pressure), + InputAfter: sniperOptions.InputAfter, + }, } - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 30 - lg.Max = 80 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 50 - lg.TimeLimit = 0 }) }, - }) - cmd.AddCommand(&cobra.Command{ - Use: "lock ", + } + sniperCmd.Flags().IntVar( + &sniperOptions.InitialPos, + "initial-pos", + 50, + "Initial trigger position (0–192)", + ) + sniperCmd.Flags().IntVar( + &sniperOptions.Length, + "length", + 30, + "trigger length (1–255)", + ) + sniperCmd.Flags().IntVar( + &sniperOptions.Pressure, + "pressure", + 1, + "Trigger pressure (1–255)", + ) + sniperCmd.Flags().BoolVar( + &sniperOptions.InputAfter, + "input-after", + true, + "Only triggers the input after the start position", + ) + sniperCmd.Flags().SortFlags = false + cmd.AddCommand(sniperCmd) + + lockCmd := &cobra.Command{ + Use: "lock", Short: "Set this trigger to lock mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - initialPos := 40 // 20-200 + if lockOptions.InitialPos < 0 || lockOptions.InitialPos > 192 { + return fmt.Errorf("initial-pos must be between 0 and 192") + } return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - cfg.AutoTrigger.Mode = 4 - cfg.AutoTrigger.VibrationBind.Type = 0 - cfg.AutoTrigger.VibrationBind.MinFilter = 10 - cfg.AutoTrigger.VibrationBind.Scale = 50 - cfg.AutoTrigger.VibrationBind.TriggerParams = - []int32{100, 1, 255, 70, 0} - - cfg.AutoTrigger.MixedBorder = 0 - cfg.AutoTrigger.MixedParams = []int32{ - int32(initialPos), 255, 1, 0, 0, - 0, 0, 0, 0, 0, + cfg.Mode = &pb.TriggerConfiguration_Lock{ + Lock: &pb.TriggerLock{ + InitialPos: int32(lockOptions.InitialPos), + }, } - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 30 - lg.Max = 80 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 50 - lg.TimeLimit = 0 }) }, - }) - cmd.AddCommand(&cobra.Command{ + } + lockCmd.Flags().IntVar( + &lockOptions.InitialPos, + "initial-pos", + 40, + "Initial trigger position (0–192)", + ) + lockCmd.Flags().SortFlags = false + cmd.AddCommand(lockCmd) + + vibrationCmd := &cobra.Command{ Use: "vibration", Short: "Set this trigger to vibration mode", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - coefficient := 50 // 0 - 200 - threshold := 10 // 1 - 255 - travelRange := 20 // 0 - 200 - frequency := 90 // 0 - 200 - - return modifyConfiguration(func(conf *pb.GamepadConfiguration) { - cfg := side.GetBean(conf) - cfg.AutoTrigger.Mode = 5 - cfg.AutoTrigger.VibrationBind.Type = 2 - cfg.AutoTrigger.VibrationBind.MinFilter = int32(threshold) - cfg.AutoTrigger.VibrationBind.Scale = int32(coefficient) - cfg.AutoTrigger.VibrationBind.TriggerParams = - []int32{int32(travelRange), 1, 1, int32(frequency), 0} - - cfg.AutoTrigger.MixedBorder = 0 - cfg.AutoTrigger.MixedParams = []int32{ - 1, 1, 1, 90, 0, - 0, 0, 0, 0, 0, - } - - lg := cfg.TriggerMotor.LineGear - lg.Type = 1 - lg.Min = 30 - lg.Max = 80 - lg.Filter = 5 - lg.VibrLimit = 1 - lg.Scale = 50 - lg.TimeLimit = 0 - }) - }, - }) - cmd.AddCommand(&cobra.Command{ - Use: "custom ", - Short: "Load custom trigger configuration from JSON file", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - path := args[0] - - info, err := os.Stat(path) - if err != nil { - if os.IsNotExist(err) { - return fmt.Errorf("file does not exist: %s", path) - } - return fmt.Errorf("cannot access file %s: %w", path, err) + if vibrationOptions.Coefficient < 0 || vibrationOptions.Coefficient > 200 { + return fmt.Errorf("intensity must be between 0 and 200") } - - if info.IsDir() { - return fmt.Errorf("path is a directory, not a file: %s", path) + if vibrationOptions.Threshold < 1 || vibrationOptions.Threshold > 255 { + return fmt.Errorf("threshold must be between 1 and 255") } - - if filepath.Ext(path) != ".json" { - return fmt.Errorf("expected a .json file: %s", path) + if vibrationOptions.TravelRange < 1 || vibrationOptions.TravelRange > 200 { + return fmt.Errorf("range must be between 1 and 200") + } + if vibrationOptions.Frequency < 1 || vibrationOptions.Frequency > 255 { + return fmt.Errorf("frequency must be between 1 and 255") } return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) - jsonCfg, err := loadTriggerJSON(path) - if err != nil { - panic(err) + cfg.Mode = &pb.TriggerConfiguration_Vibration{ + Vibration: &pb.TriggerVibration{ + Coefficient: int32(vibrationOptions.Coefficient), + Threshold: int32(vibrationOptions.Threshold), + TravelRange: int32(vibrationOptions.TravelRange), + Frequency: int32(vibrationOptions.Frequency), + }, } - applyTriggerJSON(cfg, jsonCfg) }) }, - }) + } + vibrationCmd.Flags().IntVar( + &vibrationOptions.Coefficient, + "intensity", + 50, + "Intensity of the trigger (0–200)", + ) + vibrationCmd.Flags().IntVar( + &vibrationOptions.Threshold, + "threshold", + 10, + "Vibration threshold (1–255). Below this value, the trigger will not vibrate.", + ) + vibrationCmd.Flags().IntVar( + &vibrationOptions.TravelRange, + "range", + 20, + "Trigger travel range for sustained vibration feedback (1-200)", + ) + vibrationCmd.Flags().IntVar( + &vibrationOptions.Frequency, + "frequency", + 90, + "Vibration frequency (1-255)", + ) + vibrationCmd.Flags().SortFlags = false + cmd.AddCommand(vibrationCmd) return cmd } @@ -468,6 +402,19 @@ func init() { var triggerLeftCommand = genTriggerCommand(triggerLeft) var triggerRightCommand = genTriggerCommand(triggerRight) + triggerLeftCommand.Flags().BoolVar( + &showDetails, + "details", + false, + "Show detailed trigger configuration", + ) + triggerRightCommand.Flags().BoolVar( + &showDetails, + "details", + false, + "Show detailed trigger configuration", + ) + triggerCommand.AddCommand(triggerLeftCommand) triggerCommand.AddCommand(triggerRightCommand) diff --git a/pkg/dbus/pb/convert.go b/pkg/dbus/pb/convert.go index f7e5b57..9bcb220 100644 --- a/pkg/dbus/pb/convert.go +++ b/pkg/dbus/pb/convert.go @@ -72,38 +72,56 @@ func (c *JoystickConfiguration) ApplyTo(bean *config.JoyStickBean) { } func ConvertTriggerConfiguration(bean *config.Trigger) *TriggerConfiguration { - return &TriggerConfiguration{ - AutoTrigger: &AutoTrigger{ - Mode: bean.AutoTrigger.Mode, - VibrationBind: &VibrationBind{ - Type: bean.AutoTrigger.VibrationBind.Type, - MinFilter: bean.AutoTrigger.VibrationBind.MinFilter, - Scale: bean.AutoTrigger.VibrationBind.Scale, - TriggerParams: bean.AutoTrigger.VibrationBind.TriggerParams, + var mode isTriggerConfiguration_Mode + + switch bean.AutoTrigger.Mode { + case 0: + mode = &TriggerConfiguration_Default{} + case 1: + mode = &TriggerConfiguration_Race{ + Race: &TriggerRace{ + InitialPos: bean.AutoTrigger.MixedParams[0], + Pressure: bean.AutoTrigger.MixedParams[1], + }, + } + case 2: + mode = &TriggerConfiguration_Recoil{ + Recoil: &TriggerRecoil{ + InitialPos: bean.AutoTrigger.MixedParams[0], + InitialStrength: bean.AutoTrigger.MixedParams[1], + Intensity: bean.AutoTrigger.MixedParams[2], + Frequency: bean.AutoTrigger.MixedParams[3], + InputAfter: bean.AutoTrigger.MixedParams[4] == 1, }, - MixedBorder: bean.AutoTrigger.MixedBorder, - MixedParams: bean.AutoTrigger.MixedParams, - }, - TriggerMotor: &TriggerMotor{ - LineGear: &TriggerMotorSet{ - Type: bean.TriggerMotor.LineGear.Type, - Min: bean.TriggerMotor.LineGear.Min, - Max: bean.TriggerMotor.LineGear.Max, - Filter: bean.TriggerMotor.LineGear.Filter, - VibrLimit: bean.TriggerMotor.LineGear.Vibrlimit, - Scale: bean.TriggerMotor.LineGear.Scale, - TimeLimit: bean.TriggerMotor.LineGear.TimeLimit, + } + case 3: + mode = &TriggerConfiguration_Sniper{ + Sniper: &TriggerSniper{ + InitialPos: bean.AutoTrigger.MixedParams[0], + Length: bean.AutoTrigger.MixedParams[1], + Pressure: bean.AutoTrigger.MixedParams[2], + InputAfter: bean.AutoTrigger.MixedParams[4] == 1, }, - MicrGear: &TriggerMotorSet{ - Type: bean.TriggerMotor.MicrGear.Type, - Min: bean.TriggerMotor.MicrGear.Min, - Max: bean.TriggerMotor.MicrGear.Max, - Filter: bean.TriggerMotor.MicrGear.Filter, - VibrLimit: bean.TriggerMotor.MicrGear.Vibrlimit, - Scale: bean.TriggerMotor.MicrGear.Scale, - TimeLimit: bean.TriggerMotor.MicrGear.TimeLimit, + } + case 4: + mode = &TriggerConfiguration_Lock{ + Lock: &TriggerLock{ + InitialPos: bean.AutoTrigger.MixedParams[0], + }, + } + case 5: + mode = &TriggerConfiguration_Vibration{ + Vibration: &TriggerVibration{ + Coefficient: bean.AutoTrigger.VibrationBind.Scale, + Threshold: bean.AutoTrigger.VibrationBind.MinFilter, + TravelRange: bean.AutoTrigger.VibrationBind.TriggerParams[0], + Frequency: bean.AutoTrigger.VibrationBind.TriggerParams[3], }, - }, + } + } + + return &TriggerConfiguration{ + Mode: mode, } } @@ -112,37 +130,27 @@ func (c *TriggerConfiguration) ApplyTo(bean *config.Trigger) { return } - bean.Type = 0 - bean.AutoTrigger = &config.Autotrigger{ - Mode: c.AutoTrigger.Mode, - VibrationBind: &config.Vibrationbind{ - Type: c.AutoTrigger.VibrationBind.Type, - MinFilter: c.AutoTrigger.VibrationBind.MinFilter, - Scale: c.AutoTrigger.VibrationBind.Scale, - TriggerParams: c.AutoTrigger.VibrationBind.TriggerParams, - }, - MixedBorder: c.AutoTrigger.MixedBorder, - MixedParams: c.AutoTrigger.MixedParams, - } - bean.TriggerMotor = &config.TriggerMotor{ - LineGear: &config.TriggerMotorSet{ - Type: c.TriggerMotor.LineGear.Type, - Min: c.TriggerMotor.LineGear.Min, - Max: c.TriggerMotor.LineGear.Max, - Filter: c.TriggerMotor.LineGear.Filter, - Vibrlimit: c.TriggerMotor.LineGear.VibrLimit, - Scale: c.TriggerMotor.LineGear.Scale, - TimeLimit: c.TriggerMotor.LineGear.TimeLimit, - }, - MicrGear: &config.TriggerMotorSet{ - Type: c.TriggerMotor.MicrGear.Type, - Min: c.TriggerMotor.MicrGear.Min, - Max: c.TriggerMotor.MicrGear.Max, - Filter: c.TriggerMotor.MicrGear.Filter, - Vibrlimit: c.TriggerMotor.MicrGear.VibrLimit, - Scale: c.TriggerMotor.MicrGear.Scale, - TimeLimit: c.TriggerMotor.MicrGear.TimeLimit, - }, + switch mode := c.Mode.(type) { + case *TriggerConfiguration_Default: + bean.ApplyDefaultTrigger() + case *TriggerConfiguration_Race: + bean.ApplyRaceTrigger(mode.Race.InitialPos, mode.Race.Pressure) + case *TriggerConfiguration_Recoil: + outputInt := int32(0) + if mode.Recoil.InputAfter { + outputInt = 1 + } + bean.ApplyRecoilTrigger(mode.Recoil.InitialPos, mode.Recoil.InitialStrength, mode.Recoil.Intensity, mode.Recoil.Frequency, outputInt) + case *TriggerConfiguration_Sniper: + outputInt := int32(0) + if mode.Sniper.InputAfter { + outputInt = 1 + } + bean.ApplySniperTrigger(mode.Sniper.InitialPos, mode.Sniper.Length, mode.Sniper.Pressure, outputInt) + case *TriggerConfiguration_Lock: + bean.ApplyLockTrigger(mode.Lock.InitialPos) + case *TriggerConfiguration_Vibration: + bean.ApplyVibrationTrigger(mode.Vibration.Coefficient, mode.Vibration.Threshold, mode.Vibration.TravelRange, mode.Vibration.Frequency) } } diff --git a/pkg/dbus/pb/flydigi.pb.go b/pkg/dbus/pb/flydigi.pb.go index 71f0ccb..3135067 100644 --- a/pkg/dbus/pb/flydigi.pb.go +++ b/pkg/dbus/pb/flydigi.pb.go @@ -258,30 +258,35 @@ func (x *JoystickConfiguration) GetDeadzone() int32 { return 0 } -type VibrationBind struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` - MinFilter int32 `protobuf:"varint,2,opt,name=minFilter,proto3" json:"minFilter,omitempty"` - Scale int32 `protobuf:"varint,3,opt,name=scale,proto3" json:"scale,omitempty"` - TriggerParams []int32 `protobuf:"varint,4,rep,packed,name=triggerParams,proto3" json:"triggerParams,omitempty"` +type TriggerConfiguration struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Mode: + // + // *TriggerConfiguration_Default + // *TriggerConfiguration_Race + // *TriggerConfiguration_Recoil + // *TriggerConfiguration_Sniper + // *TriggerConfiguration_Lock + // *TriggerConfiguration_Vibration + Mode isTriggerConfiguration_Mode `protobuf_oneof:"mode"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *VibrationBind) Reset() { - *x = VibrationBind{} +func (x *TriggerConfiguration) Reset() { + *x = TriggerConfiguration{} mi := &file_flydigi_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *VibrationBind) String() string { +func (x *TriggerConfiguration) String() string { return protoimpl.X.MessageStringOf(x) } -func (*VibrationBind) ProtoMessage() {} +func (*TriggerConfiguration) ProtoMessage() {} -func (x *VibrationBind) ProtoReflect() protoreflect.Message { +func (x *TriggerConfiguration) ProtoReflect() protoreflect.Message { mi := &file_flydigi_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -293,61 +298,132 @@ func (x *VibrationBind) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use VibrationBind.ProtoReflect.Descriptor instead. -func (*VibrationBind) Descriptor() ([]byte, []int) { +// Deprecated: Use TriggerConfiguration.ProtoReflect.Descriptor instead. +func (*TriggerConfiguration) Descriptor() ([]byte, []int) { return file_flydigi_proto_rawDescGZIP(), []int{3} } -func (x *VibrationBind) GetType() int32 { +func (x *TriggerConfiguration) GetMode() isTriggerConfiguration_Mode { if x != nil { - return x.Type + return x.Mode } - return 0 + return nil } -func (x *VibrationBind) GetMinFilter() int32 { +func (x *TriggerConfiguration) GetDefault() *TriggerDefault { if x != nil { - return x.MinFilter + if x, ok := x.Mode.(*TriggerConfiguration_Default); ok { + return x.Default + } } - return 0 + return nil } -func (x *VibrationBind) GetScale() int32 { +func (x *TriggerConfiguration) GetRace() *TriggerRace { if x != nil { - return x.Scale + if x, ok := x.Mode.(*TriggerConfiguration_Race); ok { + return x.Race + } } - return 0 + return nil } -func (x *VibrationBind) GetTriggerParams() []int32 { +func (x *TriggerConfiguration) GetRecoil() *TriggerRecoil { if x != nil { - return x.TriggerParams + if x, ok := x.Mode.(*TriggerConfiguration_Recoil); ok { + return x.Recoil + } } return nil } -type TriggerConfiguration struct { +func (x *TriggerConfiguration) GetSniper() *TriggerSniper { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Sniper); ok { + return x.Sniper + } + } + return nil +} + +func (x *TriggerConfiguration) GetLock() *TriggerLock { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Lock); ok { + return x.Lock + } + } + return nil +} + +func (x *TriggerConfiguration) GetVibration() *TriggerVibration { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Vibration); ok { + return x.Vibration + } + } + return nil +} + +type isTriggerConfiguration_Mode interface { + isTriggerConfiguration_Mode() +} + +type TriggerConfiguration_Default struct { + Default *TriggerDefault `protobuf:"bytes,10,opt,name=default,proto3,oneof"` +} + +type TriggerConfiguration_Race struct { + Race *TriggerRace `protobuf:"bytes,11,opt,name=race,proto3,oneof"` +} + +type TriggerConfiguration_Recoil struct { + Recoil *TriggerRecoil `protobuf:"bytes,12,opt,name=recoil,proto3,oneof"` +} + +type TriggerConfiguration_Sniper struct { + Sniper *TriggerSniper `protobuf:"bytes,13,opt,name=sniper,proto3,oneof"` +} + +type TriggerConfiguration_Lock struct { + Lock *TriggerLock `protobuf:"bytes,14,opt,name=lock,proto3,oneof"` +} + +type TriggerConfiguration_Vibration struct { + Vibration *TriggerVibration `protobuf:"bytes,15,opt,name=vibration,proto3,oneof"` +} + +func (*TriggerConfiguration_Default) isTriggerConfiguration_Mode() {} + +func (*TriggerConfiguration_Race) isTriggerConfiguration_Mode() {} + +func (*TriggerConfiguration_Recoil) isTriggerConfiguration_Mode() {} + +func (*TriggerConfiguration_Sniper) isTriggerConfiguration_Mode() {} + +func (*TriggerConfiguration_Lock) isTriggerConfiguration_Mode() {} + +func (*TriggerConfiguration_Vibration) isTriggerConfiguration_Mode() {} + +type TriggerDefault struct { state protoimpl.MessageState `protogen:"open.v1"` - AutoTrigger *AutoTrigger `protobuf:"bytes,1,opt,name=autoTrigger,proto3" json:"autoTrigger,omitempty"` - TriggerMotor *TriggerMotor `protobuf:"bytes,2,opt,name=triggerMotor,proto3" json:"triggerMotor,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *TriggerConfiguration) Reset() { - *x = TriggerConfiguration{} +func (x *TriggerDefault) Reset() { + *x = TriggerDefault{} mi := &file_flydigi_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *TriggerConfiguration) String() string { +func (x *TriggerDefault) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TriggerConfiguration) ProtoMessage() {} +func (*TriggerDefault) ProtoMessage() {} -func (x *TriggerConfiguration) ProtoReflect() protoreflect.Message { +func (x *TriggerDefault) ProtoReflect() protoreflect.Message { mi := &file_flydigi_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -359,50 +435,89 @@ func (x *TriggerConfiguration) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use TriggerConfiguration.ProtoReflect.Descriptor instead. -func (*TriggerConfiguration) Descriptor() ([]byte, []int) { +// Deprecated: Use TriggerDefault.ProtoReflect.Descriptor instead. +func (*TriggerDefault) Descriptor() ([]byte, []int) { return file_flydigi_proto_rawDescGZIP(), []int{4} } -func (x *TriggerConfiguration) GetAutoTrigger() *AutoTrigger { +type TriggerRace struct { + state protoimpl.MessageState `protogen:"open.v1"` + InitialPos int32 `protobuf:"varint,1,opt,name=initialPos,proto3" json:"initialPos,omitempty"` + Pressure int32 `protobuf:"varint,2,opt,name=pressure,proto3" json:"pressure,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerRace) Reset() { + *x = TriggerRace{} + mi := &file_flydigi_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerRace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerRace) ProtoMessage() {} + +func (x *TriggerRace) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[5] if x != nil { - return x.AutoTrigger + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return nil + return mi.MessageOf(x) } -func (x *TriggerConfiguration) GetTriggerMotor() *TriggerMotor { +// Deprecated: Use TriggerRace.ProtoReflect.Descriptor instead. +func (*TriggerRace) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{5} +} + +func (x *TriggerRace) GetInitialPos() int32 { if x != nil { - return x.TriggerMotor + return x.InitialPos } - return nil + return 0 } -type AutoTrigger struct { - state protoimpl.MessageState `protogen:"open.v1"` - Mode int32 `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"` - VibrationBind *VibrationBind `protobuf:"bytes,2,opt,name=vibrationBind,proto3" json:"vibrationBind,omitempty"` - MixedBorder int32 `protobuf:"varint,3,opt,name=mixedBorder,proto3" json:"mixedBorder,omitempty"` - MixedParams []int32 `protobuf:"varint,4,rep,packed,name=mixedParams,proto3" json:"mixedParams,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache +func (x *TriggerRace) GetPressure() int32 { + if x != nil { + return x.Pressure + } + return 0 } -func (x *AutoTrigger) Reset() { - *x = AutoTrigger{} - mi := &file_flydigi_proto_msgTypes[5] +type TriggerRecoil struct { + state protoimpl.MessageState `protogen:"open.v1"` + InitialPos int32 `protobuf:"varint,1,opt,name=initialPos,proto3" json:"initialPos,omitempty"` + InitialStrength int32 `protobuf:"varint,2,opt,name=initialStrength,proto3" json:"initialStrength,omitempty"` + Intensity int32 `protobuf:"varint,3,opt,name=intensity,proto3" json:"intensity,omitempty"` + Frequency int32 `protobuf:"varint,4,opt,name=frequency,proto3" json:"frequency,omitempty"` + InputAfter bool `protobuf:"varint,5,opt,name=inputAfter,proto3" json:"inputAfter,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerRecoil) Reset() { + *x = TriggerRecoil{} + mi := &file_flydigi_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AutoTrigger) String() string { +func (x *TriggerRecoil) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AutoTrigger) ProtoMessage() {} +func (*TriggerRecoil) ProtoMessage() {} -func (x *AutoTrigger) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[5] +func (x *TriggerRecoil) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -413,62 +528,71 @@ func (x *AutoTrigger) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AutoTrigger.ProtoReflect.Descriptor instead. -func (*AutoTrigger) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{5} +// Deprecated: Use TriggerRecoil.ProtoReflect.Descriptor instead. +func (*TriggerRecoil) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{6} } -func (x *AutoTrigger) GetMode() int32 { +func (x *TriggerRecoil) GetInitialPos() int32 { if x != nil { - return x.Mode + return x.InitialPos } return 0 } -func (x *AutoTrigger) GetVibrationBind() *VibrationBind { +func (x *TriggerRecoil) GetInitialStrength() int32 { if x != nil { - return x.VibrationBind + return x.InitialStrength } - return nil + return 0 } -func (x *AutoTrigger) GetMixedBorder() int32 { +func (x *TriggerRecoil) GetIntensity() int32 { if x != nil { - return x.MixedBorder + return x.Intensity } return 0 } -func (x *AutoTrigger) GetMixedParams() []int32 { +func (x *TriggerRecoil) GetFrequency() int32 { if x != nil { - return x.MixedParams + return x.Frequency } - return nil + return 0 +} + +func (x *TriggerRecoil) GetInputAfter() bool { + if x != nil { + return x.InputAfter + } + return false } -type TriggerMotor struct { +type TriggerSniper struct { state protoimpl.MessageState `protogen:"open.v1"` - LineGear *TriggerMotorSet `protobuf:"bytes,1,opt,name=lineGear,proto3" json:"lineGear,omitempty"` - MicrGear *TriggerMotorSet `protobuf:"bytes,2,opt,name=micrGear,proto3" json:"micrGear,omitempty"` + InitialPos int32 `protobuf:"varint,1,opt,name=initialPos,proto3" json:"initialPos,omitempty"` + Length int32 `protobuf:"varint,2,opt,name=length,proto3" json:"length,omitempty"` + Pressure int32 `protobuf:"varint,3,opt,name=pressure,proto3" json:"pressure,omitempty"` + InputAfter bool `protobuf:"varint,4,opt,name=inputAfter,proto3" json:"inputAfter,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *TriggerMotor) Reset() { - *x = TriggerMotor{} - mi := &file_flydigi_proto_msgTypes[6] +func (x *TriggerSniper) Reset() { + *x = TriggerSniper{} + mi := &file_flydigi_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *TriggerMotor) String() string { +func (x *TriggerSniper) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TriggerMotor) ProtoMessage() {} +func (*TriggerSniper) ProtoMessage() {} -func (x *TriggerMotor) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[6] +func (x *TriggerSniper) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -479,53 +603,61 @@ func (x *TriggerMotor) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use TriggerMotor.ProtoReflect.Descriptor instead. -func (*TriggerMotor) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{6} +// Deprecated: Use TriggerSniper.ProtoReflect.Descriptor instead. +func (*TriggerSniper) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{7} } -func (x *TriggerMotor) GetLineGear() *TriggerMotorSet { +func (x *TriggerSniper) GetInitialPos() int32 { if x != nil { - return x.LineGear + return x.InitialPos } - return nil + return 0 } -func (x *TriggerMotor) GetMicrGear() *TriggerMotorSet { +func (x *TriggerSniper) GetLength() int32 { if x != nil { - return x.MicrGear + return x.Length } - return nil + return 0 } -type TriggerMotorSet struct { +func (x *TriggerSniper) GetPressure() int32 { + if x != nil { + return x.Pressure + } + return 0 +} + +func (x *TriggerSniper) GetInputAfter() bool { + if x != nil { + return x.InputAfter + } + return false +} + +type TriggerLock struct { state protoimpl.MessageState `protogen:"open.v1"` - Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` - Min int32 `protobuf:"varint,2,opt,name=min,proto3" json:"min,omitempty"` - Max int32 `protobuf:"varint,3,opt,name=max,proto3" json:"max,omitempty"` - Filter int32 `protobuf:"varint,4,opt,name=filter,proto3" json:"filter,omitempty"` - VibrLimit int32 `protobuf:"varint,5,opt,name=vibrLimit,proto3" json:"vibrLimit,omitempty"` - Scale int32 `protobuf:"varint,6,opt,name=scale,proto3" json:"scale,omitempty"` - TimeLimit int32 `protobuf:"varint,7,opt,name=timeLimit,proto3" json:"timeLimit,omitempty"` + InitialPos int32 `protobuf:"varint,1,opt,name=initialPos,proto3" json:"initialPos,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *TriggerMotorSet) Reset() { - *x = TriggerMotorSet{} - mi := &file_flydigi_proto_msgTypes[7] +func (x *TriggerLock) Reset() { + *x = TriggerLock{} + mi := &file_flydigi_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *TriggerMotorSet) String() string { +func (x *TriggerLock) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TriggerMotorSet) ProtoMessage() {} +func (*TriggerLock) ProtoMessage() {} -func (x *TriggerMotorSet) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[7] +func (x *TriggerLock) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -536,56 +668,82 @@ func (x *TriggerMotorSet) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use TriggerMotorSet.ProtoReflect.Descriptor instead. -func (*TriggerMotorSet) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{7} +// Deprecated: Use TriggerLock.ProtoReflect.Descriptor instead. +func (*TriggerLock) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{8} } -func (x *TriggerMotorSet) GetType() int32 { +func (x *TriggerLock) GetInitialPos() int32 { if x != nil { - return x.Type + return x.InitialPos } return 0 } -func (x *TriggerMotorSet) GetMin() int32 { - if x != nil { - return x.Min - } - return 0 +type TriggerVibration struct { + state protoimpl.MessageState `protogen:"open.v1"` + Coefficient int32 `protobuf:"varint,1,opt,name=coefficient,proto3" json:"coefficient,omitempty"` + Threshold int32 `protobuf:"varint,2,opt,name=threshold,proto3" json:"threshold,omitempty"` + TravelRange int32 `protobuf:"varint,3,opt,name=travelRange,proto3" json:"travelRange,omitempty"` + Frequency int32 `protobuf:"varint,4,opt,name=frequency,proto3" json:"frequency,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerVibration) Reset() { + *x = TriggerVibration{} + mi := &file_flydigi_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerVibration) String() string { + return protoimpl.X.MessageStringOf(x) } -func (x *TriggerMotorSet) GetMax() int32 { +func (*TriggerVibration) ProtoMessage() {} + +func (x *TriggerVibration) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[9] if x != nil { - return x.Max + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerVibration.ProtoReflect.Descriptor instead. +func (*TriggerVibration) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{9} } -func (x *TriggerMotorSet) GetFilter() int32 { +func (x *TriggerVibration) GetCoefficient() int32 { if x != nil { - return x.Filter + return x.Coefficient } return 0 } -func (x *TriggerMotorSet) GetVibrLimit() int32 { +func (x *TriggerVibration) GetThreshold() int32 { if x != nil { - return x.VibrLimit + return x.Threshold } return 0 } -func (x *TriggerMotorSet) GetScale() int32 { +func (x *TriggerVibration) GetTravelRange() int32 { if x != nil { - return x.Scale + return x.TravelRange } return 0 } -func (x *TriggerMotorSet) GetTimeLimit() int32 { +func (x *TriggerVibration) GetFrequency() int32 { if x != nil { - return x.TimeLimit + return x.Frequency } return 0 } @@ -598,7 +756,7 @@ type LedsOff struct { func (x *LedsOff) Reset() { *x = LedsOff{} - mi := &file_flydigi_proto_msgTypes[8] + mi := &file_flydigi_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -610,7 +768,7 @@ func (x *LedsOff) String() string { func (*LedsOff) ProtoMessage() {} func (x *LedsOff) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[8] + mi := &file_flydigi_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -623,7 +781,7 @@ func (x *LedsOff) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsOff.ProtoReflect.Descriptor instead. func (*LedsOff) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{8} + return file_flydigi_proto_rawDescGZIP(), []int{10} } type LedsSteady struct { @@ -635,7 +793,7 @@ type LedsSteady struct { func (x *LedsSteady) Reset() { *x = LedsSteady{} - mi := &file_flydigi_proto_msgTypes[9] + mi := &file_flydigi_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -647,7 +805,7 @@ func (x *LedsSteady) String() string { func (*LedsSteady) ProtoMessage() {} func (x *LedsSteady) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[9] + mi := &file_flydigi_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -660,7 +818,7 @@ func (x *LedsSteady) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsSteady.ProtoReflect.Descriptor instead. func (*LedsSteady) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{9} + return file_flydigi_proto_rawDescGZIP(), []int{11} } func (x *LedsSteady) GetColor() *Color { @@ -679,7 +837,7 @@ type LedsStreamlined struct { func (x *LedsStreamlined) Reset() { *x = LedsStreamlined{} - mi := &file_flydigi_proto_msgTypes[10] + mi := &file_flydigi_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -691,7 +849,7 @@ func (x *LedsStreamlined) String() string { func (*LedsStreamlined) ProtoMessage() {} func (x *LedsStreamlined) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[10] + mi := &file_flydigi_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -704,7 +862,7 @@ func (x *LedsStreamlined) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsStreamlined.ProtoReflect.Descriptor instead. func (*LedsStreamlined) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{10} + return file_flydigi_proto_rawDescGZIP(), []int{12} } func (x *LedsStreamlined) GetSpeed() float32 { @@ -724,7 +882,7 @@ type LedsGradient struct { func (x *LedsGradient) Reset() { *x = LedsGradient{} - mi := &file_flydigi_proto_msgTypes[11] + mi := &file_flydigi_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -736,7 +894,7 @@ func (x *LedsGradient) String() string { func (*LedsGradient) ProtoMessage() {} func (x *LedsGradient) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[11] + mi := &file_flydigi_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -749,7 +907,7 @@ func (x *LedsGradient) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsGradient.ProtoReflect.Descriptor instead. func (*LedsGradient) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{11} + return file_flydigi_proto_rawDescGZIP(), []int{13} } func (x *LedsGradient) GetSpeed() float32 { @@ -782,7 +940,7 @@ type LedsConfiguration struct { func (x *LedsConfiguration) Reset() { *x = LedsConfiguration{} - mi := &file_flydigi_proto_msgTypes[12] + mi := &file_flydigi_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -794,7 +952,7 @@ func (x *LedsConfiguration) String() string { func (*LedsConfiguration) ProtoMessage() {} func (x *LedsConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[12] + mi := &file_flydigi_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -807,7 +965,7 @@ func (x *LedsConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use LedsConfiguration.ProtoReflect.Descriptor instead. func (*LedsConfiguration) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{12} + return file_flydigi_proto_rawDescGZIP(), []int{14} } func (x *LedsConfiguration) GetBrightness() float32 { @@ -897,7 +1055,7 @@ type Color struct { func (x *Color) Reset() { *x = Color{} - mi := &file_flydigi_proto_msgTypes[13] + mi := &file_flydigi_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -909,7 +1067,7 @@ func (x *Color) String() string { func (*Color) ProtoMessage() {} func (x *Color) ProtoReflect() protoreflect.Message { - mi := &file_flydigi_proto_msgTypes[13] + mi := &file_flydigi_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -922,7 +1080,7 @@ func (x *Color) ProtoReflect() protoreflect.Message { // Deprecated: Use Color.ProtoReflect.Descriptor instead. func (*Color) Descriptor() ([]byte, []int) { - return file_flydigi_proto_rawDescGZIP(), []int{13} + return file_flydigi_proto_rawDescGZIP(), []int{15} } func (x *Color) GetRgb() int32 { @@ -949,31 +1107,50 @@ const file_flydigi_proto_rawDesc = "" + "\fleft_trigger\x18\x03 \x01(\v2\x1d.flydigi.TriggerConfigurationR\vleftTrigger\x12B\n" + "\rright_trigger\x18\x04 \x01(\v2\x1d.flydigi.TriggerConfigurationR\frightTrigger\"3\n" + "\x15JoystickConfiguration\x12\x1a\n" + - "\bdeadzone\x18\x01 \x01(\x05R\bdeadzone\"}\n" + - "\rVibrationBind\x12\x12\n" + - "\x04type\x18\x01 \x01(\x05R\x04type\x12\x1c\n" + - "\tminFilter\x18\x02 \x01(\x05R\tminFilter\x12\x14\n" + - "\x05scale\x18\x03 \x01(\x05R\x05scale\x12$\n" + - "\rtriggerParams\x18\x04 \x03(\x05R\rtriggerParams\"\x89\x01\n" + - "\x14TriggerConfiguration\x126\n" + - "\vautoTrigger\x18\x01 \x01(\v2\x14.flydigi.AutoTriggerR\vautoTrigger\x129\n" + - "\ftriggerMotor\x18\x02 \x01(\v2\x15.flydigi.TriggerMotorR\ftriggerMotor\"\xa3\x01\n" + - "\vAutoTrigger\x12\x12\n" + - "\x04mode\x18\x01 \x01(\x05R\x04mode\x12<\n" + - "\rvibrationBind\x18\x02 \x01(\v2\x16.flydigi.VibrationBindR\rvibrationBind\x12 \n" + - "\vmixedBorder\x18\x03 \x01(\x05R\vmixedBorder\x12 \n" + - "\vmixedParams\x18\x04 \x03(\x05R\vmixedParams\"z\n" + - "\fTriggerMotor\x124\n" + - "\blineGear\x18\x01 \x01(\v2\x18.flydigi.TriggerMotorSetR\blineGear\x124\n" + - "\bmicrGear\x18\x02 \x01(\v2\x18.flydigi.TriggerMotorSetR\bmicrGear\"\xb3\x01\n" + - "\x0fTriggerMotorSet\x12\x12\n" + - "\x04type\x18\x01 \x01(\x05R\x04type\x12\x10\n" + - "\x03min\x18\x02 \x01(\x05R\x03min\x12\x10\n" + - "\x03max\x18\x03 \x01(\x05R\x03max\x12\x16\n" + - "\x06filter\x18\x04 \x01(\x05R\x06filter\x12\x1c\n" + - "\tvibrLimit\x18\x05 \x01(\x05R\tvibrLimit\x12\x14\n" + - "\x05scale\x18\x06 \x01(\x05R\x05scale\x12\x1c\n" + - "\ttimeLimit\x18\a \x01(\x05R\ttimeLimit\"\t\n" + + "\bdeadzone\x18\x01 \x01(\x05R\bdeadzone\"\xca\x02\n" + + "\x14TriggerConfiguration\x123\n" + + "\adefault\x18\n" + + " \x01(\v2\x17.flydigi.TriggerDefaultH\x00R\adefault\x12*\n" + + "\x04race\x18\v \x01(\v2\x14.flydigi.TriggerRaceH\x00R\x04race\x120\n" + + "\x06recoil\x18\f \x01(\v2\x16.flydigi.TriggerRecoilH\x00R\x06recoil\x120\n" + + "\x06sniper\x18\r \x01(\v2\x16.flydigi.TriggerSniperH\x00R\x06sniper\x12*\n" + + "\x04lock\x18\x0e \x01(\v2\x14.flydigi.TriggerLockH\x00R\x04lock\x129\n" + + "\tvibration\x18\x0f \x01(\v2\x19.flydigi.TriggerVibrationH\x00R\tvibrationB\x06\n" + + "\x04mode\"\x10\n" + + "\x0eTriggerDefault\"I\n" + + "\vTriggerRace\x12\x1e\n" + + "\n" + + "initialPos\x18\x01 \x01(\x05R\n" + + "initialPos\x12\x1a\n" + + "\bpressure\x18\x02 \x01(\x05R\bpressure\"\xb5\x01\n" + + "\rTriggerRecoil\x12\x1e\n" + + "\n" + + "initialPos\x18\x01 \x01(\x05R\n" + + "initialPos\x12(\n" + + "\x0finitialStrength\x18\x02 \x01(\x05R\x0finitialStrength\x12\x1c\n" + + "\tintensity\x18\x03 \x01(\x05R\tintensity\x12\x1c\n" + + "\tfrequency\x18\x04 \x01(\x05R\tfrequency\x12\x1e\n" + + "\n" + + "inputAfter\x18\x05 \x01(\bR\n" + + "inputAfter\"\x83\x01\n" + + "\rTriggerSniper\x12\x1e\n" + + "\n" + + "initialPos\x18\x01 \x01(\x05R\n" + + "initialPos\x12\x16\n" + + "\x06length\x18\x02 \x01(\x05R\x06length\x12\x1a\n" + + "\bpressure\x18\x03 \x01(\x05R\bpressure\x12\x1e\n" + + "\n" + + "inputAfter\x18\x04 \x01(\bR\n" + + "inputAfter\"-\n" + + "\vTriggerLock\x12\x1e\n" + + "\n" + + "initialPos\x18\x01 \x01(\x05R\n" + + "initialPos\"\x92\x01\n" + + "\x10TriggerVibration\x12 \n" + + "\vcoefficient\x18\x01 \x01(\x05R\vcoefficient\x12\x1c\n" + + "\tthreshold\x18\x02 \x01(\x05R\tthreshold\x12 \n" + + "\vtravelRange\x18\x03 \x01(\x05R\vtravelRange\x12\x1c\n" + + "\tfrequency\x18\x04 \x01(\x05R\tfrequency\"\t\n" + "\aLedsOff\"2\n" + "\n" + "LedsSteady\x12$\n" + @@ -1013,46 +1190,49 @@ func file_flydigi_proto_rawDescGZIP() []byte { } var file_flydigi_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_flydigi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_flydigi_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_flydigi_proto_goTypes = []any{ (ConnectionType)(0), // 0: flydigi.ConnectionType (*GamepadInfo)(nil), // 1: flydigi.GamepadInfo (*GamepadConfiguration)(nil), // 2: flydigi.GamepadConfiguration (*JoystickConfiguration)(nil), // 3: flydigi.JoystickConfiguration - (*VibrationBind)(nil), // 4: flydigi.VibrationBind - (*TriggerConfiguration)(nil), // 5: flydigi.TriggerConfiguration - (*AutoTrigger)(nil), // 6: flydigi.AutoTrigger - (*TriggerMotor)(nil), // 7: flydigi.TriggerMotor - (*TriggerMotorSet)(nil), // 8: flydigi.TriggerMotorSet - (*LedsOff)(nil), // 9: flydigi.LedsOff - (*LedsSteady)(nil), // 10: flydigi.LedsSteady - (*LedsStreamlined)(nil), // 11: flydigi.LedsStreamlined - (*LedsGradient)(nil), // 12: flydigi.LedsGradient - (*LedsConfiguration)(nil), // 13: flydigi.LedsConfiguration - (*Color)(nil), // 14: flydigi.Color + (*TriggerConfiguration)(nil), // 4: flydigi.TriggerConfiguration + (*TriggerDefault)(nil), // 5: flydigi.TriggerDefault + (*TriggerRace)(nil), // 6: flydigi.TriggerRace + (*TriggerRecoil)(nil), // 7: flydigi.TriggerRecoil + (*TriggerSniper)(nil), // 8: flydigi.TriggerSniper + (*TriggerLock)(nil), // 9: flydigi.TriggerLock + (*TriggerVibration)(nil), // 10: flydigi.TriggerVibration + (*LedsOff)(nil), // 11: flydigi.LedsOff + (*LedsSteady)(nil), // 12: flydigi.LedsSteady + (*LedsStreamlined)(nil), // 13: flydigi.LedsStreamlined + (*LedsGradient)(nil), // 14: flydigi.LedsGradient + (*LedsConfiguration)(nil), // 15: flydigi.LedsConfiguration + (*Color)(nil), // 16: flydigi.Color } var file_flydigi_proto_depIdxs = []int32{ 0, // 0: flydigi.GamepadInfo.connection_type:type_name -> flydigi.ConnectionType 3, // 1: flydigi.GamepadConfiguration.left_joystick:type_name -> flydigi.JoystickConfiguration 3, // 2: flydigi.GamepadConfiguration.right_joystick:type_name -> flydigi.JoystickConfiguration - 5, // 3: flydigi.GamepadConfiguration.left_trigger:type_name -> flydigi.TriggerConfiguration - 5, // 4: flydigi.GamepadConfiguration.right_trigger:type_name -> flydigi.TriggerConfiguration - 6, // 5: flydigi.TriggerConfiguration.autoTrigger:type_name -> flydigi.AutoTrigger - 7, // 6: flydigi.TriggerConfiguration.triggerMotor:type_name -> flydigi.TriggerMotor - 4, // 7: flydigi.AutoTrigger.vibrationBind:type_name -> flydigi.VibrationBind - 8, // 8: flydigi.TriggerMotor.lineGear:type_name -> flydigi.TriggerMotorSet - 8, // 9: flydigi.TriggerMotor.micrGear:type_name -> flydigi.TriggerMotorSet - 14, // 10: flydigi.LedsSteady.color:type_name -> flydigi.Color - 14, // 11: flydigi.LedsGradient.colors:type_name -> flydigi.Color - 9, // 12: flydigi.LedsConfiguration.off:type_name -> flydigi.LedsOff - 10, // 13: flydigi.LedsConfiguration.steady:type_name -> flydigi.LedsSteady - 11, // 14: flydigi.LedsConfiguration.streamlined:type_name -> flydigi.LedsStreamlined - 12, // 15: flydigi.LedsConfiguration.gradient:type_name -> flydigi.LedsGradient - 16, // [16:16] is the sub-list for method output_type - 16, // [16:16] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 4, // 3: flydigi.GamepadConfiguration.left_trigger:type_name -> flydigi.TriggerConfiguration + 4, // 4: flydigi.GamepadConfiguration.right_trigger:type_name -> flydigi.TriggerConfiguration + 5, // 5: flydigi.TriggerConfiguration.default:type_name -> flydigi.TriggerDefault + 6, // 6: flydigi.TriggerConfiguration.race:type_name -> flydigi.TriggerRace + 7, // 7: flydigi.TriggerConfiguration.recoil:type_name -> flydigi.TriggerRecoil + 8, // 8: flydigi.TriggerConfiguration.sniper:type_name -> flydigi.TriggerSniper + 9, // 9: flydigi.TriggerConfiguration.lock:type_name -> flydigi.TriggerLock + 10, // 10: flydigi.TriggerConfiguration.vibration:type_name -> flydigi.TriggerVibration + 16, // 11: flydigi.LedsSteady.color:type_name -> flydigi.Color + 16, // 12: flydigi.LedsGradient.colors:type_name -> flydigi.Color + 11, // 13: flydigi.LedsConfiguration.off:type_name -> flydigi.LedsOff + 12, // 14: flydigi.LedsConfiguration.steady:type_name -> flydigi.LedsSteady + 13, // 15: flydigi.LedsConfiguration.streamlined:type_name -> flydigi.LedsStreamlined + 14, // 16: flydigi.LedsConfiguration.gradient:type_name -> flydigi.LedsGradient + 17, // [17:17] is the sub-list for method output_type + 17, // [17:17] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_flydigi_proto_init() } @@ -1060,7 +1240,15 @@ func file_flydigi_proto_init() { if File_flydigi_proto != nil { return } - file_flydigi_proto_msgTypes[12].OneofWrappers = []any{ + file_flydigi_proto_msgTypes[3].OneofWrappers = []any{ + (*TriggerConfiguration_Default)(nil), + (*TriggerConfiguration_Race)(nil), + (*TriggerConfiguration_Recoil)(nil), + (*TriggerConfiguration_Sniper)(nil), + (*TriggerConfiguration_Lock)(nil), + (*TriggerConfiguration_Vibration)(nil), + } + file_flydigi_proto_msgTypes[14].OneofWrappers = []any{ (*LedsConfiguration_Off)(nil), (*LedsConfiguration_Steady)(nil), (*LedsConfiguration_Streamlined)(nil), @@ -1072,7 +1260,7 @@ func file_flydigi_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_flydigi_proto_rawDesc), len(file_flydigi_proto_rawDesc)), NumEnums: 1, - NumMessages: 14, + NumMessages: 16, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/dbus/pb/flydigi.proto b/pkg/dbus/pb/flydigi.proto index 0d298e1..00b3b3a 100644 --- a/pkg/dbus/pb/flydigi.proto +++ b/pkg/dbus/pb/flydigi.proto @@ -29,38 +29,49 @@ message JoystickConfiguration { int32 deadzone = 1; } -message VibrationBind { - int32 type = 1; - int32 minFilter = 2; - int32 scale = 3; - repeated int32 triggerParams = 4; +message TriggerConfiguration { + oneof mode { + TriggerDefault default = 10; + TriggerRace race = 11; + TriggerRecoil recoil = 12; + TriggerSniper sniper = 13; + TriggerLock lock = 14; + TriggerVibration vibration = 15; + } } -message TriggerConfiguration { - AutoTrigger autoTrigger = 1; - TriggerMotor triggerMotor = 2; +message TriggerDefault { +} + +message TriggerRace { + int32 initialPos = 1; + int32 pressure = 2; +} + +message TriggerRecoil { + int32 initialPos = 1; + int32 initialStrength = 2; + int32 intensity = 3; + int32 frequency = 4; + bool inputAfter = 5; } -message AutoTrigger { - int32 mode = 1; - VibrationBind vibrationBind = 2; - int32 mixedBorder = 3; - repeated int32 mixedParams = 4; +message TriggerSniper { + int32 initialPos = 1; + int32 length = 2; + int32 pressure = 3; + bool inputAfter = 4; } -message TriggerMotor { - TriggerMotorSet lineGear = 1; - TriggerMotorSet micrGear = 2; +message TriggerLock { + int32 initialPos = 1; } -message TriggerMotorSet { - int32 type = 1; - int32 min = 2; - int32 max = 3; - int32 filter = 4; - int32 vibrLimit = 5; - int32 scale = 6; - int32 timeLimit = 7; +message TriggerVibration { + int32 coefficient = 1; + int32 threshold = 2; + int32 travelRange = 3; + int32 frequency = 4; } message LedsOff { diff --git a/pkg/flydigi/config/beans.go b/pkg/flydigi/config/beans.go index dad8bb5..3f395f3 100644 --- a/pkg/flydigi/config/beans.go +++ b/pkg/flydigi/config/beans.go @@ -309,7 +309,7 @@ func (t *Trigger) ApplyDefaultTrigger() { lg.TimeLimit = 0 } -func (t *Trigger) ApplyRaceTrigger() { +func (t *Trigger) ApplyRaceTrigger(initialPos int32, pressure int32) { t.Type = 0 t.AutoTrigger.Mode = 1 t.AutoTrigger.VibrationBind.TriggerParams = []int32{100, 1, 255, 70, 0} @@ -317,7 +317,9 @@ func (t *Trigger) ApplyRaceTrigger() { for i := range t.AutoTrigger.MixedParams { t.AutoTrigger.MixedParams[i] = 0 } - t.AutoTrigger.MixedParams[1] = 30 + + t.AutoTrigger.MixedParams[0] = int32(initialPos) + t.AutoTrigger.MixedParams[1] = int32(pressure) lg := t.TriggerMotor.LineGear lg.Type = 1 @@ -329,9 +331,9 @@ func (t *Trigger) ApplyRaceTrigger() { lg.TimeLimit = 0 } -func (t *Trigger) ApplySniperTrigger() { +func (t *Trigger) ApplyRecoilTrigger(InitialPos int32, InitialStrength int32, Intensity int32, Frequency int32, OutputFromVibration int32) { t.Type = 0 - t.AutoTrigger.Mode = 3 + t.AutoTrigger.Mode = 2 t.AutoTrigger.VibrationBind.Type = 0 t.AutoTrigger.VibrationBind.MinFilter = 10 t.AutoTrigger.VibrationBind.Scale = 50 @@ -340,7 +342,7 @@ func (t *Trigger) ApplySniperTrigger() { t.AutoTrigger.MixedBorder = 0 t.AutoTrigger.MixedParams = []int32{ - 50, 30, 1, 0, 1, + InitialPos, InitialStrength, Intensity, Frequency, OutputFromVibration, 0, 0, 0, 0, 0, } @@ -354,9 +356,9 @@ func (t *Trigger) ApplySniperTrigger() { lg.TimeLimit = 0 } -func (t *Trigger) ApplyRecoilTrigger() { +func (t *Trigger) ApplySniperTrigger(InitialPos int32, Length int32, Pressure int32, OutputFromVibration int32) { t.Type = 0 - t.AutoTrigger.Mode = 2 + t.AutoTrigger.Mode = 3 t.AutoTrigger.VibrationBind.Type = 0 t.AutoTrigger.VibrationBind.MinFilter = 10 t.AutoTrigger.VibrationBind.Scale = 50 @@ -365,7 +367,7 @@ func (t *Trigger) ApplyRecoilTrigger() { t.AutoTrigger.MixedBorder = 0 t.AutoTrigger.MixedParams = []int32{ - 0, 1, 50, 15, 1, + InitialPos, Length, Pressure, 0, OutputFromVibration, 0, 0, 0, 0, 0, } @@ -379,7 +381,7 @@ func (t *Trigger) ApplyRecoilTrigger() { lg.TimeLimit = 0 } -func (t *Trigger) ApplyLockTrigger() { +func (t *Trigger) ApplyLockTrigger(InitialPos int32) { t.Type = 0 t.AutoTrigger.Mode = 4 t.AutoTrigger.VibrationBind.Type = 0 @@ -390,7 +392,7 @@ func (t *Trigger) ApplyLockTrigger() { t.AutoTrigger.MixedBorder = 0 t.AutoTrigger.MixedParams = []int32{ - 40, 250, 1, 0, 0, + InitialPos, 250, 1, 0, 0, 0, 0, 0, 0, 0, } @@ -404,14 +406,14 @@ func (t *Trigger) ApplyLockTrigger() { lg.TimeLimit = 0 } -func (t *Trigger) ApplyVibrationTrigger() { +func (t *Trigger) ApplyVibrationTrigger(Coefficient int32, Threshold int32, TravelRange int32, Frequency int32) { t.Type = 0 t.AutoTrigger.Mode = 5 t.AutoTrigger.VibrationBind.Type = 2 - t.AutoTrigger.VibrationBind.MinFilter = 10 - t.AutoTrigger.VibrationBind.Scale = 50 + t.AutoTrigger.VibrationBind.Scale = Coefficient + t.AutoTrigger.VibrationBind.MinFilter = Threshold t.AutoTrigger.VibrationBind.TriggerParams = - []int32{1, 1, 1, 90, 0} + []int32{TravelRange, 1, 1, Frequency, 0} t.AutoTrigger.MixedBorder = 0 t.AutoTrigger.MixedParams = []int32{ From 3106f4912489abe13db6588e9ced5b0fecc10b0f Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sat, 24 Jan 2026 16:25:16 -0300 Subject: [PATCH 4/7] added device validation for triggers adjust valid device Ids --- pkg/commands/info.go | 2 +- pkg/commands/trigger.go | 130 +++++++++++++++++++++++++++++----------- 2 files changed, 95 insertions(+), 37 deletions(-) diff --git a/pkg/commands/info.go b/pkg/commands/info.go index b676e31..10bd3d9 100644 --- a/pkg/commands/info.go +++ b/pkg/commands/info.go @@ -24,7 +24,7 @@ var gamepadNames = map[int32]string{ 81: "Vader 3 Pro ONE PIECE", 82: "Direwolf 2", 83: "fp2ip", - 84: "k2", + 84: "Apex 4", 85: "Vader 4", } diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go index 6d5b962..b99ffb0 100644 --- a/pkg/commands/trigger.go +++ b/pkg/commands/trigger.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "slices" "github.com/pipe01/flydigictl/pkg/dbus/pb" "github.com/spf13/cobra" @@ -16,21 +17,8 @@ const ( triggerRight triggerSide = "right" ) -func (s triggerSide) GetBean(b *pb.GamepadConfiguration) *pb.TriggerConfiguration { - switch s { - case triggerLeft: - return b.LeftTrigger - case triggerRight: - return b.RightTrigger - } - panic("invalid trigger side") -} - -var triggerCommand = &cobra.Command{ - Use: "trigger", - Short: "Configure triggers (Apex 4)", -} var showDetails bool +var skipValidation bool var raceOptions struct { InitialPos int @@ -62,10 +50,48 @@ var vibrationOptions struct { Frequency int } +func (s triggerSide) GetBean(b *pb.GamepadConfiguration) *pb.TriggerConfiguration { + switch s { + case triggerLeft: + return b.LeftTrigger + case triggerRight: + return b.RightTrigger + } + panic("invalid trigger side") +} + +func ValidateTrigger(cmd *cobra.Command, args []string) error { + validIds := []int32{84} + + if skipValidation { + return nil + } + + return useConnection(func() error { + info, err := dbusClient.GetDeviceInfo() + + if err != nil { + return fmt.Errorf("get device info: %w", err) + } + + if slices.Contains(validIds, info.DeviceId) == false { + return fmt.Errorf("Trigger not supported for this device") + } + + return nil + }) +} + +var triggerCommand = &cobra.Command{ + Use: "trigger", + Short: "Configure triggers (Apex 4)", +} + func genTriggerCommand(side triggerSide) *cobra.Command { cmd := &cobra.Command{ - Use: string(side), - Short: fmt.Sprintf("Manage %s trigger configuration", side), + Use: string(side), + Short: fmt.Sprintf("Manage %s trigger configuration", side), + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { cfg, err := readConfiguration(func(conf *pb.GamepadConfiguration) *pb.TriggerConfiguration { return side.GetBean(conf) @@ -75,6 +101,14 @@ func genTriggerCommand(side triggerSide) *cobra.Command { } switch mode := cfg.Mode.(type) { + case *pb.TriggerConfiguration_Default: + if terseOutput { + fmt.Print("default") + return nil + } + + fmt.Printf("%s trigger mode: Default\n", cases.Title(language.English, cases.NoLower).String(string(side))) + case *pb.TriggerConfiguration_Race: if terseOutput { @@ -82,7 +116,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { return nil } - fmt.Printf("%s trigger mode: Race", side) + fmt.Printf("%s trigger mode: Race\n", cases.Title(language.English, cases.NoLower).String(string(side))) if showDetails { fmt.Printf(" %-22s : %v\n", "Initial position", mode.Race.InitialPos) @@ -94,7 +128,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { return nil } - fmt.Printf("%s trigger mode: Race\n", cases.Title(language.English, cases.NoLower).String(string(side))) + fmt.Printf("%s trigger mode: Recoil\n", cases.Title(language.English, cases.NoLower).String(string(side))) if showDetails { fmt.Printf(" %-22s : %v\n", "Initial position", mode.Recoil.InitialPos) fmt.Printf(" %-22s : %v\n", "Initial strength", mode.Recoil.InitialStrength) @@ -135,6 +169,12 @@ func genTriggerCommand(side triggerSide) *cobra.Command { fmt.Printf(" %-22s : %v\n", "Travel range", mode.Vibration.TravelRange) fmt.Printf(" %-22s : %v\n", "Frequency", mode.Vibration.Frequency) } + default: + if terseOutput { + fmt.Println("unknown") + return nil + } + fmt.Printf("%s trigger mode: Unknown\n", cases.Title(language.English, cases.NoLower).String(string(side))) } return nil @@ -142,9 +182,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { } cmd.AddCommand(&cobra.Command{ - Use: "default", - Short: "Set this trigger to default mode", - Args: cobra.NoArgs, + Use: "default", + Short: "Set this trigger to default mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { return modifyConfiguration(func(conf *pb.GamepadConfiguration) { cfg := side.GetBean(conf) @@ -154,9 +195,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { }) raceCmd := &cobra.Command{ - Use: "race", - Short: "Set this trigger to race mode", - Args: cobra.NoArgs, + Use: "race", + Short: "Set this trigger to race mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { if raceOptions.InitialPos < 0 || raceOptions.InitialPos > 192 { return fmt.Errorf("initial-pos must be between 0 and 192") @@ -191,9 +233,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cmd.AddCommand(raceCmd) recoilCmd := &cobra.Command{ - Use: "recoil", - Short: "Set this trigger to recoil mode", - Args: cobra.NoArgs, + Use: "recoil", + Short: "Set this trigger to recoil mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { if recoilOptions.InitialPos < 0 || recoilOptions.InitialPos > 192 { return fmt.Errorf("start-pos must be between 0 and 192") @@ -256,9 +299,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { recoilCmd.Flags().SortFlags = false sniperCmd := &cobra.Command{ - Use: "sniper", - Short: "Set this trigger to sniper mode", - Args: cobra.NoArgs, + Use: "sniper", + Short: "Set this trigger to sniper mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { if sniperOptions.InitialPos < 0 || sniperOptions.InitialPos > 192 { return fmt.Errorf("initial-pos must be between 0 and 192") @@ -311,9 +355,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cmd.AddCommand(sniperCmd) lockCmd := &cobra.Command{ - Use: "lock", - Short: "Set this trigger to lock mode", - Args: cobra.NoArgs, + Use: "lock", + Short: "Set this trigger to lock mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { if lockOptions.InitialPos < 0 || lockOptions.InitialPos > 192 { return fmt.Errorf("initial-pos must be between 0 and 192") @@ -338,9 +383,10 @@ func genTriggerCommand(side triggerSide) *cobra.Command { cmd.AddCommand(lockCmd) vibrationCmd := &cobra.Command{ - Use: "vibration", - Short: "Set this trigger to vibration mode", - Args: cobra.NoArgs, + Use: "vibration", + Short: "Set this trigger to vibration mode", + Args: cobra.NoArgs, + PreRunE: ValidateTrigger, RunE: func(cmd *cobra.Command, args []string) error { if vibrationOptions.Coefficient < 0 || vibrationOptions.Coefficient > 200 { return fmt.Errorf("intensity must be between 0 and 200") @@ -414,6 +460,18 @@ func init() { false, "Show detailed trigger configuration", ) + triggerLeftCommand.PersistentFlags().BoolVar( + &skipValidation, + "dangerous-skip", + false, + "Skips the trigger device validation. Only use it if you are sure the device has adaptive triggers", + ) + triggerRightCommand.PersistentFlags().BoolVar( + &skipValidation, + "dangerous-skip", + false, + "Skips the trigger device validation. Only use it if you are sure the device has adaptive triggers", + ) triggerCommand.AddCommand(triggerLeftCommand) triggerCommand.AddCommand(triggerRightCommand) From f9f3a4cd148785bf5a8247662d7bfaadd43dcd52 Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sun, 25 Jan 2026 00:51:50 -0300 Subject: [PATCH 5/7] adjust trigger validation --- pkg/commands/trigger.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go index b99ffb0..096b232 100644 --- a/pkg/commands/trigger.go +++ b/pkg/commands/trigger.go @@ -67,7 +67,10 @@ func ValidateTrigger(cmd *cobra.Command, args []string) error { return nil } - return useConnection(func() error { + var startPersist = persistConnection + + var response = useConnection(func() error { + persistConnection = true info, err := dbusClient.GetDeviceInfo() if err != nil { @@ -80,6 +83,8 @@ func ValidateTrigger(cmd *cobra.Command, args []string) error { return nil }) + persistConnection = startPersist + return response } var triggerCommand = &cobra.Command{ From 74601ea6ef1d4e48bf53670a6eb0bfeac111d1fe Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Sun, 25 Jan 2026 20:18:34 -0300 Subject: [PATCH 6/7] added apex 4 battery info adjust apex 4 battery info adjust apex 4 battery info fix mistake final adjusts --- pkg/commands/trigger.go | 12 ++++++------ pkg/flydigi/gamepad.go | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pkg/commands/trigger.go b/pkg/commands/trigger.go index 096b232..0c4100e 100644 --- a/pkg/commands/trigger.go +++ b/pkg/commands/trigger.go @@ -298,7 +298,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { &recoilOptions.InputAfter, "input-after", true, - "Only triggers the input after the start position", + "Only triggers the input after start position", ) cmd.AddCommand(recoilCmd) recoilCmd.Flags().SortFlags = false @@ -342,7 +342,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { &sniperOptions.Length, "length", 30, - "trigger length (1–255)", + "Trigger length (1–255)", ) sniperCmd.Flags().IntVar( &sniperOptions.Pressure, @@ -354,7 +354,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { &sniperOptions.InputAfter, "input-after", true, - "Only triggers the input after the start position", + "Only triggers the input after start position", ) sniperCmd.Flags().SortFlags = false cmd.AddCommand(sniperCmd) @@ -382,7 +382,7 @@ func genTriggerCommand(side triggerSide) *cobra.Command { &lockOptions.InitialPos, "initial-pos", 40, - "Initial trigger position (0–192)", + "Lock start position (0–192)", ) lockCmd.Flags().SortFlags = false cmd.AddCommand(lockCmd) @@ -423,13 +423,13 @@ func genTriggerCommand(side triggerSide) *cobra.Command { &vibrationOptions.Coefficient, "intensity", 50, - "Intensity of the trigger (0–200)", + "Vibration intensity (0–200)", ) vibrationCmd.Flags().IntVar( &vibrationOptions.Threshold, "threshold", 10, - "Vibration threshold (1–255). Below this value, the trigger will not vibrate.", + "Vibration threshold, below this value no vibration occurs (1–255)", ) vibrationCmd.Flags().IntVar( &vibrationOptions.TravelRange, diff --git a/pkg/flydigi/gamepad.go b/pkg/flydigi/gamepad.go index 7ac6333..8c884be 100644 --- a/pkg/flydigi/gamepad.go +++ b/pkg/flydigi/gamepad.go @@ -189,8 +189,13 @@ func (g *Gamepad) handleDeviceInfo(msg protocol.MessageGamePadInfo) error { devInfo.FirmwareVersion = fmt.Sprintf("%d.%d.%d.%d", fw_h_2, fw_h, fw_l_2, fw_l) battery := msg.Battery - const apex2MinBY = 98 - const apex2MaxBY = 114 + var apex2MinBY byte = 98 + var apex2MaxBY byte = 114 + + if devInfo.DeviceId == 84 { + apex2MinBY = 0 + apex2MaxBY = 4 + } if battery < apex2MinBY { battery = apex2MinBY @@ -199,6 +204,24 @@ func (g *Gamepad) handleDeviceInfo(msg protocol.MessageGamePadInfo) error { } batteryPercent := int(100 * float32(battery-apex2MinBY) / float32(apex2MaxBY-apex2MinBY)) + + if devInfo.DeviceId == 84 { + switch battery { + case 0: + batteryPercent = 15 + case 1: + batteryPercent = 25 + case 2: + batteryPercent = 50 + case 3: + batteryPercent = 75 + case 4: + batteryPercent = 100 + default: + batteryPercent = 100 + } + } + devInfo.BatteryPercent = int32(batteryPercent) switch msg.MotionSensorType { From 9ef39d9c6b5a5894ec85f4150b389674ec46c74f Mon Sep 17 00:00:00 2001 From: Rezendeveloper Date: Wed, 28 Jan 2026 12:54:59 -0300 Subject: [PATCH 7/7] added fallback for xpad load --- pkg/flydigi/protocol/xinput/xinput.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/flydigi/protocol/xinput/xinput.go b/pkg/flydigi/protocol/xinput/xinput.go index 3c3ad20..70f5a19 100644 --- a/pkg/flydigi/protocol/xinput/xinput.go +++ b/pkg/flydigi/protocol/xinput/xinput.go @@ -3,6 +3,8 @@ package xinput import ( "fmt" "io" + "os" + "os/exec" "sync/atomic" "time" @@ -117,7 +119,17 @@ func (d *protocolXInput) Close() error { err = modprobe.Load("xpad", "") if err != nil { - log.Err(err).Msg("failed to load xpad module") + log.Debug().Msg("failed to load xpad module with package, trying exec") + cmd := exec.Command("modprobe", "xpad") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err = cmd.Run() + + if err != nil { + log.Err(err).Msg("failed to load xpad with exec") + } else { + log.Debug().Msg("xpad loaded") + } } }