--- layout: post title: Linux下使用高漫M5数位板的方法 subtitle: 基于Ubuntu 22.04及衍生版 date: 2022-10-21 author: Duter2016 header-img: img/post-bg-debug.png catalog: true music-id: music-idfull: tags: - 数位板 - Linux --- > 本文基于Linuxmint 21 (基于Ubuntu 22.04)测试通过 高漫M5数位板官方驱动是支持Win/Mac/Android的, 然而没有提供Linux驱动。 但是已有高手发现Huion(绘王)和Gaomon(高漫)数位板某些型号是相互对应的,驱动也能通用。这就好办了! 先在软件管理器安装两个软件,或命令安装: ``` sudo apt-get install Xserver-xorg-input-wacom sudo apt-get install Kde-config-tablet ``` ## 1、检查数位板设备 目前的Linux内核大部分都能识别出高漫数位板了。 (1)首先查看设备id,终端运行: `lsusb` 显示: `Bus 002 Device 013: ID 256c:0064 GAOMON Gaomon Tablet` 设备id是256c:0064。也就是 ``` idVendor 256c idProduct 0064 ``` (2)终端运行命令: ``` sudo usbhid-dump -es -m 256c:0064 | tee frame_wheel_srolling.txt ``` 查看设备是否能正常上报,发现能正常上报数据,说明设备本身没有问题。 ## 2、安装驱动 DIGImend项目旨在改进Linux对通用图形输入板的支持,是用于Linux内核的图形输入板驱动程序的集合。今天我们的主角就是它 * 项目主页:[http://digimend.github.io/](http://digimend.github.io/) * 项目地址:[https://github.com/DIGImend/digimend-kernel-drivers](https://github.com/DIGImend/digimend-kernel-drivers) 访问这个项目网址: [DIGImend/digimend-kernel-drivers](https://github.com/DIGImend/digimend-kernel-drivers) ,下载最新的zip文件,并解压。 按照网站的提示,做如下操作: (1)安装内核头文件: ``` sudo apt-get install -y "linux-headers-$(uname -r)" ``` (2)安装DKMS (Dynamic Kernel Module Support): ``` sudo apt-get install -y dkms ``` (3)进入刚刚的解压文件目录,运行终端: ``` sudo make dkms_install ``` 以上为自动安装,网站还提供了手动安装的步骤,此处从略。 (4)卸载原先的设备: ``` sudo modprobe -r hid-kye hid-uclogic hid-polostar hid-viewsonic ``` (5)在`/etc/X11/xorg.conf.d`目录下添加文件`50-digimend.conf`, 内容如下: ``` Section "InputClass" Identifier "Tablet" MatchUSBID "256c:0064" MatchDevicePath "/dev/input/event*" Driver "wacom" EndSection ``` 上面就完成了驱动适配。 现在项目主页已经有打包的deb包了,也可以直接安装deb包,然后 `cd /usr/share/X11/xorg.conf.d/` 然后修改`50-digimend.conf` 文件 在`husion tablets with wacom driver` 下面增加一个(高漫m5是`256c:0064`)然后就可以了。 拔下数位板USB连线,重启或注销一下系统就可以正常使用数位板了。 ## 3、将M5由竖屏映射更改为横屏映射 以上安装完驱动后,你在Xournal++中使用数位板时,你会发现数位板中书写文字,文字是扁的,比较难看,原因是M5在Linux上的默认映射是竖屏的,而笔记本屏幕是横屏的,写上的字自然是扁的! 只需要把高漫M5数位板由竖屏映射更改为横屏映射即可! 如下修改方法参考了如下wiki内容: * [【xsetwacom】](https://github.com/linuxwacom/xf86-input-wacom/wiki/xsetwacom) * [【Rotation】](https://github.com/linuxwacom/xf86-input-wacom/wiki/Rotation) (1)首先,查找终端中使用的“设备名称”: ``` xinput list ``` 会输出含有如下信息的内容: ``` ⎜ ↳ GAOMON Gaomon Tablet stylus id=15 [slave pointer (2)] ⎜ ↳ GAOMON Gaomon Tablet eraser id=16 [slave pointer (2)] ``` (2)数位板驱动程序支持90度角的旋转。旋转可以在运行时应用(例如通过 xsetwacom)。对于 Rotate 参数,只需选择您喜欢旋转的一个输入工具方向。这四个有效的设置是: * "none": 数位板不在软件中旋转,而是使用其默认方向。 * "half": 数位板旋转180度(上下颠倒)。 * "cw": 数位板顺时针旋转90度。 * "ccw": 数位板逆时针旋转90度。 **请注意**,旋转是一个数位板范围的选择。如果你旋转一个输入工具,与同一个数位板相关的所有其他工具都要旋转到相同的方向。 因此,我们在终端运行如下命令,即可把M5旋转为横向: ``` xsetwacom set "GAOMON Gaomon Tablet stylus" rotate ccw xsetwacom set "GAOMON Gaomon Tablet eraser" rotate ccw ``` 虽然 xsetwacom 设置命令一旦输入终端就会应用,但是它们不会在重新启动后持续,及重启后,数位板又再次变为竖屏映射。为此,您可以使用这些命令创建一个可执行脚本,并将其添加到启动应用程序中。 (3)创建横屏映射脚本 如果我们每次重启系统后,都要输入命令来改变映射方向,记命令有点麻烦,我们直接建立一个sh脚本就能简化过程了! 建立一个sh文件`Tablet_PC_Rotation.sh`,脚本内容如下: ``` #!/bin/sh # 将高漫 M5 数位板由竖屏改为横屏映射 CCW # '''none''': the tablet is not rotated in software and uses its natural rotation. # '''half''': the tablet is rotated by 180 degrees (upside-down) # '''cw''': the tablet is rotated 90 degrees clockwise # '''ccw''': the tablet is rotated 90 degrees counter-clockwise # 更改为横屏start xsetwacom set "GAOMON Gaomon Tablet stylus" rotate ccw xsetwacom set "GAOMON Gaomon Tablet eraser" rotate ccw # 更改为横屏end # 更改为竖屏start # xsetwacom set "GAOMON Gaomon Tablet stylus" rotate none # xsetwacom set "GAOMON Gaomon Tablet eraser" rotate none # 更改为竖屏end #任意键 get_char() { SAVEDSTTY=`stty -g` stty -echo stty cbreak dd if=/dev/tty bs=1 count=1 2> /dev/null stty -raw stty echo stty $SAVEDSTTY } #任意键 #任意键退出 开始 echo "已将高漫 M5 数位板由竖屏映射改为横屏映射!" echo "" echo "【若想将高漫 M5 数位板恢复为竖屏映射,仅需热插拔一次数位板即可!】" echo "" echo "每热插拔一次数位板,改为横屏映射需执行一次本脚本!" echo "" # echo "组合键 CTRL+C 终止运行脚本命令! ..." echo "按任意键退出对话框..." char=`get_char` #任意键退出 结束 ``` 然后,建立一个执行以上脚本的.desktop启动快捷方式,命名为`GaomonM5Rotation.desktop`,内容如下: ``` #!/usr/bin/env xdg-open [Desktop Entry] Encoding=UTF-8 Name=GaomonM5Rotation Name[zh_CN]=高漫M5横屏 Exec=sh /home/用户名/opt/Gaomon/Tablet_PC_Rotation.sh Type=Application Terminal=true Comment[zh_CN]=将高漫M5由竖屏改为横屏 Icon=/home/用户名/opt/icons/Gaomon.png Name[zh_CN]=GaomonM5Rotation.desktop Categories=Office; ``` 图标`Gaomon.png`,自己下载一个图片文件吧。 然后把以上三个文件`Tablet_PC_Rotation.sh`、`GaomonM5Rotation.desktop`、`Gaomon.png`都放到`/home/用户名/opt/Gaomon/`目录下,然后,将`GaomonM5Rotation.desktop`加入开始菜单就可以了。 **注意:** * 若想将高漫 M5 数位板恢复为竖屏映射,仅需热插拔一次数位板即可! * 每热插拔一次数位板,改为横屏映射需执行一次本脚本! ## 参考 * [Linux下使用高漫(Gaomon)1060 Pro数位板](https://fspark.me/archives/Linux-Gaomon-1060Pro-Graphics-Tablet.html#fn-2) * [入手高漫 1060pro linux驱动适配 与设置](https://www.bilibili.com/read/cv14090353) * [Linux下安装高漫数位板的驱动](https://zhuanlan.zhihu.com/p/89877402) * [wiki/xsetwacom](https://github.com/linuxwacom/xf86-input-wacom/wiki/xsetwacom)