Cleaned up output, replaced std::cout with log_*
This commit is contained in:
parent
5ffd625a2b
commit
88afcf459e
36 changed files with 247 additions and 201 deletions
src
arg_parser.cpparg_parser.hppaxis_event.cppbutton_event.cppbutton_filter.cppchatpad.cppcommand_line_options.cppevdev_controller.cppevdev_controller.hppfirestorm_dual_controller.cppfirestorm_dual_controller.hppforce_feedback_handler.cppheadset.cpphelper.cpplog.cpplog.hppoptions.cppoptions.hppplaystation3_usb_controller.cppplaystation3_usb_controller.hppsaitek_p2500_controller.cppsaitek_p2500_controller.hppuinput_config.cppword_wrap.cppword_wrap.hppxbox360_controller.cppxbox360_controller.hppxbox360_wireless_controller.cppxbox360_wireless_controller.hppxbox_controller.cppxbox_controller.hppxbox_generic_controller.hppxboxdrv.cppxboxdrv_daemon.cppxboxdrv_thread.cppxboxmsg.cpp
|
@ -19,6 +19,7 @@
|
|||
#include "arg_parser.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ostream>
|
||||
|
||||
#include "helper.hpp"
|
||||
#include "pretty_printer.hpp"
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#ifndef HEADER_ARG_PARSER_HPP
|
||||
#define HEADER_ARG_PARSER_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class ArgParser
|
||||
{
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
bool visible = true);
|
||||
|
||||
ParsedOptions parse_args(int argc, char** argv);
|
||||
void print_help(std::ostream& out = std::cout) const;
|
||||
void print_help(std::ostream& out) const;
|
||||
|
||||
bool next();
|
||||
int get_key();
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include "axis_event.hpp"
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "log.hpp"
|
||||
#include "uinput.hpp"
|
||||
|
||||
AxisEventPtr
|
||||
|
@ -83,17 +84,17 @@ AxisEvent::from_string(const std::string& str)
|
|||
ev.reset(new AxisEvent(KeyAxisEventHandler::from_string(str)));
|
||||
break;
|
||||
|
||||
case -1:
|
||||
std::cout << "--------- invalid --------------" << std::endl;
|
||||
case -1: // void/none
|
||||
ev = invalid();
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"AxisEvent::from_string(): should never be reached");
|
||||
assert(!"should never be reached");
|
||||
}
|
||||
}
|
||||
|
||||
//std::cout << "AxisEvent::from_string():\n in: " << str << "\n out: " << ev->str() << std::endl;
|
||||
log_debug("in: " << str);
|
||||
log_debug("out: " << ev->str());
|
||||
|
||||
return ev;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "log.hpp"
|
||||
#include "uinput.hpp"
|
||||
|
||||
ButtonEventPtr
|
||||
|
@ -519,7 +519,7 @@ ExecButtonEventHandler::send(UInput& uinput, bool value)
|
|||
|
||||
if (execvp(m_args[0].c_str(), argv) == -1)
|
||||
{
|
||||
std::cout << "error: ExecButtonEventHandler::send(): " << strerror(errno) << std::endl;
|
||||
log_error("exec failed: " << strerror(errno));
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
#include "button_filter.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <iostream>
|
||||
|
||||
ButtonFilterPtr
|
||||
ButtonFilter::from_string(const std::string& str)
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#include "chatpad.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "helper.hpp"
|
||||
#include "linux_uinput.hpp"
|
||||
#include "log.hpp"
|
||||
#include "usb_helper.hpp"
|
||||
#include "raise_exception.hpp"
|
||||
#include "usb_helper.hpp"
|
||||
|
||||
Chatpad::Chatpad(libusb_device_handle* handle, uint16_t bcdDevice,
|
||||
bool no_init, bool debug) :
|
||||
|
@ -211,24 +211,11 @@ Chatpad::read_thread()
|
|||
{
|
||||
raise_exception(std::runtime_error, "libusb_interrupt_transfer() failed: " << usb_strerror(ret));
|
||||
}
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
std::cout << "Error in read_thread" << std::endl;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_logger.get_log_level() > Logger::kDebug)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "read: " << len << "/5: data: ";
|
||||
for(int i = 0; i < len; ++i)
|
||||
{
|
||||
str << boost::format("0x%02x ") % int(data[i]);
|
||||
}
|
||||
|
||||
log_debug(str);
|
||||
log_debug("read: " << len << "/5: data: " << raw2str(data, len));
|
||||
}
|
||||
|
||||
if (data[0] == 0x00)
|
||||
|
@ -304,11 +291,11 @@ Chatpad::keep_alive_thread()
|
|||
while(!m_quit_thread)
|
||||
{
|
||||
send_ctrl(0x41, 0x0, 0x1f, 0x02, NULL, 0);
|
||||
if (m_debug) std::cout << "[chatpad] 0x1f" << std::endl;
|
||||
log_debug("0x1f");
|
||||
sleep(1);
|
||||
|
||||
send_ctrl(0x41, 0x0, 0x1e, 0x02, NULL, 0);
|
||||
if (m_debug) std::cout << "[chatpad] 0x1e" << std::endl;
|
||||
log_debug("0x1e");
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
@ -328,17 +315,17 @@ Chatpad::send_init()
|
|||
|
||||
// these three will fail, but are necessary to have the later ones succeed
|
||||
ret = libusb_control_transfer(m_handle, 0x40, 0xa9, 0xa30c, 0x4423, NULL, 0, 0);
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret));
|
||||
|
||||
ret = libusb_control_transfer(m_handle, 0x40, 0xa9, 0x2344, 0x7f03, NULL, 0, 0);
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret));
|
||||
|
||||
ret = libusb_control_transfer(m_handle, 0x40, 0xa9, 0x5839, 0x6832, NULL, 0, 0);
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret));
|
||||
|
||||
// make chatpad ready
|
||||
ret = libusb_control_transfer(m_handle, 0xc0, 0xa1, 0x0000, 0xe416, buf, 2, 0); // (read 2 bytes, will return a mode)
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << " " << static_cast<int>(buf[0]) << " " << static_cast<int>(buf[1])<< std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret) << " " << static_cast<int>(buf[0]) << " " << static_cast<int>(buf[1]));
|
||||
|
||||
if (buf[1] & 2)
|
||||
{
|
||||
|
@ -363,10 +350,10 @@ Chatpad::send_init()
|
|||
}
|
||||
|
||||
ret = libusb_control_transfer(m_handle, 0x40, 0xa1, 0x0000, 0xe416, buf, 2, 0); // (send 2 bytes, data must be 0x09 0x00)
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret));
|
||||
|
||||
ret = libusb_control_transfer(m_handle, 0xc0, 0xa1, 0x0000, 0xe416, buf, 2, 0); // (read 2 bytes, this should return the NEW mode)
|
||||
if (m_debug) std::cout << "[chatpad] ret: " << usb_strerror(ret) << " " << static_cast<int>(buf[0]) << " " << static_cast<int>(buf[1]) << std::endl;
|
||||
log_debug("ret: " << usb_strerror(ret) << " " << static_cast<int>(buf[0]) << " " << static_cast<int>(buf[1]));
|
||||
|
||||
/* FIXME: not proper way to check if the chatpad is alive
|
||||
if (!(buf[1] & 2)) // FIXME: check for {9,0} for bcdDevice==0x114
|
||||
|
@ -380,15 +367,15 @@ Chatpad::send_init()
|
|||
|
||||
// only when we get "01 02" back is the chatpad ready
|
||||
libusb_control_transfer(m_handle, 0x41, 0x0, 0x1f, 0x02, 0, NULL, 0);
|
||||
if (m_debug) std::cout << "[chatpad] 0x1f" << std::endl;
|
||||
log_debug("0x1f");
|
||||
sleep(1);
|
||||
|
||||
libusb_control_transfer(m_handle, 0x41, 0x0, 0x1e, 0x02, 0, NULL, 0);
|
||||
if (m_debug) std::cout << "[chatpad] 0x1e" << std::endl;
|
||||
log_debug("0x1e");
|
||||
|
||||
// can't send 1b before 1f before one rotation
|
||||
libusb_control_transfer(m_handle, 0x41, 0x0, 0x1b, 0x02, 0, NULL, 0);
|
||||
if (m_debug) std::cout << "[chatpad] 0x1b" << std::endl;
|
||||
log_debug("0x1b");
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -19,12 +19,14 @@
|
|||
#include "command_line_options.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
#include "helper.hpp"
|
||||
#include "ini_parser.hpp"
|
||||
#include "ini_schema_builder.hpp"
|
||||
#include "log.hpp"
|
||||
#include "options.hpp"
|
||||
|
||||
#define RAISE_EXCEPTION(x) do { \
|
||||
|
@ -39,6 +41,7 @@ enum {
|
|||
OPTION_HELP,
|
||||
OPTION_VERBOSE,
|
||||
OPTION_VERSION,
|
||||
OPTION_DEBUG,
|
||||
OPTION_QUIET,
|
||||
OPTION_SILENT,
|
||||
OPTION_DAEMON,
|
||||
|
@ -140,13 +143,13 @@ CommandLineParser::init_argp()
|
|||
.add_option(OPTION_HELP, 'h', "help", "", "display this help and exit")
|
||||
.add_option(OPTION_VERSION, 'V', "version", "", "print the version number and exit")
|
||||
.add_option(OPTION_VERBOSE, 'v', "verbose", "", "print verbose messages")
|
||||
.add_option(OPTION_HELP_LED, 0, "help-led", "", "list possible values for the led")
|
||||
.add_option(OPTION_HELP_DEVICES, 0, "help-devices", "", "list supported devices")
|
||||
.add_option(OPTION_DEBUG, 0, "debug", "", "be even more verbose then --verbose")
|
||||
.add_option(OPTION_SILENT, 's', "silent", "", "do not display events on console")
|
||||
.add_option(OPTION_QUIET, 0, "quiet", "", "do not display startup text")
|
||||
.add_option(OPTION_LIST_CONTROLLER, 'L', "list-controller", "", "list available controllers")
|
||||
.add_option(OPTION_LIST_SUPPORTED_DEVICES, 0, "list-supported-devices", "", "list supported devices (used by xboxdrv-daemon.py)")
|
||||
.add_option(OPTION_LIST_SUPPORTED_DEVICES_XPAD, 0, "list-supported-devices-xpad", "", "list supported devices in xpad.c style")
|
||||
.add_newline()
|
||||
|
||||
.add_text("Configuration Options: ")
|
||||
.add_option(OPTION_CONFIG, 'c', "config", "FILE", "read configuration from FILE")
|
||||
.add_option(OPTION_ALT_CONFIG, 0, "alt-config", "FILE", "read alternative configuration from FILE ")
|
||||
.add_option(OPTION_CONFIG_OPTION,'o', "option", "NAME=VALUE", "Set the given configuration option")
|
||||
|
@ -154,6 +157,10 @@ CommandLineParser::init_argp()
|
|||
.add_newline()
|
||||
|
||||
.add_text("List Options: ")
|
||||
.add_option(OPTION_LIST_SUPPORTED_DEVICES, 0, "list-supported-devices", "", "list supported devices (used by xboxdrv-daemon.py)")
|
||||
.add_option(OPTION_LIST_SUPPORTED_DEVICES_XPAD, 0, "list-supported-devices-xpad", "", "list supported devices in xpad.c style")
|
||||
.add_option(OPTION_HELP_LED, 0, "help-led", "", "list possible values for the led")
|
||||
.add_option(OPTION_HELP_DEVICES, 0, "help-devices", "", "list supported devices")
|
||||
.add_option(OPTION_LIST_ABS, 0, "list-abs", "", "List all possible EV_ABS names")
|
||||
.add_option(OPTION_LIST_REL, 0, "list-rel", "", "List all possible EV_REL names")
|
||||
.add_option(OPTION_LIST_KEY, 0, "list-key", "", "List all possible EV_KEY names")
|
||||
|
@ -288,7 +295,7 @@ CommandLineParser::init_ini(Options* opts)
|
|||
m_ini.clear();
|
||||
|
||||
m_ini.section("xboxdrv")
|
||||
("verbose", &opts->verbose)
|
||||
("verbose", boost::bind(&Options::set_verbose, boost::ref(opts)), boost::function<void ()>())
|
||||
("silent", &opts->silent)
|
||||
("quiet", &opts->quiet)
|
||||
("rumble", &opts->rumble)
|
||||
|
@ -343,8 +350,10 @@ CommandLineParser::init_ini(Options* opts)
|
|||
;
|
||||
|
||||
m_ini.section("xboxdrv-daemon")
|
||||
("detach", &opts->detach)
|
||||
("pid-file", &opts->pid_file)
|
||||
("detach",
|
||||
boost::bind(&Options::set_daemon_detach, boost::ref(opts), true),
|
||||
boost::bind(&Options::set_daemon_detach, boost::ref(opts), false))
|
||||
("pid-file", &opts->pid_file)
|
||||
("on-connect", &opts->on_connect)
|
||||
("on-disconnect", &opts->on_disconnect)
|
||||
;
|
||||
|
@ -389,19 +398,23 @@ CommandLineParser::parse_args(int argc, char** argv, Options* options)
|
|||
break;
|
||||
|
||||
case OPTION_VERBOSE:
|
||||
opts.verbose = true;
|
||||
opts.set_verbose();
|
||||
break;
|
||||
|
||||
case OPTION_QUIET:
|
||||
opts.quiet = true;
|
||||
opts.quiet = true;
|
||||
break;
|
||||
|
||||
case OPTION_SILENT:
|
||||
opts.silent = true;
|
||||
break;
|
||||
|
||||
case OPTION_DEBUG:
|
||||
opts.set_debug();
|
||||
break;
|
||||
|
||||
case OPTION_DAEMON:
|
||||
opts.mode = Options::RUN_DAEMON;
|
||||
opts.set_daemon();
|
||||
break;
|
||||
|
||||
case OPTION_DAEMON_MATCH:
|
||||
|
@ -736,7 +749,7 @@ CommandLineParser::parse_args(int argc, char** argv, Options* options)
|
|||
break;
|
||||
|
||||
case OPTION_DAEMON_DETACH:
|
||||
opts.detach = true;
|
||||
opts.set_daemon_detach(true);
|
||||
break;
|
||||
|
||||
case OPTION_DAEMON_PID_FILE:
|
||||
|
@ -845,6 +858,8 @@ CommandLineParser::parse_args(int argc, char** argv, Options* options)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
options->finish();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
#include <boost/format.hpp>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "evdev_helper.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#define BITS_PER_LONG (sizeof(long) * 8)
|
||||
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
|
||||
|
@ -62,7 +62,7 @@ EvdevController::EvdevController(const std::string& filename,
|
|||
char c_name[1024] = "unknown";
|
||||
ioctl(m_fd, EVIOCGNAME(sizeof(c_name)), c_name);
|
||||
m_name = c_name;
|
||||
std::cout << "Name: " << m_name << std::endl;
|
||||
log_debug("name: " << m_name);
|
||||
}
|
||||
|
||||
if (m_grab)
|
||||
|
@ -99,7 +99,7 @@ EvdevController::EvdevController(const std::string& filename,
|
|||
struct input_absinfo absinfo;
|
||||
ioctl(m_fd, EVIOCGABS(i), &absinfo);
|
||||
|
||||
std::cout << boost::format("abs: %-20s min: %6d max: %6d") % abs2str(i) % absinfo.minimum % absinfo.maximum << std::endl;
|
||||
log_debug(boost::format("abs: %-20s min: %6d max: %6d") % abs2str(i) % absinfo.minimum % absinfo.maximum);
|
||||
m_absinfo[i] = absinfo;
|
||||
//abs2idx[i] = abs_port_out.size();
|
||||
//abs_port_out.push_back(new AbsPortOut("EvdevDriver:abs", absinfo.minimum, absinfo.maximum));
|
||||
|
@ -110,7 +110,7 @@ EvdevController::EvdevController(const std::string& filename,
|
|||
{
|
||||
if (test_bit(i, rel_bit))
|
||||
{
|
||||
std::cout << "rel: " << rel2str(i) << std::endl;
|
||||
log_debug("rel: " << rel2str(i));
|
||||
//rel2idx[i] = rel_port_out.size();
|
||||
//rel_port_out.push_back(new RelPortOut("EvdevDriver:rel"));
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ EvdevController::EvdevController(const std::string& filename,
|
|||
{
|
||||
if (test_bit(i, key_bit))
|
||||
{
|
||||
std::cout << "key: " << key2str(i) << std::endl;
|
||||
log_debug("key: " << key2str(i));
|
||||
//key2idx[i] = btn_port_out.size();
|
||||
//btn_port_out.push_back(new BtnPortOut("EvdevDriver:btn"));
|
||||
}
|
||||
|
@ -148,19 +148,19 @@ EvdevController::apply(XboxGenericMsg& msg, const struct input_event& ev)
|
|||
switch(ev.type)
|
||||
{
|
||||
case EV_KEY:
|
||||
std::cout << "[evdev] EV_KEY " << key2str(ev.code) << " " << ev.value << std::endl;
|
||||
log_debug("EV_KEY " << key2str(ev.code) << " " << ev.value);
|
||||
break;
|
||||
|
||||
case EV_REL:
|
||||
std::cout << "[evdev] EV_REL " << rel2str(ev.code) << " " << ev.value << std::endl;
|
||||
log_debug("EV_REL " << rel2str(ev.code) << " " << ev.value);
|
||||
break;
|
||||
|
||||
case EV_ABS:
|
||||
std::cout << "[evdev] EV_ABS " << abs2str(ev.code) << " " << ev.value << std::endl;
|
||||
log_debug("EV_ABS " << abs2str(ev.code) << " " << ev.value);
|
||||
break;
|
||||
|
||||
case EV_SYN:
|
||||
std::cout << "------------------- sync -------------------" << std::endl;
|
||||
log_debug("------------------- sync -------------------");
|
||||
break;
|
||||
|
||||
case EV_MSC:
|
||||
|
@ -169,7 +169,7 @@ EvdevController::apply(XboxGenericMsg& msg, const struct input_event& ev)
|
|||
break;
|
||||
|
||||
default:
|
||||
std::cout << "[evdev] unknown: " << ev.type << " " << ev.code << " " << ev.value << std::endl;
|
||||
log_debug("unknown: " << ev.type << " " << ev.code << " " << ev.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ EvdevController::read_data_to_buffer()
|
|||
}
|
||||
|
||||
bool
|
||||
EvdevController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
EvdevController::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
read_data_to_buffer();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
void set_led(uint8_t status);
|
||||
|
||||
/** @param timeout timeout in msec, 0 means forever */
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
bool apply(XboxGenericMsg& msg, const struct input_event& ev);
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
#include "firestorm_dual_controller.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "helper.hpp"
|
||||
#include "log.hpp"
|
||||
#include "usb_helper.hpp"
|
||||
|
||||
// 044f:b312
|
||||
|
@ -141,16 +141,16 @@ FirestormDualController::set_led(uint8_t status)
|
|||
}
|
||||
|
||||
bool
|
||||
FirestormDualController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
FirestormDualController::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
if (is_vsb)
|
||||
return read_vsb(msg, verbose, timeout);
|
||||
return read_vsb(msg, timeout);
|
||||
else
|
||||
return read_default(msg, verbose, timeout);
|
||||
return read_default(msg, timeout);
|
||||
}
|
||||
|
||||
bool
|
||||
FirestormDualController::read_vsb(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
FirestormDualController::read_vsb(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
Firestorm_vsb_Msg data;
|
||||
int len = 0;
|
||||
|
@ -171,12 +171,13 @@ FirestormDualController::read_vsb(XboxGenericMsg& msg, bool verbose, int timeout
|
|||
{
|
||||
if (0)
|
||||
{ // debug output
|
||||
std::ostringstream str;
|
||||
for(size_t i = 0; i < sizeof(data); ++i)
|
||||
{
|
||||
uint8_t v = reinterpret_cast<char*>(&data)[i];
|
||||
std::cout << boost::format("0x%02x ") % static_cast<int>(v);
|
||||
str << boost::format("0x%02x ") % static_cast<int>(v);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
log_debug(str.str());
|
||||
}
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
@ -233,7 +234,7 @@ FirestormDualController::read_vsb(XboxGenericMsg& msg, bool verbose, int timeout
|
|||
}
|
||||
|
||||
bool
|
||||
FirestormDualController::read_default(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
FirestormDualController::read_default(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
FirestormMsg data;
|
||||
int len = 0;
|
||||
|
|
|
@ -41,11 +41,11 @@ public:
|
|||
void set_led(uint8_t status);
|
||||
|
||||
/** @param timeout timeout in msec, 0 means forever */
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
bool read_default(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read_vsb(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read_default(XboxGenericMsg& msg, int timeout);
|
||||
bool read_vsb(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
FirestormDualController(const FirestormDualController&);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "force_feedback_handler.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include "log.hpp"
|
||||
#include "options.hpp"
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const struct ff_envelope& envelope)
|
||||
|
@ -44,7 +44,7 @@ std::ostream& operator<<(std::ostream& out, const struct ff_trigger& trigger)
|
|||
|
||||
std::ostream& operator<<(std::ostream& out, const struct ff_effect& effect)
|
||||
{
|
||||
std::cout << "Effect(";
|
||||
out << "Effect(";
|
||||
switch (effect.type)
|
||||
{
|
||||
case FF_CONSTANT:
|
||||
|
@ -197,7 +197,7 @@ ForceFeedbackEffect::ForceFeedbackEffect(const struct ff_effect& effect) :
|
|||
// case FF_FRICTION:
|
||||
// case FF_DAMPER
|
||||
// case FF_INERTIA:
|
||||
std::cout << "Unsupported effect: " << effect << std::endl;
|
||||
log_info("unsupported effect: " << effect);
|
||||
start_weak_magnitude = 0;
|
||||
start_strong_magnitude = 0;
|
||||
end_weak_magnitude = 0;
|
||||
|
@ -293,12 +293,11 @@ ForceFeedbackHandler::get_max_effects()
|
|||
void
|
||||
ForceFeedbackHandler::upload(const struct ff_effect& effect)
|
||||
{
|
||||
if (g_options->verbose)
|
||||
std::cout << "FF_UPLOAD("
|
||||
<< "effect_id:" << effect.id
|
||||
<< ", effect_type:" << effect.type
|
||||
<< ",\n " << effect
|
||||
<< ")" << std::endl;
|
||||
log_debug("FF_UPLOAD("
|
||||
<< "effect_id:" << effect.id
|
||||
<< ", effect_type:" << effect.type
|
||||
<< ",\n " << effect
|
||||
<< ")");
|
||||
|
||||
std::map<int, ForceFeedbackEffect>::iterator i = effects.find(effect.id);
|
||||
if (i == effects.end())
|
||||
|
@ -324,40 +323,49 @@ ForceFeedbackHandler::upload(const struct ff_effect& effect)
|
|||
void
|
||||
ForceFeedbackHandler::erase(int id)
|
||||
{
|
||||
if (g_options->verbose)
|
||||
std::cout << "FF_ERASE(effect_id:" << id << ")" << std::endl;
|
||||
log_debug("FF_ERASE(effect_id:" << id << ")");
|
||||
|
||||
std::map<int, ForceFeedbackEffect>::iterator i = effects.find(id);
|
||||
if (i != effects.end())
|
||||
{
|
||||
effects.erase(i);
|
||||
}
|
||||
else
|
||||
std::cout << "Error: ForceFeedbackHandler::erase: Unknown id " << id << std::endl;
|
||||
{
|
||||
log_warn("unknown id " << id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ForceFeedbackHandler::play(int id)
|
||||
{
|
||||
if (g_options->verbose)
|
||||
std::cout << "FFPlay(effect_id:" << id << ")" << std::endl;
|
||||
log_debug("FFPlay(effect_id:" << id << ")");
|
||||
|
||||
std::map<int, ForceFeedbackEffect>::iterator i = effects.find(id);
|
||||
if (i != effects.end())
|
||||
{
|
||||
i->second.play();
|
||||
}
|
||||
else
|
||||
std::cout << "Error: ForceFeedbackHandler::play: Unknown id " << id << std::endl;
|
||||
{
|
||||
log_warn("unknown id " << id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ForceFeedbackHandler::stop(int id)
|
||||
{
|
||||
if (g_options->verbose)
|
||||
std::cout << "FFStop(effect_id:" << id << ")" << std::endl;
|
||||
log_debug("FFStop(effect_id:" << id << ")");
|
||||
|
||||
std::map<int, ForceFeedbackEffect>::iterator i = effects.find(id);
|
||||
if (i != effects.end())
|
||||
{
|
||||
i->second.stop();
|
||||
}
|
||||
else
|
||||
std::cout << "Error: ForceFeedbackHandler::play: Unknown id " << id << std::endl;
|
||||
{
|
||||
log_warn("unknown id " << id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
#include <boost/format.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "helper.hpp"
|
||||
#include "raise_exception.hpp"
|
||||
#include "usb_helper.hpp"
|
||||
|
||||
Headset::Headset(libusb_device_handle* handle,
|
||||
|
@ -84,7 +85,7 @@ Headset::write_thread(const std::string& filename)
|
|||
throw std::runtime_error(out.str());
|
||||
}
|
||||
|
||||
std::cout << "[headset] starting playback: " << filename << std::endl;
|
||||
log_info("starting playback: " << filename);
|
||||
|
||||
uint8_t data[32];
|
||||
while(in)
|
||||
|
@ -103,14 +104,12 @@ Headset::write_thread(const std::string& filename)
|
|||
&transferred, 0);
|
||||
if (ret != LIBUSB_SUCCESS)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "[headset] " << usb_strerror(ret);
|
||||
throw std::runtime_error(out.str());
|
||||
raise_exception(std::runtime_error, "libusb_interrupt_transfer failed: " << usb_strerror(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "[headset] finished playback: " << filename << std::endl;
|
||||
log_info("finished playback: " << filename);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -124,9 +123,7 @@ Headset::read_thread(const std::string& filename, bool debug)
|
|||
|
||||
if (!*out)
|
||||
{
|
||||
std::ostringstream outstr;
|
||||
outstr << "[headset] " << filename << ": " << strerror(errno);
|
||||
throw std::runtime_error(outstr.str());
|
||||
raise_exception(std::runtime_error, filename << ": " << strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +144,7 @@ Headset::read_thread(const std::string& filename, bool debug)
|
|||
{
|
||||
if (len == 0)
|
||||
{
|
||||
std::cout << "[headset] -- empty read --" << std::endl;
|
||||
log_debug("-- empty read --");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -156,15 +153,7 @@ Headset::read_thread(const std::string& filename, bool debug)
|
|||
out->write(reinterpret_cast<char*>(data), sizeof(data));
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
std::cout << "[headset] ";
|
||||
for(int i = 0; i < len; ++i)
|
||||
{
|
||||
std::cout << boost::format("0x%02x ") % int(data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
log_debug(raw2str(data, len));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "helper.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
|
11
src/log.cpp
11
src/log.cpp
|
@ -46,7 +46,16 @@ Logger::Logger() :
|
|||
{}
|
||||
|
||||
void
|
||||
Logger::set_level(LogLevel level)
|
||||
Logger::incr_log_level(LogLevel level)
|
||||
{
|
||||
if (get_log_level() < level)
|
||||
{
|
||||
set_log_level(level);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Logger::set_log_level(LogLevel level)
|
||||
{
|
||||
m_log_level = level;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ private:
|
|||
|
||||
public:
|
||||
Logger();
|
||||
void set_level(LogLevel level);
|
||||
void incr_log_level(LogLevel level);
|
||||
void set_log_level(LogLevel level);
|
||||
LogLevel get_log_level() const;
|
||||
void append(LogLevel level, const std::string& str);
|
||||
void append_unchecked(LogLevel level, const std::string& str);
|
||||
|
|
|
@ -28,7 +28,6 @@ Options* g_options;
|
|||
|
||||
Options::Options() :
|
||||
mode(RUN_DEFAULT),
|
||||
verbose(false),
|
||||
silent (false),
|
||||
quiet (false),
|
||||
rumble (false),
|
||||
|
@ -148,6 +147,18 @@ Options::next_config()
|
|||
controller_slots[controller_slot].get_options(config_slot);
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_verbose()
|
||||
{
|
||||
g_logger.incr_log_level(Logger::kInfo);
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_debug()
|
||||
{
|
||||
g_logger.incr_log_level(Logger::kDebug);
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_device_name(const std::string& name)
|
||||
{
|
||||
|
@ -200,6 +211,31 @@ Options::set_mimic_xpad()
|
|||
get_controller_options().uinput.mimic_xpad();
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_daemon()
|
||||
{
|
||||
mode = RUN_DAEMON;
|
||||
silent = true;
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_daemon_detach(bool value)
|
||||
{
|
||||
detach = value;
|
||||
if (detach)
|
||||
{
|
||||
silent = true;
|
||||
quiet = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Options::set_quiet()
|
||||
{
|
||||
quiet = true;
|
||||
silent = true;
|
||||
}
|
||||
|
||||
void
|
||||
Options::add_match(const std::string& lhs, const std::string& rhs)
|
||||
{
|
||||
|
@ -263,4 +299,10 @@ Options::set_match_group(const std::string& str)
|
|||
assert(!"not implemented");
|
||||
}
|
||||
|
||||
void
|
||||
Options::finish()
|
||||
{
|
||||
// FIXME: add some checks for conflicting options here
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -55,7 +55,6 @@ public:
|
|||
};
|
||||
|
||||
// General program options
|
||||
bool verbose;
|
||||
bool silent;
|
||||
bool quiet;
|
||||
bool rumble;
|
||||
|
@ -101,7 +100,7 @@ public:
|
|||
std::string headset_play;
|
||||
|
||||
// daemon options
|
||||
bool detach;
|
||||
bool detach;
|
||||
std::string pid_file;
|
||||
std::string on_connect;
|
||||
std::string on_disconnect;
|
||||
|
@ -130,6 +129,10 @@ public:
|
|||
void next_controller();
|
||||
void next_config();
|
||||
|
||||
void set_verbose();
|
||||
void set_debug();
|
||||
void set_quiet();
|
||||
|
||||
void set_device_name(const std::string& name);
|
||||
void set_mouse();
|
||||
void set_guitar();
|
||||
|
@ -140,9 +143,14 @@ public:
|
|||
void set_force_feedback(const std::string& value);
|
||||
void set_mimic_xpad();
|
||||
|
||||
void set_daemon();
|
||||
void set_daemon_detach(bool value);
|
||||
|
||||
void add_match(const std::string& lhs, const std::string& rhs);
|
||||
void set_match(const std::string& str);
|
||||
void set_match_group(const std::string& str);
|
||||
|
||||
void finish();
|
||||
};
|
||||
|
||||
extern Options* g_options;
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#include "playstation3_usb_controller.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
#include "xboxmsg.hpp"
|
||||
#include "log.hpp"
|
||||
#include "usb_helper.hpp"
|
||||
#include "xboxmsg.hpp"
|
||||
|
||||
Playstation3USBController::Playstation3USBController(libusb_device* dev, bool try_detach) :
|
||||
m_handle(0),
|
||||
|
@ -72,7 +72,7 @@ Playstation3USBController::set_led(uint8_t status)
|
|||
#define bitswap(x) x = ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8)
|
||||
|
||||
bool
|
||||
Playstation3USBController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
Playstation3USBController::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
int len;
|
||||
uint8_t data[64] = {0};
|
||||
|
@ -101,32 +101,34 @@ Playstation3USBController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
|||
|
||||
if (false)
|
||||
{
|
||||
std::cout << boost::format("X:%5d Y:%5d Z:%5d RZ:%5d\n")
|
||||
% (static_cast<int>(msg.ps3usb.accl_x) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.accl_y) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.accl_z) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.rot_z));
|
||||
log_debug(boost::format("X:%5d Y:%5d Z:%5d RZ:%5d\n")
|
||||
% (static_cast<int>(msg.ps3usb.accl_x) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.accl_y) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.accl_z) - 512)
|
||||
% (static_cast<int>(msg.ps3usb.rot_z)));
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// values are normalized to 1g (-116 is force by gravity)
|
||||
std::cout << boost::format("X:%6.3f Y:%6.3f Z:%6.3f RZ:%6.3f\n")
|
||||
% ((static_cast<int>(msg.ps3usb.accl_x) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.accl_y) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.accl_z) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.rot_z) - 5));
|
||||
log_debug(boost::format("X:%6.3f Y:%6.3f Z:%6.3f RZ:%6.3f\n")
|
||||
% ((static_cast<int>(msg.ps3usb.accl_x) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.accl_y) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.accl_z) - 512) / 116.0f)
|
||||
% ((static_cast<int>(msg.ps3usb.rot_z) - 5)));
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
std::cout << len << ": ";
|
||||
std::ostringstream str;
|
||||
str << len << ": ";
|
||||
for(int i = 0; i < len; ++i)
|
||||
{
|
||||
//std::cout << boost::format("%d:%02x ") % i % static_cast<int>(data[i]);
|
||||
std::cout << boost::format("%02x ") % static_cast<int>(data[i]);
|
||||
str << boost::format("%02x ") % static_cast<int>(data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
str << std::endl;
|
||||
log_debug(str.str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
void set_rumble(uint8_t left, uint8_t right);
|
||||
void set_led(uint8_t status);
|
||||
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
Playstation3USBController(const Playstation3USBController&);
|
||||
|
|
|
@ -109,7 +109,7 @@ SaitekP2500Controller::set_led(uint8_t status)
|
|||
}
|
||||
|
||||
bool
|
||||
SaitekP2500Controller::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
SaitekP2500Controller::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
SaitekP2500Msg data;
|
||||
int len = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void set_led(uint8_t status);
|
||||
|
||||
/** @param timeout timeout in msec, 0 means forever */
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
SaitekP2500Controller(const SaitekP2500Controller&);
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
#include "uinput_config.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "uinput.hpp"
|
||||
|
||||
namespace {
|
||||
|
@ -71,8 +69,7 @@ UInputConfig::send(XboxGenericMsg& msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
std::cout << "XboxGenericMsg type: " << msg.type << std::endl;
|
||||
assert(!"UInputConfig: Unknown XboxGenericMsg type");
|
||||
assert(!"never reached");
|
||||
}
|
||||
|
||||
m_uinput.sync();
|
||||
|
@ -258,13 +255,6 @@ UInputConfig::update(int msec_delta)
|
|||
m_btn_map.update(m_uinput, msec_delta);
|
||||
m_axis_map.update(m_uinput, msec_delta);
|
||||
|
||||
#ifdef FIXME
|
||||
if (cfg.force_feedback)
|
||||
{
|
||||
get_force_feedback_uinput()->update_force_feedback(msec_delta);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_uinput.sync();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "word_wrap.hpp"
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <iostream>
|
||||
|
||||
WordWrap::WordWrap(int terminal_width) :
|
||||
m_terminal_width(terminal_width)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef HEADER_XBOXDRV_WORD_WRAP_HPP
|
||||
#define HEADER_XBOXDRV_WORD_WRAP_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class WordWrap
|
||||
{
|
||||
|
|
|
@ -183,7 +183,7 @@ Xbox360Controller::set_led(uint8_t status)
|
|||
}
|
||||
|
||||
bool
|
||||
Xbox360Controller::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
Xbox360Controller::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
uint8_t data[32];
|
||||
int len = 0;
|
||||
|
@ -212,14 +212,11 @@ Xbox360Controller::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
|||
}
|
||||
else if (len == 3 && data[0] == 0x03 && data[1] == 0x03)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
// data[2] == 0x00 means that rumble is disabled
|
||||
// data[2] == 0x01 unknown, but rumble works
|
||||
// data[2] == 0x02 unknown, but rumble works
|
||||
// data[2] == 0x03 is default with rumble enabled
|
||||
log_info("Xbox360Controller: rumble status: " << int(data[2]));
|
||||
}
|
||||
// data[2] == 0x00 means that rumble is disabled
|
||||
// data[2] == 0x01 unknown, but rumble works
|
||||
// data[2] == 0x02 unknown, but rumble works
|
||||
// data[2] == 0x03 is default with rumble enabled
|
||||
log_info("rumble status: " << int(data[2]));
|
||||
}
|
||||
else if (len == 3 && data[0] == 0x08 && data[1] == 0x03)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
void set_rumble(uint8_t left, uint8_t right);
|
||||
void set_led(uint8_t status);
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
void find_endpoints();
|
||||
|
|
|
@ -97,7 +97,7 @@ Xbox360WirelessController::set_led(uint8_t status)
|
|||
}
|
||||
|
||||
bool
|
||||
Xbox360WirelessController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
Xbox360WirelessController::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
uint8_t data[32];
|
||||
int len = 0;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
void set_rumble(uint8_t left, uint8_t right);
|
||||
void set_led(uint8_t status);
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
uint8_t get_battery_status() const;
|
||||
private:
|
||||
Xbox360WirelessController (const Xbox360WirelessController&);
|
||||
|
|
|
@ -126,7 +126,7 @@ XboxController::set_led(uint8_t status)
|
|||
}
|
||||
|
||||
bool
|
||||
XboxController::read(XboxGenericMsg& msg, bool verbose, int timeout)
|
||||
XboxController::read(XboxGenericMsg& msg, int timeout)
|
||||
{
|
||||
// FIXME: Add tracking for duplicate data packages (send by logitech controller)
|
||||
uint8_t data[32];
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
void set_rumble(uint8_t left, uint8_t right);
|
||||
void set_led(uint8_t status);
|
||||
bool read(XboxGenericMsg& msg, bool verbose, int timeout);
|
||||
bool read(XboxGenericMsg& msg, int timeout);
|
||||
|
||||
private:
|
||||
XboxController (const XboxController&);
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
@param timeout timeout in msec, 0 means forever
|
||||
@return true if something was read, false otherwise
|
||||
*/
|
||||
virtual bool read(XboxGenericMsg& msg, bool verbose, int timeout) =0;
|
||||
virtual bool read(XboxGenericMsg& msg, int timeout) =0;
|
||||
|
||||
private:
|
||||
XboxGenericController (const XboxGenericController&);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -498,19 +499,15 @@ Xboxdrv::print_info(libusb_device* dev,
|
|||
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)")
|
||||
% dev_type.name % uint16_t(desc.idVendor) % uint16_t(desc.idProduct) << std::endl;
|
||||
std::cout << "Controller: " << dev_type.name << std::endl;
|
||||
std::cout << "Vendor/Product: " << boost::format("%04x:%04x")
|
||||
% uint16_t(desc.idVendor) % uint16_t(desc.idProduct) << std::endl;
|
||||
if (dev_type.type == GAMEPAD_XBOX360_WIRELESS)
|
||||
std::cout << "Wireless Port: " << opts.wireless_id << std::endl;
|
||||
std::cout << "Controller Type: " << dev_type.type << std::endl;
|
||||
std::cout << "Rumble Debug: " << (opts.rumble ? "on" : "off") << std::endl;
|
||||
std::cout << "Rumble Speed: " << "left: " << opts.rumble_l << " right: " << opts.rumble_r << std::endl;
|
||||
if (opts.led == -1)
|
||||
std::cout << "LED Status: " << "auto" << std::endl;
|
||||
else
|
||||
std::cout << "LED Status: " << opts.led << std::endl;
|
||||
std::cout << "Wireless Port: -" << std::endl;
|
||||
std::cout << "Controller Type: " << dev_type.type << std::endl;
|
||||
|
||||
std::cout << "RumbleGain: " << opts.rumble_gain << std::endl;
|
||||
//std::cout << "ForceFeedback: " << ((opts.controller.back().uinput.force_feedback) ? "enabled" : "disabled") << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <boost/format.hpp>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include "uinput_message_processor.hpp"
|
||||
#include "dummy_message_processor.hpp"
|
||||
|
@ -139,7 +138,7 @@ XboxdrvDaemon::cleanup_threads()
|
|||
void
|
||||
XboxdrvDaemon::process_match(const Options& opts, struct udev_device* device)
|
||||
{
|
||||
if (false)
|
||||
if (g_logger.get_log_level() >= Logger::kDebug)
|
||||
{
|
||||
print_info(device);
|
||||
}
|
||||
|
@ -156,8 +155,8 @@ XboxdrvDaemon::process_match(const Options& opts, struct udev_device* device)
|
|||
XPadDevice dev_type;
|
||||
if (!find_xpad_device(vendor, product, &dev_type))
|
||||
{
|
||||
log_info("ignoring " << boost::format("%04x:%04x") % vendor % product <<
|
||||
" not a valid Xboxdrv device");
|
||||
log_debug("ignoring " << boost::format("%04x:%04x") % vendor % product <<
|
||||
" not a valid Xboxdrv device");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -337,7 +336,7 @@ XboxdrvDaemon::run_loop(const Options& opts)
|
|||
if (!device)
|
||||
{
|
||||
// seem to be normal, do we get this when the given device is filtered out?
|
||||
std::cout << "udev device couldn't be read: " << device << std::endl;
|
||||
log_debug("udev device couldn't be read: " << device);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -355,77 +354,77 @@ XboxdrvDaemon::run_loop(const Options& opts)
|
|||
void
|
||||
XboxdrvDaemon::print_info(struct udev_device* device)
|
||||
{
|
||||
std::cout << "/---------------------------------------------" << std::endl;
|
||||
std::cout << "devpath: " << udev_device_get_devpath(device) << std::endl;
|
||||
log_debug("/---------------------------------------------");
|
||||
log_debug("devpath: " << udev_device_get_devpath(device));
|
||||
|
||||
if (udev_device_get_action(device))
|
||||
std::cout << "action: " << udev_device_get_action(device) << std::endl;
|
||||
//std::cout << "init: " << udev_device_get_is_initialized(device) << std::endl;
|
||||
log_debug("action: " << udev_device_get_action(device));
|
||||
//log_debug("init: " << udev_device_get_is_initialized(device));
|
||||
|
||||
if (udev_device_get_subsystem(device))
|
||||
std::cout << "subsystem: " << udev_device_get_subsystem(device) << std::endl;
|
||||
log_debug("subsystem: " << udev_device_get_subsystem(device));
|
||||
|
||||
if (udev_device_get_devtype(device))
|
||||
std::cout << "devtype: " << udev_device_get_devtype(device) << std::endl;
|
||||
log_debug("devtype: " << udev_device_get_devtype(device));
|
||||
|
||||
if (udev_device_get_syspath(device))
|
||||
std::cout << "syspath: " << udev_device_get_syspath(device) << std::endl;
|
||||
log_debug("syspath: " << udev_device_get_syspath(device));
|
||||
|
||||
if (udev_device_get_sysname(device))
|
||||
std::cout << "sysname: " << udev_device_get_sysname(device) << std::endl;
|
||||
log_debug("sysname: " << udev_device_get_sysname(device));
|
||||
|
||||
if (udev_device_get_sysnum(device))
|
||||
std::cout << "sysnum: " << udev_device_get_sysnum(device) << std::endl;
|
||||
log_debug("sysnum: " << udev_device_get_sysnum(device));
|
||||
|
||||
if (udev_device_get_devnode(device))
|
||||
std::cout << "devnode: " << udev_device_get_devnode(device) << std::endl;
|
||||
log_debug("devnode: " << udev_device_get_devnode(device));
|
||||
|
||||
if (udev_device_get_driver(device))
|
||||
std::cout << "driver: " << udev_device_get_driver(device) << std::endl;
|
||||
log_debug("driver: " << udev_device_get_driver(device));
|
||||
|
||||
if (udev_device_get_action(device))
|
||||
std::cout << "action: " << udev_device_get_action(device) << std::endl;
|
||||
log_debug("action: " << udev_device_get_action(device));
|
||||
|
||||
//udev_device_get_sysattr_value(device, "busnum");
|
||||
//udev_device_get_sysattr_value(device, "devnum");
|
||||
|
||||
{
|
||||
std::cout << "list: " << std::endl;
|
||||
log_debug("list: ");
|
||||
struct udev_list_entry* it = udev_device_get_tags_list_entry(device);
|
||||
while((it = udev_list_entry_get_next(it)) != 0)
|
||||
{
|
||||
std::cout << " "
|
||||
log_debug(" "
|
||||
<< udev_list_entry_get_name(it) << " = "
|
||||
<< udev_list_entry_get_value(it)
|
||||
<< std::endl;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "properties: " << std::endl;
|
||||
log_debug("properties: ");
|
||||
struct udev_list_entry* it = udev_device_get_properties_list_entry(device);
|
||||
while((it = udev_list_entry_get_next(it)) != 0)
|
||||
{
|
||||
std::cout << " "
|
||||
log_debug(" "
|
||||
<< udev_list_entry_get_name(it) << " = "
|
||||
<< udev_list_entry_get_value(it)
|
||||
<< std::endl;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "devlist: " << std::endl;
|
||||
log_debug("devlist: ");
|
||||
struct udev_list_entry* it = udev_device_get_tags_list_entry(device);
|
||||
while((it = udev_list_entry_get_next(it)) != 0)
|
||||
{
|
||||
std::cout << " "
|
||||
log_debug(" "
|
||||
<< udev_list_entry_get_name(it) << " = "
|
||||
<< udev_list_entry_get_value(it)
|
||||
<< std::endl;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "\\----------------------------------------------" << std::endl;
|
||||
log_debug("\\----------------------------------------------");
|
||||
}
|
||||
|
||||
XboxdrvDaemon::ControllerSlot*
|
||||
|
|
|
@ -128,7 +128,7 @@ XboxdrvThread::controller_loop(const Options& opts)
|
|||
{
|
||||
XboxGenericMsg msg;
|
||||
|
||||
if (m_controller->read(msg, opts.verbose, m_timeout))
|
||||
if (m_controller->read(msg, m_timeout))
|
||||
{
|
||||
m_oldrealmsg = msg;
|
||||
|
||||
|
|
|
@ -220,8 +220,7 @@ std::ostream& operator<<(std::ostream& out, const Xbox360Msg& msg)
|
|||
out << boost::format(" LT:%3d RT:%3d")
|
||||
% int(msg.lt) % int(msg.rt);
|
||||
|
||||
if (g_options->verbose)
|
||||
out << " Dummy: " << msg.dummy1 << " " << msg.dummy2 << " " << msg.dummy3;
|
||||
// out << " Dummy: " << msg.dummy1 << " " << msg.dummy2 << " " << msg.dummy3;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -260,8 +259,7 @@ std::ostream& operator<<(std::ostream& out, const XboxMsg& msg)
|
|||
% int(msg.lt)
|
||||
% int(msg.rt);
|
||||
|
||||
if (g_options->verbose)
|
||||
out << " Dummy: " << msg.dummy;
|
||||
// out << " Dummy: " << msg.dummy;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue