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 /// C representation of [`PointerEvent`]. 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 /// C representation of [`KeyEvent`]. 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 /// C representation of [`AxisEvent`]. 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 /// C representation of [`PointerStyle`]. 42 #[repr(C)] 43 pub struct CPointerStyle { 44 /// Pointer style size property 45 pub size: i32, 46 /// Pointer style color property 47 pub color: i32, 48 /// Pointer style id property 49 pub id: i32, 50 } 51 52 /// C representation of [`ExtraData`]. 53 #[repr(C)] 54 pub struct CExtraData { 55 /// Extra data appended property 56 pub appended: bool, 57 /// Extra data buffer property 58 pub buffer: *const u8, 59 /// Extra data buffer_size property 60 pub buffer_size: usize, 61 /// Extra data source_type property 62 pub source_type: i32, 63 /// Extra data pointer_id property 64 pub pointer_id: i32, 65 } 66 67 // Callback function type for OnPointerEventCallback() from native, 68 // this callback is invoked when listening for a pointer event. 69 pub type OnPointerEventCallback = unsafe extern "C" fn( 70 event: *const CPointerEvent 71 ); 72 73 // C interface for pointer event 74 extern "C" { CGetPointerId(event: *const CPointerEvent) -> i3275 pub fn CGetPointerId(event: *const CPointerEvent) -> i32; CGetPointerAction(event: *const CPointerEvent) -> i3276 pub fn CGetPointerAction(event: *const CPointerEvent) -> i32; CGetTargetWindowId(event: *const CPointerEvent) -> i3277 pub fn CGetTargetWindowId(event: *const CPointerEvent) -> i32; CGetSourceType(event: *const CPointerEvent) -> i3278 pub fn CGetSourceType(event: *const CPointerEvent) -> i32; CGetTargetDisplayId(event: *const CPointerEvent) -> i3279 pub fn CGetTargetDisplayId(event: *const CPointerEvent) -> i32; CGetDisplayX(event: *const CPointerEvent) -> i3280 pub fn CGetDisplayX(event: *const CPointerEvent) -> i32; CGetDisplayY(event: *const CPointerEvent) -> i3281 pub fn CGetDisplayY(event: *const CPointerEvent) -> i32; CPointerEventAddFlag(event: *const CPointerEvent)82 pub fn CPointerEventAddFlag(event: *const CPointerEvent); CGetDeviceId(event: *const CPointerEvent) -> i3283 pub fn CGetDeviceId(event: *const CPointerEvent) -> i32; CGetWindowPid(event: *const CPointerEvent) -> i3284 pub fn CGetWindowPid(event: *const CPointerEvent) -> i32; 85 } 86 87 // C interface for key event 88 extern "C" { CKeyEventAddFlag(event: *const CKeyEvent)89 pub fn CKeyEventAddFlag(event: *const CKeyEvent); CGetKeyCode(event: *const CKeyEvent) -> i3290 pub fn CGetKeyCode(event: *const CKeyEvent) -> i32; 91 } 92 93 // C interface for input manager 94 extern "C" { CAddMonitor(callback: OnPointerEventCallback) -> i3295 pub fn CAddMonitor(callback: OnPointerEventCallback) -> i32; CGetPointerStyle(pointer_style: &mut CPointerStyle) -> i3296 pub fn CGetPointerStyle(pointer_style: &mut CPointerStyle) -> i32; CAppendExtraData(extra_data: &CExtraData)97 pub fn CAppendExtraData(extra_data: &CExtraData); CSetPointerVisible(visible: bool) -> i3298 pub fn CSetPointerVisible(visible: bool) -> i32; CEnableInputDevice(enable: bool) -> i3299 pub fn CEnableInputDevice(enable: bool) -> i32; CRemoveInputEventFilter(filterId: i32) -> i32100 pub fn CRemoveInputEventFilter(filterId: i32) -> i32; CRemoveMonitor(monitorId: i32)101 pub fn CRemoveMonitor(monitorId: i32); CRemoveInterceptor(interceptorId: i32)102 pub fn CRemoveInterceptor(interceptorId: i32); CSetPointerLocation(physicalX: i32, physicalY: i32)103 pub fn CSetPointerLocation(physicalX: i32, physicalY: i32); 104 CDestroyPointerEvent(event: *mut CPointerEvent)105 pub fn CDestroyPointerEvent(event: *mut CPointerEvent); 106 }