Documentation
¶
Overview ¶
SPDX-FileCopyrightText: 2025 Peter Magnusson <me@kmpm.se>
SPDX-License-Identifier: BSD-3-Clause
SPDX-FileCopyrightText: 2020-2021 Nirenjan Krishnan
SPDX-License-Identifier: BSD-3-Clause
SPDX-FileCopyrightText: 2020-2021 Nirenjan Krishnan SPDX-FileCopyrightText: 2025 Peter Magnusson
SPDX-License-Identifier: BSD-3-Clause
SPDX-FileCopyrightText: 2020-2021 Nirenjan Krishnan SPDX-FileCopyrightText: 2025 Peter Magnusson
SPDX-License-Identifier: BSD-3-Clause
SPDX-FileCopyrightText: 2025 Peter Magnusson
SPDX-License-Identifier: BSD-3-Clause
SPDX-FileCopyrightText: 2020-2021 Nirenjan Krishnan SPDX-FileCopyrightText: 2025 Peter Magnusson
SPDX-License-Identifier: BSD-3-Clause
Index ¶
- Constants
- Variables
- type Action
- type Button
- type ClockFormat
- type ClockID
- type Context
- func (ctx *Context) Close() error
- func (ctx *Context) Debug(level LogLevel)
- func (ctx *Context) DebugUSB(level LogLevel)
- func (ctx *Context) Do() Action
- func (ctx *Context) HasFeature(feature uint32) bool
- func (ctx *Context) Open() bool
- func (ctx *Context) Raw(index, value uint16) error
- func (ctx *Context) ReadInput(cctx context.Context, cb func(r *Report)) error
- func (ctx *Context) Reset() error
- func (ctx *Context) SetBlink(enable bool) error
- func (ctx *Context) SetClockFormat(clock ClockID, format ClockFormat) error
- func (ctx *Context) SetDateFormat(format DateFormat) error
- func (ctx *Context) SetLed(led Led, state LedState) error
- func (ctx *Context) SetLedBrightness(brightness uint16) error
- func (ctx *Context) SetLocation(clock ClockID, loc *time.Location) error
- func (ctx *Context) SetMfdBrightness(brightness uint16) error
- func (ctx *Context) SetMfdText(line uint8, data []byte) error
- func (ctx *Context) SetShift(enable bool) error
- func (ctx *Context) SetTime(t time.Time) error
- func (ctx *Context) Update() error
- type DateFormat
- type Led
- type LedState
- type LogLevel
- type Report
- type TextAlignment
Constants ¶
const ( LedFire = Led(0x01) LedA = Led(0x02) LedB = Led(0x04) LedD = Led(0x06) LedE = Led(0x08) LedT1 = Led(0x0a) LedT2 = Led(0x0c) LedT3 = Led(0x0e) LedPOV = Led(0x10) LedClutch = Led(0x12) LedThrottle = Led(0x14) )
LED Identifiers
const (
FeatureLed uint32 = iota
)
Feature flags
Variables ¶
var ErrInvalidAlignment = errors.New("invalid alignment")
var ErrInvalidLine = errors.New("invalid line")
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
SetMfdBrightness(v uint16) Action
SetMfdText(line uint8, s string) Action
SetMfdTextAlign(line uint8, s string, align TextAlignment) Action
SetMfdShift(state bool) Action
SetLed(led Led, state LedState) Action
SetLedBrightness(v uint16) Action
Execute() error
}
Action represents chainable actions to be executed on a Saitek X52 Pro joystick. Always call Execute() to execute the actions.
type Button ¶
type Button int
Button definitions
const ( BtnTrigger Button = iota BtnTrigger2 BtnFire BtnPinky BtnA BtnB BtnC BtnD BtnE BtnT1Up BtnT1Dn BtnT2Up BtnT2Dn BtnT3Up BtnT3Dn BtnPOV1N // Stick POV North BtnPOV1E // Stick POV East BtnPOV1S // Stick POV South BtnPOV1W // Stick POV West BtnPOV2N // Throttle POV North BtnPOV2E // Throttle POV East BtnPOV2S // Throttle POV South BtnPOV2W // Throttle POV West BtnClutch BtnMousePrimary BtnMouseSecondary BtnMouseScrollUp BtnMouseScrollDn BtnFunction BtnStartStop BtnReset BtnPgUp // X52 Pro only BtnPgDn // X52 Pro only BtnUp // X52 Pro only BtnDn // X52 Pro only BtnSelect // X52 Pro only BtnMode1 BtnMode2 BtnMode3 ButtonMax )
type ClockFormat ¶
type ClockFormat uint
ClockFormat describes the time format on the MFD
const ( ClockFormat12Hr ClockFormat = iota ClockFormat24Hr )
Clock Format Identifiers
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context manages all resources related to device handling
func NewContext ¶
func NewContext() *Context
NewContext returns a new Connection against which to run device operations
func (*Context) Close ¶
Close closes the connection, and any devices that may have been opened will also be closed
func (*Context) Debug ¶
Debug changes the debug level. Level 0 means no debug, higher levels will print out more debugging information.
func (*Context) DebugUSB ¶
DebugUSB changes the debug level of the USB subsystem. Level 0 means no debug, higher levels will print out more debugging information.
func (*Context) HasFeature ¶
HasFeature returns true if the X52 device supports the requested feature
func (*Context) Open ¶
Open will try to connect to a supported X52/X52Pro joystick. If the joystick is plugged in and the function succeeds, it returns true, otherwise it returns false. If multiple supported devices are plugged in, then it will pick one of the supported devices in an unspecified manner.
func (*Context) Reset ¶
Reset resets the connected device. If there is no device connected, it returns errNotConnected, otherwise it will return a corresponding USB error
func (*Context) SetClockFormat ¶
func (ctx *Context) SetClockFormat(clock ClockID, format ClockFormat) error
SetClockFormat sets the clock format of the given clock
func (*Context) SetDateFormat ¶
func (ctx *Context) SetDateFormat(format DateFormat) error
SetDateFormat sets the date format
func (*Context) SetLed ¶
SetLed sets the state of the given LED. Not all LEDs support all states, LedFire and LedThrottle only support LedOn and LedOff states, the remaining LEDs support every state except LedOn. **Limitation**: This function will not work on a non-pro X52 at this time.
func (*Context) SetLedBrightness ¶
SetLedBrightness will set the brightness of the LED.
func (*Context) SetLocation ¶
SetLocation updates the location of the given clock. You may not update the location of the primary clock, as it is computed when you call SetTime
func (*Context) SetMfdBrightness ¶
SetMfdBrightness will set the brightness of the MFD.
func (*Context) SetMfdText ¶
SetMfdText sets the display on the given MFD line. The data must be in the code page recognized by the MFD. This function only accepts line lengths of up to 16 bytes, with any additional data being silently discarded.
type DateFormat ¶
type DateFormat uint
DateFormat describes the date format on the MFD
const ( DateFormatDDMMYY DateFormat = iota DateFormatMMDDYY DateFormatYYMMDD )
Date Format Identifiers
type LedState ¶
type LedState uint
LedState contains the possible LED states. Each LED only supports a subset of the states
type Report ¶
type Report struct {
// Axes
X uint16
Y uint16
Rz uint16 // Twist
Throttle uint8
Rx uint8 // Rotary X, Around I button
Ry uint8 // Rotary Y, Around E button
Slider uint8
// Buttons (39 bits for Pro, 34 for regular)
Buttons uint64
// Hat and thumbstick
Hat uint8
MouseX uint8
MouseY uint8
IsPro bool
}
func (*Report) ParseButtons ¶
type TextAlignment ¶
type TextAlignment int
const ( AlignLeft TextAlignment = iota AlignCenter AlignRight )