Some code cleanup

This commit is contained in:
Ingo Ruhnke 2011-01-27 01:10:51 +01:00
parent 19b3955e2d
commit 283cbf48f3
7 changed files with 52 additions and 52 deletions

67
TODO
View file

@ -42,38 +42,11 @@ $ dput my-ppa ../xboxdrv_0.7.0-1~lucid1_source.changes
Stuff to do before 0.7.0 release:
=================================
* get rid of all std::cout stuff when using detached daemon, redirect
log output to a file somewhere else:
--silent: stops event output
--quiet: stops all stdout output (automatically used when --detach is given)
--verbose: print info level log output
--debug: print debug level log output
--log-level: only log stuff at LEVEL or below
* figure out a good place to set the LEDs off when Xboxdrv is quit,
just doing it in the destructor causes trouble, as the usbdev might
be no longer usable (when controller got unplugged)
* AxisSensitivity filter has overflow issue
* fix the FIXME's
* need to hide/disable the toggle button from the UIButtonmap
- maybe implement some full post-parsing option verification to
check for conflicts and necessary modifications?
- Options::finish() to do final things?
* move XBOX_BTN_UNKNOWN behind XBOX_BTN_MAX, so iteration can start
from 0 instead of 1, also fix incorrect iterations all over the
place -> doesn't work as some code uses XBOX_BTN_UNKNOWN as 'no
button is pressed'
Daemon Related Stuff
====================
* improve output on which uinput devices are created
* cleanup device_id, don't manually do (slot<<16) | devid
* might need magic to give device-ids in a slot fashion:
@ -95,13 +68,34 @@ List Output
* rename --list-key to --help-key?
* do modifier/filter dump when --verbose is given, make verbose
overall more useful
* turn EnumBox into singleton
* Keysym2Keycode is currently always constructed at startup, even when
not used, construct it on demand
not used, construct it on demand to avoid X11 server connection
Stuff to do before 0.7.1 release:
=================================
* figure out a good place to set the LEDs off when Xboxdrv is quit,
just doing it in the destructor causes trouble, as the usbdev might
be no longer usable (when controller got unplugged)
* get rid of all std::cout stuff when using detached daemon, redirect
log output to a file somewhere else:
--silent: stops event output
--quiet: stops all stdout output (automatically used when --detach is given)
--verbose: print info level log output
--debug: print debug level log output
* move XBOX_BTN_UNKNOWN behind XBOX_BTN_MAX, so iteration can start
from 0 instead of 1, also fix incorrect iterations all over the
place -> doesn't work as some code uses XBOX_BTN_UNKNOWN as 'no
button is pressed'
* improve output on which uinput devices are created (even with udev
there doesn't seem to be a bullet proof way to detect what gets
created)
* document significant patches in AUTHORS
@ -112,9 +106,14 @@ List Output
1 Author: Aaron Denney <wnoise@ofb.net>
1 hal daemon from Thomas Debouverie <debouverie_thomas@yahoo.fr>
1 Implemented --ui-buttonmap A=BTN_A@{device_id} ??!?!?
Stuff to do before 0.7.1 release:
=================================
* do modifier/filter dump when --verbose is given, make verbose
overall more useful
* need to hide/disable the toggle button from the UIButtonmap
- maybe implement some full post-parsing option verification to
check for conflicts and necessary modifications?
- Options::finish() to do final things?
* print controller type/name in daemon (little tricky as that is only
known after opening the USB connection)

View file

@ -317,13 +317,8 @@ AbsAxisEventHandler::init(UInput& uinput, int slot, bool extra_devices)
}
void
AbsAxisEventHandler:: send(UInput& uinput, int value)
AbsAxisEventHandler::send(UInput& uinput, int value)
{
/*FIXME for(std::vector<AxisFilterPtr>::const_iterator i = m_filters.begin(); i != m_filters.end(); ++i)
{
value = (*i)->filter(old_value, value);
}*/
uinput.send_abs(m_code.get_device_id(), m_code.code, value);
}

