From 7ce678aa5f6bc1acc255cb029f3b91fbe1fbfa3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 29 May 2007 20:21:33 +0000 Subject: [PATCH] * implement conversion of absolute mouse coordinates (0..1) in device messages to normal screen coordinates git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21274 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/input/InputServer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 02d506d487..9d7257f58f 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -1434,6 +1434,7 @@ InputServer::_SanitizeEvents(EventList& events) { BPoint where; int32 x, y; + float absX, absY; if (event->FindInt32("x", &x) == B_OK && event->FindInt32("y", &y) == B_OK) { @@ -1447,6 +1448,21 @@ InputServer::_SanitizeEvents(EventList& events) PRINT(("new position: %f, %f, %ld, %ld\n", fMousePos.x, fMousePos.y, x, y)); + } else if (event->FindFloat("x", &absX) == B_OK + && event->FindFloat("y", &absY) == B_OK) { + // device gives us absolute screen coords + // in range 0..1 + // convert to absolute screen pos + // (the message is supposed to contain the original + // absolute coordinates as "be:tablet_x/y") + fMousePos.x = absX * fFrame.Width(); + fMousePos.y = absY * fFrame.Height(); + fMousePos.ConstrainTo(fFrame); + + event->RemoveName("x"); + event->RemoveName("y"); + event->AddPoint("where", fMousePos); + PRINT(("new position : %f, %f\n", fMousePos.x, fMousePos.y)); } else if (event->FindPoint("where", &where) == B_OK) { fMousePos = where; fMousePos.ConstrainTo(fFrame);