Bongofish
November 19, 2017, 04:59:00 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can attach photos hosted by the forum rather than using an external image hosting site, this means they will stay forever and not disappear after a year or two.
 
   Home   Help Search Login Register  
Pages: 1 2 3 [4] 5
  Print  
Author Topic: Converting Wacom GD-1218-R from Serial to USB  (Read 32978 times)
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #45 on: December 18, 2011, 07:20:21 AM »

Thanks for the compiler options!  With a little research I found the "Mfile" tool that comes with AVR and used that to generate a Makefile.  After a little tweaking to make it match your command line options I got a hex file built and shoved it into waxbee.jar with this command:

...\waxbee>jar -ufv waxbee.jar -C ...\waxbee\source\waxbee-read-only\WaxB_Adb2Usb WaxB_Adb2Usb.hex
adding: WaxB_Adb2Usb.hex(in = 67412) (out= 23640)(deflated 64%)

Ran waxbee.jar and had it generate another .hex file (oddly, my final hex turns out to be 70kb but before putting my hex into the jar, the final hex files were 78kb).  Flashed the hex file to Teensy and it works!  Huzaah!

I've attached the Makefile I use in case anyone else wants to compile it.  All I had to do was install Win-AVR from here, leave default install options like "Add to PATH".
Get the source code with "svn checkout http://waxbee.googlecode.com/svn/ waxbee-read-only"  I actually had svn installed on my Mac (it might come preinstalled since I don't remember installing it) so I ran the command from there, but on PC you can download TortoiseSVN or various other similar tools.
Put the Makefile from this post in ...\waxbee-read-only\WaxB_Adb2Usb
Open a command prompt
cd ...\waxbee-read-only\WaxB_Adb2Usb
make

Well, it won't let me attach a file of "Makefile" type, so you can download the file here.  I can't paste the Makefile into this post because little things like having tab characters instead of spaces are actually important (which is stupid but these files were probably invented before the concept of copy and paste).  So be sure to right click the link above and choose "Save as..." instead of viewing it and copying.
« Last Edit: December 28, 2011, 04:23:02 AM by Dragon » Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #46 on: December 18, 2011, 07:52:41 AM »

Awesome!  Makefile committed.  Cool

Also added a comment on the project page pointing back to this thread.  (we can update later with something better not relying on bongofish servers and people reading the whole thread)

So you only need to checkout the source from SVN and you will have the Makefile readily available.

I see that the list of C/CPP files is "hardcoded" in the Makefile.  I wonder if we could just put *.cpp? -- (that would be awesome since I would not need to update the Makefile each time I add/remove/rename C/CPP source files).

Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #47 on: December 18, 2011, 07:56:57 AM »

I found a XC-100 (intuos2) mouse in my basement!  Yay!  I did not think I had one of those, but I actually do!  When I get a chance, I will hook up a USB intuos2 to my machine, run a usb tracer utility and dump the mouse-related packets. But probably this will not happen before christmas, I am far too busy atm.
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #48 on: December 18, 2011, 04:55:29 PM »

Woot!  Intuos2 mouse!

I updated the Makefile to just compile *.c and *.cpp and it works great.  =)
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #49 on: December 18, 2011, 06:00:33 PM »

Very cool. I committed the new version.
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #50 on: December 29, 2011, 11:19:57 PM »

I've updated it to pass through the Intuos1 tool serial number.  The serial shows up in the About > Diagnostics dialog but it doesn't show up as a second tool in the Wacom control panel.  According to this topic the different settings for different pens was a feature removed from recent driver versions!  Stupid.  From what I've read elsewhere, different settings for different pens has also had support reduced or removed from Photoshop and other paint programs.  I don't get it.

Anyway, do you want to grant me access to upload my changes to svn or do you want to review them somehow?
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #51 on: December 30, 2011, 04:25:04 AM »

send me a patch file and I will review it. We can then see how we do the commit.

Ah! Wacom is weird sometimes. The old ultrapads had tons of features built-in. As time passes, they are going "dummier" and "dummier".  (for example, before you could do multiple area mappings on the same monitor). Or support for dual devices.

So you are saying that the intuos1 tool id is recognized through an intuos2 device? The Wacom drivers recognizes it as the good tool?
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #52 on: December 30, 2011, 07:46:39 AM »

