Skip to content

Commit 520cef0

Browse files
author
stacksmith
committed
Renamed to mono_22, much cleanup
1 parent d124d3e commit 520cef0

11 files changed

+151
-263
lines changed

Makefile

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LIB=-L/lib/$(arch)-linux-gnu/libusb-1.0.so.0
44

55
.PHONY: all clean archive
66

7-
obj-m += bosto_2g.o
7+
obj-m += mono_22.o
88

99
all:
1010
$(CC) detach_usbhid.c $(INC) $(LIB) -lusb-1.0 -o detach_usbhid
@@ -15,24 +15,24 @@ clean:
1515
rm detach_usbhid
1616

1717
archive:
18-
tar f - --exclude=.git -C ../ -c bosto_2g | gzip -c9 > ../bosto_2g-`date +%Y%m%d`.tgz
18+
tar f - --exclude=.git -C ../ -c mono_22 | gzip -c9 > ../mono_22-`date +%Y%m%d`.tgz
1919

2020
install:
21-
cp ./bosto_2g.ko /lib/modules/$(shell uname -r)/kernel/drivers/input/tablet/
22-
echo bosto_2g >> /etc/modules
21+
cp ./mono_22.ko /lib/modules/$(shell uname -r)/kernel/drivers/input/tablet/
22+
echo mono_22 >> /etc/modules
2323
depmod
24-
cp ./load_bosto_2g.sh /usr/local/bin
24+
cp ./load_mono_22.sh /usr/local/bin
2525
cp ./detach_usbhid /usr/local/bin
26-
cp ./load_bosto_2g.rules /etc/udev/rules.d
26+
cp ./load_mono_22.rules /etc/udev/rules.d
2727
/sbin/udevadm control --reload
28-
modprobe bosto_2g
28+
modprobe mono_22
2929

3030
uninstall:
31-
rm /usr/local/bin/load_bosto_2g.sh
31+
rm /usr/local/bin/load_mono_22.sh
3232
rm /usr/local/bin/detach_usbhid
33-
rm /etc/udev/rules.d/load_bosto_2g.rules
33+
rm /etc/udev/rules.d/load_mono_22.rules
3434
/sbin/udevadm control --reload
35-
rm /lib/modules/$(shell uname -r)/kernel/drivers/input/tablet/bosto_2g.ko
36-
sed -i '/bosto_2g/d' /etc/modules
35+
rm /lib/modules/$(shell uname -r)/kernel/drivers/input/tablet/mono_22.ko
36+
sed -i '/mono_22/d' /etc/modules
3737
depmod
38-
rmmod bosto_2g
38+
rmmod mono_22

README.md

