• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 //! rust input binding sys
17 
18 #![allow(dead_code)]
19 
20 /// struct CPointerEvent
21 #[repr(C)]
22 pub struct CPointerEvent {
23     /// Corresponding to the C-side 'void' type, one way to avoid using 'unsafe'
24     _private: [u8; 0],
25 }
26 
27 /// struct CKeyEvent
28 #[repr(C)]
29 pub struct CKeyEvent {
30     /// Corresponding to the C-side 'void' type, one way to avoid using 'unsafe'
31     _private: [u8; 0],
32 }
33 
34 /// struct CAxisEvent
35 #[repr(C)]
36 pub struct CAxisEvent {
37     /// Corresponding to the C-side 'void' type, one way to avoid using 'unsafe'
38     _private: [u8; 0],
39 }
40 
41 /// struct CPointerStyleColor
42 #[repr(C)]
43 pub struct CPointerStyleColor {
44     /// Pointer style color r property
45     pub r: u8,
46     /// Pointer style color g property
47     pub g: u8,
48     /// Pointer style color b property
49     pub b: u8,
50 }
51 
52 /// struct CPointerStyle
53 #[repr(C)]
54 pub struct CPointerStyle {
55     /// Pointer style size property
56     pub size: i32,
57     /// Pointer style color property
58     pub color: CPointerStyleColor,
59     /// Pointer style id property
60     pub id: i32,
61 }
62 
63 /// struct CExtraData
64 #[repr(C)]
65 pub struct CExtraData {
66     /// Extra data appended property
67     pub appended: bool,
68     /// Extra data buffer property
69     pub buffer: *const u8,
70     /// Extra data buffer_size property
71     pub buffer_size: usize,
72     /// Extra data source_type property
73     pub source_type: i32,
74     /// Extra data pointer_id property
75     pub pointer_id: i32,
76 }
77 
78 // Callback function type for OnPointerEventCallback() from native,
79 // this callback is invoked when listening for a pointer event.
80 pub type OnPointerEventCallback = unsafe extern "C" fn(
81     event: *const CPointerEvent
82 );
83 
84 // C interface for pointer event
85 extern "C" {
CGetPointerId(event: *const CPointerEvent) -> i3286     pub fn CGetPointerId(event: *const CPointerEvent) -> i32;
CGetPointerAction(event: *const CPointerEvent) -> i3287     pub fn CGetPointerAction(event: *const CPointerEvent) -> i32;
CGetTargetWindowId(event: *const CPointerEvent) -> i3288     pub fn CGetTargetWindowId(event: *const CPointerEvent) -> i32;
CGetSourceType(event: *const CPointerEvent) -> i3289     pub fn CGetSourceType(event: *const CPointerEvent) -> i32;
CGetTargetDisplayId(event: *const CPointerEvent) -> i3290     pub fn CGetTargetDisplayId(event: *const CPointerEvent) -> i32;
CGetDisplayX(event: *const CPointerEvent) -> i3291     pub fn CGetDisplayX(event: *const CPointerEvent) -> i32;
CGetDisplayY(event: *const CPointerEvent) -> i3292     pub fn CGetDisplayY(event: *const CPointerEvent) -> i32;
CPointerEventAddFlag(event: *const CPointerEvent)93     pub fn CPointerEventAddFlag(event: *const CPointerEvent);
CGetDeviceId(event: *const CPointerEvent) -> i3294     pub fn CGetDeviceId(event: *const CPointerEvent) -> i32;
CGetWindowPid(event: *const CPointerEvent) -> i3295     pub fn CGetWindowPid(event: *const CPointerEvent) -> i32;
96 }
97 
98 // C interface for key event
99 extern "C" {
CKeyEventAddFlag(event: *const CKeyEvent)100     pub fn CKeyEventAddFlag(event: *const CKeyEvent);
CGetKeyCode(event: *const CKeyEvent) -> i32101     pub fn CGetKeyCode(event: *const CKeyEvent) -> i32;
102 }
103 
104 // C interface for input manager
105 extern "C" {
CAddMonitor(callback: OnPointerEventCallback) -> i32106     pub fn CAddMonitor(callback: OnPointerEventCallback) -> i32;
CGetPointerStyle(pointer_style: &mut CPointerStyle) -> i32107     pub fn CGetPointerStyle(pointer_style: &mut CPointerStyle) -> i32;
CAppendExtraData(extra_data: &CExtraData)108     pub fn CAppendExtraData(extra_data: &CExtraData);
CSetPointerVisible(visible: bool) -> i32109     pub fn CSetPointerVisible(visible: bool) -> i32;
CEnableInputDevice(enable: bool) -> i32110     pub fn CEnableInputDevice(enable: bool) -> i32;
CRemoveInputEventFilter(filterId: i32) -> i32111     pub fn CRemoveInputEventFilter(filterId: i32) -> i32;
CRemoveMonitor(monitorId: i32)112     pub fn CRemoveMonitor(monitorId: i32);
CRemoveInterceptor(interceptorId: i32)113     pub fn CRemoveInterceptor(interceptorId: i32);
CSetPointerLocation(physicalX: i32, physicalY: i32)114     pub fn CSetPointerLocation(physicalX: i32, physicalY: i32);
115 
CDestroyPointerEvent(event: *mut CPointerEvent)116     pub fn CDestroyPointerEvent(event: *mut CPointerEvent);
117 }