1use std::mem::ManuallyDrop;
2autocxx::include_cpp! {
3 #include "../third-party/openvr/headers/openvr.h"
4 generate!("vr::IVRSystem")
5 generate!("vr::IVROverlay")
6 generate!("vr::IVRCompositor")
7 generate!("vr::IVRInput")
8 generate_pod!("vr::VRActiveActionSet_t")
9 generate_pod!("vr::VREvent_Reserved_t")
10 generate_pod!("vr::VREvent_Controller_t")
11 generate_pod!("vr::VREvent_Mouse_t")
12 generate_pod!("vr::VREvent_Scroll_t")
13 generate_pod!("vr::VREvent_Process_t")
14 generate_pod!("vr::VREvent_Notification_t")
15 generate_pod!("vr::VREvent_Overlay_t")
16 generate_pod!("vr::VREvent_Status_t")
17 generate_pod!("vr::VREvent_Keyboard_t")
18 generate_pod!("vr::VREvent_Ipd_t")
19 generate_pod!("vr::VREvent_Chaperone_t")
20 generate_pod!("vr::VREvent_PerformanceTest_t")
21 generate_pod!("vr::VREvent_TouchPadMove_t")
22 generate_pod!("vr::VREvent_SeatedZeroPoseReset_t")
23 generate_pod!("vr::VREvent_Screenshot_t")
24 generate_pod!("vr::VREvent_ScreenshotProgress_t")
25 generate_pod!("vr::VREvent_ApplicationLaunch_t")
26 generate_pod!("vr::VREvent_EditingCameraSurface_t")
27 generate_pod!("vr::VREvent_MessageOverlay_t")
28 generate_pod!("vr::VREvent_Property_t")
29 generate_pod!("vr::VREvent_HapticVibration_t")
30 generate_pod!("vr::VREvent_WebConsole_t")
31 generate_pod!("vr::VREvent_InputBindingLoad_t")
32 generate_pod!("vr::VREvent_InputActionManifestLoad_t")
33 generate_pod!("vr::VREvent_SpatialAnchor_t")
34 generate_pod!("vr::VREvent_ProgressUpdate_t")
35 generate_pod!("vr::VREvent_ShowUI_t")
36 generate_pod!("vr::VREvent_ShowDevTools_t")
37 generate_pod!("vr::VREvent_HDCPError_t")
38 generate_pod!("vr::TrackedDeviceIndex_t")
39 generate_pod!("vr::TrackedDevicePose_t")
40 generate_pod!("vr::VRTextureBounds_t")
41 generate_pod!("vr::VRVulkanTextureData_t")
42 generate_pod!("vr::Texture_t")
43 generate_pod!("vr::ETextureType")
44 generate_pod!("vr::EVRInputError")
45 generate_pod!("vr::HmdMatrix34_t")
46 generate_pod!("vr::InputDigitalActionData_t")
47 generate!("vr::k_ulInvalidInputValueHandle")
48 generate!("vr::VR_Init")
49 generate!("vr::VR_Shutdown")
50 generate!("vr::VR_IsHmdPresent")
51 generate!("vr::VROverlay")
52 generate!("vr::VRCompositor")
53 generate!("vr::VRInput")
54 safety!(unsafe)
55}
56
57#[allow(non_camel_case_types, non_snake_case)]
58#[repr(C)]
59pub union VREvent_Data_t {
60 pub reserved: ManuallyDrop<ffi::vr::VREvent_Reserved_t>,
61 pub controller: ManuallyDrop<ffi::vr::VREvent_Controller_t>,
62 pub mouse: ManuallyDrop<ffi::vr::VREvent_Mouse_t>,
63 pub scroll: ManuallyDrop<ffi::vr::VREvent_Scroll_t>,
64 pub process: ManuallyDrop<ffi::vr::VREvent_Process_t>,
65 pub notification: ManuallyDrop<ffi::vr::VREvent_Notification_t>,
66 pub overlay: ManuallyDrop<ffi::vr::VREvent_Overlay_t>,
67 pub status: ManuallyDrop<ffi::vr::VREvent_Status_t>,
68 pub keyboard: ManuallyDrop<ffi::vr::VREvent_Keyboard_t>,
69 pub ipd: ManuallyDrop<ffi::vr::VREvent_Ipd_t>,
70 pub chaperone: ManuallyDrop<ffi::vr::VREvent_Chaperone_t>,
71 pub performanceTest: ManuallyDrop<ffi::vr::VREvent_PerformanceTest_t>,
72 pub touchPadMove: ManuallyDrop<ffi::vr::VREvent_TouchPadMove_t>,
73 pub seatedZeroPoseReset: ManuallyDrop<ffi::vr::VREvent_SeatedZeroPoseReset_t>,
74 pub screenshot: ManuallyDrop<ffi::vr::VREvent_Screenshot_t>,
75 pub screenshotProgress: ManuallyDrop<ffi::vr::VREvent_ScreenshotProgress_t>,
76 pub applicationLaunch: ManuallyDrop<ffi::vr::VREvent_ApplicationLaunch_t>,
77 pub cameraSurface: ManuallyDrop<ffi::vr::VREvent_EditingCameraSurface_t>,
78 pub messageOverlay: ManuallyDrop<ffi::vr::VREvent_MessageOverlay_t>,
79 pub property: ManuallyDrop<ffi::vr::VREvent_Property_t>,
80 pub hapticVibration: ManuallyDrop<ffi::vr::VREvent_HapticVibration_t>,
81 pub webConsole: ManuallyDrop<ffi::vr::VREvent_WebConsole_t>,
82 pub inputBinding: ManuallyDrop<ffi::vr::VREvent_InputBindingLoad_t>,
83 pub actionManifest: ManuallyDrop<ffi::vr::VREvent_InputActionManifestLoad_t>,
84 pub spatialAnchor: ManuallyDrop<ffi::vr::VREvent_SpatialAnchor_t>,
85 pub progressUpdate: ManuallyDrop<ffi::vr::VREvent_ProgressUpdate_t>,
86 pub showUi: ManuallyDrop<ffi::vr::VREvent_ShowUI_t>,
87 pub showDevTools: ManuallyDrop<ffi::vr::VREvent_ShowDevTools_t>,
88 pub hdcpError: ManuallyDrop<ffi::vr::VREvent_HDCPError_t>,
89}
90
91#[allow(non_camel_case_types, non_snake_case)]
92#[repr(C, packed(4))]
93pub struct VREvent_t {
94 pub eventType: u32,
95 pub trackedDeviceIndex: ffi::vr::TrackedDeviceIndex_t,
96 pub eventAgeSeconds: f32,
97 pub data: VREvent_Data_t,
98}
99
100pub use ffi::vr::*;
101pub use ffi::*;
102
103impl TryFrom<u32> for EVREventType {
104 type Error = ();
105 fn try_from(value: u32) -> Result<Self, Self::Error> {
106 Ok(match value {
107 0 => EVREventType::VREvent_None,
108
109 100 => EVREventType::VREvent_TrackedDeviceActivated,
110 101 => EVREventType::VREvent_TrackedDeviceDeactivated,
111 102 => EVREventType::VREvent_TrackedDeviceUpdated,
112 103 => EVREventType::VREvent_TrackedDeviceUserInteractionStarted,
113 104 => EVREventType::VREvent_TrackedDeviceUserInteractionEnded,
114 105 => EVREventType::VREvent_IpdChanged,
115 106 => EVREventType::VREvent_EnterStandbyMode,
116 107 => EVREventType::VREvent_LeaveStandbyMode,
117 108 => EVREventType::VREvent_TrackedDeviceRoleChanged,
118 109 => EVREventType::VREvent_WatchdogWakeUpRequested,
119 110 => EVREventType::VREvent_LensDistortionChanged,
120 111 => EVREventType::VREvent_PropertyChanged,
121 112 => EVREventType::VREvent_WirelessDisconnect,
122 113 => EVREventType::VREvent_WirelessReconnect,
123
124 200 => EVREventType::VREvent_ButtonPress, 201 => EVREventType::VREvent_ButtonUnpress, 202 => EVREventType::VREvent_ButtonTouch, 203 => EVREventType::VREvent_ButtonUntouch, 257 => EVREventType::VREvent_Modal_Cancel, 300 => EVREventType::VREvent_MouseMove, 301 => EVREventType::VREvent_MouseButtonDown, 302 => EVREventType::VREvent_MouseButtonUp, 303 => EVREventType::VREvent_FocusEnter, 304 => EVREventType::VREvent_FocusLeave, 305 => EVREventType::VREvent_ScrollDiscrete, 306 => EVREventType::VREvent_TouchPadMove, 307 => EVREventType::VREvent_OverlayFocusChanged, 308 => EVREventType::VREvent_ReloadOverlays,
147 309 => EVREventType::VREvent_ScrollSmooth, 310 => EVREventType::VREvent_LockMousePosition,
149 311 => EVREventType::VREvent_UnlockMousePosition,
150
151 400 => EVREventType::VREvent_InputFocusCaptured, 401 => EVREventType::VREvent_InputFocusReleased, 404 => EVREventType::VREvent_SceneApplicationChanged, 405 => EVREventType::VREvent_SceneFocusChanged, 406 => EVREventType::VREvent_InputFocusChanged, 408 => EVREventType::VREvent_SceneApplicationUsingWrongGraphicsAdapter, 409 => EVREventType::VREvent_ActionBindingReloaded, 410 => EVREventType::VREvent_HideRenderModels, 411 => EVREventType::VREvent_ShowRenderModels, 412 => EVREventType::VREvent_SceneApplicationStateChanged, 420 => EVREventType::VREvent_ConsoleOpened,
168 421 => EVREventType::VREvent_ConsoleClosed,
169
170 500 => EVREventType::VREvent_OverlayShown,
171 501 => EVREventType::VREvent_OverlayHidden,
172 502 => EVREventType::VREvent_DashboardActivated,
173 503 => EVREventType::VREvent_DashboardDeactivated,
174 505 => EVREventType::VREvent_DashboardRequested, 506 => EVREventType::VREvent_ResetDashboard, 508 => EVREventType::VREvent_ImageLoaded, 509 => EVREventType::VREvent_ShowKeyboard, 510 => EVREventType::VREvent_HideKeyboard, 511 => EVREventType::VREvent_OverlayGamepadFocusGained, 512 => EVREventType::VREvent_OverlayGamepadFocusLost, 513 => EVREventType::VREvent_OverlaySharedTextureChanged,
184 516 => EVREventType::VREvent_ScreenshotTriggered, 517 => EVREventType::VREvent_ImageFailed, 518 => EVREventType::VREvent_DashboardOverlayCreated,
189 519 => EVREventType::VREvent_SwitchGamepadFocus,
190
191 520 => EVREventType::VREvent_RequestScreenshot, 521 => EVREventType::VREvent_ScreenshotTaken, 522 => EVREventType::VREvent_ScreenshotFailed, 523 => EVREventType::VREvent_SubmitScreenshotToDashboard, 524 => EVREventType::VREvent_ScreenshotProgressToDashboard, 525 => EVREventType::VREvent_PrimaryDashboardDeviceChanged,
199 526 => EVREventType::VREvent_RoomViewShown, 527 => EVREventType::VREvent_RoomViewHidden, 528 => EVREventType::VREvent_ShowUI, 529 => EVREventType::VREvent_ShowDevTools, 530 => EVREventType::VREvent_DesktopViewUpdating,
204 531 => EVREventType::VREvent_DesktopViewReady,
205
206 532 => EVREventType::VREvent_StartDashboard,
207 533 => EVREventType::VREvent_ElevatePrism,
208
209 534 => EVREventType::VREvent_OverlayClosed,
210
211 600 => EVREventType::VREvent_Notification_Shown,
212 601 => EVREventType::VREvent_Notification_Hidden,
213 602 => EVREventType::VREvent_Notification_BeginInteraction,
214 603 => EVREventType::VREvent_Notification_Destroyed,
215
216 700 => EVREventType::VREvent_Quit, 701 => EVREventType::VREvent_ProcessQuit, 703 => EVREventType::VREvent_QuitAcknowledged, 704 => EVREventType::VREvent_DriverRequestedQuit, 705 => EVREventType::VREvent_RestartRequested, 706 => EVREventType::VREvent_InvalidateSwapTextureSets,
223
224 800 => EVREventType::VREvent_ChaperoneDataHasChanged, 801 => EVREventType::VREvent_ChaperoneUniverseHasChanged,
226 802 => EVREventType::VREvent_ChaperoneTempDataHasChanged, 803 => EVREventType::VREvent_ChaperoneSettingsHaveChanged,
228 804 => EVREventType::VREvent_SeatedZeroPoseReset,
229 805 => EVREventType::VREvent_ChaperoneFlushCache, 806 => EVREventType::VREvent_ChaperoneRoomSetupStarting, 807 => EVREventType::VREvent_ChaperoneRoomSetupFinished, 808 => EVREventType::VREvent_StandingZeroPoseReset,
233
234 820 => EVREventType::VREvent_AudioSettingsHaveChanged,
235
236 850 => EVREventType::VREvent_BackgroundSettingHasChanged,
237 851 => EVREventType::VREvent_CameraSettingsHaveChanged,
238 852 => EVREventType::VREvent_ReprojectionSettingHasChanged,
239 853 => EVREventType::VREvent_ModelSkinSettingsHaveChanged,
240 854 => EVREventType::VREvent_EnvironmentSettingsHaveChanged,
241 855 => EVREventType::VREvent_PowerSettingsHaveChanged,
242 856 => EVREventType::VREvent_EnableHomeAppSettingsHaveChanged,
243 857 => EVREventType::VREvent_SteamVRSectionSettingChanged,
244 858 => EVREventType::VREvent_LighthouseSectionSettingChanged,
245 859 => EVREventType::VREvent_NullSectionSettingChanged,
246 860 => EVREventType::VREvent_UserInterfaceSectionSettingChanged,
247 861 => EVREventType::VREvent_NotificationsSectionSettingChanged,
248 862 => EVREventType::VREvent_KeyboardSectionSettingChanged,
249 863 => EVREventType::VREvent_PerfSectionSettingChanged,
250 864 => EVREventType::VREvent_DashboardSectionSettingChanged,
251 865 => EVREventType::VREvent_WebInterfaceSectionSettingChanged,
252 866 => EVREventType::VREvent_TrackersSectionSettingChanged,
253 867 => EVREventType::VREvent_LastKnownSectionSettingChanged,
254 868 => EVREventType::VREvent_DismissedWarningsSectionSettingChanged,
255 869 => EVREventType::VREvent_GpuSpeedSectionSettingChanged,
256 870 => EVREventType::VREvent_WindowsMRSectionSettingChanged,
257 871 => EVREventType::VREvent_OtherSectionSettingChanged,
258
259 900 => EVREventType::VREvent_StatusUpdate,
260
261 950 => EVREventType::VREvent_WebInterface_InstallDriverCompleted,
262
263 1000 => EVREventType::VREvent_MCImageUpdated,
264
265 1100 => EVREventType::VREvent_FirmwareUpdateStarted,
266 1101 => EVREventType::VREvent_FirmwareUpdateFinished,
267
268 1200 => EVREventType::VREvent_KeyboardClosed,
269 1201 => EVREventType::VREvent_KeyboardCharInput,
270 1202 => EVREventType::VREvent_KeyboardDone, 1303 => EVREventType::VREvent_ApplicationListUpdated,
276 1304 => EVREventType::VREvent_ApplicationMimeTypeLoad,
277 1306 => EVREventType::VREvent_ProcessConnected,
279 1307 => EVREventType::VREvent_ProcessDisconnected,
280
281 1410 => EVREventType::VREvent_Compositor_ChaperoneBoundsShown,
284 1411 => EVREventType::VREvent_Compositor_ChaperoneBoundsHidden,
285 1412 => EVREventType::VREvent_Compositor_DisplayDisconnected,
286 1413 => EVREventType::VREvent_Compositor_DisplayReconnected,
287 1414 => EVREventType::VREvent_Compositor_HDCPError, 1415 => EVREventType::VREvent_Compositor_ApplicationNotResponding,
289 1416 => EVREventType::VREvent_Compositor_ApplicationResumed,
290 1417 => EVREventType::VREvent_Compositor_OutOfVideoMemory,
291 1418 => EVREventType::VREvent_Compositor_DisplayModeNotSupported, 1419 => EVREventType::VREvent_Compositor_StageOverrideReady,
293 1420 => EVREventType::VREvent_Compositor_RequestDisconnectReconnect,
294
295 1500 => EVREventType::VREvent_TrackedCamera_StartVideoStream,
296 1501 => EVREventType::VREvent_TrackedCamera_StopVideoStream,
297 1502 => EVREventType::VREvent_TrackedCamera_PauseVideoStream,
298 1503 => EVREventType::VREvent_TrackedCamera_ResumeVideoStream,
299 1550 => EVREventType::VREvent_TrackedCamera_EditingSurface,
300
301 1600 => EVREventType::VREvent_PerformanceTest_EnableCapture,
302 1601 => EVREventType::VREvent_PerformanceTest_DisableCapture,
303 1602 => EVREventType::VREvent_PerformanceTest_FidelityLevel,
304
305 1650 => EVREventType::VREvent_MessageOverlay_Closed,
306 1651 => EVREventType::VREvent_MessageOverlayCloseRequested,
307
308 1700 => EVREventType::VREvent_Input_HapticVibration, 1701 => EVREventType::VREvent_Input_BindingLoadFailed, 1702 => EVREventType::VREvent_Input_BindingLoadSuccessful, 1703 => EVREventType::VREvent_Input_ActionManifestReloaded, 1704 => EVREventType::VREvent_Input_ActionManifestLoadFailed, 1705 => EVREventType::VREvent_Input_ProgressUpdate, 1706 => EVREventType::VREvent_Input_TrackerActivated,
315 1707 => EVREventType::VREvent_Input_BindingsUpdated,
316 1708 => EVREventType::VREvent_Input_BindingSubscriptionChanged,
317
318 1800 => EVREventType::VREvent_SpatialAnchors_PoseUpdated, 1801 => EVREventType::VREvent_SpatialAnchors_DescriptorUpdated, 1802 => EVREventType::VREvent_SpatialAnchors_RequestPoseUpdate, 1803 => EVREventType::VREvent_SpatialAnchors_RequestDescriptorUpdate, 1900 => EVREventType::VREvent_SystemReport_Started, 2000 => EVREventType::VREvent_Monitor_ShowHeadsetView, 2001 => EVREventType::VREvent_Monitor_HideHeadsetView, 10000 => EVREventType::VREvent_VendorSpecific_Reserved_Start,
330 19999 => EVREventType::VREvent_VendorSpecific_Reserved_End,
331 _ => return Err(()),
332 })
333 }
334}
335
336impl EVROverlayError {
337 pub fn into_result(self) -> Result<(), Self> {
338 if self == EVROverlayError::VROverlayError_None {
339 Ok(())
340 } else {
341 Err(self)
342 }
343 }
344}
345
346impl std::fmt::Debug for EVROverlayError {
347 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
348 match self {
349 Self::VROverlayError_None => write!(f, "VROverlayError_None"),
350 Self::VROverlayError_UnknownOverlay => write!(f, "VROverlayError_UnknownOverlay"),
351 Self::VROverlayError_InvalidHandle => write!(f, "VROverlayError_InvalidHandle"),
352 Self::VROverlayError_PermissionDenied => write!(f, "VROverlayError_PermissionDenied"),
353 Self::VROverlayError_OverlayLimitExceeded => {
354 write!(f, "VROverlayError_OverlayLimitExceeded")
355 }
356 Self::VROverlayError_WrongVisibilityType => {
357 write!(f, "VROverlayError_WrongVisibilityType")
358 }
359 Self::VROverlayError_KeyTooLong => write!(f, "VROverlayError_KeyTooLong"),
360 Self::VROverlayError_NameTooLong => write!(f, "VROverlayError_NameTooLong"),
361 Self::VROverlayError_KeyInUse => write!(f, "VROverlayError_KeyInUse"),
362 Self::VROverlayError_WrongTransformType => {
363 write!(f, "VROverlayError_WrongTransformType")
364 }
365 Self::VROverlayError_InvalidTrackedDevice => {
366 write!(f, "VROverlayError_InvalidTrackedDevice")
367 }
368 Self::VROverlayError_InvalidParameter => write!(f, "VROverlayError_InvalidParameter"),
369 Self::VROverlayError_ThumbnailCantBeDestroyed => {
370 write!(f, "VROverlayError_ThumbnailCantBeDestroyed")
371 }
372 Self::VROverlayError_ArrayTooSmall => write!(f, "VROverlayError_ArrayTooSmall"),
373 Self::VROverlayError_RequestFailed => write!(f, "VROverlayError_RequestFailed"),
374 Self::VROverlayError_InvalidTexture => write!(f, "VROverlayError_InvalidTexture"),
375 Self::VROverlayError_UnableToLoadFile => write!(f, "VROverlayError_UnableToLoadFile"),
376 Self::VROverlayError_KeyboardAlreadyInUse => {
377 write!(f, "VROverlayError_KeyboardAlreadyInUse")
378 }
379 Self::VROverlayError_NoNeighbor => write!(f, "VROverlayError_NoNeighbor"),
380 Self::VROverlayError_TooManyMaskPrimitives => {
381 write!(f, "VROverlayError_TooManyMaskPrimitives")
382 }
383 Self::VROverlayError_BadMaskPrimitive => write!(f, "VROverlayError_BadMaskPrimitive"),
384 Self::VROverlayError_TextureAlreadyLocked => {
385 write!(f, "VROverlayError_TextureAlreadyLocked")
386 }
387 Self::VROverlayError_TextureLockCapacityReached => {
388 write!(f, "VROverlayError_TextureLockCapacityReached")
389 }
390 Self::VROverlayError_TextureNotLocked => write!(f, "VROverlayError_TextureNotLocked"),
391 Self::VROverlayError_TimedOut => write!(f, "VROverlayError_TimedOut"),
392 }
393 }
394}
395
396impl std::fmt::Display for EVROverlayError {
397 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
398 <Self as std::fmt::Debug>::fmt(self, f)
399 }
400}
401
402impl std::error::Error for EVROverlayError {}
403
404impl std::fmt::Debug for ETrackedPropertyError {
405 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
406 use ETrackedPropertyError::*;
407 match self {
408 TrackedProp_Success => write!(f, "TrackedProp_Success"),
409 TrackedProp_WrongDataType => write!(f, "TrackedProp_WrongDataType"),
410 TrackedProp_WrongDeviceClass => write!(f, "TrackedProp_WrongDeviceClass"),
411 TrackedProp_BufferTooSmall => write!(f, "TrackedProp_BufferTooSmall"),
412 TrackedProp_UnknownProperty => write!(f, "TrackedProp_UnknownProperty"),
413 TrackedProp_InvalidDevice => write!(f, "TrackedProp_InvalidDevice"),
414 TrackedProp_CouldNotContactServer => write!(f, "TrackedProp_CouldNotContactServer"),
415 TrackedProp_ValueNotProvidedByDevice => {
416 write!(f, "TrackedProp_ValueNotProvidedByDevice")
417 }
418 TrackedProp_StringExceedsMaximumLength => {
419 write!(f, "TrackedProp_StringExceedsMaximumLength")
420 }
421 TrackedProp_NotYetAvailable => write!(f, "TrackedProp_NotYetAvailable"),
422 TrackedProp_PermissionDenied => write!(f, "TrackedProp_PermissionDenied"),
423 TrackedProp_InvalidOperation => write!(f, "TrackedProp_InvalidOperation"),
424 TrackedProp_CannotWriteToWildcards => write!(f, "TrackedProp_CannotWriteToWildcards"),
425 TrackedProp_IPCReadFailure => write!(f, "TrackedProp_IPCReadFailure"),
426 TrackedProp_OutOfMemory => write!(f, "TrackedProp_OutOfMemory"),
427 TrackedProp_InvalidContainer => write!(f, "TrackedProp_InvalidContainer"),
428 }
429 }
430}
431
432impl std::fmt::Display for ETrackedPropertyError {
433 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
434 <Self as std::fmt::Debug>::fmt(self, f)
435 }
436}
437
438impl ETrackedPropertyError {
439 pub fn into_result(self) -> Result<(), Self> {
440 if self == ETrackedPropertyError::TrackedProp_Success {
441 Ok(())
442 } else {
443 Err(self)
444 }
445 }
446}
447
448impl std::error::Error for ETrackedPropertyError {}
449
450impl std::fmt::Debug for EVRInputError {
451 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
452 use EVRInputError::*;
453 match self {
454 VRInputError_None => write!(f, "VRInputError_None"),
455 VRInputError_NameNotFound => write!(f, "VRInputError_NameNotFound"),
456 VRInputError_WrongType => write!(f, "VRInputError_WrongType"),
457 VRInputError_InvalidHandle => write!(f, "VRInputError_InvalidHandle"),
458 VRInputError_InvalidParam => write!(f, "VRInputError_InvalidParam"),
459 VRInputError_NoSteam => write!(f, "VRInputError_NoSteam"),
460 VRInputError_MaxCapacityReached => write!(f, "VRInputError_MaxCapacityReached"),
461 VRInputError_IPCError => write!(f, "VRInputError_IPCError"),
462 VRInputError_NoActiveActionSet => write!(f, "VRInputError_NoActiveActionSet"),
463 VRInputError_InvalidDevice => write!(f, "VRInputError_InvalidDevice"),
464 VRInputError_InvalidSkeleton => write!(f, "VRInputError_InvalidSkeleton"),
465 VRInputError_InvalidBoneCount => write!(f, "VRInputError_InvalidBoneCount"),
466 VRInputError_InvalidCompressedData => write!(f, "VRInputError_InvalidCompressedData"),
467 VRInputError_NoData => write!(f, "VRInputError_NoData"),
468 VRInputError_BufferTooSmall => write!(f, "VRInputError_BufferTooSmall"),
469 VRInputError_MismatchedActionManifest => {
470 write!(f, "VRInputError_MismatchedActionManifest")
471 }
472 VRInputError_MissingSkeletonData => write!(f, "VRInputError_MissingSkeletonData"),
473 VRInputError_InvalidBoneIndex => write!(f, "VRInputError_InvalidBoneIndex"),
474 VRInputError_InvalidPriority => write!(f, "VRInputError_InvalidPriority"),
475 VRInputError_PermissionDenied => write!(f, "VRInputError_PermissionDenied"),
476 VRInputError_InvalidRenderModel => write!(f, "VRInputError_InvalidRenderModel"),
477 }
478 }
479}
480
481impl std::fmt::Display for EVRInputError {
482 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
483 <Self as std::fmt::Debug>::fmt(self, f)
484 }
485}
486
487impl std::error::Error for EVRInputError {}
488
489impl EVRInputError {
490 pub fn into_result(self) -> Result<(), Self> {
491 if self == EVRInputError::VRInputError_None {
492 Ok(())
493 } else {
494 Err(self)
495 }
496 }
497}
498
499impl EVRInitError {
500 pub fn into_result(self) -> Result<(), Self> {
501 if self == EVRInitError::VRInitError_None {
502 Ok(())
503 } else {
504 Err(self)
505 }
506 }
507}
508
509impl std::fmt::Debug for EVRInitError {
510 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
511 match self {
512 _ => write!(f, "VRInitError_Unknown"),
513 }
514 }
515}
516
517impl std::fmt::Display for EVRInitError {
518 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
519 <Self as std::fmt::Debug>::fmt(self, f)
520 }
521}
522
523impl std::error::Error for EVRInitError {}
524
525impl<T: num::NumCast + num::Float + num::Zero + num::One + nalgebra::Scalar> From<&'_ HmdMatrix34_t>
526 for nalgebra::Matrix4<T>
527{
528 fn from(m: &HmdMatrix34_t) -> nalgebra::Matrix4<T> {
529 let mut tmp = [[T::nan(); 4]; 4];
531 for i in 0..3 {
532 for j in 0..4 {
533 tmp[j][i] = T::from(m.m[i][j]).unwrap();
534 }
535 }
536 for i in 0..3 {
537 tmp[i][3] = T::zero();
538 }
539 tmp[3][3] = T::one();
540 tmp.into()
541 }
542}
543
544impl<T: num::NumCast + num::Float + num::Zero + num::One + nalgebra::Scalar> From<HmdMatrix34_t>
545 for nalgebra::Matrix4<T>
546{
547 fn from(m: HmdMatrix34_t) -> nalgebra::Matrix4<T> {
548 Self::from(&m)
549 }
550}
551
552impl<T: num::ToPrimitive> From<&'_ nalgebra::Matrix4<T>> for HmdMatrix34_t {
553 fn from(m: &nalgebra::Matrix4<T>) -> Self {
554 let mut ret = unsafe { std::mem::MaybeUninit::<Self>::zeroed().assume_init() };
555 for i in 0..3 {
556 for j in 0..4 {
557 ret.m[i][j] = m[(i, j)].to_f32().unwrap();
558 }
559 }
560 ret
561 }
562}