utils

package
v0.0.0-...-8dab19a Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2015 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPC_COMMAND      = "utils/assets/ir-syscalls-rpc.exe"
	DATA_CHANGE_TICK = time.Duration(time.Millisecond * 9)
)
View Source
const (
	MEMMAPFILENAME     = "Local\\IRSDKMemMapFileName"
	BROADCASTMSGNAME   = "IRSDK_BROADCASTMSG"
	DATAVALIDEVENTNAME = "Local\\IRSDKDataValidEvent"
	INT_MAX            = 2147483647
	MEMMAPFILESIZE     = 780 * 1024

	MAX_BUFS   = 4
	MAX_STRING = 32
	// descriptions can be longer than max_string!
	MAX_DESC = 64

	TIMEOUT = time.Duration(time.Second * 30) // timeout after 30 seconds with no communication
)

Variables

View Source
var (
	ErrInitialize     = errors.New("Failed to initialize")
	ErrDataChanged    = errors.New("Data changed out from under us")
	ErrDisconnected   = errors.New("We probably disconnected")
	ErrNothingChanged = errors.New("Nothing changed this tick")
)
View Source
var VarTypeBytes = [ETCount]VarType{
	1,
	1,

	4,
	4,
	4,

	8,
}

const doesn't work for some reason

View Source
var (
	WineCmd = []string{"/opt/iracing/bin/wine", "--bottle", "default"}
)

Functions

func CToGoString

func CToGoString(c []byte) string

func MAKELONG

func MAKELONG(lo, hi uint16) uint32

Types

type BroadcastMsg

type BroadcastMsg uint16
const (
	BroadcastCamSwitchPos          BroadcastMsg = 0    // car position, group, camera
	BroadcastCamSwitchNum          BroadcastMsg = iota // driver #, group, camera
	BroadcastCamSetState           BroadcastMsg = iota // CameraState, unused, unused
	BroadcastReplaySetPlaySpeed    BroadcastMsg = iota // speed, slowMotion, unused
	BroadcastReplaySetPlayPosition BroadcastMsg = iota // RpyPosMode, Frame Number (high, low)
	BroadcastReplaySearch          BroadcastMsg = iota // RpySrchMode, unused, unused
	BroadcastReplaySetState        BroadcastMsg = iota // RpyStateMode, unused, unused
	BroadcastReloadTextures        BroadcastMsg = iota // ReloadTexturesMode, carIdx, unused
	BroadcastChatComand            BroadcastMsg = iota // ChatCommandMode, subCommand, unused
	BroadcastPitCommand            BroadcastMsg = iota // PitCommandMode, parameter
	BroadcastTelemCommand          BroadcastMsg = iota // TelemCommandMode, unused, unused
	BroadcastLast                  BroadcastMsg = iota // unused placeholder
)

type CWrapper

type CWrapper struct {
	// contains filtered or unexported fields
}

func NewCWrapper

func NewCWrapper() (*CWrapper, error)

func (*CWrapper) CloseHandle

func (cw *CWrapper) CloseHandle(handle uintptr) error

func (*CWrapper) OpenEvent

func (cw *CWrapper) OpenEvent(lpName string) (uintptr, error)

func (*CWrapper) RegisterWindowMessageA

func (cw *CWrapper) RegisterWindowMessageA(lpString string) (uint, error)

func (*CWrapper) RegisterWindowMessageW

func (cw *CWrapper) RegisterWindowMessageW(lpString string) (uint, error)

func (*CWrapper) SendNotifyMessage

func (cw *CWrapper) SendNotifyMessage(msgID uint, wParam uint32, lParam uint32) error

func (*CWrapper) SendNotifyMessageW

func (cw *CWrapper) SendNotifyMessageW(msgID uint, wParam uint32, lParam uint32) error

func (*CWrapper) UnmapViewOfFile

func (cw *CWrapper) UnmapViewOfFile(lpBaseAddress uintptr) error

func (*CWrapper) WaitForDataChange

