Ticket #8338: touchscreen.diff
File touchscreen.diff, 9.1 KB (added by , 12 years ago) |
---|
-
headers/os/drivers/usb/USB_hid_page_digitizers.h
diff --git a/headers/os/drivers/usb/USB_hid_page_digitizers.h b/headers/os/drivers/usb/USB_hid_page_digitizers.h index 1bfc9ba..66460a8 100644
a b enum { 54 54 B_HID_UID_DIG_SECONDARY_TIP_SWITCH, 55 55 B_HID_UID_DIG_BARREL_SWITCH, 56 56 B_HID_UID_DIG_ERASER, 57 B_HID_UID_DIG_TABLET_PICK 57 B_HID_UID_DIG_TABLET_PICK, 58 B_HID_UID_DIG_CONFIDENCE, 59 B_HID_UID_DIG_CONTACT_IDENTIFIER = 0x51, 58 60 }; 59 61 60 62 -
headers/private/input/keyboard_mouse_driver.h
diff --git a/headers/private/input/keyboard_mouse_driver.h b/headers/private/input/keyboard_mouse_driver.h index 99306fd..5eab743 100644
a b typedef struct { 111 111 int32 wheel_xdelta; 112 112 float tilt_x; 113 113 float tilt_y; 114 uint32 contact_id; 114 115 } tablet_movement; 115 116 116 117 -
src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp
diff --git a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp index 283231a..2e20997 100644
a b 33 33 34 34 35 35 #undef TRACE 36 // #define TRACE_TABLET_DEVICE36 // #define TRACE_TABLET_DEVICE 37 37 #ifdef TRACE_TABLET_DEVICE 38 38 39 39 class FunctionTracer { … … TabletDevice::_ControlThread() 289 289 } 290 290 291 291 _UpdateSettings(); 292 292 293 struct { 294 uint32 buttons; 295 float xpos, ypos; 296 } trackingState[4]; 297 memset(&trackingState, 0, sizeof(trackingState)); 298 293 299 static const bigtime_t kTransferDelay = 1000000 / 125; 294 300 // 125 transfers per second should be more than enough 295 301 bigtime_t nextTransferTime = system_time() + kTransferDelay; 296 uint32 lastButtons = 0;297 float lastXPosition = 0;298 float lastYPosition = 0;299 302 300 303 while (fActive) { 301 304 tablet_movement movements; … … TabletDevice::_ControlThread() 309 312 return; 310 313 } 311 314 315 if (movements.contact_id >= 4) 316 continue; 317 312 318 // take care of updating the settings first, if necessary 313 319 if (fUpdateSettings) { 314 320 fUpdateSettings = false; … … TabletDevice::_ControlThread() 324 330 325 331 // Send single messages for each event 326 332 327 uint32 buttons = lastButtons ^ movements.buttons; 333 if (movements.xpos != trackingState[movements.contact_id].xpos 334 || movements.ypos != trackingState[movements.contact_id].ypos) { 335 BMessage* message = _BuildMouseMessage(B_MOUSE_MOVED, 336 movements.timestamp, trackingState[movements.contact_id].buttons, movements.xpos, 337 movements.ypos); 338 if (message != NULL) { 339 message->AddFloat("be:tablet_x", movements.xpos); 340 message->AddFloat("be:tablet_y", movements.ypos); 341 message->AddFloat("be:tablet_pressure", movements.pressure); 342 message->AddInt32("be:tablet_eraser", movements.eraser); 343 if (movements.tilt_x != 0.0 || movements.tilt_y != 0.0) { 344 message->AddFloat("be:tablet_tilt_x", movements.tilt_x); 345 message->AddFloat("be:tablet_tilt_y", movements.tilt_y); 346 } 347 348 if (movements.contact_id != 0) 349 message->AddInt32("be:tablet_contact_id", movements.contact_id); 350 351 fTarget.EnqueueMessage(message); 352 trackingState[movements.contact_id].xpos = movements.xpos; 353 trackingState[movements.contact_id].ypos = movements.ypos; 354 } 355 } 356 357 uint32 buttons = trackingState[movements.contact_id].buttons ^ movements.buttons; 328 358 if (buttons != 0) { 329 359 bool pressedButton = (buttons & movements.buttons) > 0; 330 360 BMessage* message = _BuildMouseMessage( … … TabletDevice::_ControlThread() 339 369 LOG_EVENT("B_MOUSE_UP\n"); 340 370 341 371 fTarget.EnqueueMessage(message); 342 lastButtons = movements.buttons; 343 } 344 } 345 346 if (movements.xpos != lastXPosition 347 || movements.ypos != lastYPosition) { 348 BMessage* message = _BuildMouseMessage(B_MOUSE_MOVED, 349 movements.timestamp, movements.buttons, movements.xpos, 350 movements.ypos); 351 if (message != NULL) { 352 message->AddFloat("be:tablet_x", movements.xpos); 353 message->AddFloat("be:tablet_y", movements.ypos); 354 message->AddFloat("be:tablet_pressure", movements.pressure); 355 message->AddInt32("be:tablet_eraser", movements.eraser); 356 if (movements.tilt_x != 0.0 || movements.tilt_y != 0.0) { 357 message->AddFloat("be:tablet_tilt_x", movements.tilt_x); 358 message->AddFloat("be:tablet_tilt_y", movements.tilt_y); 359 } 360 361 fTarget.EnqueueMessage(message); 362 lastXPosition = movements.xpos; 363 lastYPosition = movements.ypos; 372 trackingState[movements.contact_id].buttons = movements.buttons; 364 373 } 365 374 } 366 375 -
src/add-ons/kernel/drivers/input/usb_hid/Driver.h
diff --git a/src/add-ons/kernel/drivers/input/usb_hid/Driver.h b/src/add-ons/kernel/drivers/input/usb_hid/Driver.h index 3b7528e..e857d3c 100644
a b const char ** publish_devices(); 34 34 device_hooks * find_device(const char *name); 35 35 } 36 36 37 #define TRACE(x...) / *dprintf(DRIVER_NAME ": " x)*/37 #define TRACE(x...) // dprintf(DRIVER_NAME ": " x) 38 38 #define TRACE_ALWAYS(x...) dprintf(DRIVER_NAME ": " x) 39 39 40 40 #endif //_USB_HID_DRIVER_H_ -
src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.cpp
diff --git a/src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.cpp b/src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.cpp index 0ba0680..c9238e8 100644
a b MouseProtocolHandler::MouseProtocolHandler(HIDReport &report, bool tablet, 53 53 54 54 fWheel = report.FindItem(B_HID_USAGE_PAGE_GENERIC_DESKTOP, 55 55 B_HID_UID_GD_WHEEL); 56 57 fTipSwitch = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER, 58 B_HID_UID_DIG_TIP_SWITCH); 56 59 60 fInRange = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER, 61 B_HID_UID_DIG_IN_RANGE); 62 63 fContactId = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER, 64 B_HID_UID_DIG_CONTACT_IDENTIFIER); 65 66 fConfidence = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER, 67 B_HID_UID_DIG_CONFIDENCE); 68 57 69 TRACE("mouse device with %lu buttons and %swheel\n", buttonCount, 58 70 fWheel == NULL ? "no " : ""); 59 71 TRACE("report id: %u\n", report.ID()); … … MouseProtocolHandler::AddHandlers(HIDDevice &device, HIDCollection &collection, 127 139 128 140 if (!xAxis->Relative() && !yAxis->Relative()) 129 141 tablet = true; 130 142 143 /* W500 hack */ 144 if (tablet && (inputReport->ID() != 4)) 145 continue; 146 131 147 ProtocolHandler *newHandler = new(std::nothrow) MouseProtocolHandler( 132 148 *inputReport, tablet, *xAxis, *yAxis); 133 149 if (newHandler == NULL) { … … MouseProtocolHandler::_ReadReport(void *buffer) 223 239 wheelData = fWheel->Data(); 224 240 225 241 uint32 buttons = 0; 226 for (uint32 i = 0; i < B_MAX_MOUSE_BUTTONS; i++) { 227 HIDReportItem *button = fButtons[i]; 228 if (button == NULL) 229 break; 242 uint32 tipSwitchData, inRangeData, contactIdData, confidenceData; 230 243 231 if (button->Extract() == B_OK && button->Valid()) 232 buttons |= (button->Data() & 1) << (button->UsageID() - 1); 244 if (fTablet) { 245 if (fTipSwitch != NULL && fTipSwitch->Extract() == B_OK && fTipSwitch->Valid()) 246 tipSwitchData = fTipSwitch->Data(); 247 248 if (fInRange != NULL && fInRange->Extract() == B_OK && fInRange->Valid()) 249 inRangeData = fInRange->Data(); 250 251 if (fContactId != NULL && fContactId->Extract() == B_OK && fContactId->Valid()) 252 contactIdData = fContactId->Data(); 253 254 if (fConfidence != NULL && fConfidence->Extract() == B_OK && fConfidence->Valid()) 255 confidenceData = fConfidence->Data(); 256 257 TRACE("tipSwitch = %ld, inRange = %ld, contactId = %ld, confidence = %ld\n", tipSwitchData, inRangeData, contactIdData, confidenceData); 258 259 if (tipSwitchData != 0) 260 buttons = 1; 261 else 262 buttons = 0; 263 264 } else { 265 for (uint32 i = 0; i < B_MAX_MOUSE_BUTTONS; i++) { 266 HIDReportItem *button = fButtons[i]; 267 if (button == NULL) 268 break; 269 270 if (button->Extract() == B_OK && button->Valid()) 271 buttons |= (button->Data() & 1) << (button->UsageID() - 1); 272 } 233 273 } 234 274 275 235 276 fReport.DoneProcessing(); 236 277 TRACE("got mouse report\n"); 237 278 … … MouseProtocolHandler::_ReadReport(void *buffer) 257 298 258 299 info->xpos = axisAbsoluteData[0]; 259 300 info->ypos = axisAbsoluteData[1]; 260 info->has_contact = true;301 info->has_contact = buttons & 0x1; 261 302 info->pressure = 1.0; 262 303 info->eraser = false; 263 304 info->tilt_x = 0.0; … … MouseProtocolHandler::_ReadReport(void *buffer) 267 308 info->clicks = clicks; 268 309 info->timestamp = timestamp; 269 310 info->wheel_ydelta = -wheelData; 311 312 info->contact_id = contactIdData; 270 313 } else { 271 314 mouse_movement *info = (mouse_movement *)buffer; 272 315 memset(info, 0, sizeof(mouse_movement)); -
src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.h
diff --git a/src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.h b/src/add-ons/kernel/drivers/input/usb_hid/MouseProtocolHandler.h index ec6121b..b14665e 100644
a b private: 43 43 HIDReportItem & fYAxis; 44 44 HIDReportItem * fWheel; 45 45 HIDReportItem * fButtons[B_MAX_MOUSE_BUTTONS]; 46 HIDReportItem * fTipSwitch; 47 HIDReportItem * fInRange; 48 HIDReportItem * fContactId; 49 HIDReportItem * fConfidence; 46 50 47 51 uint32 fLastButtons; 48 52 uint32 fClickCount;