Documentation
¶
Overview ¶
Package ns2pro provides a Nintendo Switch 2 Pro Controller compatible HID device.
Index ¶
- Constants
- func MakeDescriptor() usb.Descriptor
- type InputState
- type MetaState
- type NS2Pro
- func (d *NS2Pro) GetDescriptor() *usb.Descriptor
- func (d *NS2Pro) GetDeviceSpecificArgs() map[string]any
- func (d *NS2Pro) HandleControl(bmRequestType, bRequest uint8, wValue, wIndex uint16, wLength uint16, ...) ([]byte, bool)
- func (d *NS2Pro) HandleTransfer(ep uint32, dir uint32, out []byte) []byte
- func (d *NS2Pro) SetMetaState(meta MetaState)
- func (d *NS2Pro) SetOutputCallback(f func(OutputState)) func()
- func (d *NS2Pro) UpdateInputState(state InputState)
- type OutputState
Constants ¶
View Source
const ( DefaultVID = 0x057E DefaultPID = 0x2069 DefaultSerialEnding = "00" DefaultSerial = "VIIPER-NS2PRO-" + DefaultSerialEnding DefaultBatteryVolts uint16 = 3800 )
View Source
const ( EndpointHIDIn = 0x81 EndpointHIDOut = 0x01 EndpointBulkOut = 0x02 EndpointBulkIn = 0x82 )
View Source
const ( ReportIDCommon = 0x05 ReportIDPro = 0x09 ReportIDOutput = 0x02 )
View Source
const ( InputReportSize = 64 OutputReportSize = 64 InputWireSize = 24 OutputRumbleSize = 32 OutputWireSize = 34 )
View Source
const ( OutputFlagRumble = 0x01 OutputFlagLED = 0x02 )
View Source
const ( StickMin uint16 = 0 StickCenter uint16 = 0x0800 StickMax uint16 = 0x0FFF BatteryMax uint8 = 9 )
View Source
const ( FeatureButtons = 0x01 FeatureSticks = 0x02 FeatureIMU = 0x04 FeatureMouse = 0x10 FeatureRumble = 0x20 )
View Source
const ( ButtonB uint32 = 1 << iota ButtonA ButtonY ButtonX ButtonR ButtonZR ButtonPlus ButtonRightStick ButtonDown ButtonRight ButtonLeft ButtonUp ButtonL ButtonZL ButtonMinus ButtonLeftStick ButtonHome ButtonCapture ButtonGR ButtonGL ButtonC ButtonHeadset )
Variables ¶
This section is empty.
Functions ¶
func MakeDescriptor ¶
func MakeDescriptor() usb.Descriptor
Types ¶
type InputState ¶
type InputState struct {
Buttons uint32
LX, LY uint16
RX, RY uint16
AccelX, AccelY, AccelZ int16
GyroX, GyroY, GyroZ int16
}
nolint viiper:wire ns2pro c2s buttons:u32 lx:u16 ly:u16 rx:u16 ry:u16 accelX:i16 accelY:i16 accelZ:i16 gyroX:i16 gyroY:i16 gyroZ:i16
func (*InputState) MarshalBinary ¶
func (s *InputState) MarshalBinary() ([]byte, error)
func (*InputState) UnmarshalBinary ¶
func (s *InputState) UnmarshalBinary(data []byte) error
type NS2Pro ¶
type NS2Pro struct {
// contains filtered or unexported fields
}
func (*NS2Pro) GetDescriptor ¶
func (d *NS2Pro) GetDescriptor() *usb.Descriptor
func (*NS2Pro) GetDeviceSpecificArgs ¶
func (*NS2Pro) HandleControl ¶
func (*NS2Pro) HandleTransfer ¶
func (*NS2Pro) SetMetaState ¶
func (*NS2Pro) SetOutputCallback ¶
func (d *NS2Pro) SetOutputCallback(f func(OutputState)) func()
func (*NS2Pro) UpdateInputState ¶
func (d *NS2Pro) UpdateInputState(state InputState)
type OutputState ¶
type OutputState struct {
LeftRumble [16]byte
RightRumble [16]byte
Flags uint8
PlayerLedMask uint8
}
nolint viiper:wire ns2pro s2c leftRumble:u8*16 rightRumble:u8*16 flags:u8 playerLedMask:u8
func (*OutputState) MarshalBinary ¶
func (o *OutputState) MarshalBinary() ([]byte, error)
func (*OutputState) UnmarshalBinary ¶
func (o *OutputState) UnmarshalBinary(data []byte) error
Click to show internal directories.
Click to hide internal directories.