func (cw *CWrapper) WaitForDataChange(timeout time.Duration) error

func (*CWrapper) WaitForDataChangeChannel

func (cw *CWrapper) WaitForDataChangeChannel(timeout time.Duration) error

func (*CWrapper) WaitForSingleObject

func (cw *CWrapper) WaitForSingleObject(hDataValidEvent uintptr, timeOut int) error

type CameraState

type CameraState int32
const (
	IsSessionScreen CameraState = 0x0001 // the camera tool can only be activated if viewing the session screen (out of car)
	IsScenicActive  CameraState = 0x0002 // the scenic camera is active (no focus car)

	//these can be changed with a broadcast message
	CamToolActive         CameraState = 0x0004
	UIHidden              CameraState = 0x0008
	UseAutoShotSelection  CameraState = 0x0010
	UseTemporaryEdits     CameraState = 0x0020
	UseKeyAcceleration    CameraState = 0x0040
	UseKey10xAcceleration CameraState = 0x0080
	UseMouseAimMode       CameraState = 0x0100
)

type ChatCommandMode

type ChatCommandMode int32
const (
	ChatCommand_Macro     ChatCommandMode = 0    // pass in a number from 1-15 representing the chat macro to launch
	ChatCommand_BeginChat ChatCommandMode = iota // Open up a new chat window
	ChatCommand_Reply     ChatCommandMode = iota // Reply to last private chat
	ChatCommand_Cancel    ChatCommandMode = iota // Close chat window
)

type CsMode

type CsMode int32

BroadcastCamSwitchPos or BroadcastCamSwitchNum camera focus defines pass these in for the first parameter to select the 'focus at' types in the camera system.

const (
	CsFocusAtIncident CsMode = -3
	CsFocusAtLeader   CsMode = -2
	CsFocusAtExiting  CsMode = -1
	// ctFocusAtDriver + car number...
	CsFocusAtDriver CsMode = 0
)

type DiskSubHeader

type DiskSubHeader struct {
	// contains filtered or unexported fields
}

sub header used when writing telemetry to disk

type EngineWarnings

type EngineWarnings int32

bit fields

const (
	WaterTempWarning    EngineWarnings = 0x01
	FuelPressureWarning EngineWarnings = 0x02
	OilPressureWarning  EngineWarnings = 0x04
	EngineStalled       EngineWarnings = 0x08
	PitSpeedLimiter     EngineWarnings = 0x10
	RevLimiterActive    EngineWarnings = 0x20
)

type Flags

type Flags uint32
const (
	// global flags
	CheckeredFlag     Flags = 0x00000001
	WhiteFlag         Flags = 0x00000002
	GreenFlag         Flags = 0x00000004
	YellowFlag        Flags = 0x00000008
	RedFlag           Flags = 0x00000010
	BlueFlag          Flags = 0x00000020
	DebrisFlag        Flags = 0x00000040
	CrossedFlag       Flags = 0x00000080
	YellowWavingFlag  Flags = 0x00000100
	OneLapToGreenFlag Flags = 0x00000200
	GreenHeldFlag     Flags = 0x00000400
	TenToGoFlag       Flags = 0x00000800
	FiveToGoFlag      Flags = 0x00001000
	RandomWavingFlag  Flags = 0x00002000
	CautionFlag       Flags = 0x00004000
	CautionWavingFlag Flags = 0x00008000

	// drivers black flags
	BlackFlag      Flags = 0x00010000
	DisqualifyFlag Flags = 0x00020000
	ServicibleFlag Flags = 0x00040000 // car is allowed service (not a flag)
	FurledFlag     Flags = 0x00080000
	RepairFlag     Flags = 0x00100000

	// start lights
	StartHidden Flags = 0x10000000
	StartReady  Flags = 0x20000000
	StartSet    Flags = 0x40000000
	StartGo     Flags = 0x80000000
)

type GetMemoryArgs

