Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.96 KB | None | 0 0
  1. extern crate libc;
  2. use libc::{c_char, c_int, c_float};
  3. #[repr(C)]
  4. #[derive(Clone, Copy)]
  5. struct ohmd_context;
  6. #[repr(C)]
  7. #[derive(Clone, Copy)]
  8. struct ohmd_device;
  9. enum ohmd_float_value{
  10.     OHMD_ROTATION_QUAT
  11. }
  12.  
  13. #[link(name = "openhmd")]
  14. extern {
  15.     fn ohmd_ctx_create() -> ohmd_context;
  16.     fn ohmd_ctx_destroy(ctx: ohmd_context) -> ohmd_context;
  17.     fn ohmd_ctx_get_error(ctx: ohmd_context) -> c_char;
  18.     fn ohmd_ctx_probe(ctx: ohmd_context) -> c_int;
  19.     fn ohmd_ctx_update(ctx: ohmd_context);
  20.     fn ohmd_device_getf(device: ohmd_device, otype: ohmd_float_value, out: c_float) -> c_int;
  21.     fn ohmd_list_open_device(ctx: ohmd_context, index: c_int) -> ohmd_device;
  22. }
  23.  
  24. pub fn test(){
  25.     unsafe{
  26.         let contex = ohmd_ctx_create();
  27.         let probe = ohmd_ctx_probe(contex);
  28.         println!("ohmd_ctx_get_error {} ; ohmd_ctx_probe {}", ohmd_ctx_get_error(contex), probe);
  29.         let device = ohmd_list_open_device(contex, probe);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement