Ticket #7354: tablet.patch

File tablet.patch, 4.1 KB (added by lt_henry, 13 years ago)

input server addon

  • TabletInputDevice.cpp

    diff -Nuar tablet/TabletInputDevice.cpp tablet.mine/TabletInputDevice.cpp
    old new  
    2929
    3030#include "TabletInputDevice.h"
    3131#include "kb_mouse_settings.h"
    32 #include "kb_mouse_driver.h"
     32//#include "kb_mouse_driver.h"
     33#include <keyboard_mouse_driver.h>
    3334
    3435#include <stdlib.h>
    3536#include <unistd.h>
     
    176177    device->fd = open(device->path, O_RDWR);
    177178    if (device->fd<0)
    178179        return B_ERROR;
     180       
     181    LOG("opening:%s\n",device->path);
    179182
    180183    InitFromSettings(device);
    181184   
     
    198201    tablet_device *device = (tablet_device *)cookie;
    199202   
    200203    LOG("%s(%s)\n", __PRETTY_FUNCTION__, name);
    201 
     204    LOG("closing:%s\n",device->path);
    202205    close(device->fd);
    203206   
    204207    device->active = false;
     
    265268   
    266269    if (opcode == B_ENTRY_CREATED)
    267270            AddDevice(path.Path());
     271    /*
    268272    else
    269273            RemoveDevice(path.Path());
    270    
     274    */
    271275    return status; 
    272276}
    273277
     
    276280TabletInputDevice::AddDevice(const char *path)
    277281{
    278282    CALLED();
    279 
     283    LOG("adding %s\n",path);
    280284    tablet_device *device = new tablet_device(path);
    281285    if (!device) {
    282286        LOG("No memory\n");
     
    289293   
    290294    fDevices.AddItem(device);
    291295   
     296    LOG("registering input device: %s:%s\n",device->device_ref.name,(device->active) ? "yes":"no");
     297    LOG("device path: %s\n",&device->path);
    292298    return RegisterDevices(devices);
    293299}
    294300
     
    298304{
    299305    CALLED();
    300306    int32 i = 0;
     307    input_device_ref *devices[2];
     308   
     309    devices[1] = NULL;
     310   
    301311    tablet_device *device = NULL;
    302312    while ((device = (tablet_device *)fDevices.ItemAt(i)) != NULL) {
    303313        if (!strcmp(device->path, path)) {
     314            LOG("deleting node:%s\n",device->path);
     315            devices[0] = &device->device_ref;
     316            UnregisterDevices(devices);
    304317            fDevices.RemoveItem(device);
    305318            delete device;
    306319            return B_OK;
    307         }   
     320        }
    308321    }
    309322   
    310323    return B_ENTRY_NOT_FOUND;
     324   
    311325}
    312326
    313327
     
    320334    tablet_movement old_movements;
    321335    uint32 buttons_state = 0;
    322336    BMessage *message;
     337   
     338       
     339    LOG("Entering DeviceWatcher for %s::%x\n",dev->path,dev->fd);
     340   
    323341    while (dev->active) {
    324342        memset(&movements, 0, sizeof(movements));
    325343        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;
    328352        }
    329353       
    330354        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;
    337361        float x = movements.xpos;
    338362        float y = movements.ypos;
    339363
    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);
    341365       
    342366        if (buttons != 0) {
    343367            message = new BMessage(B_MOUSE_UP);             
     
    391415        old_movements = movements;
    392416       
    393417    }
    394    
     418    LOG("Exiting DeviceWatcher for %s\n",dev->path);
    395419    return 0;
    396420}
    397421
     
    436460static char *
    437461get_short_name(const char *longName)
    438462{
     463    LOG("longname:%s\n",longName);
    439464    BString string(longName);
    440465    BString name;
    441466   
    442467    int32 slash = string.FindLast("/");
    443468    string.CopyInto(name, slash + 1, string.Length() - slash);
     469   
    444470    int32 index = atoi(name.String()) + 1;
    445471   
    446472    int32 previousSlash = string.FindLast("/", slash);
    447473    string.CopyInto(name, previousSlash + 1, slash - previousSlash - 1);
    448474    name << " Tablet " << index;
     475   
    449476       
    450477    return strdup(name.String());
     478   
     479    //return strdup(longName);
    451480}