irsdk

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 23 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SimStatusUrl       = "http://127.0.0.1:32034/get_sim_status?object=simStatus"
	DataValidEventName = "Local\\IRSDKDataValidEvent"
	BroadcastMsg       = "IRSDK_BROADCASTMSG"
)
View Source
const (
	MemMapFileSize = 1164 * 1024
	MemMapFile     = "Local\\IRSDKMemMapFileName"

	IrsdkMaxBufs   = 3
	IrsdkMaxString = 32
	IrsdkMaxDesc   = 64
)
View Source
const (
	TrackWetnessUnknown = iota
	TrackWetnessDry
	TrackWetnessMostlyDry
	TrackWetnessVeryLightlyWet
	TrackWetnessLightlyWet
	TrackWetnessModeratelyWet
	TrackWetnessVeryWet
	TrackWetnessExtremeWet
)
View Source
const (
	CameraStateIsSessionScreen = 0x0001 // the camera tool can only be activated if viewing the session screen (out of car)
	CameraStateIsScenicActive  = 0x0002 // the scenic camera is active (no focus car)
	// these can be changed with broadcast messages
	CameraStateCamToolActive         = 0x0004
	CameraStateUiHidden              = 0x0008
	CameraStateUseAutoShotSelection  = 0x0010
	CameraStateUseTemporaryEdits     = 0x0020
	CameraStateUseKeyAcceleration    = 0x0040
	CameraStateUseKey10xAcceleration = 0x0080
	CameraStateUseMouseAimMode       = 0x0100
)

Variables

View Source
var (
	ErrInvalidDataRequest = errors.New("Invalid data request")
	ErrNoMatchingDataType = errors.New("requested data type does not match iRacing data type")
	ErrBroadcastError     = errors.New("could not send broadcast message")
)

Functions

func CheckIfSimIsRunning

func CheckIfSimIsRunning() bool

@deprecated use IsSimRunning instead

func IsSimRunning added in v0.7.1

func IsSimRunning(ctx context.Context, client *http.Client) (bool, error)

checks if the iRacing simulation is running

Types

type ApiConfig

type ApiConfig struct {
	WaitForSimTimeout int
}

type BroadcastCmd added in v0.6.1

type BroadcastCmd int32
const (
	BroadcastCamSwitchPos            BroadcastCmd = iota // car position, group, camera
	BroadcastCamSwitchNum                                // driver #, group, camera
	BroadcastCamSetState                                 // CameraState, unused, unused
	BroadcastReplaySetPlaySpeed                          // speed, slowMotion, unused
	BroadcastReplaySetPlayPosition                       // ReplayPosMode, Frame Number (high, low)
	BroadcastReplaySearch                                // ReplaySearchMode, unused, unused
	BroadcastReplaySetState                              // ReplayStateMode, unused, unused
	BroadcastReloadTextures                              // ReloadTexturesMode, carIdx, unused
	BroadcastChatComand                                  // ChatCommand, subcommand, unused
	BroadcastPitCommand                                  // PitCommand, parameter, unused
	BroadcastTelemetryCommand                            // TelemetryCommand, unused, unused
	BroadcastFFBCommand                                  // FFBCommand, value (float, high,low)
	BroadcastReplaySearchSessionTime                     //
	BroadcastVideoCapture
)

type CameraState added in v0.6.1

type CameraState uint32

type ChatCommand added in v0.6.1

type ChatCommand uint32
const (
	ChatCommandMacro     ChatCommand = iota // pass in a number from 1-15 representing the chat macro to launch
	ChatCommandBeginChat                    // Open up a new chat window
	ChatCommandReply                        // Reply to last private chat
	ChatCommandCancel                       // Close chat window
)

type FFBCommand added in v0.6.1

type FFBCommand uint32
const (
	FFBCommandMaxForce FFBCommand = iota
)

type Flags

