主题
键鼠监听回调类型 - InputMonitorCallback
类型简介
InputMonitorCallback 用于 SetInputMonitor 注册键鼠事件监听。在工作线程可能触发,须快进快出;禁止在回调内重入同实例的 EnableInputSync / InputRecord / InputSyncLink / InputPlayback。
类型定义
cpp
typedef void (OLA_CALL_TYPE *InputMonitorCallback)(
int64_t instance,
int32_t type, // OLAInputEventType
int32_t source, // OLAInputEventSource
int32_t vk_or_button,
int32_t x,
int32_t y,
int32_t wheel_delta,
int32_t flags, // OLAInputEventFlags
int64_t seq,
int64_t t_ms,
int64_t user_data);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | 触发事件的 OLAPlug 对象指针。 |
| type | 整数型 | 事件类型,见下表。 |
| source | 整数型 | 事件来源,见下表。 |
| vk_or_button | 整数型 | 键盘虚拟键码或鼠标按键。 |
| x | 整数型 | 鼠标 X;RELATIVE 时为相对位移 rx。 |
| y | 整数型 | 鼠标 Y;RELATIVE 时为相对位移 ry。 |
| wheel_delta | 整数型 | 滚轮增量。 |
| flags | 整数型 | 标志位,见下表。 |
| seq | 长整数型 | 事件序号。 |
| t_ms | 长整数型 | 相对时间(毫秒)。 |
| user_data | 长整数型 | SetInputMonitor 注册时传入的上下文,可为 0。 |
常用 type
| 值 | 含义 |
|---|---|
| 1 | key_down |
| 2 | key_up |
| 3 | mouse_move(绝对或相对,见 flags) |
| 4 | mouse_down |
| 5 | mouse_up |
| 6 | mouse_wheel |
常用 source
| 值 | 含义 |
|---|---|
| 1 | host_api |
| 2 | fg_real |
| 3 | playback |
| 4 | sync_replay |
flags 位
| 值 | 含义 |
|---|---|
| 0x1 | TRAJECTORY(绝对 MoveTo 轨迹) |
| 0x2 | RELATIVE(MoveR,x/y 为 rx/ry) |
注意事项
| 项目 | 说明 |
|---|---|
| 快进快出 | 回调可能在非调用线程触发,须快速返回,禁止阻塞 IO。 |
| 禁止重入 | 回调内不要调用同实例的 EnableInputSync / InputRecord / InputSyncLink / InputPlayback。 |
| 仅本地 | SetInputMonitor 仅本地进程 有效,远程实例不支持函数指针。 |
