Bit more error checking and a few bug fixes

This commit is contained in:
Ingo Ruhnke 2011-01-14 00:01:41 +01:00
parent 0e9723a40c
commit 42855bb01e
6 changed files with 17 additions and 19 deletions

10
TODO
View file

@ -41,16 +41,10 @@ $ dput my-ppa xboxdrv_0.6.4_source.changes
Stuff to do before 0.6.5 release:
=================================
* dpad mapping is messed up
Stuff to do before 0.6.6 release:
=================================
* added return value checking to:
libusb_open
libusb_interrupt_transfer
libusb_open [done]
libusb_interrupt_transfer [done]
libusb_control_transfer
make sure libusb_control_transfer has proper endpoint number

View file

@ -1 +1 @@
0.6.4
0.6.5

View file

@ -185,8 +185,12 @@ Chatpad::read_thread()
while(!m_quit_thread)
{
int len = 0;
libusb_interrupt_transfer(m_handle, LIBUSB_ENDPOINT_IN | 6,
data, sizeof(data), &len, 0);
int ret = libusb_interrupt_transfer(m_handle, LIBUSB_ENDPOINT_IN | 6,
data, sizeof(data), &len, 0);
if (ret != LIBUSB_SUCCESS)
{
throw std::runtime_error("-- failure --"); // FIXME
}
if (len < 0)
{

View file

@ -96,11 +96,10 @@ Headset::write_thread(const std::string& filename)
}
else
{
int len = 0;
const int ret = libusb_interrupt_transfer(m_handle,
LIBUSB_ENDPOINT_OUT | 4,
int transferred = 0;
const int ret = libusb_interrupt_transfer(m_handle, LIBUSB_ENDPOINT_OUT | 4,
data, sizeof(data),
&len, 0);
&transferred, 0);
if (ret != LIBUSB_SUCCESS)
{
std::ostringstream out;

View file

@ -55,7 +55,7 @@ Xbox360Controller::Xbox360Controller(libusb_device* dev_,
std::cout << "EP(OUT): " << endpoint_out << std::endl;
}
libusb_open(dev, &handle);
int ret = libusb_open(dev, &handle);
if (0)
{
@ -69,7 +69,7 @@ Xbox360Controller::Xbox360Controller(libusb_device* dev_,
}
}
if (!handle)
if (ret != LIBUSB_SUCCESS)
{
throw std::runtime_error("Error opening Xbox360 controller");
}
@ -110,7 +110,8 @@ Xbox360Controller::Xbox360Controller(libusb_device* dev_,
}
uint8_t data[32];
int ret = libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_IN | endpoint_in, reinterpret_cast<char*>(data), sizeof(data), 20);
int ret = libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_IN | endpoint_in,
reinterpret_cast<char*>(data), sizeof(data), 20);
print_raw_data(std::cout, data, ret);
}
}

View file

@ -120,7 +120,7 @@ Xbox360WirelessController::read(XboxGenericMsg& msg, bool verbose, int timeout)
}
else
{
ret = libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_OUT | endpoint,
ret = libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_IN | endpoint,
data, sizeof(data),
&len, timeout);
}