Quote
So you are saying that the intuos1 tool id is recognized through an intuos2 device? The Wacom drivers recognizes it as the good tool?

"Tool id", at least in the language being used in the Waxbee source code, is a 16 bit value that is unique for every type of tool across the entire Wacom line.  So an Intuos1 pen has tool id 0x822, an Intuos2 pen has tool id 0x852, etc.  Actually, the serial interface on my Intuos1 reports "tool id" for the 4D mouse as 0x094 but if I pass that tool ID to the USB Wacom driver, it also considers it a 4D mouse and it shows a picture of an Intuos2 style 4D mouse in the Wacom control panel.  So I think they may have left tool id unchanged for certain devices.  I also tried using 0x09C which the Wacom driver also shows as a 4D mouse with the same picture and rotation works but the scroll wheel does not.  Weird.

At any rate, the tool-specific "serial number" is a separate concept from the "tool id".  The serial number is just a 32 bit value that is different for every single tool (it's different for my two Intuos1 pens and my two Intuos1 mice) and, if I'm reading the Linux drivers correctly, the serial number seems to be 32 bits for every Wacom that supports the concept of a tool serial number.  So yes, I can pass the 32 bit value detected by the serial side to the USB side and it's accepted by the Wacom driver and shows up in the "Device S/N" field of About > Diagnose.

I've also finished handling the serial 4D mouse packets and passing them on to the USB interface so my 4D mouse is working as far as moving the pointer.  The rotation and scroll wheel also work correctly, but none of the buttons works.  I can see the button bits are changing on the serial side, but the values I pass to the USB side are ignored.  I've checked a bunch of times that I'm sending the values expected by the USB linux driver for a 4d mouse so I'm not sure what else to try at the moment.
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #53 on: December 30, 2011, 08:51:36 AM »

Ok, I got the 4d mouse buttons working by setting protocol5_packet.bit6 to 1 which is how it's set for the regular stylus.  Oddly, the Linux driver doesn't care if that bit is set or not as far as I can tell.

In the serial protocol, bit6 is actually the proximity bit, so I tried using it for proximity and setting bit5 (the USB proximity bit) to 0.  When I put my Intuos1 stylus near the Wacom control panel in the About > Diagnose dialog about 10 different tools suddenly showed up in my available selection of tools.  I think I must have activated a debugging bit because many of the tools don't actually exist such as "Rotation stylus", "Designer pen", "Wood pen" and "10 button stylus"!


* Rotation stylus.jpg (73.31 KB. 548x610 - viewed 692 times.)


I also tried setting bit5 to 1 and using bit6 as proximity but it wouldn't recognize the stylus, so I returned to using bit5 as proximity and just keeping bit6 set to 1.

Now I think everything is working great except I just noticed my stylus eraser isn't being detected as an eraser... grrr.

Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #54 on: December 30, 2011, 08:56:30 AM »

Awesome!  

The linux driver code only decodes what it wants to look at. The Wacom driver might be looking at more bits. Would it be valuable to put my Intuos2-series XC-100 2D Mouse under the USB packet sniffer -- does this device have the same buttons as the 4D mouse of yours?

Looking forward to review the code! (you can email me the patch)

I need to understand this tool id vs. serial number thingy a bit more. I am under the impression that the tool id is constructed using bits and bytes from from the serial number and I thought this was a Linux driver-only "concept". But you may prove me wrong.  Tongue
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #55 on: December 30, 2011, 09:47:15 AM »

I'll have to figure out how to make a patch with svn.  I'm more used to git.

The problem with the eraser on my stylus seemed to be corruption in the control panel data.  Neither pen pressure nor eraser pressure were showing up in the control panel (but they did show up in About > Diagnose).  I removed my stylus from the list of tools, which crashed the control panel, and when I put it back it was detecting eraser pressure on the eraser tab and pen pressure on the pen tab.

The Intuos2 4D mouse has the same number of buttons as the Intuos1 4D mouse.  The only difference is the scroll wheel on the intuos2 mouse is where the middle button is on the Intuos1 mouse.  You can click the scroll wheel to act as the middle button.

If you packet sniff your Intuos2 mouse we can maybe confirm what bits should appear after hid_identifier, though the bits I've used seem to be working fine.

BTW, here's comments I added to the code describing how the bits for tool id and serial are encoded:
Code:
// This is how the tool type is decoded by the USB linux driver:
//   (data[2] << 4) | (data[3] >> 4) | ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
// And this is how the serial is decoded:
//   ((data[3] & 0x0f) << 28) + (data[4] << 20) + (data[5] << 12) + (data[6] << 4) + (data[7] >> 4);
// We need to reverse these equations to encode the tool id and serial.  If you look at the equations,
// Tool id (T) is encoded using 20 bits and serial (S) is encoded using 32 bits.  However, notice that
// tool id decodes to a 24 bit number where only bits 23-16, 11-0 are assigned values stored in the
// encoded data.  It would be logical to place bits 15-12 as the last 4 bits of data[8] but the
// decoding equation ignores those bits using & 0xf0.  That could be a bug in the decoding equation.
// Either way, these bits are all 0 in the data we plan to send so it doesn't matter for our purposes.
// The tool id bits are spread out in a strange pattern, presumably because tool type started out as 12 bits
// and was later padded to 24 by placing additional bits in the last half of data[7] and the first
// half of data[8].
// data[2]  [3]      [4]      [5]      [6]      [7]      [8]
// TTTTTTTT TTTTSSSS SSSSSSSS SSSSSSSS SSSSSSSS SSSSTTTT TTTT????
// Bit numbers (a 3 above a 1 means bit 31):
// 11987654 32103322 22222222 11111111 11987654 32102222 1111
// 10           1098 76543210 98765432 10           3210 9876

More evidence that the serial number is a separate 32 bit value from the tool id is that the About > Diagnose dialog shows S/N as a value like "0x12345678".  This is a 32-bit number in hex and it displays the same 32 bit number I pass to it in the data above and it doesn't include the tool id.
« Last Edit: December 30, 2011, 06:25:55 PM by Dragon » Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #56 on: December 31, 2011, 06:57:06 AM »

The XC-100 is a 2D mouse with 2 buttons (not a 4D mouse with 4 buttons).
Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #57 on: December 31, 2011, 07:23:35 AM »

The XC-100 is a 2D mouse with 2 buttons (not a 4D mouse with 4 buttons).

Whoops, you did say it was a 2D mouse originally - I missed that bit.

I think the best thing would be to simply test your mouse to see if the 2D mouse code I added works and if not, then you can packet sniff.

But basically a 2D mouse is the same as a 4D mouse except it has two fewer buttons and a "relative" scroll wheel that just sends +1 or -1 scroll events each time you roll the wheel a little.  The 2D mouse does have a middle button which is activated by pushing the scroll wheel in.

The Intuos1 4D mouse has a "throttle" scroll wheel that sends a value between -255 to +255 depending how far you push it up or down.  I assume the Intuos2 4D mouse is the same, except its scroll wheel replaces the middle button instead of being located where your thumb is.

Also, the 4D mouse reports its rotation between 0 and 360 degrees.  From looking at the linux driver, I don't think the 2D mouse reports rotation.
Logged
tufty
New Poster
*
Posts: 25


View Profile
« Reply #58 on: March 31, 2014, 12:16:20 PM »

I need to understand this tool id vs. serial number thingy a bit more. I am under the impression that the tool id is constructed using bits and bytes from from the serial number and I thought this was a Linux driver-only "concept". But you may prove me wrong.  Tongue
According to Wacom, the unique tool id is a catenation of the tool id (16 bits, although not all used) and the serial number (32 bits).  In other words, the tool serial number is only guaranteed unique within a particular tool type.

The tool id gives you what type of tool you're dealing with (and, with a little creative masking, you can say, for example, "pen" vs "mouse", where pen might mean any stylus-type device, and mouse means any mouseish thing).  Then you can use the serial number to distinguish between multiple similr devices on the same tablet.

Simon
Logged
Aerendraca
Administrator
Hero Member
*****
Posts: 1068


View Profile
« Reply #59 on: March 31, 2014, 08:14:20 PM »

Hey Tufty, this is quite an old thread now, but hey, all new information is great, maybe it'll help someone out.
Logged
Pages: 1 2 3 [4] 5
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!