+31-130
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,47 @@
1-
My Monoprice 22 almost works with Aidyw's Bosto 22HD driver: https://github.com/aidyw/bosto-2g-linux-kernel-module. According to Aidyw, his Bosto's USB device id is identical to my Monoprice (0b57:9016 via lsusb). But the x-y range is much bigger, for some reason. I also had some issues with the driver (no disrespect intended, mostly because I just can't figure out why things are done the way they are done).
1+
This is an experimental driver for Monoprice 22
22

3-
This repo is my take on the driver. I tried to work to https://www.kernel.org/doc/Documentation/input/event-codes.txt
3+
Current status: stable as of 11 Nov 2016. Please open issues for any bugs you find.
44

5-
The dirver now does the following:
65
- BTN_TOOL_PEN and BUTTON_TOOL_RUBBER are signaled as soon as they are in hover range;
76
- BTN_TOUCH is set when stylus or rubber touch the screen;
8-
- BTN_STYLUS is set while button pressed;
9-
- Initialization has been reworked;
10-
- packet decoder keeps no state, much more compact
11-
- GIMP and KRITA work, but eraser is not recognized...TODO...
12-
- absolute valuator 3 used to report the tool, removed.
13-
14-
This is highly experimental, and I know very little about Linux drivers. It seems stable and inserting/removing is very easy with `sudo make uninstall`
15-
16-
17-
Aidyw's readme follows
18-
======================
19-
20-
This is a Linux driver for the 2nd generation Bosto Kingtee 22HD and Bosto Kingtee 14WA tablets.
21-
These tablets were released around November 2013.
22-
23-
Using this driver requires some manual work but is definitely possible right now. We are
24-
working to get the drivers to a point where using these tablets under Linux will be automatic
25-
and convenient.
26-
27-
Multiple drivers
28-
================
29-
30-
The 14WA tablet requires two different drivers, one for the pen and one for the keys.
31-
The pen driver works quite well (with proper tracking and pressure support) but key support
32-
is handled by the USBHID driver which treats the tablet like a keyboard. This means the keys
33-
emulate numbers and letters. We are working to improve this.
34-
The pen driver has a landing spot in a switch statement to handle buttons events from the tablet. This is a work in progress.
35-
Hardware needed such as 22HD+ with tablet buttons.
36-
37-
Current Status
38-
==============
39-
40-
* Pen pressure: working (pressure magnified by pen tool button. Usage: Ignore the right click response, maintain the button pressed, and continue to draw with magnified pressure sensitivity.)
41-
* Pen tracking: working
42-
* Keys: produce numbers like a numeric keypad
43-
* Scroll wheels: produce 'a', 'b', 'c', 'd' like a keyboard
44-
* Removed fuzz factor from driver when reporting absolute position x & y. This is not a joystick and we should have negligable jitter on the reported position.
45-
* ~~Added delay before pressure reports when tool is presented for the first time.~~
46-
* Added conditional for origin 0,0, and don't report. This prevents lines drawn to the absolute origin when pen first in or when stylus button presses during contact. We loose one pixel. I'm not loosing any sleep.
47-
48-
**Tested programs**
49-
50-
Tracking and pressure sensitivity working on:
51-
52-
* GIMP 2.8
53-
* MyPaint 1.1.0
54-
* Inkscape 0.48
55-
* Synfig 0.64.1
56-
* Krita 2.9.7 (Nov 2016 this is the distro version on Ubuntu)
57-
* Blender 2.76b
58-
59-
In each program, you will need to find the "Input Devices" configuration and select the Bosto (change 'disabled' to 'screen') and you might need to map axis 3 to pressure (but that's usually the default).
60-
61-
* Krita 2.7.2 has tracking but it's unknown right now whether pressure works.
62-
* Krita 2.8.1 doesn't seem to work at all.
63-
* Krita 3+ works without pressure. Working on this with krita guys?
64-
65-
**Distributions**
66-
67-
The installation has been tested on Ubuntu 13.10, 14.04, 16.04 LTS. Please let us know your experiences on other distributions.
68-
69-
70-
In each program, you will need to find the "Input Devices" configuration and select the Bosto (change 'disabled' to 'screen') and you might need to map axis 3 to pressure (but that's usually the default).
71-
72-
Krita 2.8.1 doesn't seem to work properly, though a newer version is known to work. Later versions 3+ have major rework within Krita, its broken something. We're looking into it.
7+
- BTN_STYLUS2 is set while button pressed;
8+
- GIMP and KRITA work, but eraser is not recognized, as in all drivers I've seen
739

7410
Installation
7511
============
7612

77-
**Build and install the driver**
13+
To install:
14+
- verify that your computer sees your Monoprice. `lsusb` should show 'ID 0b57:9016 Beijing HanwangTechnology Co., Ltd';
15+
- `make` to build the driver;
16+
- `sudo make install` to install the driver.
7817

79-
```bash
80-
sudo apt-get install libusb-1.0.0-dev build-essential linux-headers-generic git # install requirements
81-
cd ~
82-
git clone https://github.com/aidyw/bosto-2g-linux-kernel-module.git
83-
cd bosto-2g-linux-kernel-module
84-
git checkout <branch> # only if you want to change the branch
85-
make clean && make
86-
sudo make install
87-
```
88-
89-
**Load the module**
90-
Now if you plug in the tablet, the pen should work right away. If not, please post an issue and we'll try to improve the code.
91-
92-
If you have a multiscreen setup you can automagically! adjust the transform matrix on X using the wonderful little script written by Leslie 'inputtransform'.
93-
This helps you identify the Tablet monitor and adjust accordingly.
94-
95-
The "git checkout" to change the branch allows you to select a different stream of development.
96-
The "master" branch is the default and should be the right choice for the official release version.
97-
Keep an eye on "testing" any modifications are happening here and will merge as appropriate into master.
98-
99-
100-
TODO
101-
====
102-
103-
1. Make the pen driver load automatically when the tablet is plugged in <-- done (22HD (master branch) now uses usblib based userspace code to detach the generic kernel module. 14WA using unbind.
104-
2. Write another or configure USBHID driver to allow remapping of keys and scroll wheels
105-
3. Try to get the driver updated in the kernel tree so no installation is required in future
106-
4. Understand and improve the mapping of the rubber tool, to a working software interface. Krita etc ? Probably need to report each tool as a different device?
107-
5. Consider implementing fuzz factor for the position reports when eraser tool is presented. The eraser tool currently reports with a great deal of jitter. (Hardware)
108-
109-
Diagnostics
110-
===========
111-
112-
After running modprobe, check if the module was loaded properly with dmesg.
113-
"Bosto 2nd Generation USB Driver module being initialised." should appear in the listing.
18+
At this point you should be able to use the stylus as the mouse and with GIMP or Krita, etc.
11419

115-
lsmod should also contain `bosto_2g` in its listing: lsmod | grep bosto_2g
116-
117-
Debug ouput now pattern matched to entries in the /sys/kernel/debug/dynamic_debug/control file
118-
119-
120-
For example to see each time the driver detects a TOOL event, echo the following:
121-
122-
echo -n 'format "Bosto TOOL" +p' > /sys/kernel/debug/dynamic_debug/control
123-
124-
Then view the debug output in syslog. To switch debug output off again:
125-
126-
echo -n 'format "Bosto TOOL" -p' > /sys/kernel/debug/dynamic_debug/control
127-
128-
check the 'dev_dbg' lines in bosto_2g.c for other debug pattern matches that are possible.
20+
To uninstall, of course
21+
```
22+
sudo make uninstall
23+
```
12924

130-
Another possibility based on per line number in the source file.
131-
(See https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt )
132-
echo -n 'file ./<path to source>/bosto_2g.ko line 230 +p' > <debugfs>/control
25+
Troubleshooting
26+
===============
13327

134-
Known Hardware Issues
135-
=====================
28+
If your stylus is not responsive after hybernation, type `sudo /usr/local/bin/load_mono_22.sh`. This is a known issue.
13629

137-
The Bosto 22HD (v1) Shipped with a firmware issue. If the USB port is detached and then re-attached, the data coming from the tablet becomes corrupted when pressure exceeds a certain level.
138-
To resolve the issue it is necessary to power cycle the tablet totally, removing both power input and USB cable, in some cases even a DVI connector.
139-
The tablet will remain internally powered from any available source and all power sources need to be removed to make the USB firmware reboot.
30+
You can try checking
31+
- `lsusb` for 0b57:9016;
32+
- `lsmod | grep mono` for mono_22
33+
- `cat /proc/bus/input/devices` to see where your device is attached
34+
With xinput, you can look try
35+
- `xinput` and look for 'Monoprice 22'
36+
- `xinput list --long "Monoprice 22"`
37+
- `while :; do xinput --query-state "Monoprice 22"; sleep 1; done`
38+
- `xinput test "Monoprice 22"`
39+
also,
40+
- `evtest`
14041

141-
Feedback
142-
========
42+
Hacking
43+
=======
44+
Obviously, sudo make uninstall and make clean as needed...
45+
See aidyw's repo for more information about debugging the driver.
14346

144-
The best place for feedback is probably the Bosto community Google Group:
145-
https://groups.google.com/forum/#!categories/bosto-user-group/mac--linux-discussion
14647

bosto_2g.rules

-3
This file was deleted.

detach_usbhid.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
if (res == 0)
3838
{
3939
kernelDriverDetached = 1;
40-
printf("Driver Module detached from bosto device.\n");
40+
printf("Driver Module detached from mono device.\n");
4141
}
4242
else
4343
{

insert_bosto_2g insert_mono_22

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
echo -n "$1" > /sys/bus/usb/drivers/usbhid/unbind
3-
echo -n "$2 $3" > /sys/bus/usb/drivers/bosto_2g/new_id
3+
echo -n "$2 $3" > /sys/bus/usb/drivers/mono_22/new_id

load_bosto_2g.rules

-3
This file was deleted.

load_bosto_2g.sh

-15
This file was deleted.

load_mono_22.rules

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Rules for hotplugging Monoprice 22 touchscreen
2+
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0b57", ATTR{idProduct}=="9016", RUN+="/usr/local/bin/load_mono_22.sh"

load_mono_22.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# Script called by udev to initialise mono_22 module during usb hotplug event.
4+
5+
logger udev rule triggered to load mono_22
6+
#Make sure mono module is not loaded
7+
rmmod mono_22
8+
logger removed mono_22 driver module from kernel
9+
10+
#Detach the usbhid module
11+
/usr/local/bin/detach_usbhid
12+
logger detached usbhid driver module from mono device
13+
14+
#Now insert Bosto module
15+
insmod /lib/modules/$(uname -r)/kernel/drivers/input/tablet/mono_22.ko

0 commit comments

Comments
 (0)