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/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..0c4100e --- /dev/null +++ b/pkg/commands/trigger.go @@ -0,0 +1,485 @@ +package commands + +import ( + "fmt" + "slices" + + "github.com/pipe01/flydigictl/pkg/dbus/pb" + "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type triggerSide string + +const ( + triggerLeft triggerSide = "left" + triggerRight triggerSide = "right" +) + +var showDetails bool +var skipValidation bool + +var raceOptions struct { + InitialPos int + Pressure int +} +var recoilOptions struct { + InitialPos int + InitialStrength int + Intensity int + Frequency int + InputAfter bool +} + +var sniperOptions struct { + InitialPos int + Length int + Pressure int + InputAfter bool +} + +var lockOptions struct { + InitialPos int +} + +var vibrationOptions struct { + Coefficient int + Threshold int + TravelRange int + 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 + } + + var startPersist = persistConnection + + var response = useConnection(func() error { + persistConnection = true + 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 + }) + persistConnection = startPersist + return response +} + +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), + PreRunE: ValidateTrigger, + RunE: func(cmd *cobra.Command, args []string) error { + cfg, err := readConfiguration(func(conf *pb.GamepadConfiguration) *pb.TriggerConfiguration { + return side.GetBean(conf) + }) + if err != nil { + return fmt.Errorf("get configuration: %w", err) + } + + 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 { + fmt.Print("race") + 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.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: 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) + 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) + } + 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 + }, + } + + cmd.AddCommand(&cobra.Command{ + 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) + cfg.Mode = &pb.TriggerConfiguration_Default{} + }) + }, + }) + + raceCmd := &cobra.Command{ + 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") + } + 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.Mode = &pb.TriggerConfiguration_Race{ + Race: &pb.TriggerRace{ + InitialPos: int32(raceOptions.InitialPos), + Pressure: int32(raceOptions.Pressure), + }, + } + }) + }, + } + 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, + 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") + } + 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.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, + }, + } + }) + }, + } + 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 start position", + ) + cmd.AddCommand(recoilCmd) + recoilCmd.Flags().SortFlags = false + + sniperCmd := &cobra.Command{ + 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") + } + 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.Mode = &pb.TriggerConfiguration_Sniper{ + Sniper: &pb.TriggerSniper{ + InitialPos: int32(sniperOptions.InitialPos), + Length: int32(sniperOptions.Length), + Pressure: int32(sniperOptions.Pressure), + InputAfter: sniperOptions.InputAfter, + }, + } + }) + }, + } + 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 start position", + ) + sniperCmd.Flags().SortFlags = false + cmd.AddCommand(sniperCmd) + + lockCmd := &cobra.Command{ + 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") + } + return modifyConfiguration(func(conf *pb.GamepadConfiguration) { + cfg := side.GetBean(conf) + cfg.Mode = &pb.TriggerConfiguration_Lock{ + Lock: &pb.TriggerLock{ + InitialPos: int32(lockOptions.InitialPos), + }, + } + }) + }, + } + lockCmd.Flags().IntVar( + &lockOptions.InitialPos, + "initial-pos", + 40, + "Lock start 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, + 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") + } + if vibrationOptions.Threshold < 1 || vibrationOptions.Threshold > 255 { + return fmt.Errorf("threshold must be between 1 and 255") + } + 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) + cfg.Mode = &pb.TriggerConfiguration_Vibration{ + Vibration: &pb.TriggerVibration{ + Coefficient: int32(vibrationOptions.Coefficient), + Threshold: int32(vibrationOptions.Threshold), + TravelRange: int32(vibrationOptions.TravelRange), + Frequency: int32(vibrationOptions.Frequency), + }, + } + }) + }, + } + vibrationCmd.Flags().IntVar( + &vibrationOptions.Coefficient, + "intensity", + 50, + "Vibration intensity (0–200)", + ) + vibrationCmd.Flags().IntVar( + &vibrationOptions.Threshold, + "threshold", + 10, + "Vibration threshold, below this value no vibration occurs (1–255)", + ) + 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 +} + +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", + ) + 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) + + rootCmd.AddCommand(triggerCommand) +} diff --git a/pkg/dbus/pb/convert.go b/pkg/dbus/pb/convert.go index b1accc8..9bcb220 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,89 @@ func (c *JoystickConfiguration) ApplyTo(bean *config.JoyStickBean) { bean.Curve.Zero = c.Deadzone } +func ConvertTriggerConfiguration(bean *config.Trigger) *TriggerConfiguration { + 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, + }, + } + 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, + }, + } + 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, + } +} + +func (c *TriggerConfiguration) ApplyTo(bean *config.Trigger) { + if bean == nil { + return + } + + 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) + } +} + func ConvertLEDConfiguration(bean *config.NewLedConfigBean) *LedsConfiguration { var leds isLedsConfiguration_Leds @@ -89,6 +176,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 +222,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..3135067 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,507 @@ func (x *JoystickConfiguration) GetDeadzone() int32 { return 0 } -type LedsOff struct { - state protoimpl.MessageState +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 *TriggerConfiguration) Reset() { + *x = TriggerConfiguration{} + mi := &file_flydigi_proto_msgTypes[3] + 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[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 TriggerConfiguration.ProtoReflect.Descriptor instead. +func (*TriggerConfiguration) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{3} +} + +func (x *TriggerConfiguration) GetMode() isTriggerConfiguration_Mode { + if x != nil { + return x.Mode + } + return nil +} + +func (x *TriggerConfiguration) GetDefault() *TriggerDefault { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Default); ok { + return x.Default + } + } + return nil +} + +func (x *TriggerConfiguration) GetRace() *TriggerRace { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Race); ok { + return x.Race + } + } + return nil +} + +func (x *TriggerConfiguration) GetRecoil() *TriggerRecoil { + if x != nil { + if x, ok := x.Mode.(*TriggerConfiguration_Recoil); ok { + return x.Recoil + } + } + return nil +} + +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"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *LedsOff) Reset() { - *x = LedsOff{} - if protoimpl.UnsafeEnabled { - mi := &file_flydigi_proto_msgTypes[3] +func (x *TriggerDefault) Reset() { + *x = TriggerDefault{} + mi := &file_flydigi_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerDefault) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerDefault) ProtoMessage() {} + +func (x *TriggerDefault) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[4] + 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 TriggerDefault.ProtoReflect.Descriptor instead. +func (*TriggerDefault) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{4} +} + +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 { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// 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.InitialPos + } + return 0 +} + +func (x *TriggerRace) GetPressure() int32 { + if x != nil { + return x.Pressure + } + return 0 +} + +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 *TriggerRecoil) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerRecoil) ProtoMessage() {} + +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 { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerRecoil.ProtoReflect.Descriptor instead. +func (*TriggerRecoil) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{6} +} + +func (x *TriggerRecoil) GetInitialPos() int32 { + if x != nil { + return x.InitialPos + } + return 0 +} + +func (x *TriggerRecoil) GetInitialStrength() int32 { + if x != nil { + return x.InitialStrength + } + return 0 +} + +func (x *TriggerRecoil) GetIntensity() int32 { + if x != nil { + return x.Intensity + } + return 0 +} + +func (x *TriggerRecoil) GetFrequency() int32 { + if x != nil { + return x.Frequency + } + return 0 +} + +func (x *TriggerRecoil) GetInputAfter() bool { + if x != nil { + return x.InputAfter + } + return false +} + +type TriggerSniper struct { + state protoimpl.MessageState `protogen:"open.v1"` + 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 *TriggerSniper) Reset() { + *x = TriggerSniper{} + mi := &file_flydigi_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerSniper) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerSniper) ProtoMessage() {} + +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 { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerSniper.ProtoReflect.Descriptor instead. +func (*TriggerSniper) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{7} +} + +func (x *TriggerSniper) GetInitialPos() int32 { + if x != nil { + return x.InitialPos + } + return 0 +} + +func (x *TriggerSniper) GetLength() int32 { + if x != nil { + return x.Length + } + return 0 +} + +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"` + InitialPos int32 `protobuf:"varint,1,opt,name=initialPos,proto3" json:"initialPos,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerLock) Reset() { + *x = TriggerLock{} + mi := &file_flydigi_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerLock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerLock) ProtoMessage() {} + +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 { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerLock.ProtoReflect.Descriptor instead. +func (*TriggerLock) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{8} +} + +func (x *TriggerLock) GetInitialPos() int32 { + if x != nil { + return x.InitialPos + } + 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 (*TriggerVibration) ProtoMessage() {} + +func (x *TriggerVibration) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[9] + 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 TriggerVibration.ProtoReflect.Descriptor instead. +func (*TriggerVibration) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{9} +} + +func (x *TriggerVibration) GetCoefficient() int32 { + if x != nil { + return x.Coefficient + } + return 0 +} + +func (x *TriggerVibration) GetThreshold() int32 { + if x != nil { + return x.Threshold + } + return 0 +} + +func (x *TriggerVibration) GetTravelRange() int32 { + if x != nil { + return x.TravelRange + } + return 0 +} + +func (x *TriggerVibration) GetFrequency() int32 { + if x != nil { + return x.Frequency + } + 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[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsOff) String() string { @@ -272,8 +768,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[10] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -285,24 +781,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{10} } 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[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsSteady) String() string { @@ -312,8 +805,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[11] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -325,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{4} + return file_flydigi_proto_rawDescGZIP(), []int{11} } func (x *LedsSteady) GetColor() *Color { @@ -336,20 +829,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[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsStreamlined) String() string { @@ -359,8 +849,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[12] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -372,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{5} + return file_flydigi_proto_rawDescGZIP(), []int{12} } func (x *LedsStreamlined) GetSpeed() float32 { @@ -382,27 +872,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[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LedsGradient) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LedsGradient) ProtoMessage() {} + +func (x *LedsGradient) ProtoReflect() protoreflect.Message { + mi := &file_flydigi_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} - Brightness float32 `protobuf:"fixed32,1,opt,name=brightness,proto3" json:"brightness,omitempty"` - // Types that are assignable to Leds: +// Deprecated: Use LedsGradient.ProtoReflect.Descriptor instead. +func (*LedsGradient) Descriptor() ([]byte, []int) { + return file_flydigi_proto_rawDescGZIP(), []int{13} +} + +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[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LedsConfiguration) String() string { @@ -412,8 +952,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[14] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -425,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{6} + return file_flydigi_proto_rawDescGZIP(), []int{14} } func (x *LedsConfiguration) GetBrightness() float32 { @@ -435,30 +975,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 +1034,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[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Color) String() string { @@ -509,8 +1067,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[15] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -522,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{7} + return file_flydigi_proto_rawDescGZIP(), []int{15} } func (x *Color) GetRgb() int32 { @@ -534,103 +1092,147 @@ 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\"\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" + + "\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, 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 - (*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 + (*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 - 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 + 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() } @@ -638,116 +1240,27 @@ 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[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[6].OneofWrappers = []interface{}{ + file_flydigi_proto_msgTypes[14].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: 16, NumExtensions: 0, NumServices: 0, }, @@ -757,7 +1270,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..00b3b3a 100644 --- a/pkg/dbus/pb/flydigi.proto +++ b/pkg/dbus/pb/flydigi.proto @@ -20,12 +20,60 @@ 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 TriggerConfiguration { + oneof mode { + TriggerDefault default = 10; + TriggerRace race = 11; + TriggerRecoil recoil = 12; + TriggerSniper sniper = 13; + TriggerLock lock = 14; + TriggerVibration vibration = 15; + } +} + +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 TriggerSniper { + int32 initialPos = 1; + int32 length = 2; + int32 pressure = 3; + bool inputAfter = 4; +} + +message TriggerLock { + int32 initialPos = 1; +} + +message TriggerVibration { + int32 coefficient = 1; + int32 threshold = 2; + int32 travelRange = 3; + int32 frequency = 4; +} + message LedsOff { } @@ -37,12 +85,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..3f395f3 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,147 @@ 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(initialPos int32, pressure int32) { + 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[0] = int32(initialPos) + t.AutoTrigger.MixedParams[1] = int32(pressure) + + 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) ApplyRecoilTrigger(InitialPos int32, InitialStrength int32, Intensity int32, Frequency int32, OutputFromVibration int32) { + 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{ + InitialPos, InitialStrength, Intensity, Frequency, OutputFromVibration, + 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) ApplySniperTrigger(InitialPos int32, Length int32, Pressure int32, OutputFromVibration int32) { + 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{ + InitialPos, Length, Pressure, 0, OutputFromVibration, + 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(InitialPos int32) { + 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{ + InitialPos, 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(Coefficient int32, Threshold int32, TravelRange int32, Frequency int32) { + t.Type = 0 + t.AutoTrigger.Mode = 5 + t.AutoTrigger.VibrationBind.Type = 2 + t.AutoTrigger.VibrationBind.Scale = Coefficient + t.AutoTrigger.VibrationBind.MinFilter = Threshold + t.AutoTrigger.VibrationBind.TriggerParams = + []int32{TravelRange, 1, 1, Frequency, 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 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 { 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") + } } }