type Flags int64
const (
	FlagCheckered Flags = 1 << iota
	FlagWhite
	FlagGreen
	FlagYello
	FlagRed
	FlagBlue
	FlagDebris
	FlagCrossed
	FlagYellowWaving
	FlagOneLapToGreen
	FlagGreenHeld
	FlagTenToGo
	FlagFiveToGo
	FlagRandomWaving
	FlagCaution
	FlagCautionWaving

	// driver black flacks
	FlagBlack      Flags = 0x010000
	FlagDisqualify Flags = 0x020000
	FlagServicible Flags = 0x040000
	FlagFurled     Flags = 0x080000
	FlagRepair     Flags = 0x100000

	// start lights
	FlagStartHidden Flags = 0x10000000
	FlagStartReady  Flags = 0x20000000
	FlagStartSet    Flags = 0x40000000
	FlagStartGo     Flags = 0x80000000
)
type Header struct {
	Version           int32
	Status            int32
	TickRate          int32
	SessionInfoUpdate int32
	SessionInfoLen    int32
	SessionInfoOffset int32
	NumVars           int32
	VarOffsetHeader   int32
	NumBuf            int32
	BufLen            int32
	Pad               [2]int32
	VarBufs           [IrsdkMaxBufs]VarBuffer
}

type Irsdk

type Irsdk struct {
	SimIsRunning bool
	// contains filtered or unexported fields
}

func NewIrsdk

func NewIrsdk(opts ...Option) *Irsdk

func NewIrsdkWithFile

func NewIrsdkWithFile(f *os.File) *Irsdk

func (*Irsdk) BroadcastMsg added in v0.6.1

func (irsdk *Irsdk) BroadcastMsg(cmd BroadcastCmd, var1, var2, var3 int32) error

func (*Irsdk) CamSetState added in v0.6.1

func (irsdk *Irsdk) CamSetState(mode CameraState) error

convenience function to for BroadcastCamSetState

func (*Irsdk) CamSwitchNum added in v0.6.1

func (irsdk *Irsdk) CamSwitchNum(carNum string, group, camera int32) error

convenience function to for BroadcastCamSwitchNum

func (*Irsdk) CamSwitchPos added in v0.6.1

func (irsdk *Irsdk) CamSwitchPos(position, group, camera int32) error

convenience function to for BroadcastCamSwitchPos

func (*Irsdk) ChatCommand added in v0.6.1

func (irsdk *Irsdk) ChatCommand() error

convenience function to for BroadcastChatComand

func (*Irsdk) ChatCommandMacro added in v0.6.1

func (irsdk *Irsdk) ChatCommandMacro(macroNum int32) error

convenience function to for BroadcastChatComand

func (*Irsdk) Close

func (irsdk *Irsdk) Close()

func (*Irsdk) DumpHeaders

func (irsdk *Irsdk) DumpHeaders()

func (*Irsdk) GetBoolValue

func (irsdk *Irsdk) GetBoolValue(name string) (bool, error)

func (*Irsdk) GetBoolValues

func (irsdk *Irsdk) GetBoolValues(name string) ([]bool, error)

func (*Irsdk) GetData

func (irsdk *Irsdk) GetData() bool

returns true if new valid data is copied from iRacing telemetry to this Irdsk struct

func (*Irsdk) GetDataWithDataReadyTimeout added in v0.5.0

func (irsdk *Irsdk) GetDataWithDataReadyTimeout(dataReadyTimeout time.Duration) bool

returns true if new valid data is copied from iRacing telemetry to this Irdsk struct The call will wait up to dataReadyTimeout for new data to arrive

func (*Irsdk) GetDoubleValue

func (irsdk *Irsdk) GetDoubleValue(name string) (float64, error)

func (*Irsdk) GetDoubleValues

func (irsdk *Irsdk) GetDoubleValues(name string) ([]float64, error)

func (*Irsdk) GetFloatValue

func (irsdk *Irsdk) GetFloatValue(name string) (float32, error)

func (*Irsdk) GetFloatValues

func (irsdk *Irsdk) GetFloatValues(name string) ([]float32, error)

func (*Irsdk) GetIntValue

func (irsdk *Irsdk) GetIntValue(name string) (int32, error)

func (*Irsdk) GetIntValues

func (irsdk *Irsdk) GetIntValues(name string) ([]int32, error)

func (*Irsdk) GetLatestYaml

func (irsdk *Irsdk) GetLatestYaml() *yaml.IrsdkYaml

func (*Irsdk) GetValue

