Use quadratic response curve for wiimote steering

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12379 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
funto66 2013-01-17 22:03:06 +00:00
parent 67dc8141da
commit 7a223cc9b5
3 changed files with 25 additions and 4 deletions

View File

@ -167,8 +167,18 @@ void Wiimote::updateIrrEvent()
//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);
const float wiimote_to_joystick = -JOYSTICK_ABS_MAX_ANGLE / WIIMOTE_ABS_MAX_ANGLE;
const float angle = wiimote_to_joystick * m_wiimote_handle->orient.pitch;
// --- Linear response version ---
//const float wiimote_to_joystick = -JOYSTICK_ABS_MAX_ANGLE / WIIMOTE_ABS_MAX_ANGLE;
//const float angle = wiimote_to_joystick * m_wiimote_handle->orient.pitch;
// --- Quadratic response version ---
const float normalized_angle = -m_wiimote_handle->orient.pitch / WIIMOTE_ABS_MAX_ANGLE; // around [-1, 1]
const float normalized_angle_2 = normalized_angle * normalized_angle; // change the response curve to be
// less sensitive with values near 0
const float sign = normalized_angle >= 0.0f ? 1.0f : -1.0f;
const float angle = sign * normalized_angle_2 * JOYSTICK_ABS_MAX_ANGLE;
m_irr_event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X] =
(irr::s16)(irr::core::clamp(angle, -JOYSTICK_ABS_MAX_ANGLE, +JOYSTICK_ABS_MAX_ANGLE));

View File

@ -16,7 +16,6 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/add_device_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "config/player.hpp"
#include "guiengine/engine.hpp"
@ -174,6 +173,7 @@ GUIEngine::EventPropagation AddDeviceDialog::processEvent
#ifdef ENABLE_WIIUSE
else if (eventSource == "addwiimote")
{
//new MessageDialog( _("Press the buttons 1+2 of your wiimote..."), MessageDialog::MESSAGE_DIALOG_OK, this, false);
//new MessageDialog( _("Press the buttons 1+2 of your wiimote..."));
wiimote_manager->launchDetection(5);
@ -202,3 +202,9 @@ GUIEngine::EventPropagation AddDeviceDialog::processEvent
} // processEvent
// ----------------------------------------------------------------------------
void AddDeviceDialog::onConfirm()
{
ModalDialog::dismiss();
printf("TEST\n");
}

View File

@ -21,13 +21,16 @@
#include "config/player.hpp"
#include "guiengine/modaldialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "utils/cpp2011.h"
/**
* \brief Dialog that warns the user about the potential problems of
* creating multiple keyboard configs.
* \ingroup states_screens
*/
class AddDeviceDialog : public GUIEngine::ModalDialog
class AddDeviceDialog : public GUIEngine::ModalDialog,
public MessageDialog::IConfirmDialogListener
{
public:
@ -35,6 +38,8 @@ public:
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onConfirm() OVERRIDE;
};