1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Event;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::mem;

glib::wrapper! {
    /// An event related to a pad-based device.
    #[doc(alias = "GdkPadEvent")]
    pub struct PadEvent(Shared<ffi::GdkPadEvent>);

    match fn {
        ref => |ptr| ffi::gdk_event_ref(ptr as *mut ffi::GdkEvent),
        unref => |ptr| ffi::gdk_event_unref(ptr as *mut ffi::GdkEvent),
    }
}

impl glib::StaticType for PadEvent {
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gdk_pad_event_get_type()) }
    }
}

impl PadEvent {
    /// Extracts the information from a pad strip or ring event.
    ///
    /// # Returns
    ///
    ///
    /// ## `index`
    /// Return location for the axis index
    ///
    /// ## `value`
    /// Return location for the axis value
    #[doc(alias = "gdk_pad_event_get_axis_value")]
    #[doc(alias = "get_axis_value")]
    pub fn axis_value(&self) -> (u32, f64) {
        unsafe {
            let mut index = mem::MaybeUninit::uninit();
            let mut value = mem::MaybeUninit::uninit();
            ffi::gdk_pad_event_get_axis_value(
                self.to_glib_none().0,
                index.as_mut_ptr(),
                value.as_mut_ptr(),
            );
            (index.assume_init(), value.assume_init())
        }
    }

    /// Extracts information about the pressed button from
    /// a pad event.
    ///
    /// # Returns
    ///
    /// the button of @self
    #[doc(alias = "gdk_pad_event_get_button")]
    #[doc(alias = "get_button")]
    pub fn button(&self) -> u32 {
        unsafe { ffi::gdk_pad_event_get_button(self.to_glib_none().0) }
    }

    /// Extracts group and mode information from a pad event.
    ///
    /// # Returns
    ///
    ///
    /// ## `group`
    /// return location for the group
    ///
    /// ## `mode`
    /// return location for the mode
    #[doc(alias = "gdk_pad_event_get_group_mode")]
    #[doc(alias = "get_group_mode")]
    pub fn group_mode(&self) -> (u32, u32) {
        unsafe {
            let mut group = mem::MaybeUninit::uninit();
            let mut mode = mem::MaybeUninit::uninit();
            ffi::gdk_pad_event_get_group_mode(
                self.to_glib_none().0,
                group.as_mut_ptr(),
                mode.as_mut_ptr(),
            );
            (group.assume_init(), mode.assume_init())
        }
    }
}

impl fmt::Display for PadEvent {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("PadEvent")
    }
}