- Timestamp:
- Sep 22, 2012 1:53:03 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/haiku/VBoxMouse
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/haiku/VBoxMouse/VBoxMouse.cpp
r43364 r43405 70 70 71 71 72 static inline int vboxMouseAcquire() 73 { 74 uint32_t fFeatures = 0; 75 int rc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL); 76 if (RT_SUCCESS(rc)) 77 { 78 rc = VbglR3SetMouseStatus(fFeatures | VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL); 79 if (RT_FAILURE(rc)) 80 LogRel(("VbglR3SetMouseStatus failed. rc=%d\n", rc)); 81 } 82 else 83 LogRel(("VbglR3GetMouseStatus failed. rc=%d\n", rc)); 84 return rc; 85 } 86 87 88 static inline int vboxMouseRelease() 89 { 90 uint32_t fFeatures = 0; 91 int rc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL); 92 if (RT_SUCCESS(rc)) 93 { 94 rc = VbglR3SetMouseStatus(fFeatures & ~VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE & ~VMMDEV_MOUSE_NEW_PROTOCOL); 95 if (RT_FAILURE(rc)) 96 LogRel(("VbglR3SetMouseStatus failed. rc=%d\n", rc)); 97 } 98 else 99 LogRel(("VbglR3GetMouseStatus failed. rc=%d\n", rc)); 100 return rc; 101 } 102 103 72 104 VBoxMouse::VBoxMouse() 73 105 : BInputServerDevice(), … … 114 146 status_t VBoxMouse::Start(const char *device, void *cookie) 115 147 { 148 #if 0 116 149 status_t err; 117 150 int rc; … … 149 182 150 183 return B_ERROR; 184 #endif 185 186 status_t err = B_OK; 187 int rc; 188 uint32_t fFeatures = 0; 189 LogFlowFunc(("device=%s cookie=%p\n", device, cookie)); 190 191 rc = vboxMouseAcquire(); 192 if (RT_SUCCESS(rc)) 193 { 194 err = fServiceThreadID = spawn_thread(_ServiceThreadNub, "VBoxMouse", B_NORMAL_PRIORITY, this); 195 if (err >= B_OK) 196 { 197 resume_thread(fServiceThreadID); 198 return B_OK; 199 } 200 else 201 LogRel(("VBoxMouse::Start Error starting service thread: 0x%08lx\n", err)); 202 203 vboxMouseRelease(); 204 err = B_ERROR; 205 } 206 else 207 { 208 LogRel(("VBoxMouse::Start vboxMouseAcquire failed. rc=%d\n", rc)); 209 err = B_DEVICE_NOT_FOUND; 210 } 211 212 return err; 151 213 } 152 214 … … 161 223 fExiting = true; 162 224 163 164 rc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL); 165 if (RT_SUCCESS(rc)) 166 rc = VbglR3SetMouseStatus(fFeatures 167 & ~VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE 168 & ~VMMDEV_MOUSE_NEW_PROTOCOL); 169 225 vboxMouseRelease(); 170 226 171 227 close(fDriverFD); … … 183 239 status_t VBoxMouse::Control(const char *device, void *cookie, uint32 code, BMessage *message) 184 240 { 185 // respond to changes in the system186 241 switch (code) 187 242 { … … 216 271 uint32_t cx, cy, fFeatures; 217 272 int rc; 218 219 273 220 274 fd_set readSet, writeSet, errorSet; … … 233 287 } 234 288 235 if (RT_SUCCESS(VbglR3GetMouseStatus(&fFeatures, &cx, &cy)) 289 int rc = VbglR3GetMouseStatus(&fFeatures, &cx, &cy); 290 if ( RT_SUCCESS(rc) 236 291 && (fFeatures & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE)) 237 292 { … … 241 296 _debugPrintf("VBoxMouse: at %d,%d %f,%f\n", cx, cy, x, y); 242 297 243 /* send absolute movement */ 244 298 /* Send absolute movement */ 245 299 bigtime_t now = system_time(); 246 300 BMessage *event = new BMessage(B_MOUSE_MOVED); -
trunk/src/VBox/Additions/haiku/VBoxMouse/VBoxMouse.h
r43364 r43405 50 50 #include <InputServerDevice.h> 51 51 52 extern "C" 53 _EXPORT BInputServerDevice* instantiate_input_device(); 52 extern "C" _EXPORT BInputServerDevice* instantiate_input_device(); 54 53 55 54 class VBoxMouse : public BInputServerDevice … … 59 58 virtual ~VBoxMouse(); 60 59 61 virtual status_t 62 virtual status_t 60 virtual status_t InitCheck(); 61 virtual status_t SystemShuttingDown(); 63 62 64 virtual status_t Start(const char *device, void *cookie); 65 virtual status_t Stop(const char *device, void *cookie); 66 virtual status_t Control(const char *device, 67 void *cookie, 68 uint32 code, 69 BMessage *message); 63 virtual status_t Start(const char *device, void *cookie); 64 virtual status_t Stop(const char *device, void *cookie); 65 virtual status_t Control(const char *device, void *cookie, uint32 code, BMessage *message); 70 66 71 67 private: 72 68 73 static status_t 74 status_t 69 static status_t _ServiceThreadNub(void *_this); 70 status_t _ServiceThread(); 75 71 76 int fDriverFD; 77 thread_id fServiceThreadID; 78 bool fExiting; 79 72 int fDriverFD; 73 thread_id fServiceThreadID; 74 bool fExiting; 80 75 }; 81 82 76 83 77 #endif /* __VBOXMOUSE__H */ -
trunk/src/VBox/Additions/haiku/VBoxMouse/VBoxMouseFilter.cpp
r43364 r43405 62 62 #include <iprt/err.h> 63 63 64 / / TODO can this be merged with VBoxMouse?64 /* @todo can this be merged with VBoxMouse? */ 65 65 66 66 RTDECL(BInputServerFilter *) … … 79 79 } 80 80 81 81 82 VBoxMouseFilter::~VBoxMouseFilter() 82 83 { 83 84 } 85 84 86 85 87 filter_result VBoxMouseFilter::Filter(BMessage *message, BList *outList) … … 92 94 printf("click|release\n"); 93 95 message->FindInt32("buttons", &fCurrentButtons); 96 /** @todo r=ramshankar this looks wrong, no 'break' here? */ 94 97 } 98 95 99 case B_MOUSE_MOVED: 96 100 { 97 101 printf("mouse moved\n"); 98 102 message->ReplaceInt32("buttons", fCurrentButtons); 103 /** @todo r=ramshankar: 'break' or explicit comment please. */ 99 104 } 100 105 } … … 102 107 return B_DISPATCH_MESSAGE; 103 108 } 109 -
trunk/src/VBox/Additions/haiku/VBoxMouse/VBoxMouseFilter.h
r43363 r43405 45 45 */ 46 46 47 #ifndef __VBOXMOUSE_ _H48 #define __VBOXMOUSE_ _H47 #ifndef __VBOXMOUSE_FILTER__H 48 #define __VBOXMOUSE_FILTER__H 49 49 50 50 #include <InputServerFilter.h> … … 52 52 extern "C" _EXPORT BInputServerFilter* instantiate_input_filter(); 53 53 54 class VBoxMouseFilter : public BInputServerFilter { 55 public: 56 VBoxMouseFilter(); 57 virtual ~VBoxMouseFilter(); 58 // virtual status_t InitCheck(); 59 virtual filter_result Filter(BMessage* message, BList* outList); 54 class VBoxMouseFilter : public BInputServerFilter 55 { 56 public: 57 VBoxMouseFilter(); 58 virtual ~VBoxMouseFilter(); 60 59 61 private: 60 virtual filter_result Filter(BMessage* message, BList* outList); 62 61 63 static status_t _ServiceThreadNub(void *_this); 64 status_t _ServiceThread(); 62 private: 63 static status_t _ServiceThreadNub(void *_this); 64 status_t _ServiceThread(); 65 65 66 intfDriverFD;67 thread_idfServiceThreadID;68 boolfExiting;69 boolfEnabled;70 int32fCurrentButtons;66 int fDriverFD; 67 thread_id fServiceThreadID; 68 bool fExiting; 69 bool fEnabled; 70 int32 fCurrentButtons; 71 71 }; 72 72 73 #endif /* __VBOXMOUSE_FILTER__H */ 73 74 74 #endif /* __VBOXMOUSE__H */75
Note:
See TracChangeset
for help on using the changeset viewer.