-
-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
use ash::vk; | ||
use std::{ | ||
ffi::{c_char, CStr}, | ||
time::Instant, | ||
}; | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrFov { | ||
/// Negative, radians | ||
pub left: f32, | ||
/// Positive, radians | ||
pub right: f32, | ||
/// Positive, radians | ||
pub up: f32, | ||
/// Negative, radians | ||
pub down: f32, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrQuat { | ||
pub x: f32, | ||
pub y: f32, | ||
pub z: f32, | ||
pub w: f32, | ||
} | ||
impl Default for AlvrQuat { | ||
fn default() -> Self { | ||
Self { | ||
x: 0.0, | ||
y: 0.0, | ||
z: 0.0, | ||
w: 1.0, | ||
} | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy, Default)] | ||
pub struct AlvrPose { | ||
orientation: AlvrQuat, | ||
position: [f32; 3], | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrSpaceRelation { | ||
pub pose: AlvrPose, | ||
pub linear_velocity: [f32; 3], | ||
pub angular_velocity: [f32; 3], | ||
pub has_velocity: bool, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrJoint { | ||
relation: AlvrSpaceRelation, | ||
radius: f32, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrJointSet { | ||
values: [AlvrJoint; 26], | ||
global_hand_relation: AlvrSpaceRelation, | ||
is_active: bool, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub union AlvrInputValue { | ||
pub bool_: bool, | ||
pub float_: f32, | ||
} | ||
|
||
// the profile is implied | ||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrInput { | ||
pub id: u64, | ||
pub value: AlvrInputValue, | ||
} | ||
|
||
#[repr(u8)] | ||
#[derive(Clone, Copy)] | ||
pub enum AlvrOutput { | ||
Haptics { | ||
Check warning on line 88 in alvr/server/src/c_api.rs GitHub Actions / clippyvariant `Haptics` is never constructed
|
||
frequency: f32, | ||
amplitude: f32, | ||
duration_ns: u64, | ||
}, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrBatteryValue { | ||
pub device_id: u64, | ||
/// range [0, 1] | ||
pub value: f32, | ||
} | ||
|
||
#[repr(C)] | ||
pub enum AlvrEvent { | ||
Battery(AlvrBatteryValue), | ||
Check warning on line 105 in alvr/server/src/c_api.rs GitHub Actions / clippyvariants `Battery`, `Bounds`, `Restart`, and `Shutdown` are never constructed
|
||
Bounds([f32; 2]), | ||
Restart, | ||
Shutdown, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrTargetConfig { | ||
target_width: u32, | ||
target_height: u32, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct AlvrDeviceConfig { | ||
device_id: u64, | ||
interaction_profile_id: u64, | ||
} | ||
|
||
// Get ALVR server time. The libalvr user should provide timestamps in the provided time frame of | ||
// reference in the following functions | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_time_ns() -> u64 { | ||
Instant::now().elapsed().as_nanos() as u64 | ||
} | ||
|
||
// The libalvr user is responsible of interpreting values and calling functions using | ||
// device/input/output identifiers obtained using this function | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_path_to_id(path_string: *const c_char) -> u64 { | ||
alvr_common::hash_string(CStr::from_ptr(path_string).to_str().unwrap()) | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_initialize(out_target_config: *mut AlvrTargetConfig) { | ||
Check warning on line 140 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_target_config`
|
||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_poll_event(out_event: *mut AlvrEvent) -> bool { | ||
Check warning on line 145 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_event`
|
||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_shutdown() { | ||
todo!() | ||
} | ||
|
||
// Device API: | ||
|
||
// Use the two-call pattern to first get the array length then the array data. | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_devices(out_device_configs: *mut AlvrDeviceConfig) -> u64 { | ||
Check warning on line 158 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_device_configs`
|
||
todo!() | ||
} | ||
|
||
// After this call, previous button and tracking data is discarded | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_update_inputs(device_id: u64) { | ||
Check warning on line 164 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `device_id`
|
||
todo!() | ||
} | ||
|
||
// Use the two-call pattern to first get the array length then the array data. | ||
// Data is updated after a call to alvr_update_inputs. | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_inputs( | ||
device_id: u64, | ||
Check warning on line 172 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `device_id`
|
||
out_inputs_arr: *mut AlvrInput, | ||
Check warning on line 173 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_inputs_arr`
|
||
out_timestamp_ns: u64, | ||
Check warning on line 174 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_timestamp_ns`
|
||
) -> u64 { | ||
todo!() | ||
} | ||
|
||
// pose_id is something like /user/hand/left/input/grip/pose | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_tracked_pose( | ||
pose_id: u64, | ||
Check warning on line 182 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `pose_id`
|
||
timestamp_ns: u64, | ||
Check warning on line 183 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `timestamp_ns`
|
||
out_relation: *mut AlvrSpaceRelation, | ||
Check warning on line 184 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_relation`
|
||
) { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_hand_tracking( | ||
device_id: u64, | ||
Check warning on line 191 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `device_id`
|
||
timestamp_ns: u64, | ||
Check warning on line 192 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `timestamp_ns`
|
||
out_joint_set: *mut AlvrJointSet, | ||
Check warning on line 193 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_joint_set`
|
||
) { | ||
todo!() | ||
} | ||
|
||
// Currently only haptics is supported | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_set_output(output_id: u64, value: *const AlvrOutput) { | ||
Check warning on line 200 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `value`
Check warning on line 200 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `output_id`
|
||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_view_poses( | ||
out_head_relation: *mut AlvrSpaceRelation, | ||
Check warning on line 206 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_head_relation`
|
||
out_fov_arr: *mut AlvrFov, // 2 elements | ||
Check warning on line 207 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_fov_arr`
|
||
out_relative_pose_arr: *mut AlvrPose, // 2 elements | ||
Check warning on line 208 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_relative_pose_arr`
|
||
) { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_destroy_device(device_id: u64) { | ||
Check warning on line 214 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `device_id`
|
||
todo!() | ||
} | ||
|
||
// Compositor target API: | ||
|
||
// This should reflect the client current framerate | ||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_get_framerate() -> f32 { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_pre_vulkan() { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_post_vulkan() { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_create_vk_target_swapchain( | ||
width: u32, | ||
Check warning on line 238 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `width`
|
||
height: u32, | ||
Check warning on line 239 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `height`
|
||
color_format: vk::Format, | ||
Check warning on line 240 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `color_format`
|
||
color_space: vk::ColorSpaceKHR, | ||
Check warning on line 241 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `color_space`
|
||
image_usage: vk::ImageUsageFlags, | ||
Check warning on line 242 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `image_usage`
|
||
present_mode: vk::PresentModeKHR, | ||
Check warning on line 243 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `present_mode`
|
||
image_count: u64, | ||
Check warning on line 244 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `image_count`
|
||
) { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_acquire_image(out_swapchain_index: u64) -> vk::Result { | ||
Check warning on line 250 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `out_swapchain_index`
|
||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_present( | ||
queue: vk::Queue, | ||
Check warning on line 256 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `queue`
|
||
swapchain_index: u64, | ||
Check warning on line 257 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `swapchain_index`
|
||
timeline_semaphore_value: u64, | ||
Check warning on line 258 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `timeline_semaphore_value`
|
||
timestamp_ns: u64, | ||
Check warning on line 259 in alvr/server/src/c_api.rs GitHub Actions / clippyunused variable: `timestamp_ns`
|
||
) -> vk::Result { | ||
todo!() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn alvr_destroy_vk_target_swapchain() { | ||
todo!() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod bitrate; | ||
mod c_api; | ||
mod connection; | ||
mod face_tracking; | ||
mod hand_gestures; | ||
|