Minor improvement in error handling
This commit is contained in:
parent
ef92ac46e1
commit
b7509ffe10
5 changed files with 16 additions and 7 deletions
2
NEWS
2
NEWS
|
@ -1,4 +1,4 @@
|
|||
xboxdrv 0.3 - (26/Aug/2008)
|
||||
xboxdrv 0.3 - (06/Nov/2008)
|
||||
============================
|
||||
|
||||
* added short note when the USB device is busy
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- python -*-
|
||||
|
||||
env = Environment(CPPFLAGS=["-g", "-O0", "-Wall"], LIBS=["usb"])
|
||||
env = Environment(CPPFLAGS=["-g", "-O2", "-Wall"], LIBS=["usb"])
|
||||
env.Program("xboxdrv", ["xboxdrv.cpp",
|
||||
"xboxmsg.cpp",
|
||||
"uinput.cpp",
|
||||
|
|
1
tools/.gitignore
vendored
1
tools/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*~
|
||||
evtest
|
||||
jstest
|
||||
usbdebug
|
||||
|
|
12
uinput.cpp
12
uinput.cpp
|
@ -201,7 +201,8 @@ uInput::setup_xbox360_gamepad(GamepadType type)
|
|||
uinp.absmax[ABS_HAT0Y] = 1;
|
||||
}
|
||||
|
||||
write(fd, &uinp, sizeof(uinp));
|
||||
if (write(fd, &uinp, sizeof(uinp)) < 0)
|
||||
throw std::runtime_error(strerror(errno));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -247,7 +248,8 @@ uInput::setup_xbox360_guitar()
|
|||
uinp.absmax[ABS_Y] = 32767;
|
||||
|
||||
|
||||
write(fd, &uinp, sizeof(uinp));
|
||||
if (write(fd, &uinp, sizeof(uinp)) < 0)
|
||||
throw std::runtime_error(strerror(errno));
|
||||
}
|
||||
|
||||
uInput::~uInput()
|
||||
|
@ -267,7 +269,8 @@ uInput::send_button(uint16_t code, int32_t value)
|
|||
ev.code = code;
|
||||
ev.value = (value>0) ? 1 : 0;
|
||||
|
||||
write(fd, &ev, sizeof(ev));
|
||||
if (write(fd, &ev, sizeof(ev)) < 0)
|
||||
throw std::runtime_error(strerror(errno));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -281,7 +284,8 @@ uInput::send_axis(uint16_t code, int32_t value)
|
|||
ev.code = code;
|
||||
ev.value = value;
|
||||
|
||||
write(fd, &ev, sizeof(ev));
|
||||
if (write(fd, &ev, sizeof(ev)) < 0)
|
||||
throw std::runtime_error(strerror(errno));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <boost/format.hpp>
|
||||
#include <usb.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1079,7 +1080,10 @@ int main(int argc, char** argv)
|
|||
|
||||
pid_t sid = setsid();
|
||||
std::cout << "Sid: " << sid << std::endl;
|
||||
chdir("/");
|
||||
if (chdir("/") != 0)
|
||||
{
|
||||
throw std::runtime_error(strerror(errno));
|
||||
}
|
||||
|
||||
run_main(opts);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue