linux - 模拟手写笔输入

标签 linux input simulate wacom

我正在寻找一种将 wacom 输入注入(inject)正在运行的 X 服务器的方法。我有点卡在一开始就找不到关于这个主题的任何资源。

有很多关于如何注入(inject)击键和鼠标输入的信息,但这不是我要找的,而且它似乎没有模拟 wacom 的东西。

有没有人有关于这个主题的任何信息?

最佳答案

On Linux, the various input devices generate a variety of events.

例如,

Keyboards - EV_KEY
Mice      - EV_REL
Tablets   - EV_ABS

任何特定输入设备支持/生成的事件都可以通过在系统上运行 xinput 来识别,输入设备连接到它,如下所示:

xinput --list <name of the connected input device>

通过连接 Wacom 数位板创建的输入设备示例列表:

$ > xinput --list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=14   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos4 6x9 eraser                  id=17   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos4 6x9 cursor                  id=18   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos4 6x9 pad                     id=19   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos4 6x9 stylus                  id=20   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=13   [slave  keyboard (3)]

..以及注册为从 Wacom 数位板输入事件的 4 个 Wacom 设备之一支持/生成的输入事件列表:

$ > xinput --list "Wacom Intuos4 6x9 eraser"
Wacom Intuos4 6x9 eraser                    id=17   [slave  pointer  (2)]
    Reporting 8 classes:
        Class originated from: 17
        Buttons supported: 9
        Button labels: None None None None None None None None None
        Button state:
        Class originated from: 17
        Keycodes supported: 248
        Class originated from: 17
        Detail for Valuator 0:
          Label: Abs X
          Range: 0.000000 - 44704.000000
          Resolution: 200000 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 17
        Detail for Valuator 1:
          Label: Abs Y
          Range: 0.000000 - 27940.000000
          Resolution: 200000 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 17
        Detail for Valuator 2:
          Label: Abs Pressure
          Range: 0.000000 - 2048.000000
          Resolution: 1 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 17
        Detail for Valuator 3:
          Label: Abs Tilt X
          Range: -64.000000 - 63.000000
          Resolution: 1 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 17
        Detail for Valuator 4:
          Label: Abs Tilt Y
          Range: -64.000000 - 63.000000
          Resolution: 1 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 17
        Detail for Valuator 5:
          Label: Abs Tilt Y
          Range: -64.000000 - 63.000000
          Resolution: 1 units/m
          Mode: absolute
          Current value: 0.000000

The above shows 9 buttons, and several axes with their corresponding min/max values for each type of input event(referred to by their lables).

例如,绝对 x 轴的最小值/最大值为 0 - 44704 个单位,即 20000 个单位/米。据推测,EV_ABS 类型的输入事件仅在 X 轴的此范围内生成。

Once the types of events being generated by the input device have been identified, it is easy to inject fake events into the Xinput queue using uinput framework. A simple example is available here

当您打算模拟 Wacom 数位板时,您可能需要注入(inject)典型 Wacom 数位板在使用时生成的所有输入事件。

xinput can be used to monitor the sequence and timing of input events generated by an actual device as shown in this answer.

关于linux - 模拟手写笔输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34895938/

相关文章:

linux - 如何强制 vmware 桥接以太网而不是 wlan

C++用户输入到字符串数组无限循环

python - input() 阻塞进程的使用

stata - 存储来自 Stata 的 n 次重复的预测和系数

jquery - 使用Jquery模拟键盘按键

linux - 如何将OTRS 5与Microsoft LDAP服务器连接以进行用户身份验证?

linux - 比较文件的日期 bash

c# - NancyFX/Linux/Mono - 大型上传(超过 1MB)适用于 Windows 服务器,但不适用于 Linux

javascript - 从文本字段获取数据并确定是否按下了"is"或“取消”

java - 如何使用java模拟云环境