There is a distinction of 2 cases:

Code: Select all

```
/*--------------------------------------------------------------------------*\
* decode_gin()
*
* Decodes a GIN tek vector string into an xy pair of relative device
* coordinates. It's best to not use absolute device coordinates since the
* coordinate bounds are different depending on the report encoding used.
*
* Standard: <HiX><LoX><HiY><LoY>
* Extended: <HiY><Extra><LoY><HiX><LoX>
*
* where <Extra> holds the two low order bits for each coordinate.
\*--------------------------------------------------------------------------*/
static void
decode_gin(char *c, PLGraphicsIn *gin)
{
int x, y, lc = strlen(c);
if (lc == 4) {
x = ((c[0] & 0x1f) << 5) +
((c[1] & 0x1f) );
y = ((c[2] & 0x1f) << 5) +
((c[3] & 0x1f) );
gin->pX = x;
gin->pY = y;
gin->dX = x / (double) TEKX;
gin->dY = y / (double) TEKY;
}
else if (lc == 5) {
y = ((c[0] & 0x1f) << 7) +
((c[2] & 0x1f) << 2) +
((c[1] & 0x06) >> 2);
x = ((c[3] & 0x1f) << 7) +
((c[4] & 0x1f) << 2) +
((c[1] & 0x03) );
gin->pX = x;
gin->pY = y;
gin->dX = x / (double) (TEKX << 2);
gin->dY = y / (double) (TEKY << 2);
}
else { /* Illegal encoding */
gin->pX = 0;
gin->pY = 0;
gin->dY = 0;
gin->dX = 0;
}
}
```