rust_libretro_sys/
lib.rs

1#![no_std]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5#![doc(
6    html_logo_url = "https://raw.githubusercontent.com/max-m/rust-libretro/master/media/logo.png",
7    html_favicon_url = "https://raw.githubusercontent.com/max-m/rust-libretro/master/media/favicon.png"
8)]
9
10use core::fmt::Display;
11use rust_libretro_sys_proc::TryFromPrimitive;
12
13include!(concat!(env!("OUT_DIR"), "/bindings_libretro.rs"));
14
15#[cfg(feature = "vulkan")]
16pub mod vulkan;
17
18#[cfg(feature = "vulkan")]
19use vulkan::*;
20
21#[cfg(feature = "vulkan")]
22include!(concat!(env!("OUT_DIR"), "/bindings_libretro_vulkan.rs"));
23
24/// #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)
25#[macro_export]
26macro_rules! RETRO_DEVICE_SUBCLASS {
27    ($base:expr, $id:expr) => {
28        (($id + 1) << RETRO_DEVICE_TYPE_SHIFT) | $base
29    };
30}
31
32#[deprecated = "This uses relative positions. Use `RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X` instead."]
33pub const RETRO_DEVICE_ID_LIGHTGUN_X: u32 = 0;
34#[deprecated = "This uses relative positions. Use `RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y` instead."]
35pub const RETRO_DEVICE_ID_LIGHTGUN_Y: u32 = 1;
36#[deprecated = "Use `RETRO_DEVICE_ID_LIGHTGUN_AUX_A` instead."]
37pub const RETRO_DEVICE_ID_LIGHTGUN_CURSOR: u32 = 3;
38#[deprecated = "Use `RETRO_DEVICE_ID_LIGHTGUN_AUX_B` instead."]
39pub const RETRO_DEVICE_ID_LIGHTGUN_TURBO: u32 = 4;
40#[deprecated = "Use `RETRO_DEVICE_ID_LIGHTGUN_START` instead."]
41pub const RETRO_DEVICE_ID_LIGHTGUN_PAUSE: u32 = 5;
42
43/// Pass this to [`retro_video_refresh_t`] if rendering to hardware.
44/// Passing NULL to [`retro_video_refresh_t`] is still a frame dupe as normal.
45///
46/// For some reason bindgen did not export this #define
47pub const RETRO_HW_FRAME_BUFFER_VALID: *mut core::ffi::c_void = -1_i32 as *mut core::ffi::c_void;
48
49#[derive(Debug, Default)]
50pub struct InvalidEnumValue<T: Display>(T);
51
52impl<T: Display> InvalidEnumValue<T> {
53    pub fn new(value: T) -> Self {
54        InvalidEnumValue(value)
55    }
56}
57
58impl<T: Display> Display for InvalidEnumValue<T> {
59    fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
60        writeln!(fmt, "Invalid enum value: {}", self.0)
61    }
62}