use
super::*;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
{
storage: Storage,
align: [Align; 0],
}
impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
{
#[inline]
pub fn new(storage: Storage) -> Self {
Self { storage, align: [] }
}
#[inline]
pub fn get_bit(&self, index: usize) -> bool {
debug_assert!(index / 8 < self.storage.as_ref().len());
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
let bit_index = if cfg!(target_endian = "big") {
7 - (index % 8)
} else {
index % 8
};
let mask = 1 << bit_index;
byte & mask == mask
}
#[inline]
pub fn set_bit(&mut self, index: usize, val: bool) {
debug_assert!(index / 8 < self.storage.as_ref().len());
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
let bit_index = if cfg!(target_endian = "big") {
7 - (index % 8)
} else {
index % 8
};
let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
*byte &= !mask;
}
}
#[inline]
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
let mut val = 0;
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
let index = if cfg!(target_endian = "big") {
bit_width as usize - 1 - i
} else {
i
};
val |= 1 << index;
}
}
val
}
#[inline]
pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
let index = if cfg!(target_endian = "big") {
bit_width as usize - 1 - i
} else {
i
};
self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
pub const LV_INDEV_DEF_READ_PERIOD: u32 = 30;
pub const LV_INDEV_DEF_DRAG_LIMIT: u32 = 10;
pub const LV_INDEV_DEF_DRAG_THROW: u32 = 20;
pub const LV_INDEV_DEF_LONG_PRESS_TIME: u32 = 400;
pub const LV_INDEV_DEF_LONG_PRESS_REP_TIME: u32 = 100;
pub const LV_INDEV_DEF_GESTURE_LIMIT: u32 = 50;
pub const LV_INDEV_DEF_GESTURE_MIN_VELOCITY: u32 = 3;
pub type lv_coord_t = i16;
pub type lv_indev_drv_user_data_t = *mut ::cty::c_void;
#[doc = " Represents a point on the screen."]
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_point_t {
pub x: lv_coord_t,
pub y: lv_coord_t,
}
#[doc = " Tasks execute this type type of functions."]
pub type lv_task_cb_t = ::core::option::Option<unsafe extern "C" fn(arg1: *mut _lv_task_t)>;
#[doc = " TYPEDEFS"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_task_t {
#[doc = "< How often the task should run"]
pub period: u32,
#[doc = "< Last time the task ran"]
pub last_run: u32,
#[doc = "< Task function"]
pub task_cb: lv_task_cb_t,
#[doc = "< Custom user data"]
pub user_data: *mut ::cty::c_void,
#[doc = "< 1: Task times; -1 : infinity; 0 : stop ; n>0: residual times"]
pub repeat_count: i32,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: [u8; 3usize],
}
impl Default for _lv_task_t {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl _lv_task_t {
#[inline]
pub fn prio(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 3u8) as u8) }
}
#[inline]
pub fn set_prio(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(0usize, 3u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(prio: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 3u8, {
let prio: u8 = unsafe { ::core::mem::transmute(prio) };
prio as u64
});
__bindgen_bitfield_unit
}
}
pub type lv_task_t = _lv_task_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _disp_t {
_unused: [u8; 0],
}
#[doc = "< Uninitialized state"]
pub const LV_INDEV_TYPE_NONE: _bindgen_ty_4 = 0;
#[doc = "< Touch pad, mouse, external button"]
pub const LV_INDEV_TYPE_POINTER: _bindgen_ty_4 = 1;
#[doc = "< Keypad or keyboard"]
pub const LV_INDEV_TYPE_KEYPAD: _bindgen_ty_4 = 2;
#[doc = "< External (hardware button) which is assigned to a specific point of the"]
#[doc = "screen"]
pub const LV_INDEV_TYPE_BUTTON: _bindgen_ty_4 = 3;
#[doc = "< Encoder with only Left, Right turn and a Button"]
pub const LV_INDEV_TYPE_ENCODER: _bindgen_ty_4 = 4;
#[doc = " Possible input device types"]
pub type _bindgen_ty_4 = u32;
pub type lv_indev_type_t = u8;
pub const LV_INDEV_STATE_REL: _bindgen_ty_5 = 0;
pub const LV_INDEV_STATE_PR: _bindgen_ty_5 = 1;
#[doc = " States for input devices"]
pub type _bindgen_ty_5 = u32;
pub type lv_indev_state_t = u8;
pub type lv_drag_dir_t = u8;
pub type lv_gesture_dir_t = u8;
#[doc = " Data structure passed to an input driver to fill"]
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_indev_data_t {
#[doc = "< For LV_INDEV_TYPE_POINTER the currently pressed point"]
pub point: lv_point_t,
#[doc = "< For LV_INDEV_TYPE_KEYPAD the currently pressed key"]
pub key: u32,
#[doc = "< For LV_INDEV_TYPE_BUTTON the currently pressed button"]
pub btn_id: u32,
#[doc = "< For LV_INDEV_TYPE_ENCODER number of steps since the previous read"]
pub enc_diff: i16,
#[doc = "< LV_INDEV_STATE_REL or LV_INDEV_STATE_PR"]
pub state: lv_indev_state_t,
}
#[doc = " Initialized by the user and registered by 'lv_indev_add()'"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_drv_t {
pub type_: lv_indev_type_t,
pub read_cb: ::core::option::Option<
unsafe extern "C" fn(indev_drv: *mut _lv_indev_drv_t, data: *mut lv_indev_data_t) -> bool,
>,
#[doc = " Called when an action happened on the input device."]
#[doc = " The second parameter is the event from `lv_event_t`"]
pub feedback_cb:
::core::option::Option<unsafe extern "C" fn(arg1: *mut _lv_indev_drv_t, arg2: u8)>,
pub user_data: lv_indev_drv_user_data_t,
pub disp: *mut _disp_t,
pub read_task: *mut lv_task_t,
pub drag_limit: u8,
pub drag_throw: u8,
pub gesture_min_velocity: u8,
pub gesture_limit: u8,
pub long_press_time: u16,
pub long_press_rep_time: u16,
}
impl Default for _lv_indev_drv_t {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
pub type lv_indev_drv_t = _lv_indev_drv_t;
#[doc = " Run time data of input devices"]
#[doc = " Internally used by the library, you should not need to touch it."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_proc_t {
#[doc = "< Current state of the input device."]
pub state: lv_indev_state_t,
pub types: _lv_indev_proc_t__bindgen_ty_1,
#[doc = "< Pressed time stamp"]
pub pr_timestamp: u32,
#[doc = "< Long press repeat time stamp"]
pub longpr_rep_timestamp: u32,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: [u8; 7usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union _lv_indev_proc_t__bindgen_ty_1 {
pub pointer: _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1,
pub keypad: _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_2,
_bindgen_union_align: [u64; 7usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
#[doc = "< Current point of input device."]
pub act_point: lv_point_t,
#[doc = "< Last point of input device."]
pub last_point: lv_point_t,
#[doc = "< Difference between `act_point` and `last_point`."]
pub vect: lv_point_t,
pub drag_sum: lv_point_t,
pub drag_throw_vect: lv_point_t,
pub act_obj: *mut _lv_obj_t,
pub last_obj: *mut _lv_obj_t,
pub last_pressed: *mut _lv_obj_t,
pub gesture_dir: lv_gesture_dir_t,
pub gesture_sum: lv_point_t,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: u8,
}
impl Default for _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
#[inline]
pub fn drag_limit_out(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
}
#[inline]
pub fn set_drag_limit_out(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(0usize, 1u8, val as u64)
}
}
#[inline]
pub fn drag_in_prog(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
}
#[inline]
pub fn set_drag_in_prog(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(1usize, 1u8, val as u64)
}
}
#[inline]
pub fn drag_dir(&self) -> lv_drag_dir_t {
unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 3u8) as u8) }
}
#[inline]
pub fn set_drag_dir(&mut self, val: lv_drag_dir_t) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(2usize, 3u8, val as u64)
}
}
#[inline]
pub fn gesture_sent(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) }
}
#[inline]
pub fn set_gesture_sent(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(5usize, 1u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(
drag_limit_out: u8,
drag_in_prog: u8,
drag_dir: lv_drag_dir_t,
gesture_sent: u8,
) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 1u8, {
let drag_limit_out: u8 = unsafe { ::core::mem::transmute(drag_limit_out) };
drag_limit_out as u64
});
__bindgen_bitfield_unit.set(1usize, 1u8, {
let drag_in_prog: u8 = unsafe { ::core::mem::transmute(drag_in_prog) };
drag_in_prog as u64
});
__bindgen_bitfield_unit.set(2usize, 3u8, {
let drag_dir: u8 = unsafe { ::core::mem::transmute(drag_dir) };
drag_dir as u64
});
__bindgen_bitfield_unit.set(5usize, 1u8, {
let gesture_sent: u8 = unsafe { ::core::mem::transmute(gesture_sent) };
gesture_sent as u64
});
__bindgen_bitfield_unit
}
}
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_2 {
pub last_state: lv_indev_state_t,
pub last_key: u32,
}
impl Default for _lv_indev_proc_t__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl Default for _lv_indev_proc_t {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl _lv_indev_proc_t {
#[inline]
pub fn long_pr_sent(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
}
#[inline]
pub fn set_long_pr_sent(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(0usize, 1u8, val as u64)
}
}
#[inline]
pub fn reset_query(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
}
#[inline]
pub fn set_reset_query(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(1usize, 1u8, val as u64)
}
}
#[inline]
pub fn disabled(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
}
#[inline]
pub fn set_disabled(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(2usize, 1u8, val as u64)
}
}
#[inline]
pub fn wait_until_release(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) }
}
#[inline]
pub fn set_wait_until_release(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(3usize, 1u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(
long_pr_sent: u8,
reset_query: u8,
disabled: u8,
wait_until_release: u8,
) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 1u8, {
let long_pr_sent: u8 = unsafe { ::core::mem::transmute(long_pr_sent) };
long_pr_sent as u64
});
__bindgen_bitfield_unit.set(1usize, 1u8, {
let reset_query: u8 = unsafe { ::core::mem::transmute(reset_query) };
reset_query as u64
});
__bindgen_bitfield_unit.set(2usize, 1u8, {
let disabled: u8 = unsafe { ::core::mem::transmute(disabled) };
disabled as u64
});
__bindgen_bitfield_unit.set(3usize, 1u8, {
let wait_until_release: u8 = unsafe { ::core::mem::transmute(wait_until_release) };
wait_until_release as u64
});
__bindgen_bitfield_unit
}
}
pub type lv_indev_proc_t = _lv_indev_proc_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_group_t {
_unused: [u8; 0],
}
#[doc = " The main input device descriptor with driver, runtime data ('proc') and some additional"]
#[doc = " information"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_t {
pub driver: lv_indev_drv_t,
pub proc_: lv_indev_proc_t,
#[doc = "< Cursor for LV_INPUT_TYPE_POINTER"]
pub cursor: *mut _lv_obj_t,
#[doc = "< Keypad destination group"]
pub group: *mut _lv_group_t,
#[doc = "< Array points assigned to the button ()screen will be pressed"]
#[doc = "here by the buttons"]
pub btn_points: *const lv_point_t,
}
impl Default for _lv_indev_t {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
pub type lv_indev_t = _lv_indev_t;
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Initialize an input device driver with default values."]
#[doc = " It is used to surly have known values in the fields ant not memory junk."]
#[doc = " After it you can set the fields."]
#[doc = " - __`driver`__: pointer to driver variable to initialize"]
pub fn lv_indev_drv_init(driver: *mut lv_indev_drv_t);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Register an initialized input device driver."]
#[doc = " - __`driver`__: pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)"]
#[doc = " Return: pointer to the new input device or NULL on error"]
pub fn lv_indev_drv_register(driver: *mut lv_indev_drv_t) -> *mut lv_indev_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Update the driver in run time."]
#[doc = " - __`indev`__: pointer to a input device. (return value of `lv_indev_drv_register`)"]
#[doc = " - __`new_drv`__: pointer to the new driver"]
pub fn lv_indev_drv_update(indev: *mut lv_indev_t, new_drv: *mut lv_indev_drv_t);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Get the next input device."]
#[doc = " - __`indev`__: pointer to the current input device. NULL to initialize."]
#[doc = " Return: the next input devise or NULL if no more. Give the first input device when the parameter"]
#[doc = " is NULL"]
pub fn lv_indev_get_next(indev: *mut lv_indev_t) -> *mut lv_indev_t;
}