From 6d097b6ad51d0582257b4730096849214411b681 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Thu, 16 May 2013 06:50:41 +0000 Subject: [PATCH] Added --wiimote-debug command line option to print raw values read from a wiimote. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12773 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/config/user_config.hpp | 4 ++++ src/input/wiimote_manager.cpp | 41 +++++++++++++++++++---------------- src/main.cpp | 4 ++++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 4ff9764b5..3aba718de 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -425,7 +425,11 @@ namespace UserConfigParams // ---- Debug - not saved to config file /** If gamepad debugging is enabled. */ PARAM_PREFIX bool m_gamepad_debug PARAM_DEFAULT( false ); + + /** Wiimote debugging. */ + PARAM_PREFIX bool m_wiimote_debug PARAM_DEFAULT( false ); + /** Debug gamepads by visualising their values. */ PARAM_PREFIX bool m_gamepad_visualisation PARAM_DEFAULT( false ); /** If material debugging (printing terrain specific slowdown) diff --git a/src/input/wiimote_manager.cpp b/src/input/wiimote_manager.cpp index 32f449754..08511b2fc 100644 --- a/src/input/wiimote_manager.cpp +++ b/src/input/wiimote_manager.cpp @@ -162,18 +162,17 @@ void Wiimote::updateIrrEvent() // Simulate an Irrlicht joystick event resetIrrEvent(&m_irr_event, wiimoteIdToIrrId(m_wiimote_id)); - - // --------------------- Wiimote accelerometers -------------------- - //printf("yaw: %f\n", m_wiimote_handle->orient.yaw); - //printf("pitch: %f\n", m_wiimote_handle->orient.pitch); - //printf("roll: %f\n", m_wiimote_handle->orient.roll); - - // --- Linear response version --- - //const float wiimote_to_joystick = -JOYSTICK_ABS_MAX_ANGLE / float(UserConfigParams::m_wiimote_max); - //const float angle = wiimote_to_joystick * m_wiimote_handle->orient.pitch; - - // --- Quadratic response version --- - float normalized_angle = -m_wiimote_handle->orient.pitch / UserConfigParams::m_wiimote_max; +#ifdef DEBUG + if(UserConfigParams::m_wiimote_debug) + { + Log::verbose("wiimote", "pitch: %f yaw %f roll %f", + m_wiimote_handle->orient.pitch, + m_wiimote_handle->orient.yaw, + m_wiimote_handle->orient.roll); + } +#endif + + float normalized_angle = -m_wiimote_handle->orient.pitch / UserConfigParams::m_wiimote_max; if(normalized_angle<-1.0f) normalized_angle = -1.0f; else if(normalized_angle>1.0f) @@ -202,10 +201,13 @@ void Wiimote::updateIrrEvent() { if(IS_PRESSED(m_wiimote_handle, wiimote_actions[i].wiimote_action_id)) { - //printf("wiimote %d: pressed button %s -> button id: %d\n", - // m_wiimote_id, - // wiimote_actions[i].wiimote_action_name, - // wiimote_actions[i].button_id); +#ifdef DEBUG + if(UserConfigParams::m_wiimote_debug) + Log::verbose("wiimote", "%d: pressed button %s -> button id: %d\n", + m_wiimote_id, + wiimote_actions[i].wiimote_action_name, + wiimote_actions[i].button_id); +#endif m_irr_event.JoystickEvent.ButtonStates |= (1<<(wiimote_actions[i].button_id)); } } @@ -266,9 +268,10 @@ WiimoteManager::~WiimoteManager() // ----------------------------------------------------------------------------- /** - * Launch wiimote detection and add the corresponding gamepad devices to the device manager - * TODO: this should be done in a separate thread, to not block the UI... - */ + * Launch wiimote detection and add the corresponding gamepad devices to the + * device manager. + * TODO: this should be done in a separate thread, to not block the UI... + */ void WiimoteManager::launchDetection(int timeout) { // Stop WiiUse, remove wiimotes, gamepads, gamepad configs. diff --git a/src/main.cpp b/src/main.cpp index a51728ffb..131ad6a07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -622,6 +622,10 @@ int handleCmdLine(int argc, char **argv) { UserConfigParams::m_gamepad_debug=true; } + else if (!strcmp(argv[i], "--wiimote-debug")) + { + UserConfigParams::m_wiimote_debug = true; + } else if (!strcmp(argv[i], "--tutorial-debug")) { UserConfigParams::m_tutorial_debug = true;