View file

@ -201,7 +201,7 @@ LinuxUinput::finish()
break;
case kJoystickDevice:
// FIXME: the kernel and SDL have different rules for joystick
// the kernel and SDL have different rules for joystick
// detection, so this is more a hack then a proper solution
if (!key_lst[BTN_A])
{

View file

@ -38,7 +38,7 @@ int16_t u8_to_s16(uint8_t value)
UInputConfig::UInputConfig(UInput& uinput, int slot, bool extra_devices, const UInputOptions& opts) :
m_uinput(uinput),
m_btn_map(opts.get_btn_map()), // FIXME: insert resolve magic right here
m_btn_map(opts.get_btn_map()),
m_axis_map(opts.get_axis_map())
{
std::fill_n(axis_state, static_cast<int>(XBOX_AXIS_MAX), 0);
@ -267,7 +267,7 @@ UInputConfig::send_button(XboxButton code, bool value)
// in case a shift button was changed, we have to clear all
// connected buttons
for(int i = 0; i < XBOX_BTN_MAX; ++i) // iterate over all buttons
for(int i = 1; i < XBOX_BTN_MAX; ++i) // iterate over all buttons
{
if (button_state[i])
{
@ -285,7 +285,7 @@ UInputConfig::send_button(XboxButton code, bool value)
}
// Shifted button events
for(int i = 0; i < XBOX_BTN_MAX; ++i)
for(int i = 1; i < XBOX_BTN_MAX; ++i)
{
if (button_state[i]) // shift button is pressed
{

View file

@ -205,8 +205,12 @@ Xboxdrv::find_controller_by_id(int id, int vendor_id, int product_id, libusb_dev
libusb_device* dev = list[dev_it];
libusb_device_descriptor desc;
// FIXME: we silently ignore failures
if (libusb_get_device_descriptor(dev, &desc) == LIBUSB_SUCCESS)
int ret = libusb_get_device_descriptor(dev, &desc);
if (ret != LIBUSB_SUCCESS)
{
log_warn("libusb_get_device_descriptor() failed: " << usb_strerror(ret));
}
else
{
if (desc.idVendor == vendor_id &&
desc.idProduct == product_id)
@ -243,8 +247,12 @@ Xboxdrv::find_xbox360_controller(int id, libusb_device** xbox_device, XPadDevice
libusb_device* dev = list[dev_it];
libusb_device_descriptor desc;
// FIXME: we silently ignore failures
if (libusb_get_device_descriptor(dev, &desc) == LIBUSB_SUCCESS)
int ret = libusb_get_device_descriptor(dev, &desc);
if (ret != LIBUSB_SUCCESS)
{
log_warn("libusb_get_device_descriptor() failed: " << usb_strerror(ret));
}
else
{
for(int i = 0; i < xpad_devices_count; ++i)
{

View file

@ -328,7 +328,6 @@ XboxdrvDaemon::run_loop(const Options& opts)
while(!global_exit_xboxdrv)
{
// FIXME: udev_monitor_receive_device() will block, must break out of it somehow
// FIXME: we bust udev_unref_monitor() this
struct udev_device* device = udev_monitor_receive_device(m_monitor);
cleanup_threads();
@ -346,8 +345,9 @@ XboxdrvDaemon::run_loop(const Options& opts)
{
process_match(opts, device);
}
udev_device_unref(device);
}
udev_device_unref(device);
}
}

View file

@ -180,8 +180,6 @@ std::ostream& operator<<(std::ostream& out, const Playstation3USBMsg& msg)
% static_cast<int>(msg.a_l1)
% static_cast<int>(msg.a_r1);
// FIXME: include analog buttons to
out << boost::format(" L2:%3d R2:%3d")
% int(msg.a_l2) % int(msg.a_r2);