2
2
3
3
use crate :: proto:: unsafe_protocol;
4
4
use crate :: { Event , Result , Status , StatusExt } ;
5
+ use uefi_raw:: protocol:: console:: SimplePointerProtocol ;
5
6
6
7
/// Provides information about a pointer device.
7
- #[ repr( C ) ]
8
- #[ unsafe_protocol( "31878c87-0b75-11d5-9a4f-0090273fc14d" ) ]
9
- pub struct Pointer {
10
- reset : unsafe extern "efiapi" fn ( this : & mut Pointer , ext_verif : bool ) -> Status ,
11
- get_state : unsafe extern "efiapi" fn ( this : & Pointer , state : * mut PointerState ) -> Status ,
12
- wait_for_input : Option < Event > ,
13
- mode : * const PointerMode ,
14
- }
8
+ #[ repr( transparent) ]
9
+ #[ unsafe_protocol( SimplePointerProtocol :: GUID ) ]
10
+ pub struct Pointer ( SimplePointerProtocol ) ;
15
11
16
12
impl Pointer {
17
13
/// Resets the pointer device hardware.
@@ -23,7 +19,7 @@ impl Pointer {
23
19
///
24
20
/// - `DeviceError` if the device is malfunctioning and cannot be reset.
25
21
pub fn reset ( & mut self , extended_verification : bool ) -> Result {
26
- unsafe { ( self . reset ) ( self , extended_verification) } . to_result ( )
22
+ unsafe { ( self . 0 . reset ) ( & mut self . 0 , extended_verification) } . to_result ( )
27
23
}
28
24
29
25
/// Retrieves the pointer device's current state, if a state change occurred
@@ -36,8 +32,9 @@ impl Pointer {
36
32
/// - `DeviceError` if there was an issue with the pointer device.
37
33
pub fn read_state ( & mut self ) -> Result < Option < PointerState > > {
38
34
let mut pointer_state = PointerState :: default ( ) ;
35
+ let pointer_state_ptr: * mut _ = & mut pointer_state;
39
36
40
- match unsafe { ( self . get_state ) ( self , & mut pointer_state ) } {
37
+ match unsafe { ( self . 0 . get_state ) ( & mut self . 0 , pointer_state_ptr . cast ( ) ) } {
41
38
Status :: NOT_READY => Ok ( None ) ,
42
39
other => other. to_result_with_val ( || Some ( pointer_state) ) ,
43
40
}
@@ -46,14 +43,14 @@ impl Pointer {
46
43
/// Event to be used with `BootServices::wait_for_event()` in order to wait
47
44
/// for input from the pointer device
48
45
#[ must_use]
49
- pub const fn wait_for_input_event ( & self ) -> & Option < Event > {
50
- & self . wait_for_input
46
+ pub fn wait_for_input_event ( & self ) -> Option < Event > {
47
+ unsafe { Event :: from_ptr ( self . 0 . wait_for_input ) }
51
48
}
52
49
53
50
/// Returns a reference to the pointer device information.
54
51
#[ must_use]
55
52
pub const fn mode ( & self ) -> & PointerMode {
56
- unsafe { & * self . mode }
53
+ unsafe { & * self . 0 . mode . cast ( ) }
57
54
}
58
55
}
59
56
0 commit comments