From 734218c7ab52df13b0495a5d894ca291e5618b48 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke <grumbel@gmx.de> Date: Tue, 25 Jan 2011 04:24:24 +0100 Subject: [PATCH] Minor stdout cleanup --- TODO | 2 ++ src/command_line_options.hpp | 1 + src/uinput.hpp | 1 - src/word_wrap.cpp | 6 ++++++ src/word_wrap.hpp | 1 + src/xboxdrv.cpp | 28 ++++++++++++++++++++-------- src/xboxdrv.hpp | 3 ++- 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 3fb5cb3..ffbed82 100644 --- a/TODO +++ b/TODO @@ -42,6 +42,8 @@ $ dput my-ppa ../xboxdrv_0.7.0-1~lucid1_source.changes Stuff to do before 0.7.0 release: ================================= +* print controller type/name in daemon + * log levels: debug: only shown when --debug is given diff --git a/src/command_line_options.hpp b/src/command_line_options.hpp index f6ad75d..adc1a53 100644 --- a/src/command_line_options.hpp +++ b/src/command_line_options.hpp @@ -23,6 +23,7 @@ #include "ini_schema.hpp" #include "uinput.hpp" +class Options; class Xboxdrv; class CommandLineParser diff --git a/src/uinput.hpp b/src/uinput.hpp index 359dfda..3b3796c 100644 --- a/src/uinput.hpp +++ b/src/uinput.hpp @@ -31,7 +31,6 @@ #include "evdev_helper.hpp" #include "linux_uinput.hpp" #include "uinput_options.hpp" -#include "xboxdrv.hpp" #include "xpad_device.hpp" struct Xbox360Msg; diff --git a/src/word_wrap.cpp b/src/word_wrap.cpp index 1bf86a9..7bd5135 100644 --- a/src/word_wrap.cpp +++ b/src/word_wrap.cpp @@ -37,6 +37,12 @@ WordWrap::newline() std::cout << std::endl; } +void +WordWrap::para(const std::string& str) const +{ + para("", str); +} + void WordWrap::para(const std::string& prefix, const std::string& str) const { diff --git a/src/word_wrap.hpp b/src/word_wrap.hpp index bcc99c3..1ebae80 100644 --- a/src/word_wrap.hpp +++ b/src/word_wrap.hpp @@ -29,6 +29,7 @@ private: public: WordWrap(int terminal_width); + void para(const std::string& str) const; void para(const std::string& prefix, const std::string& str) const; void println(const std::string& str); void newline(); diff --git a/src/xboxdrv.cpp b/src/xboxdrv.cpp index b7caaff..93ea90e 100644 --- a/src/xboxdrv.cpp +++ b/src/xboxdrv.cpp @@ -348,18 +348,25 @@ void set_rumble(XboxGenericController* controller, int gain, uint8_t lhs, uint8_ } } // namespace +void +Xboxdrv::print_copyright() const +{ + WordWrap wrap(get_terminal_width()); + wrap.para("xboxdrv " PACKAGE_VERSION " - http://pingus.seul.org/~grumbel/xboxdrv/"); + wrap.para("Copyright © 2008-2011 Ingo Ruhnke <grumbel@gmx.de>"); + wrap.para("Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"); + wrap.para("This program comes with ABSOLUTELY NO WARRANTY."); + wrap.para("This is free software, and you are welcome to redistribute it under certain " + "conditions; see the file COPYING for details."); + wrap.newline(); +} + void Xboxdrv::run_main(const Options& opts) { if (!opts.quiet) { - std::cout - << "xboxdrv " PACKAGE_VERSION " - http://pingus.seul.org/~grumbel/xboxdrv/\n" - << "Copyright © 2008-2011 Ingo Ruhnke <grumbel@gmx.de>\n" - << "Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" - << "This program comes with ABSOLUTELY NO WARRANTY.\n" - << "This is free software, and you are welcome to redistribute it under certain conditions; see the file COPYING for details.\n"; - std::cout << std::endl; + print_copyright(); } std::auto_ptr<XboxGenericController> controller; @@ -494,7 +501,7 @@ Xboxdrv::print_info(libusb_device* dev, raise_exception(std::runtime_error, "libusb_get_device_descriptor() failed: " << usb_strerror(ret)); } - std::cout << "USB Device: " << boost::format("%03d:%03d:") + std::cout << "USB Device: " << boost::format("%03d:%03d") % static_cast<int>(libusb_get_bus_number(dev)) % static_cast<int>(libusb_get_device_address(dev)) << std::endl; std::cout << "Controller: " << boost::format("\"%s\" (idVendor: 0x%04x, idProduct: 0x%04x)") @@ -578,6 +585,11 @@ Xboxdrv::run_help_devices() void Xboxdrv::run_daemon(const Options& opts) { + if (!opts.quiet) + { + print_copyright(); + } + int ret = libusb_init(NULL); if (ret != LIBUSB_SUCCESS) { diff --git a/src/xboxdrv.hpp b/src/xboxdrv.hpp index 0d21727..bc17e1c 100644 --- a/src/xboxdrv.hpp +++ b/src/xboxdrv.hpp @@ -25,7 +25,6 @@ struct XPadDevice; class Options; -class Options; class XboxGenericController; class Xboxdrv @@ -52,6 +51,8 @@ private: bool find_controller_by_id(int id, int vendor_id, int product_id, libusb_device** xbox_device) const; bool find_xbox360_controller(int id, libusb_device** xbox_device, XPadDevice* type) const; + void print_copyright() const; + public: Xboxdrv(); ~Xboxdrv();