Added support for WACOM 2.x/ArtZ/Digitizer II compatibility. It does require the driver (easily available via many of the classic macos archives), but it allows a simple way to have an absolute pointing device on ADB-compatible VMs.
PATCH v2 1/2 Added support for WACOM 2.x/ArtZ/Digitizer II compatibility. It does require the driver (easily available via many of the classic macos archives), but it allows a simple way to have an absolute pointing device on ADB-compatible VMs.
In reply to a message not in the archiveFrom: Patrick Eads <[email protected]>
init
Promising polling initiated and data moving cursor now
Reverted delete of dev handler for wacom tablet
got the y-axis!
getting closer
more progress. it appears to not quite be WACOM II/IV, but x-axis is controlled by the first 2-3 bytes
really? 12-bits is the key? oh well, x-axis get
it's like a weird mesh of adb extended and wacom's protocols. fine, y-axis get
x AND y
twiddling with the settings in the driver control panel works wonders!
zeroing in on the resolution / dpi scale calculation
addded commentary to describe source material and reverse engineering decisions
commentary editing
renamed to adb-wacom, s.t. that it is clear it requires the wacom driver
--- hw/input/adb-mouse.c | 1 + hw/input/adb-wacom.c | 311 +++++++++++++++++++++++++++++++++++++++++ hw/input/meson.build | 2 +- hw/input/trace-events | 6 + include/hw/input/adb.h | 1 + 5 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 hw/input/adb-wacom.c
hw/input/adb-mouse.c +1 -0
@@ -202,6 +202,7 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,* 0x03: Mouse systems A3 trackball * 0x04: Extended Apple Mouse Protocol * 0x2f: Microspeed mouse +* 0x3A: Wacom tablet * 0x42: Macally * 0x5f: Microspeed mouse * 0x66: Microspeed mouse
hw/input/adb-wacom.c new file +311 -0
311 lines not on this page · raw message
hw/input/meson.build +1 -1
@@ -1,5 +1,5 @@ system_ss.add(files('hid.c')) -system_ss.add(when: 'CONFIG_ADB', if_true: files('adb.c', 'adb-mouse.c', 'adb-kbd.c')) +system_ss.add(when: 'CONFIG_ADB', if_true: files('adb.c', 'adb-mouse.c', 'adb-kbd.c', 'adb-wacom.c',)) system_ss.add(when: 'CONFIG_PCKBD', if_true: files('pckbd.c')) system_ss.add(when: 'CONFIG_PL050', if_true: files('pl050.c')) system_ss.add(when: 'CONFIG_PS2', if_true: files('ps2.c'))
hw/input/trace-events +6 -0
@@ -14,6 +14,12 @@ adb_device_mouse_readreg(int reg, uint8_t val0, uint8_t val1) "reg %d obuf[0] 0x adb_device_mouse_request_change_addr(int devaddr) "change addr to 0x%x" adb_device_mouse_request_change_addr_and_handler(int devaddr, int handler) "change addr and handler to 0x%x, 0x%x" +# adb-wacom.c +adb_device_wacom_flush(void) "flush" +adb_device_wacom_writereg(int reg, uint64_t buf) "\t<- reg %d buf 0x%04lX" +adb_device_wacom_readreg(int reg, uint64_t obut) "\t-> reg %d obuf 0x%04lX" +adb_device_wacom_request_change_addr_and_handler(int devaddr, int handler) "change addr and handler to 0x%x, 0x%x" + # adb.c adb_bus_request(uint8_t addr, const char *cmd, int size) "device 0x%x %s cmdsize=%d" adb_bus_request_done(uint8_t addr, const char *cmd, int size) "device 0x%x %s replysize=%d"
include/hw/input/adb.h +1 -0
@@ -104,5 +104,6 @@ void adb_register_autopoll_callback(ADBBusState *s, void (*cb)(void *opaque),#define TYPE_ADB_KEYBOARD "adb-keyboard"#define TYPE_ADB_MOUSE "adb-mouse" +#define TYPE_ADB_WACOM "adb-wacom"#endif /* ADB_H */
Signature · 1 line
2.45.2
PATCH v2 2/2 Added support for WACOM 2.x/ArtZ/Digitizer II
In reply to a message not in the archiveFrom: Patrick Eads <[email protected]>
streamlined efficiency since setting the xy-values to zero is not the correct way by adding state variables against which the new xy-values can be compared
added other buttons
--- hw/input/adb-wacom.c | 50 +++++++++++++++++++++++++++---------------- hw/input/trace-events | 2 +- 2 files changed, 32 insertions(+), 20 deletions(-)
hw/input/adb-wacom.c +31 -19
@@ -37,6 +37,7 @@ struct WacomState {QemuInputHandlerState *hs;int buttons_state, last_buttons_state;uint16_t dx, dy, dz; +uint16_t last_x, last_y; };struct ADBWacomClass {
@@ -47,8 +48,11 @@ struct ADBWacomClass {DeviceRealize parent_realize; }; -#define ADB_WACOM_BUTTON_LEFT 0x01 -#define ADB_WACOM_BUTTON_RIGHT 0x02 +#define ADB_WACOM_BUTTON_MIDDLE 0x01 +#define ADB_WACOM_BUTTON_LEFT 0x02 +#define ADB_WACOM_BUTTON_RIGHT 0x04 +#define ADB_WACOM_BUTTON_SIDE 0x08 +#define ADB_WACOM_BUTTON_EXTRA 0x10static void adb_wacom_handle_event (DeviceState *dev,QemuConsole *src,InputEvent *evt) {
@@ -56,8 +60,11 @@ static void adb_wacom_handle_event(DeviceState *dev, QemuConsole *src,InputMoveEvent *move;InputBtnEvent *btn;static const int bmap[INPUT_BUTTON__MAX ] = { - [INPUT_BUTTON_LEFT ] =ADB_WACOM_BUTTON_LEFT , - [INPUT_BUTTON_RIGHT ] =ADB_WACOM_BUTTON_RIGHT , + [INPUT_BUTTON_LEFT ] =ADB_WACOM_BUTTON_LEFT , + [INPUT_BUTTON_RIGHT ] =ADB_WACOM_BUTTON_RIGHT , + [INPUT_BUTTON_MIDDLE ] =ADB_WACOM_BUTTON_MIDDLE , + [INPUT_BUTTON_SIDE ] =ADB_WACOM_BUTTON_SIDE , + [INPUT_BUTTON_EXTRA ] =ADB_WACOM_BUTTON_EXTRA };switch (evt->type) {
@@ -68,12 +75,10 @@ static void adb_wacom_handle_event(DeviceState *dev, QemuConsole *src,case INPUT_AXIS_X :// Digitizer II / Artz lpi 2540 => dpi 5080 s->dx = (uint16_t ) (move->value *qemu_console_get_width (src,640 ) /2450 ); -// s->dx = (uint16_t) (move->value * qemu_console_get_width(src, 640) / 5080); break ;case INPUT_AXIS_Y :// 6x8 inch interactive surface => 4:3 aspect ratio s->dy = (uint16_t ) (move->value *qemu_console_get_height (src,480 ) /1905 ); -// s->dy = (uint16_t) (move->value * qemu_console_get_height(src, 480) / 3810); break ;default :break ;
@@ -111,7 +116,10 @@ static const QemuInputHandler adb_wacom_handler = {static int adb_wacom_poll (ADBDevice *d,uint8_t *obuf) {WacomState *s =ADB_WACOM (d); -if (s->last_buttons_state == s->buttons_state && !(s->dx || s->dy)) { +// if state of button(s) or coordinates have changed since last poll +if (!(s->last_buttons_state != s->buttons_state + || s->dx != s->last_x + || s->dy != s->last_y)) {return 0 ; }// Not quite any of the WACOM II-S/IV/IVe, BitPad One/Two, or MM 1201/961
@@ -121,12 +129,13 @@ static int adb_wacom_poll(ADBDevice *d, uint8_t *obuf) {// with ADB unlike with a standard serial bus, the packet can be condensed // into five bytes instead of requiring seven. s->last_buttons_state = s->buttons_state; - obuf[0 ] =0xC0 | ((s->dx >>8 ) &0x3F ); + s->last_x = s->dx; + s->last_y = s->dy; + obuf[0 ] = (0xC0 | ((s->dx >>8 ) &0x3F )) &0xFF ; obuf[1 ] = s->dx &0xFF ; - obuf[2 ] = ((s->dy >>8 ) &0xFF ); + obuf[2 ] = (s->dy >>8 ) &0xFF ; obuf[3 ] = s->dy &0xFF ; - obuf[4 ] = s->buttons_state; - s->dx = s->dy =0 ; + obuf[4 ] = s->buttons_state &0xFF ;return 5 ; }
@@ -138,10 +147,8 @@ static int adb_wacom_request(ADBDevice *d, uint8_t *obuf, const uint8_t *buf,if ((buf[0 ] &0x0f ) ==ADB_FLUSH ) {/* flush wacom fifo */ - s->buttons_state = s->last_buttons_state; - s->dx =0 ; - s->dy =0 ; - s->dz =0 ; + s->last_buttons_state = s->buttons_state =0 ; + s->last_x = s->last_y = s->dx = s->dy = s->dz =0 ;trace_adb_device_wacom_flush ();return 0 ; }
@@ -153,9 +160,9 @@ static int adb_wacom_request(ADBDevice *d, uint8_t *obuf, const uint8_t *buf,case ADB_WRITEREG :switch (reg) {default : -// case 1: // receives 0xFE0449 on initialization. seems to be settings packet +case 1 :// receives 0xFE0449 on initialization. seems to be settings packet // described (the manual, p. 47)? -// case 2: // receives 0x204A when modifying certain settings in control panel +case 2 :// receives 0x204A when modifying certain settings in control panel // doesn't seem to vary based on settings values chosen. break ;case 3 :
@@ -170,6 +177,9 @@ static int adb_wacom_request(ADBDevice *d, uint8_t *obuf, const uint8_t *buf, }switch (buf[2 ]) { +case 'h' : + d->devaddr = (buf[0 ] &0xF0 ) >>4 ; +break ;case ADB_CMD_SELF_TEST :break ;case ADB_CMD_CHANGE_ID :
@@ -191,7 +201,7 @@ static int adb_wacom_request(ADBDevice *d, uint8_t *obuf, const uint8_t *buf,break ; } } -if (reg !=3 )trace_adb_device_wacom_writereg (reg, *(uint64_t *) buf); +trace_adb_device_wacom_writereg (reg, *(uint64_t *) buf);break ;case ADB_READREG :switch (reg) {
@@ -245,7 +255,7 @@ static void adb_wacom_reset(DeviceState *dev) { d->handler =0x3A ; d->devaddr =ADB_DEVID_TABLET ; s->last_buttons_state = s->buttons_state =0 ; - s->dx = s->dy = s->dz =0 ; + s->last_x = s->last_y = s->dx = s->dy = s->dz =0 ; }static const VMStateDescription vmstate_adb_wacom = {
@@ -257,6 +267,8 @@ static const VMStateDescription vmstate_adb_wacom = { ADBDevice),VMSTATE_INT32 (buttons_state, WacomState),VMSTATE_INT32 (last_buttons_state, WacomState), +VMSTATE_UINT16 (last_x, WacomState), +VMSTATE_UINT16 (last_y, WacomState),VMSTATE_UINT16 (dx, WacomState),VMSTATE_UINT16 (dy, WacomState), VMSTATE_UINT16(dz, WacomState),
hw/input/trace-events +1 -1
@@ -17,7 +17,7 @@ adb_device_mouse_request_change_addr_and_handler(int devaddr, int handler) "chan # adb-wacom.c adb_device_wacom_flush(void) "flush" adb_device_wacom_writereg(int reg, uint64_t buf) "\t<- reg %d buf 0x%04lX" -adb_device_wacom_readreg(int reg, uint64_t obut) "\t-> reg %d obuf 0x%04lX" +adb_device_wacom_readreg(int reg, uint64_t obuf) "\t-> reg %d obuf 0x%04lX" adb_device_wacom_request_change_addr_and_handler(int devaddr, int handler) "change addr and handler to 0x%x, 0x%x" # adb.c
Signature · 1 line
2.45.2