type GetMemoryArgs struct {
	SharedMemPtr uintptr
	StartByte    int
	EndByte      int
}
type Header struct {
	Ver      int32       // api version 1 for now
	Status   StatusField // bitfield using StatusField
	TickRate int32       // ticks per second (60 or 360 etc)

	// session information, updated periodicaly
	SessionInfoUpdate int32 // Incremented when session info changes
	SessionInfoLen    int32 // Length in bytes of session info string
	SessionInfoOffset int32 // Session info, encoded in YAML format

	// State data, output at tickRate
	NumVars         int32 // length of array pointed to by varHeaderOffset
	VarHeaderOffset int32 // offset to VarHeader[numVars] array, Describes the variables recieved in varBuf

	NumBuf int32    // <= MAX_BUFS (3 for now)
	BufLen int32    // length in bytes for one line
	Pad1   [2]int32 // (16 byte align)
	VarBuf [MAX_BUFS]VarBuf
}

func (*Header) GetLatestVarBufN

func (header *Header) GetLatestVarBufN() int

type Irsdk

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

func NewIrsdk

func NewIrsdk() (*Irsdk, error)

func (*Irsdk) BroadcastMsg

func (ir *Irsdk) BroadcastMsg(msg BroadcastMsg, var1 uint16, var2 uint16, var3 uint16) error

func (*Irsdk) GetBroadcastMsgID

func (ir *Irsdk) GetBroadcastMsgID() (uint, error)

func (*Irsdk) GetHeader

func (ir *Irsdk) GetHeader() (*Header, error)

func (*Irsdk) GetLastValidTime

func (ir *Irsdk) GetLastValidTime() time.Time

func (*Irsdk) GetNewData

func (ir *Irsdk) GetNewData() ([]byte, error)

func (*Irsdk) GetNumVars

func (ir *Irsdk) GetNumVars() int

func (*Irsdk) GetSessionInfoStr

func (ir *Irsdk) GetSessionInfoStr() []byte

func (*Irsdk) GetVarHeaderEntry

func (ir *Irsdk) GetVarHeaderEntry(index int) (*VarHeader, error)

func (*Irsdk) IsConnected

func (ir *Irsdk) IsConnected() bool

func (*Irsdk) PadCarNum

func (ir *Irsdk) PadCarNum(num int, zero int) int

func (*Irsdk) Shutdown

func (ir *Irsdk) Shutdown()

func (*Irsdk) Startup

func (ir *Irsdk) Startup() error

func (*Irsdk) VarNameToIndex

func (ir *Irsdk) VarNameToIndex(name string) (int, error)

Note: this is a linear search, so cache the results

func (*Irsdk) VarNameToOffset

func (ir *Irsdk) VarNameToOffset(name string) (int, error)

func (*Irsdk) WaitForDataReady

func (ir *Irsdk) WaitForDataReady(timeOut time.Duration) ([]byte, error)

type MapViewOfFileArgs

type MapViewOfFileArgs struct {
	HMemMapFile          uintptr
	DwNumberOfBytesToMap int
}

type OpenEventArgs

type OpenEventArgs struct {
	LpName string
}

type OpenFileMappingArgs

type OpenFileMappingArgs struct {
	LpName string
}

type PitCommandMode

type PitCommandMode int32
const (
	PitCommand_Clear      PitCommandMode = 0    // Clear all pit checkboxes
	PitCommand_WS         PitCommandMode = iota // Clean the winshield, using one tear off
	PitCommand_Fuel       PitCommandMode = iota // Add fuel, optionally specify the amount to add in liters or pass '0' to use existing amount
	PitCommand_LF         PitCommandMode = iota // Change the left front tire, optionally specifying the pressure in KPa or pass '0' to use existing pressure
	PitCommand_RF         PitCommandMode = iota // right front
	PitCommand_LR         PitCommandMode = iota // left rear
	PitCommand_RR         PitCommandMode = iota // right rear
	PitCommand_ClearTires PitCommandMode = iota // Clear tire pit checkboxes
)

type PitSvFlag

