diff -Nuar tablet/TabletInputDevice.cpp tablet.mine/TabletInputDevice.cpp
old
|
new
|
|
29 | 29 | |
30 | 30 | #include "TabletInputDevice.h" |
31 | 31 | #include "kb_mouse_settings.h" |
32 | | #include "kb_mouse_driver.h" |
| 32 | //#include "kb_mouse_driver.h" |
| 33 | #include <keyboard_mouse_driver.h> |
33 | 34 | |
34 | 35 | #include <stdlib.h> |
35 | 36 | #include <unistd.h> |
… |
… |
|
176 | 177 | device->fd = open(device->path, O_RDWR); |
177 | 178 | if (device->fd<0) |
178 | 179 | return B_ERROR; |
| 180 | |
| 181 | LOG("opening:%s\n",device->path); |
179 | 182 | |
180 | 183 | InitFromSettings(device); |
181 | 184 | |
… |
… |
|
198 | 201 | tablet_device *device = (tablet_device *)cookie; |
199 | 202 | |
200 | 203 | LOG("%s(%s)\n", __PRETTY_FUNCTION__, name); |
201 | | |
| 204 | LOG("closing:%s\n",device->path); |
202 | 205 | close(device->fd); |
203 | 206 | |
204 | 207 | device->active = false; |
… |
… |
|
265 | 268 | |
266 | 269 | if (opcode == B_ENTRY_CREATED) |
267 | 270 | AddDevice(path.Path()); |
| 271 | /* |
268 | 272 | else |
269 | 273 | RemoveDevice(path.Path()); |
270 | | |
| 274 | */ |
271 | 275 | return status; |
272 | 276 | } |
273 | 277 | |
… |
… |
|
276 | 280 | TabletInputDevice::AddDevice(const char *path) |
277 | 281 | { |
278 | 282 | CALLED(); |
279 | | |
| 283 | LOG("adding %s\n",path); |
280 | 284 | tablet_device *device = new tablet_device(path); |
281 | 285 | if (!device) { |
282 | 286 | LOG("No memory\n"); |
… |
… |
|
289 | 293 | |
290 | 294 | fDevices.AddItem(device); |
291 | 295 | |
| 296 | LOG("registering input device: %s:%s\n",device->device_ref.name,(device->active) ? "yes":"no"); |
| 297 | LOG("device path: %s\n",&device->path); |
292 | 298 | return RegisterDevices(devices); |
293 | 299 | } |
294 | 300 | |
… |
… |
|
298 | 304 | { |
299 | 305 | CALLED(); |
300 | 306 | int32 i = 0; |
| 307 | input_device_ref *devices[2]; |
| 308 | |
| 309 | devices[1] = NULL; |
| 310 | |
301 | 311 | tablet_device *device = NULL; |
302 | 312 | while ((device = (tablet_device *)fDevices.ItemAt(i)) != NULL) { |
303 | 313 | if (!strcmp(device->path, path)) { |
| 314 | LOG("deleting node:%s\n",device->path); |
| 315 | devices[0] = &device->device_ref; |
| 316 | UnregisterDevices(devices); |
304 | 317 | fDevices.RemoveItem(device); |
305 | 318 | delete device; |
306 | 319 | return B_OK; |
307 | | } |
| 320 | } |
308 | 321 | } |
309 | 322 | |
310 | 323 | return B_ENTRY_NOT_FOUND; |
| 324 | |
311 | 325 | } |
312 | 326 | |
313 | 327 | |
… |
… |
|
320 | 334 | tablet_movement old_movements; |
321 | 335 | uint32 buttons_state = 0; |
322 | 336 | BMessage *message; |
| 337 | |
| 338 | |
| 339 | LOG("Entering DeviceWatcher for %s::%x\n",dev->path,dev->fd); |
| 340 | |
323 | 341 | while (dev->active) { |
324 | 342 | memset(&movements, 0, sizeof(movements)); |
325 | 343 | if (ioctl(dev->fd, MS_READ, &movements) != B_OK) { |
326 | | snooze(10000); // this is a realtime thread, and something is wrong... |
327 | | continue; |
| 344 | LOG("Failed ioctl from %s\n",dev->path); |
| 345 | LOG("RemovingDevice\n"); |
| 346 | //snooze(10000); // this is a realtime thread, and something is wrong... |
| 347 | //close(dev->fd); |
| 348 | dev->active = false; |
| 349 | sSingletonTabletDevice->RemoveDevice(dev->path); |
| 350 | |
| 351 | return 0; |
328 | 352 | } |
329 | 353 | |
330 | 354 | uint32 buttons = buttons_state ^ movements.buttons; |
331 | | |
332 | | LOG("%s: buttons: 0x%lx, x: %f, y: %f, clicks:%ld, wheel_x:%ld, wheel_y:%ld\n", dev->device_ref.name, movements.buttons, |
333 | | movements.xpos, movements.ypos, movements.clicks, movements.wheel_xdelta, movements.wheel_ydelta); |
334 | | |
335 | | movements.xpos /= 10206.0; |
336 | | movements.ypos /= 7422.0; |
| 355 | /* |
| 356 | LOG("%s: buttons: 0x%lx, x: %f, y: %f, z: %f, clicks:%ld, wheel_x:%ld, wheel_y:%ld\n", dev->device_ref.name, movements.buttons, |
| 357 | movements.xpos, movements.ypos, movements.pressure, movements.clicks, movements.wheel_xdelta, movements.wheel_ydelta); |
| 358 | */ |
| 359 | //movements.xpos /= 10206.0; |
| 360 | //movements.ypos /= 7422.0; |
337 | 361 | float x = movements.xpos; |
338 | 362 | float y = movements.ypos; |
339 | 363 | |
340 | | LOG("%s: x: %f, y: %f, \n", dev->device_ref.name, x, y); |
| 364 | //LOG("%s: x: %f, y: %f, \n", dev->device_ref.name, x, y); |
341 | 365 | |
342 | 366 | if (buttons != 0) { |
343 | 367 | message = new BMessage(B_MOUSE_UP); |
… |
… |
|
391 | 415 | old_movements = movements; |
392 | 416 | |
393 | 417 | } |
394 | | |
| 418 | LOG("Exiting DeviceWatcher for %s\n",dev->path); |
395 | 419 | return 0; |
396 | 420 | } |
397 | 421 | |
… |
… |
|
436 | 460 | static char * |
437 | 461 | get_short_name(const char *longName) |
438 | 462 | { |
| 463 | LOG("longname:%s\n",longName); |
439 | 464 | BString string(longName); |
440 | 465 | BString name; |
441 | 466 | |
442 | 467 | int32 slash = string.FindLast("/"); |
443 | 468 | string.CopyInto(name, slash + 1, string.Length() - slash); |
| 469 | |
444 | 470 | int32 index = atoi(name.String()) + 1; |
445 | 471 | |
446 | 472 | int32 previousSlash = string.FindLast("/", slash); |
447 | 473 | string.CopyInto(name, previousSlash + 1, slash - previousSlash - 1); |
448 | 474 | name << " Tablet " << index; |
| 475 | |
449 | 476 | |
450 | 477 | return strdup(name.String()); |
| 478 | |
| 479 | //return strdup(longName); |
451 | 480 | } |