Ticket #7629: joystickpatch.diff

File joystickpatch.diff, 2.3 KB (added by caz_haiku, 13 years ago)

BJoystickProtocolHandler patch

  • src/add-ons/kernel/drivers/input/usb_hid/JoystickProtocolHandler.cpp

     
    136136    if (*numBytes < sizeof(extended_joystick))
    137137        return B_BUFFER_OVERFLOW;
    138138
    139     while (RingBufferReadable() == 0) {
     139    if(RingBufferReadable() == 0) {
    140140        status_t result = _ReadReport();
    141141        if (result != B_OK)
    142142            return result;
     
    209209status_t
    210210JoystickProtocolHandler::_ReadReport()
    211211{
    212     status_t result = fReport.WaitForReport(B_INFINITE_TIMEOUT);
     212    status_t result = fReport.WaitForReport(0);
    213213    if (result != B_OK) {
    214214        if (fReport.Device()->IsRemoved()) {
    215215            TRACE("device has been removed\n");
     
    223223        }
    224224
    225225        // signal that we simply want to try again
    226         return B_OK;
     226        if(result != B_TIMED_OUT) return B_OK;
    227227    }
    228228
    229229    extended_joystick info;
     
    246246            info.buttons |= (button->Data() & 1) << (button->UsageID() - 1);
    247247    }
    248248
    249     fReport.DoneProcessing();
     249    if(result != B_TIMED_OUT) fReport.DoneProcessing();
    250250    TRACE("got joystick report\n");
    251251
    252252    info.timestamp = system_time();
  • src/kits/device/Joystick.cpp

     
    5858
    5959    fBeBoxMode(false),
    6060    fFD(-1),
    61     fDevices(new(std::nothrow) BList),
     61    fDevices(NULL),
    6262    fJoystickInfo(new(std::nothrow) joystick_info),
    6363    fExtendedJoystick(new(std::nothrow) BList)
    6464{
     
    187187BJoystick::ScanDevices(bool useDisabled)
    188188{
    189189    CALLED();
     190    if(fDevices == NULL) fDevices = new(std::nothrow) BList;
    190191    if (useDisabled) {
    191192        _BJoystickTweaker joystickTweaker(*this);
    192193        joystickTweaker.scan_including_disabled();
     
    200201    CALLED();
    201202
    202203    // Refresh devices list
    203     ScanDevices(true);
     204    if(fDevices == NULL) ScanDevices(true);
    204205
    205206    int32 count = 0;
    206207    if (fDevices != NULL)
     
    215216BJoystick::GetDeviceName(int32 index, char *name, size_t bufSize)
    216217{
    217218    CALLED();
    218     if (fDevices == NULL)
    219         return B_NO_INIT;
     219    //if (fDevices == NULL)
     220        //return B_NO_INIT;
     221    if(fDevices == NULL) ScanDevices(true);
    220222
    221223    if (index >= fDevices->CountItems())
    222224        return B_BAD_INDEX;