最低 XFree 版本应为 3.3.3.1,因为此版本具有扩展的 XInput 支持,第二个侧边开关现在可以工作,并且阻塞鼠标效果已得到修复。
如果您必须使用任何更早的版本,则自 3.1.2.d 起应提供 XInput 支持。
XFree 中的 XInput 支持基本上在名为 XF86Config 的文件中配置。在大多数情况下,XF86Config 文件位于 /etc 或 /etc/x11 中。我现在将展示两个非常简短的配置部分,第一个适用于 XFree 3,另一个适用于 XFree 4。然后我将解释可以更改什么以及为什么需要这样做。
Section "Module"
# Wacom Device Driver
Load "xf86Wacom.so"
EndSection
Section "XInput"
# Settings for Wacom pen
SubSection "WacomStylus" # type of input device
Port "/dev/ttyS0" # Serial Port
DeviceName "Pen1" # Name, choose it free
Baudrate 9600 # Usable only for intuos
Mode Absolute # Map Tablet Area to Screen
AlwaysCore # See text
HistorySize 200 # Buffer size for motion events
EndSubSection
# Settings for Wacom eraser
SubSection "WacomEraser" # type of input device
Port "/dev/ttyS0" # Serial Port
DeviceName "Eraser1" # Name, choose it free
Baudrate 9600 # Usable only for intuos
Mode Absolute # Map Tablet Area to Screen
AlwaysCore # See text
HistorySize 200 # Buffer size for motion events
EndSubSection
# Settings for Wacom cursor (mouse)
SubSection "WacomCursor" # type of input device
Port "/dev/ttyS0" # Serial Port
DeviceName "Cursor" # Name, choose it free
Baudrate 9600 # Usable only for intuos
Mode Absolute # Map Tablet Area to Screen
AlwaysCore # See text
HistorySize 200 # Buffer size for motion events
EndSubSection
EndSection
# declare input devices, later defined
Section "ServerLayout"
Identifier "XFree86 Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "pen1" "AlwaysCore"
InputDevice "eraser1" "AlwaysCore"
InputDevice "cursor1" "AlwaysCore"
EndSection
Section "Module"
Load "extmod"
Load "xie"
Load "pex5"
Load "glx"
Load "dri"
Load "GLcore"
Load "dbe"
Load "record"
Load "wacom" # Wacom Device Driver
EndSection
# Settings for wacom pen
Section "InputDevice"
Identifier "pen1"
Driver "wacom"
Option "Type" "stylus"
Option "Device" "/dev/ttyS0"
Endsection
# Settings for wacom eraser
Section "InputDevice"
Identifier "eraser1"
Driver "wacom"
Option "Type" "eraser"
Option "Device" "/dev/ttyS0"
Endsection
# Settings for wacom cursor (mouse)
Section "InputDevice"
Identifier "cursor1"
Driver "wacom"
Option "Type" "cursor"
Option "Device" "/dev/ttyS0"
Endsection
请注意 XFree 3 和 XFree 4 之间不同的语法
在 XFree 3 中,配置在 “XInput” 部分中完成,每个设备都有一个子部分。XFree 3 具有关键字。
在 XFree 4 中,配置通过每个设备的 “InputDevice” 部分完成。所有设置都是 “options”,只有一个例外:identifier 语句。“Alwayscore” 选项进入 Serverlayout 部分。
由于可以从上面的示例中看到用法,因此本文档的其余部分将认为此差异是显而易见的。
XFree 中的 XInput 支持是通过使用模块实现的。XFree 3 的 wacom 设备驱动程序模块文件名为 xf86Wacom.so,XFree 4 的文件名更改为 wacom_drv.o。这些文件通常位于 /usr/X11R6/lib/modules/ 或 /usr/X11R6/lib/modules/input 中。我们必须在 “Module” 部分中指定我们要加载此驱动程序(查看上面的代码片段)
XFree 3:加载 "xf86Wacom.so"
XFree 4:加载 "wacom"
这在每个 XF86Config 文件中只能出现一次。
penpartner 和 graphire 产品仅识别设备类型,但它们无法区分它们。例如,您不能使用两支不同的笔,例如,一支配置为红色,另一支配置为蓝色 - 这些产品所说的只是:“我在我的表面上找到一个笔尖”,或 “我在我的表面上找到一个橡皮擦”,或 “我在我的表面上找到一个鼠标”。
XInput 将设备类型映射到设备,这些设备类型稍后在 XF86Config 中指定。对于 XFree 3,这是一个 XInput 部分的子部分,对于 XFree 4,这进入单独的 InputDevice 部分。
设备类型为
WacomStylus
笔或喷枪的笔尖WacomEraser
笔或喷枪的橡皮擦WacomCursor
鼠标,如 graphire 鼠标、镜头光标、4d 鼠标正如您可以从上面的示例中看到的,设备类型在 XFree 3 中使用关键字 “Devicetype” 指定,在 XFree 4 中使用选项 “Type” 指定。
您必须为每个配置的设备提供唯一的名称。此名称稍后将在您的程序中使用,以便与该设备通信。您可以自由选择此名称。此语句是强制性的。在 XFree 3 中,您将使用 “Devicename” 关键字,在 XFree 4 中,您将使用标识符 “name” 关键字。请注意,标识符不是选项!
XInput 想要知道在此串行端口可以找到哪个设备。这允许我同时使用两个不同的数位板,例如,连接到 /dev/ttyS0 的 graphire 和连接到 /dev/ttyS1 的 penpartner。
USB 也被视为串行线路,因此此语句是强制性的。如果您将产品连接到 USB,则必须使用 Option USB 指定这一点。
如何使用 USB 端口的示例 (XF4)
Section "InputDevice"
Driver "wacom"
Identifier "stylus"
Option "Device" "/dev/input/event0"
Option "Type" "stylus"
Option "Mode" "absolute"
Option "USB" "on"
Option "Tilt" "on"
EndSection
大多数人同时使用鼠标和数位板进行核心指针功能。但是,如果您想关闭鼠标并且只使用数位板,这里有一个技巧
首先,在 ServerFlags 部分中指定 AllowMouseOpenFail。然后将设备设置为一个不存在的文件(伪造或虚拟)。不要将其设置为 /dev/null,因为这会占用您的 CPU 时间。
如何关闭鼠标的示例 (XF3)
Section "Pointer"
Device "/dev/fake" #Phony device file
...
EndSection
如何关闭鼠标的示例 (XF4)
Section "ServerLayout"
...
InputDevice "Mouse0" "CorePointer"
...
EndSection
Section "InputDevice"
Identifier "Mouse0"
...
Option "Device" "/dev/fake" #Phony
#device file
Endsection
此语句控制 Wacom 驱动程序的详细程度。级别从 0 到 10。如果未给出此语句,则使用 DebugLevel 0,这将记录最少的信息。
示例 (XFree 3)
SubSection "WacomStyLus" # Pen
DeviceName "PenRed" # Name, choose it free
...
DebugLevel 10 # be very verbose
...
EndSubSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "DebugLevel" "10" # be very verbose
...
EndSection
intuos 产品比 penpartner 和 graphire 更高效,因为它可以区分许多相同类型的设备。这意味着现在可以使用两支笔,一支配置为红色,另一支配置为蓝色。如您所见,仅使用设备类型不足以处理不同的笔。因此,每个 intuos 设备,无论是笔、墨水笔、鼠标还是其他任何设备,都有一个序列号,您可以指定该序列号以帮助 XInput 解析正确的设备。这看起来像
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
Serial 2609917443 # Serial Number of that device
...
EndSubSection
SubSection "WacomStylus" # another Pen
DeviceName "PenBlue" # Name, choose it free
...
Serial 2609918664 # Serial Number of that device
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "Serial" "2609917443"
...
EndSection
Section "InputDevice"
Identifier "PenBlue" # Name, choose it free
Option "Type" "stylus"
...
Option "Serial" "2609918664"
...
EndSection
应该说,像笔这样的组合输入设备只有一个序列号。驱动程序使用它获取的序列号来识别一支特定的笔,并使用设备类型来区分该特定笔的笔尖和橡皮擦。
您应该获得不同的数字列表。
BEGIN xf86WcmProc dev=0x8354d60 priv=0x833e3f0 type=stylus flags=9 what=1
xf86WcmProc pWcm=0x8354d60 what=ON
END xf86WcmProc Success what=1 dev=0x8354d60 priv=0x833e3f0
device_id=0x96 serial_num=2595227137 type=cursor
[cursor] abs prox=false x=0 y=0 z=0 button=false buttons=0
(serial_num 在第 4 行第 2 个字中)。
如果您将设备设置为绝对模式,则意味着数位板的活动区域将映射到屏幕。每次您使用绝对设备在数位板上的同一点上按下时,指针都会出现在屏幕的同一点。
如果您将设备设置为相对模式,您将获得鼠标的众所周知的行为。这意味着,如果您将鼠标从表面抬起,移动它并再次按下,则指针(理想情况下)不会移动。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
Mode absolute
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "Mode" "absolute"
...
EndSection
XFree 知道两个指针:一个只有标准功能(按钮、移动功能)的指针,用于选择菜单、文本、单击按钮和执行其他控制操作。这是核心设备。
另一个指针供需要更多信息的应用程序使用,例如压力和倾斜度。
这是扩展设备。
从 3.3.3.1 版本开始,AlwaysCore 语句告诉驱动程序它应该发送两种类型的事件。
如果您未在 XF86Config 中指定 Alwayscore,则此设备最初用作扩展设备,这意味着它仅在应用程序中可用,但您无法使用它控制窗口管理器的菜单。
如果给出了 Alwayscore,则您的设备充当核心指针(除了鼠标之外),并且它还将倾斜度和压力信息发送到以扩展模式打开设备的应用程序。
您可以为同一物理设备配置两个不同的逻辑设备,一个处于核心模式,另一个处于扩展模式。
为此,只需键入两个相同的部分,只有 DeviceName 语句必须不同。然后仅为最后一部分指定 AlwaysCore。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
AlwaysCore
...
EndSubSection
EndSection
对于 XFree 4,这不是 InputDevice 部分中的选项,它进入 Serverlayout 部分,可以是以下之一:AlwaysCore / SendCoreEvents 或 CorePointer
示例 (XFree 4)
Section "ServerLayout"
Identifier "XFree86 Configured"
Screen 0 "Screen0" 0 0
...
InputDevice "icursor" "AlwaysCore"
EndSection
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
HistorySize 200
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "HistorySize" "200"
...
EndSection
此语句指定设备必须移动多少个单位,驱动程序才会移动指针。如果使用非常大的分辨率,则这可能是必要的。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
Suppress 10
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "Suppress" "10"
...
EndSection
这仅适用于 intuos 系列数位板。
TiltMode 启用发送 intuos 设备的倾斜信息。如果缺少此语句,则仅传输压力信息。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
TiltMode
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "Tilt" "on"
...
EndSection
Max[轴] 限制 / 覆盖通常从数位板检索的 max[轴] 值。或多或少是开发人员的东西。
Resolution[轴] 预设通常从数位板检索的 resolution[轴] 值。或多或少是开发人员的东西。
这四个语句允许减小数位板的活动区域。例如,我的 intuos A4 oversize 太大了,以至于您无法用它进行绘画工作,因为笔的行程太长了。我使用这四个语句告诉驱动程序,它应该只将数位板的左下四分之一映射到屏幕。
可以在同一数位板上定义多个活动区域:根据需要定义尽可能多的子部分,使用相同的 Port 语句,但使用不同的 Top... 语句和 Devicenames。这会产生多个逻辑设备,所有这些设备都限制在各自的边界内。您也可以在一个设备中使用绝对模式,在另一个设备中使用相对模式。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
TopX 0
TopY 5000
BottomX 5000
BottomY 10000
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "TopX" "0"
Option "TopY" "5000"
Option "BottomX" "5000"
Option "BottomY" "10000"
...
EndSection
如果您使用上述四个语句,您有时希望对要定义的矩形的大小和位置进行一些计算。通常需要最大数位板坐标和分辨率。要获取这些值,请启动您的服务器:X 2>t。杀死 X 服务器(通常是 Ctrl+Alt+Backspace)并执行 grep "X=" t 。您应该获得相关的值。
(--) Wacom IV tablet maximum X=5103 maximum Y=3711 X
resolution=1000 Y resolution=1000 suppress=6
(--) Wacom tablet top X=0 top Y=0 bottom X=5103 bottom Y=3711
(--) Wacom tablet top X=0 top Y=0 bottom X=5103 bottom Y=3711
(--) Wacom tablet top X=0 top Y=0 bottom X=5103 bottom Y=3711
此选项使用 TopX、TopY 语句(或它们的内置默认值,如果省略)并调整 BottomX、BottomY 语句,以便
任何给定的 BottomX、BottomY 语句都将被忽略,因为这些值将被计算出来。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
KeepShape
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "KeepShape" "1"
...
EndSection
自 alpha 16 起可用,用于控制检测到工具在表面上被按下所需的最小压力。它适用于 intuos 和 graphire。请注意,整数值必须编码为字符串,这与其他所有整数值不同。
示例 (XFree 3)
Section "XInput"
SubSection "WacomStylus" # Pen
DeviceName "PenRed" # Name, choose it free
...
Threshold "5"
...
EndSubSection
EndSection
示例 (XFree 4)
Section "InputDevice"
Identifier "PenRed" # Name, choose it free
Option "Type" "stylus"
...
Option "Treshold" "5"
...
EndSection
USB 告诉驱动程序串行线路是 usb 端口。这需要启用 usb 的 Kernel 2.4。Alpha 20 驱动程序仅支持绝对设备。 此处 是用于 XFree 4 的示例。
请阅读 Arnauld Claden 的 Wacom-USB-mini-HOWTO 和 Semyon Sosin 的 USB-'Micro-HOWTO',以获取有关 USB 设置的更多信息。