1
0
Fork 0
mirror of https://github.com/rfc2822/GfxTablet synced 2025-10-03 09:39:16 +02:00

update Android client to use [0,UINT16_MAX) as its range of values

This commit is contained in:
Jarrad Whitaker 2015-11-27 22:53:37 +11:00
parent 2ae8c7f213
commit 5865d3c81e
2 changed files with 6 additions and 5 deletions

View file

@ -124,17 +124,18 @@ public class CanvasView extends View implements SharedPreferences.OnSharedPrefer
return false; return false;
} }
// these overflow and wrap around to negative short values, but thankfully Java will continue
// on regardless, so we can just ignore Java's interpretation of them and send them anyway.
short normalizeX(float x) { short normalizeX(float x) {
return (short)(Math.min(Math.max(0, x), maxX) * Short.MAX_VALUE/maxX); return (short)(Math.min(Math.max(0, x), maxX) * 2*Short.MAX_VALUE/maxX);
} }
short normalizeY(float x) { short normalizeY(float x) {
return (short)(Math.min(Math.max(0, x), maxY) * Short.MAX_VALUE/maxY); return (short)(Math.min(Math.max(0, x), maxY) * 2*Short.MAX_VALUE/maxY);
} }
short normalizePressure(float x) { short normalizePressure(float x) {
return (short)(Math.min(Math.max(0, x), 2.0) * Short.MAX_VALUE/2.0); return (short)(Math.min(Math.max(0, x), 2.0) * Short.MAX_VALUE);
} }
} }

View file

@ -15,7 +15,7 @@ public class NetEvent {
TYPE_DISCONNECT TYPE_DISCONNECT
} }
static final String signature = "GfxTablet"; static final String signature = "GfxTablet";
static final short protocol_version = 1; static final short protocol_version = 2;
final Type type; final Type type;
short x, y, pressure; short x, y, pressure;