如何解决gtkmm 多点触控设备无法识别 (Windows)
版本:Gtkmm v3.22(通过vcpkg安装)
我插入了使用标准 Windows 驱动程序“HID 兼容触摸屏”的多点触控设备。
我已在此处验证本机 Windows WM_TOUCH 能够使用此触摸屏进行多点触控数字化:https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
我创建了一个基本的 gtkmm 应用程序,并在运行该应用程序之前在 set_support_multidevice()
上调用了 parent_window()
。
然而,当我将 Gtk::Button 的 signal_touch_event()
连接到一个方法时,从来没有收到任何触摸事件 - 只有基于指针的事件也可以通过鼠标发送。
然后为了验证连接了哪些设备,我编写了以下代码:
// Get the device manager from the Gdk::display object
Glib::RefPtr<Gdk::DeviceManager> dev_manager = parent_display->get_device_manager();
// Get device list from the device manager for type "floating"
std::vector<Glib::RefPtr<Gdk::Device>> devices =
dev_manager->list_devices(Gdk::DEVICE_TYPE_FLOATING);
for (int i = 0; i < devices.size(); i++) {
std::cout << "Device found: " << devices[i]->property_name() << std::endl;
}
// Get devices for type "master"
devices = dev_manager->list_devices(Gdk::DEVICE_TYPE_MASTER);
for (int i = 0; i < devices.size(); i++) {
std::cout << "Device found: " << devices[i]->property_name() << std::endl;
}
// Get devices for type "slave"
devices = dev_manager->list_devices(Gdk::DEVICE_TYPE_SLAVE);
for (int i = 0; i < devices.size(); i++) {
std::cout << "Device found: " << devices[i]->property_name() << std::endl;
}
// At this point we should have printed all devices associated with the Gdk::DeviceManager that's
// attached to the current display
它会打印出设备管理器为父显示器找到的所有设备。我得到的是以下内容:
Device found: Virtual Core Keyboard
Device found: Virtual Core Pointer
Device found: System Aggregated Keyboard
Device found: System Aggregated Pointer
我该怎么做才能让设备管理器识别支持多点触控的从设备?
我的多点触控设备被视为系统聚合指针,我无法处理典型的触摸事件 - 只能处理“类似鼠标”的事件。
解决方法
如果您可以隔离设备,则可以使用 gdk_device_set_mode() 并将设备设置为 master,这将允许它处理所有类型的事件。您可能还想使用 gdk_device_get_mode() 来确认 gdk 是否对设备进行了不同的处理。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。