scx_utils/
mangoapp.rs

1// Copyright (c) Meta Platforms, Inc. and affiliates.
2
3// This software may be used and distributed according to the terms of the
4// GNU General Public License version 2.
5
6pub const MANGOAPP_PROJ_ID: i32 = 65;
7
8#[derive(Debug, Copy, Clone)]
9#[repr(C, packed)]
10pub struct mangoapp_msg_header {
11    pub msg_type: libc::c_long,
12    pub version: u32,
13}
14
15#[derive(Debug, Copy, Clone)]
16#[repr(C, packed)]
17pub struct mangoapp_msg_v1 {
18    pub header: mangoapp_msg_header,
19    pub pid: u32,
20    pub app_frametime_ns: u64,
21    pub fsr_upscale: u8,
22    pub fsr_sharpness: u8,
23    pub visible_frametime_ns: u64,
24    pub latency_ns: u64,
25    pub output_width: u32,
26    pub output_height: u32,
27    pub display_refresh: u16,
28    b_app_wants_hdr_steam_focused: u8, // Packs bAppWantsHDR and bSteamFocused
29    pub engine_name: [libc::c_char; 40],
30}
31
32impl mangoapp_msg_v1 {
33    const B_APP_WANTS_HDR_MASK: u8 = 0b0000_0001;
34    const B_STEAM_FOCUSED_MASK: u8 = 0b0000_0010;
35
36    #[inline]
37    pub fn wants_hdr(&self) -> bool {
38        (self.b_app_wants_hdr_steam_focused & Self::B_APP_WANTS_HDR_MASK) != 0
39    }
40
41    #[inline]
42    pub fn set_wants_hdr(&mut self, value: bool) {
43        if value {
44            self.b_app_wants_hdr_steam_focused |= Self::B_APP_WANTS_HDR_MASK;
45        } else {
46            self.b_app_wants_hdr_steam_focused &= !Self::B_APP_WANTS_HDR_MASK;
47        }
48    }
49
50    #[inline]
51    pub fn steam_focused(&self) -> bool {
52        (self.b_app_wants_hdr_steam_focused & Self::B_STEAM_FOCUSED_MASK) != 0
53    }
54
55    #[inline]
56    pub fn set_steam_focused(&mut self, value: bool) {
57        if value {
58            self.b_app_wants_hdr_steam_focused |= Self::B_STEAM_FOCUSED_MASK;
59        } else {
60            self.b_app_wants_hdr_steam_focused &= !Self::B_STEAM_FOCUSED_MASK;
61        }
62    }
63}
64
65#[repr(C, packed)]
66#[derive(Debug, Copy, Clone)]
67pub struct mangoapp_ctrl_header {
68    pub msg_type: libc::c_long,
69    pub ctrl_msg_type: u32,
70    pub version: u32,
71}
72
73#[repr(C, packed)]
74#[derive(Debug, Copy, Clone)]
75pub struct mangoapp_ctrl_msgid1_v1 {
76    pub hdr: mangoapp_ctrl_header,
77    pub no_display: u8,
78    pub log_session: u8,
79    pub log_session_name: [libc::c_char; 64],
80    pub reload_config: u8,
81}