- video_window 处理右/中键(WM_RBUTTON/MBUTTON)与滚轮(WM_MOUSEWHEEL), 并通过 ttstd/video 的 mouse / wheel 方法通道交给 Dart - 键盘走 WM_KEYDOWN/UP 报 Windows 虚拟键码,Dart 侧映射成 Android keycode; Esc 仍保留为关窗,Alt 组合键旁路转发不吞掉 - 右键→返回、中键→多任务(buttons 位 bit1/bit2),滚轮按「deltaY 正=向下滚」取反 - 本机剪贴板每 700ms 轮询比较后下发 msg_type=4,被控端上行内容写入本机剪贴板; 两端都记住最近一次同步的文本,避免来回回送 - 控制栏「发送剪贴板」改为读取本机剪贴板实时内容(原先发的是固定占位字符串)
104 lines
3.3 KiB
Dart
104 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ControlToolbar extends StatelessWidget {
|
|
const ControlToolbar({super.key, required this.enabled, required this.onEvent});
|
|
|
|
final bool enabled;
|
|
final void Function(String type, Map<String, dynamic> payload) onEvent;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.gamepad),
|
|
const SizedBox(width: 8),
|
|
Text('远程控制', style: Theme.of(context).textTheme.titleSmall),
|
|
const Spacer(),
|
|
if (!enabled)
|
|
Text('连接后可用', style: Theme.of(context).textTheme.labelSmall),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
_Action(
|
|
icon: Icons.touch_app,
|
|
label: '点击中心',
|
|
enabled: enabled,
|
|
onPressed: () => onEvent('touch', {
|
|
'action': 0,
|
|
'pointerId': 1,
|
|
'x': 960,
|
|
'y': 540,
|
|
'pressure': 800,
|
|
}),
|
|
),
|
|
_Action(
|
|
icon: Icons.arrow_back,
|
|
label: '返回',
|
|
enabled: enabled,
|
|
onPressed: () => onEvent('key', {'action': 0, 'keycode': 4, 'modifiers': 0}),
|
|
),
|
|
_Action(
|
|
icon: Icons.home,
|
|
label: '主页',
|
|
enabled: enabled,
|
|
onPressed: () => onEvent('key', {'action': 0, 'keycode': 3, 'modifiers': 0}),
|
|
),
|
|
_Action(
|
|
icon: Icons.mouse,
|
|
label: '滚轮向下',
|
|
// 协议约定 deltaY 正数 = 向下滚(与真实滚轮事件一致)。
|
|
enabled: enabled,
|
|
onPressed: () => onEvent('wheel', {'deltaX': 0, 'deltaY': 1, 'buttons': 0}),
|
|
),
|
|
_Action(
|
|
icon: Icons.content_paste,
|
|
label: '发送剪贴板',
|
|
enabled: enabled,
|
|
// 不带文本:由调用方读本机剪贴板实时内容再下发。
|
|
onPressed: () => onEvent('clipboard', const <String, dynamic>{}),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Action extends StatelessWidget {
|
|
const _Action({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.enabled,
|
|
required this.onPressed,
|
|
});
|
|
|
|
final IconData icon;
|
|
final String label;
|
|
final bool enabled;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return OutlinedButton.icon(
|
|
onPressed: enabled ? onPressed : null,
|
|
icon: Icon(icon, size: 18),
|
|
label: Text(label),
|
|
style: OutlinedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
|
),
|
|
);
|
|
}
|
|
}
|