Documentation
¶
Index ¶
- Constants
- Variables
- func AccelMS2ToRaw(ms2 float64) int16
- func AccelRawToMS2(raw int16) float64
- func DefaultAccelRaw() (x, y, z int16)
- func GyroDpsToRaw(dps float64) int16
- func GyroRawToDps(raw int16) float64
- type DualSense
- func (d *DualSense) GetDescriptor() *usb.Descriptor
- func (d *DualSense) GetDeviceSpecificArgs() map[string]any
- func (d *DualSense) HandleControl(bmRequestType, bRequest uint8, wValue, wIndex, wLength uint16, data []byte) ([]byte, bool)
- func (d *DualSense) HandleTransfer(ep uint32, dir uint32, out []byte) []byte
- func (d *DualSense) SetMetaState(meta MetaState)
- func (d *DualSense) SetOutputCallback(f func(OutputState))
- func (d *DualSense) UpdateInputState(state *InputState)
- type InputState
- type MetaState
- type OutputState
Constants ¶
View Source
const ( DefaultVID = 0x054C DefaultPIDDSEdge = 0x0DF2 DefaultPIDDS = 0x0CE6 )
View Source
const ( DefaultMACAddressDSEdge = "A5:FE:9C:CF:92:00" // Steam reads this as serial? // TODO: not detected by all apps DefaultSerialNumberDSEdge = "E55E00GTD1190A500" // Byte 6 (00) is "color code" will be replaced by MetaState DefaultBoardStringEdge = "HMB-010" )
View Source
const ( DefaultMACAddressDS = "A5:FA:9C:CF:92:00" // Steam reads this as serial? // TODO: not detected by all apps DefaultSerialNumberDS = "E55700GTD1190A500" // Byte 6 (00) is "color code" will be replaced by MetaState DefaultBoardStringDS = "BDM-050" )
View Source
const ( DefaultBatteryStatus = BatteryFullyCharged DefaultTemperature = 28.0 DefaultVoltage = 3.8 DefaultShellColor = ShellColorBlack )
View Source
const ( EndpointIn = 0x84 EndpointOut = 0x03 )
View Source
const ( ReportIDInput = 0x01 ReportIDOutput = 0x02 )
View Source
const ( InputReportSize = 64 OutputReportSize = 64 InputStateSize = 33 OutputStateSize = 6 )
View Source
const ( ButtonSquare uint32 = 0x0010 ButtonCross uint32 = 0x0020 ButtonCircle uint32 = 0x0040 ButtonTriangle uint32 = 0x0080 ButtonL1 uint32 = 0x0100 ButtonR1 uint32 = 0x0200 ButtonL2 uint32 = 0x0400 ButtonR2 uint32 = 0x0800 ButtonCreate uint32 = 0x1000 ButtonOptions uint32 = 0x2000 ButtonL3 uint32 = 0x4000 ButtonR3 uint32 = 0x8000 ButtonPS uint32 = 0x00010000 ButtonTouchpad uint32 = 0x00020000 ButtonMicMute uint32 = 0x00040000 ButtonEdgeLFn uint32 = 0x00100000 ButtonEdgeRFn uint32 = 0x00200000 ButtonEdgeL4 uint32 = 0x00400000 ButtonEdgeR4 uint32 = 0x00800000 )
View Source
const ( DPadUp = 0x01 DPadDown = 0x02 DPadLeft = 0x04 DPadRight = 0x08 )
View Source
const ( DPadUSBUp = 0x00 DPadUSBUpRight = 0x01 DPadUSBRight = 0x02 DPadUSBDownRight = 0x03 DPadUSBDown = 0x04 DPadUSBDownLeft = 0x05 DPadUSBLeft = 0x06 DPadUSBUpLeft = 0x07 DPadUSBNeutral = 0x08 )
View Source
const ( GyroCountsPerDps = 16.384 AccelCountsPerMS2 = 835.07 // 8192 / 9.81 )
Gyro/Accel scale factors matching the USB report domain.
Gyro: BMI323 ±2000 dps passthrough = 16.384 LSB/dps Accel: BMI323 4096 LSB/g × ScaleAccel(×2) = 8192 LSB/g = 835.07 LSB/(m/s²)
View Source
const ( DefaultAccelXRaw int16 = 0 DefaultAccelYRaw int16 = 0 DefaultAccelZRaw int16 = -8192 // -1g (8192 counts/g) )
View Source
const ( TouchpadMinX uint16 = 0 TouchpadMinY uint16 = 0 TouchpadMaxX uint16 = 1920 TouchpadMaxY uint16 = 1080 TouchInactiveMask uint8 = 0x80 )
Touchpad dimensions.
View Source
const ( HardwareType uint8 = 0x03 HwInfo uint32 = 0x01000208 FirmwareVersion uint16 = 0x0630 )
View Source
const ( ShellColorWhite = "00" ShellColorBlack = "01" ShellColorCosmicRed = "02" ShellColorNovaPink = "03" ShellColorGalacticPurple = "04" ShellColorStarlightBlue = "05" ShellColorGreyCamouflage = "06" ShellColorVolcanicRed = "07" ShellColorSterlingSilver = "08" ShellColorCobaltBlue = "09" ShellColorChromaTeal = "10" ShellColorChromaIndigo = "11" ShellColorChromaPearl = "12" ShellColorAnniversary30th = "30" ShellColorGodOfWarRagnarok = "Z1" ShellColorSpiderMan2 = "Z2" ShellColorAstroBot = "Z3" ShellColorFortnite = "Z4" ShellColorMonsterHunterWilds = "Z5" ShellColorTheLastOfUs = "Z6" ShellColorGhostOfYotei = "Z7" ShellColorIconBlueLimitedEdition = "ZB" ShellColorAstroBotJoyfulEdition = "ZC" ShellColorGenshinImpact = "ZE" )
View Source
const (
BatteryFullyCharged = 0x2A // Status=0x2 (Full), Level=0xA (100%)
)
View Source
const DPadMask uint8 = 0x0F
View Source
const DeltaTimeNS = 333
Variables ¶
Functions ¶
func AccelMS2ToRaw ¶
func AccelRawToMS2 ¶
func DefaultAccelRaw ¶
func DefaultAccelRaw() (x, y, z int16)
func GyroDpsToRaw ¶
func GyroRawToDps ¶
Types ¶
type DualSense ¶
type DualSense struct {
// contains filtered or unexported fields
}
func (*DualSense) GetDescriptor ¶
func (d *DualSense) GetDescriptor() *usb.Descriptor
func (*DualSense) GetDeviceSpecificArgs ¶
func (*DualSense) HandleControl ¶
func (*DualSense) HandleTransfer ¶
func (*DualSense) SetMetaState ¶
func (*DualSense) SetOutputCallback ¶
func (d *DualSense) SetOutputCallback(f func(OutputState))
func (*DualSense) UpdateInputState ¶
func (d *DualSense) UpdateInputState(state *InputState)
type InputState ¶
type InputState struct {
LX, LY int8
RX, RY int8
Buttons uint32
DPad uint8
L2, R2 uint8
Touch1X, Touch1Y uint16
Touch1Active bool
Touch2X, Touch2Y uint16
Touch2Active bool
GyroX, GyroY, GyroZ int16
AccelX, AccelY, AccelZ int16
}
nolint viiper:wire dualsense c2s stickLX:i8 stickLY:i8 stickRX:i8 stickRY:i8 buttons:u32 dpad:u8 triggerL2:u8 triggerR2:u8 touch1X:u16 touch1Y:u16 touch1Active:bool touch2X:u16 touch2Y:u16 touch2Active:bool gyroX:i16 gyroY:i16 gyroZ:i16 accelX:i16 accelY:i16 accelZ:i16
func (*InputState) MarshalBinary ¶
func (s *InputState) MarshalBinary() ([]byte, error)
func (*InputState) UnmarshalBinary ¶
func (s *InputState) UnmarshalBinary(data []byte) error
type MetaState ¶
type MetaState struct {
SerialNumber string `json:"serial_number"`
MACAddress string `json:"mac_address"` // "XX:XX:XX:XX:XX:XX"
Board string `json:"board"`
BuildTime time.Time `json:"build_time"`
BatteryStatus uint8 `json:"battery_status"`
TemperatureCelsius float64 `json:"temperature_celsius"`
BatteryVoltage float64 `json:"battery_voltage"`
ShellColor string `json:"shell_color"` // hardware variant / controller color code, e.g. "00", "Z1"
}
func (*MetaState) UpdateFromMap ¶
type OutputState ¶
type OutputState struct {
RumbleSmall uint8
RumbleLarge uint8
LedRed uint8
LedGreen uint8
LedBlue uint8
PlayerLeds uint8
}
nolint viiper:wire dualsense s2c rumbleSmall:u8 rumbleLarge:u8 ledRed:u8 ledGreen:u8 ledBlue:u8 playerLeds:u8
func (*OutputState) MarshalBinary ¶
func (f *OutputState) MarshalBinary() ([]byte, error)
func (*OutputState) UnmarshalBinary ¶
func (f *OutputState) UnmarshalBinary(data []byte) error
Click to show internal directories.
Click to hide internal directories.