Documentation ¶
Index ¶
- Constants
- Variables
- func GetString(desc StringDescription) (string, error)
- func GetVersion() (int, int, int)
- func RequireVersion(major, minor, patch int) bool
- func Sleep(time float64)
- type Context
- func (c *Context) CreateSettings() *DeviceSettings
- func (c *Context) Destroy()
- func (c *Context) GetError() string
- func (c *Context) ListGetInt(deviceIndex int, value IntValue) (int, error)
- func (c *Context) ListGetString(deviceIndex int, value StringValue) string
- func (c *Context) ListOpenDevice(index int) *Device
- func (c *Context) ListOpenDeviceSettings(index int, settings *DeviceSettings) *Device
- func (c *Context) Probe() int
- func (c *Context) Update()
- type ControlHint
- type ControlType
- type DataValue
- type Device
- func (d *Device) Close() error
- func (d *Device) GetFloat(value FloatValue, length int) ([]float32, error)
- func (d *Device) GetInt(value IntValue, length int) ([]int32, error)
- func (d *Device) SetData(value DataValue, input interface{}) error
- func (d *Device) SetFloat(value FloatValue, input []float32) error
- type DeviceClass
- type DeviceFlags
- type DeviceSettings
- type FloatValue
- type IntSettings
- type IntValue
- type StringDescription
- type StringValue
Constants ¶
const StringSize = C.OHMD_STR_SIZE
StringSize defines the maximum length of a string, including termination, in OpenHMD.
Variables ¶
var ( // ErrorUnknownError defines a return value that hasn't been specifically checked for. ErrorUnknownError = errors.New("Unknown error") // ErrorInvalidParameter gets returned if invalid parameters have been given. // Note that this is also used if too many entries are supplied, so GetFloat and GetInt, SetFloat and SetInt only return or accept 16 or less values. ErrorInvalidParameter = errors.New("Invalid parameter") // ErrorUnsupported defines either an unsupported version or action. ErrorUnsupported = errors.New("Unsupported version") // ErrorInvalidOperation defines a denied or invalid operation. ErrorInvalidOperation = errors.New("Invalid operation") )
Functions ¶
func GetString ¶
func GetString(desc StringDescription) (string, error)
GetString fetches a string description value from OpenHMD.
func RequireVersion ¶
RequireVersion checks that the library is compatible with the required version. Returns true if the version is met.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context defines the current use within an application.
func CreateContext ¶
func CreateContext() *Context
CreateContext makes an OpenHMD context. Returns nil if the context can't allocate memory.
func (*Context) CreateSettings ¶
func (c *Context) CreateSettings() *DeviceSettings
CreateSettings creates a device settings instance.
func (*Context) Destroy ¶
func (c *Context) Destroy()
Destroy removes the current OpenHMD context. Note: Your context will be removed from memory and all devices associated with the context will be closed automatically.
func (*Context) ListGetInt ¶
ListGetInt gets an integer value from the enumeration list index.
func (*Context) ListGetString ¶
func (c *Context) ListGetString(deviceIndex int, value StringValue) string
ListGetString gets a given device description from the enumeration list index.
func (*Context) ListOpenDevice ¶
ListOpenDevice opens a device.
func (*Context) ListOpenDeviceSettings ¶
func (c *Context) ListOpenDeviceSettings(index int, settings *DeviceSettings) *Device
ListOpenDeviceSettings opens a device with additional settings provided.
type ControlHint ¶
type ControlHint C.ohmd_control_hint
ControlHint defines button presses, trigger pushing and analog stick movement.
const ( // ControlHintGeneric - Generic button pressed. ControlHintGeneric ControlHint = iota // ControlHintTrigger - Trigger pushed. ControlHintTrigger // ControlHintTriggerClick - Trigger "clicked" - defines that the Trigger has been pushed all the way in. ControlHintTriggerClick // ControlHintSqueeze - Grip button pressed. ControlHintSqueeze // ControlHintMenu - Menu button pressed. ControlHintMenu // ControlHintHome - Home button pressed. ControlHintHome // ControlHintAnalogX - Horizontal stick movement. ControlHintAnalogX // ControlHintAnalogY - Vertical stick movement. ControlHintAnalogY // ControlHintAnalogPress - Stick pressed. ControlHintAnalogPress // ControlHintButtonA - Button A pressed. ControlHintButtonA // ControlHintButtonB - Button B pressed. ControlHintButtonB // ControlHintButtonX - Button X pressed. ControlHintButtonX // ControlHintButtonY - Button Y pressed. ControlHintButtonY // ControlHintVolumePlus - Volume up button pressed. ControlHintVolumePlus // ControlHintVolumeMinus - Volume down button pressed. ControlHintVolumeMinus // ControlHintMicMute - Microphone mute button pressed. ControlHintMicMute )
type ControlType ¶
type ControlType C.ohmd_control_type
ControlType specifies digital or analog controls.
const ( // ControlTypeDigital defines digital controls, like a button. ControlTypeDigital ControlType = iota // ControlTypeAnalog defines analog controls, like a analog stick. ControlTypeAnalog )
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device defines a OpenHMD device, like a Head-Mounted Display or a motion Controller.
func (*Device) GetFloat ¶
func (d *Device) GetFloat(value FloatValue, length int) ([]float32, error)
GetFloat fetches (a) float value(s).
type DeviceClass ¶
type DeviceClass C.ohmd_device_class
DeviceClass defines what kind of device is being used.
const ( // DeviceClassHMD defines a HMD. DeviceClassHMD DeviceClass = iota // DeviceClassController defines a motion controller. DeviceClassController // DeviceClassGenericTracker defines a simple tracker. DeviceClassGenericTracker )
type DeviceFlags ¶
type DeviceFlags C.ohmd_device_flags
DeviceFlags specifies flags for a given devices.
const ( // DeviceFlagsNullDevice defines a dummy device. DeviceFlagsNullDevice DeviceFlags = 1 // DeviceFlagsPositionalTracking defines a position-tracking device. DeviceFlagsPositionalTracking DeviceFlags = 2 // DeviceFlagsRotationalTracking defines a rotation-tracking device. DeviceFlagsRotationalTracking DeviceFlags = 4 // DeviceFlagsLeftController defines a left-sided motion controller. DeviceFlagsLeftController DeviceFlags = 8 // DeviceFlagsRightController defines a right-sided motion controller. DeviceFlagsRightController DeviceFlags = 16 )
type DeviceSettings ¶
type DeviceSettings struct {
// contains filtered or unexported fields
}
DeviceSettings stores data used for setting up the given device.
func (*DeviceSettings) Destroy ¶
func (s *DeviceSettings) Destroy()
Destroy destroys a device settings instance.
func (*DeviceSettings) SetInt ¶
func (s *DeviceSettings) SetInt(key IntSettings, value int) error
SetInt sets the given value for the providen key.
type FloatValue ¶
type FloatValue C.ohmd_float_value
FloatValue defines various float32-based values, like position or rotation, and more data that needs to be accurate.
const ( // FloatValueRotationQuat defines the absolute rotation of the device, in space, as a quaternion. // Valid for GetFloat. // Returns 4 values: X, Y, Z, W. FloatValueRotationQuat FloatValue = iota + 1 // FloatValueLeftEyeGlModelViewMatrix defines a "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the left eye of the HMD. // Valid for GetFloat. // Returns 16 values. FloatValueLeftEyeGlModelViewMatrix // FloatValueRightEyeGlModelViewMatrix defines a "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the right eye of the HMD. // Valid for GetFloat. // Returns 16 values. FloatValueRightEyeGlModelViewMatrix // FloatValueLeftEyeGlProjectionMatrix defines a "ready to use" OpenGL style 4x4 matrix with a projection matrix for the left eye of the HMD. // Valid for GetFloat. // Returns 16 values. FloatValueLeftEyeGlProjectionMatrix // FloatValueRightEyeGlProjectionMatrix defines a "ready to use" OpenGL style 4x4 matrix with a projection matrix for the right eye of the HMD. // Valid for GetFloat. // Returns 16 values. FloatValueRightEyeGlProjectionMatrix // FloatValuePositionVector defines a 3D vector representing the absolute position of the device, in space. // Valid for GetFloat. // Returns 3 values: X, Y, Z. FloatValuePositionVector // FloatValueScreenHorizontalSize defines the width of the device's screen in metres. // Valid for GetFloat. // Returns 1 value. FloatValueScreenHorizontalSize // FloatValueScreenVerticalSize defines the height of the device's screen in metres. // Valid for GetFloat. // Returns 1 value. FloatValueScreenVerticalSize // FloatValueLensHorizontalSeparation defines the separation of the device's lenses in metres. // Valid for GetFloat. // Returns 1 value. FloatValueLensHorizontalSeparation // FloatValueLensVerticalPosition defines the vertical position of the device's lenses in metres. // Valid for GetFloat. // Returns 1 value. FloatValueLensVerticalPosition // FloatValueLeftEyeFOV defines the field of view for the left eye in degrees. // Valid for GetFloat. // Returns 1 value. FloatValueLeftEyeFOV // FloatValueLeftEyeAspectRatio defines the aspect ratio of the screen for the left eye. // Valid for GetFloat. // Returns 1 value. FloatValueLeftEyeAspectRatio // FloatValueRightEyeFOV defines the field of view for the right eye in degrees. // Valid for GetFloat. // Returns 1 value. FloatValueRightEyeFOV // FloatValueRightEyeAspectRatio defines the aspect ratio of the screen for the right eye. // Valid for GetFloat. // Returns 1 value. FloatValueRightEyeAspectRatio // FloatValueEyeIPD defines the the interpupillary distance of the user's eyes in metres. // Valid for GetFloat and SetFloat. // Returns/Accepts 1 value. FloatValueEyeIPD // FloatValueProjectionZFar defines how far the projection matrix can be drawn on the screen. // Valid for GetFloat and SetFloat. // Returns/Accepts 1 value. FloatValueProjectionZFar // FloatValueProjectionZNear defines how near the projection matrix can be drawn on the screen. This can be, for example, be used for close clipping distance. // Valid for GetFloat and SetFloat. // Returns/Accepts 1 value. FloatValueProjectionZNear // FloatValueDistortionK defines the device-specific distortion value. // Valid for GetFloat. // Returns 6 values. FloatValueDistortionK // FloatValueExternalSensorFusion defines the use of performing sensor fusion on values from the external sensors. // Valid for SetFloat. // Returns 10 values: Date + Time, X, Y, Z (gyrometer), X, Y, Z (accelerometer), X, Y, Z (magnetometer). FloatValueExternalSensorFusion // FloatValueUniversalDistortionK defines the universal shader distortion coefficients, based on the Panorama Tools model. // Valid for GetFloat. // Returns 4 values: A, B, C, D. FloatValueUniversalDistortionK // FloatValueUniversalAberrationK defines the universal shader aberration coefficients, based on Post-Warp scaling. // Valid for GetFloat. // Returns 3 values: R, G, B. FloatValueUniversalAberrationK // FloatValueControlsState defines the state of the device's controls. // Valid for GetFloat. // Returns between 1 to 16 values, based on IntValueControlsCount. FloatValueControlsState )
type IntSettings ¶
type IntSettings C.ohmd_int_settings
IntSettings can be used for integer-based settings for the device.
const ( // IntSettingsIDsAutomaticUpdate allows OpenHMD to create background threads for automatic updating. // If this is set to 0, Update needs to be called at least 10 times per second. IntSettingsIDsAutomaticUpdate IntSettings = iota )
type IntValue ¶
type IntValue C.ohmd_int_value
IntValue carries information that can be single- or double-digit long, and don't need to be accurate, like FloatValue. These can be, for example, the button count, and so on.
const ( // IntValueScreenHorizontalResolution defines the horizontal resolution of the device's screen. // Valid for GetInt. // Returns 1 value. IntValueScreenHorizontalResolution IntValue = iota // IntValueScreenVerticalResolution defines the vertical resolution of the device's screen. // Valid for GetInt. // Returns 1 value. IntValueScreenVerticalResolution // IntValueDeviceClass returns the device's class, refer to DeviceClass for more information. // Valid For GetInt and ListGetInt. // Returns 1 value. IntValueDeviceClass // IntValueDeviceFlags returns the device's flags, refer to DeviceFlags for more information. // Valid For GetInt and ListGetInt. // Returns 1 value. IntValueDeviceFlags // IntValueControlsCount returns the count of controls for the device. // Valid for GetInt. // Returns 1 value. IntValueControlsCount // IntValueControlsHints returns which buttons are supported. // Valid for GetInt. // Returns between 1 to 16 values, based on IntValueControlsCount. IntValueControlsHints // IntValueControlsTypes returns whether a control entry is analog or digital. // Valid for GetInt. // Returns between 1 to 16 values, based on IntValueControlsCount. IntValueControlsTypes )
type StringDescription ¶
type StringDescription C.ohmd_string_description
StringDescription returns information about the used shaders.
const ( StringDescriptionGlslDisortionVertSrc StringDescription = iota StringDescriptionGlslDisortionFragSRC StringDescriptionGsls330DisortionVertSrc StringDescriptionGsls330DisortionFragSrc StringDescriptionGslsEsDisortionVertSrc StringDescriptionGslsEsDisortionFragSrc )
A collection of string descriptions, returning Shader-related data.
type StringValue ¶
type StringValue C.ohmd_string_value
StringValue can be used for identifying the hardware itself.
const ( // StringValueVendor returns the name of the product's vendor. StringValueVendor StringValue = iota + 1 //StringValueProduct returns the name of the product itself. StringValueProduct // StringValuePath returns the internal path of the device. StringValuePath )