Wayland入门12:输入设备管理器

在 Wayland入门8:获取全局对象 中我们介绍了Wayland全局对象:

  • wl_display:表示与服务器的连接。
  • wl_registry:全局对象注册表,全局对象需要通过它获取。
  • wl_compositor:窗口合成器,也是服务器。
  • wl_shm:内存管理器,与窗口合成器共享内存用。
  • wl_shell:支持窗口操作功能。
  • wl_seat:输入设备管理器。
  • wl_pointer:代表鼠标设备。
  • wl_keyboard:代表键盘设备。

可以看出鼠标、键盘是输入的一种。

本文我们来获取开发平台所支持的设备。

方法和流程 Wayland入门8:获取全局对象 中一样。

关键在于wl_seat_listener的回调函数的写法。

static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
                         enum wl_seat_capability caps)
{
    if (caps & WL_SEAT_CAPABILITY_POINTER)
    {
        printf("Display has a pointer\n");
    }

    if (caps & WL_SEAT_CAPABILITY_KEYBOARD)
    {
        printf("Display has a keyboard\n");
    }

    if (caps & WL_SEAT_CAPABILITY_TOUCH)
    {
        printf("Display has a touch screen\n");
    }
}

编译执行输出为:

hyper@ubuntu:~/Nutstore Files/Nutstore/Wayland_Freshman/10.seat$ ./seat
connected to display
Display has a pointer
Display has a keyboard
disconnected from display

完整代码在Wayland_Frashman的12.seat中。

本文首发于:Wayland入门12:输入设备管理器

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幽迷狂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值