This fleshes out the HandleSetMousePosition() and the input_server now tracks the current position of the mouse cursor.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@729 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Phipps
2002-08-12 23:32:30 +00:00
parent bd348b163b
commit f85924fecf
+36 -3
View File
@@ -40,6 +40,7 @@
#include "FindDirectory.h" #include "FindDirectory.h"
#include "Entry.h" #include "Entry.h"
#include "Locker.h" #include "Locker.h"
#include "Debug.h"
#include "InputServerDeviceListEntry.h" #include "InputServerDeviceListEntry.h"
#include "InputServerFilterListEntry.h" #include "InputServerFilterListEntry.h"
@@ -736,9 +737,39 @@ void InputServer::HandleGetSetMouseSpeed(BMessage *,
* Method: InputServer::HandleSetMousePosition() * Method: InputServer::HandleSetMousePosition()
* Descr: * Descr:
*/ */
void InputServer::HandleSetMousePosition(BMessage *, void InputServer::HandleSetMousePosition(BMessage *message, BMessage *outbound)
BMessage *)
{ {
// this assumes that both supplied pointers are identical
ASSERT(outbound == message);
sMousePos.x = 200;
sMousePos.y = 200;
int32 xValue,
yValue;
message->FindInt32("x",xValue);
printf("[HandleSetMousePosition] x = %lu:\n",xValue);
switch(message->what){
case B_MOUSE_MOVED:{
// get point and button from msg
if((outbound->FindInt32(X_VALUE,&xValue) == B_OK) && (outbound->FindInt32(Y_VALUE,&yValue) == B_OK)){
sMousePos.x += xValue;
sMousePos.y += yValue;
outbound->ReplaceInt32(X_VALUE,sMousePos.x);
outbound->ReplaceInt32(Y_VALUE,sMousePos.y);
}
break;
}
// Should be some Mouse Down and Up code here ..
// Along with some Key Down and up codes ..
default:
break;
}
} }
@@ -1204,7 +1235,7 @@ void InputServer::WatchPort()
// Block until we find the size of the next message // Block until we find the size of the next message
length = port_buffer_size(EventLooperPort); length = port_buffer_size(EventLooperPort);
buffer = (char*)malloc(length); buffer = (char*)malloc(length);
printf("[Event Looper] BMessage Size = %d\n", length); printf("[Event Looper] BMessage Size = %lu\n", length);
//event = NULL; //event = NULL;
BMessage *event = new BMessage(); BMessage *event = new BMessage();
err = read_port(EventLooperPort, &code, buffer, length); err = read_port(EventLooperPort, &code, buffer, length);
@@ -1222,6 +1253,8 @@ void InputServer::WatchPort()
// This is where the message should be processed. // This is where the message should be processed.
event->PrintToStream(); event->PrintToStream();
HandleSetMousePosition(event, event);
DispatchEvent(event); DispatchEvent(event);
//printf("Event writen to port\n"); //printf("Event writen to port\n");