func (irsdk *Irsdk) GetValue(name string) (any, error)

func (*Irsdk) GetValueKeys

func (irsdk *Irsdk) GetValueKeys() []string

func (*Irsdk) GetVarHeaders added in v0.6.0

func (irsdk *Irsdk) GetVarHeaders() []VarHeader

func (*Irsdk) GetYaml

func (irsdk *Irsdk) GetYaml() (*yaml.IrsdkYaml, error)

func (*Irsdk) GetYamlString

func (irsdk *Irsdk) GetYamlString() string

func (*Irsdk) PitCommand added in v0.6.1

func (irsdk *Irsdk) PitCommand(cmd PitCommand, val int32) error

convenience function to for BroadcastPitComand

func (*Irsdk) ReloadAllTextures added in v0.6.1

func (irsdk *Irsdk) ReloadAllTextures() error

convenience function to for BroadcastReloadTextures

func (*Irsdk) ReloadTexture added in v0.6.1

func (irsdk *Irsdk) ReloadTexture(carIdx int32) error

convenience function to for BroadcastReloadTextures

func (*Irsdk) RepairedYaml added in v0.4.3

func (irsdk *Irsdk) RepairedYaml(s string) string

replaces the yaml team and user name with a quoted string these values are not quoted in the original yaml and most certainly cause issues

func (*Irsdk) ReplaySearch added in v0.6.1

func (irsdk *Irsdk) ReplaySearch(mode ReplaySearchMode) error

convenience function to for BroadcaseReplaySearch

func (*Irsdk) ReplaySearchSearchSessionTime added in v0.6.1

func (irsdk *Irsdk) ReplaySearchSearchSessionTime(sessionNum, sessionTimeMs int32) error

convenience function to for BroadcastReplaySearchSessionTime

func (*Irsdk) ReplaySetPlayPosition added in v0.6.1

func (irsdk *Irsdk) ReplaySetPlayPosition(mode ReplayPosMode, frameNum int32) error

convenience function to for BroadcastReplaySetPlayPosition

func (*Irsdk) ReplaySetPlaySpeed added in v0.6.1

func (irsdk *Irsdk) ReplaySetPlaySpeed(speed int32, slowMotion bool) error

convenience function to for BroadcastReplaySetPlaySpeed

func (*Irsdk) ReplaySetState added in v0.6.1

func (irsdk *Irsdk) ReplaySetState(mode ReplayStateMode) error

convenience function to for BroadcaseReplaySetState

func (*Irsdk) TelemetryCommand added in v0.6.1

func (irsdk *Irsdk) TelemetryCommand(cmd TelemetryCommand) error

convenience function to for BroadcastTelemetryCommand

func (*Irsdk) VideoCapture added in v0.6.1

func (irsdk *Irsdk) VideoCapture(cmd VideoCaptureMode) error

convenience function to for BroadcastVideoCapture

func (*Irsdk) WaitForValidData

func (irsdk *Irsdk) WaitForValidData() bool

func (*Irsdk) WriteDump

func (irsdk *Irsdk) WriteDump(w io.Writer) (int, error)

type MMap

type MMap []byte

type Option added in v0.5.0

type Option interface {
	// contains filtered or unexported methods
}

func WithWaitForValidDataTimeout added in v0.5.0

func WithWaitForValidDataTimeout(t time.Duration) Option

type PitCommand added in v0.6.1

type PitCommand uint32
const (
	PitCommandClear      PitCommand = iota // Clear all pit checkboxes
	PitCommandWS                           // clean the windshield, using one tear-off
	PitCommandFuel                         // add fuel, optionally specify the amount in liters
	PitCommandLF                           // change the left front tire, optionally specify the pressure in KPa
	PitCommandRF                           // change the right front tire, optionally specify the pressure in KPa
	PitCommandLR                           // change the left rear tire, optionally specify the pressure in KPa
	PitCommandRR                           // change the right rear tire, optionally specify the pressure in KPa
	PitCommandClearTires                   // clear tire pit checkboxes
	PitCommandFR                           // use fast repair
	PitCommandClearWS                      // uncheck the windshield checkbox
	PitCommandClearFR                      // clear fast repair checkbox
	PitCommandClearFuel                    // clear fuel checkbox
)