type PitSvFlag int32
const (
	LFTireChange PitSvFlag = 0x0001
	RFTireChange PitSvFlag = 0x0002
	LRTireChange PitSvFlag = 0x0004
	RRTireChange PitSvFlag = 0x0008

	FuelFill          PitSvFlag = 0x0010
	WindshieldTearoff PitSvFlag = 0x0020
	FastRepair        PitSvFlag = 0x0040
)

type PtrToHeaderArgs

type PtrToHeaderArgs struct {
	SharedMemPtr uintptr
}

type PtrToSharedMemArgs

type PtrToSharedMemArgs struct {
	SharedMemPtr uintptr
}

type PtrToVarHeaderArgs

type PtrToVarHeaderArgs struct {
	VarHeaderPtr uintptr
}

type ReloadTexturesMode

type ReloadTexturesMode int32
const (
	ReloadTextures_All    ReloadTexturesMode = 0    // reload all textuers
	ReloadTextures_CarIdx ReloadTexturesMode = iota // reload only textures for the specific carIdx
)

type RpyPosMode

type RpyPosMode int32
const (
	RpyPos_Begin   RpyPosMode = 0
	RpyPos_Current RpyPosMode = iota
	RpyPos_End     RpyPosMode = iota
	RpyPos_Last    RpyPosMode = iota // unused placeholder
)

type RpySrchMode

type RpySrchMode int32

Search replay tape for events

const (
	RpySrch_ToStart      RpySrchMode = 0
	RpySrch_ToEnd        RpySrchMode = iota
	RpySrch_PrevSession  RpySrchMode = iota
	RpySrch_NextSession  RpySrchMode = iota
	RpySrch_PrevLap      RpySrchMode = iota
	RpySrch_NextLap      RpySrchMode = iota
	RpySrch_PrevFrame    RpySrchMode = iota
	RpySrch_NextFrame    RpySrchMode = iota
	RpySrch_PrevIncident RpySrchMode = iota
	RpySrch_NextIncident RpySrchMode = iota
	RpySrch_Last         RpySrchMode = iota // unused placeholder
)

type RpyStateMode

type RpyStateMode int32
const (
	RpyState_EraseTape RpyStateMode = 0    // clear any data in the replay tape
	RpyState_Last      RpyStateMode = iota // unused place holder
)

type SessionState

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

type StatusField

type StatusField int32
const (
	StatusConnected StatusField = 1
)

type TelemCommandMode

type TelemCommandMode int32
const (
	TelemCommand_Stop    TelemCommandMode = 0    // Turn telemetry recording off
	TelemCommand_Start   TelemCommandMode = iota // Turn telemetry recording on
	TelemCommand_Restart TelemCommandMode = iota // Write current file to disk and start a new one
)

type TrkLoc

type TrkLoc int32
const (
	NotInWorld     TrkLoc = iota - 1
	OffTrack       TrkLoc = iota - 1
	InPitStall     TrkLoc = iota - 1
	AproachingPits TrkLoc = iota - 1
	OnTrac         TrkLoc = iota - 1
)

status

type VarBuf

type VarBuf struct {
	TickCount int32    // used to detect changes in data
	BufOffset int32    // offset from header
	Pad       [2]int32 // (16 byte align)
}

type VarHeader

type VarHeader struct {
	Type   VarType // VarType
	Offset int32   // offset fron start of buffer row
	Count  int32   // number of entrys (array)

	Pad [1]int32 // (16 byte align)

	Name [MAX_STRING]byte
	Desc [MAX_DESC]byte
	Unit [MAX_STRING]byte // something like "kg/m^2"
}

type VarType

type VarType int32
const (
	// 1 byte
	CharType VarType = iota
	BoolType VarType = iota

	// 4 bytes
	IntType      VarType = iota
	BitfieldType VarType = iota
	FloatType    VarType = iota

	// 8 bytes
	DoubleType VarType = iota

	// index, don't use
	ETCount = iota
)

type WaitForSingleObjectArgs

type WaitForSingleObjectArgs struct {
	HDataValidEvent uintptr
	TimeOut         int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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