commonlibsse_ng\re\c/
CharEvent.rs

1use crate::re::InputEvent::{InputEvent, InputEventVtbl};
2use crate::re::offsets_rtti::RTTI_CharEvent;
3use crate::re::offsets_vtable::VTABLE_CharEvent;
4use crate::rel::ResolvableAddress as _;
5use crate::rel::id::{DataBaseError, VariantID};
6
7#[repr(C)]
8#[derive(Debug, PartialEq)]
9pub struct CharEvent {
10    pub __base: InputEvent, // 0x00
11    pub keyCode: u32,       // 0x18
12    pub pad1C: u32,         // 0x1C
13}
14const _: () = assert!(core::mem::size_of::<CharEvent>() == 0x20);
15
16impl CharEvent {
17    /// Address & offset of RTTI for `CharEvent`.
18    pub const RTTI: VariantID = RTTI_CharEvent;
19
20    /// Address & offset of Virtual function table.
21    pub const VTABLE: [VariantID; 1] = VTABLE_CharEvent;
22
23    /// # Errors
24    pub fn vtable() -> Result<&'static CharEventVtbl, DataBaseError> {
25        Self::VTABLE[0].address().map(|vtable| unsafe { vtable.cast().as_ref() })
26    }
27
28    #[inline]
29    pub const fn init(&mut self, key_code: u32) {
30        self.keyCode = key_code;
31    }
32}
33
34pub struct CharEventVtbl {
35    pub __base: InputEventVtbl, // 0x00
36}