type ReloadTexturesMode added in v0.6.1

type ReloadTexturesMode uint32
const (
	ReloadTexturesModeAll ReloadTexturesMode = iota
	ReloadTexturesModeCarIdx
)

type ReplayPosMode added in v0.6.1

type ReplayPosMode uint32
const (
	ReplayPosModeBegin ReplayPosMode = iota
	ReplayPosModeCurrent
	ReplayPosModeEnd
)

type ReplaySearchMode added in v0.6.1

type ReplaySearchMode uint32
const (
	ReplaySearchModeStart ReplaySearchMode = iota
	ReplaySearchModeEnd
	ReplaySearchModePrevSession
	ReplaySearchModeNextSession
	ReplaySearchModePrevLap
	ReplaySearchModeNextLap
	ReplaySearchModePrevFrame
	ReplaySearchModeNextFrame
	ReplaySearchModePrevIncident
	ReplaySearchModeNextIncident
)

type ReplayStateMode added in v0.6.1

type ReplayStateMode uint32
const (
	ReplayStateModeEraseTape ReplayStateMode = iota
)

type SessionState

type SessionState int32
const (
	StateInvalid SessionState = iota
	StateGetInCar
	StateWarmup
	StateParadeLaps
	StateRacing
	StateCheckered
	StateCoolDown
)

type TelemetryCommand added in v0.6.1

type TelemetryCommand uint32
const (
	TelemetryCommandStop TelemetryCommand = iota
	TelemetryCommandStart
	TelemetryCommandRestart
)

type TrackLocation added in v0.7.0

type TrackLocation int32
const (
	TrackLocationNotInWorld TrackLocation = iota - 1
	TrackLocationOffTrack
	TrackLocationInPitStall
	TrackLocationAproachingPits
	TrackLocationOnTrack
)

type TrackSurface added in v0.7.0

type TrackSurface int32
const (
	TrackSurfaceNotInWorld TrackSurface = iota - 1
	TrackSurfaceUndefined
	TrackSurfaceAsphalt1
	TrackSurfaceAsphalt2
	TrackSurfaceAsphalt3
	TrackSurfaceAsphalt4
	TrackSurfaceConcrete1
	TrackSurfaceConcrete2
	TrackSurfaceRacingDirt1
	TrackSurfaceRacingDirt2
	TrackSurfacePaint1
	TrackSurfacePaint2
	TrackSurfaceRumble1
	TrackSurfaceRumble2
	TrackSurfaceRumble3
	TrackSurfaceRumble4
	TrackSurfaceGrass1
	TrackSurfaceGrass2
	TrackSurfaceGrass3
	TrackSurfaceGrass4
	TrackSurfaceDirt1
	TrackSurfaceDirt2
	TrackSurfaceDirt3
	TrackSurfaceDirt4
	TrackSurfaceSand
	TrackSurfaceGravel1
	TrackSurfaceGravel2
	TrackSurfaceGrasscrete
	TrackSurfaceAstroturf
)

type VarBuffer

type VarBuffer struct {
	TickCount int32
	BufOffset int32
	Pad       [2]int32
}

type VarHeader

type VarHeader struct {
	Type        VarType
	Offset      int32
	Count       int32
	CountAsTime bool
	Pad         [3]byte
	Name        [IrsdkMaxString]byte
	Desc        [IrsdkMaxDesc]byte
	Unit        [IrsdkMaxString]byte
}

type VarType

type VarType int32
const (
	// 1 byte
	IrsdkTypeChar VarType = iota
	IrsdkTypeBool
	// 4 bytes
	IrsdkTypeInt
	IrsdkTypeBitField
	IrsdkTypeFloat
	// 8 bytes
	IrsdkTypeDouble
	IrsdkTypeETCount
)

type VideoCaptureMode added in v0.6.1

type VideoCaptureMode uint32
const (
	VideoCaptureModeTriggerSreenshot VideoCaptureMode = iota
	VideoCaptureModeStartCapture
	VideoCaptureModeStopCapture
	VideoCaptureModeToggleVideoCapture
	VideoCaptureModeShowVideoTimer
	VideoCaptureModeHideVideoTimer
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL