summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/app.cpp46
-rw-r--r--src/app/app.h11
2 files changed, 35 insertions, 22 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 0d34811..23e6d9f 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -120,9 +120,6 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
- m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
- m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
-
m_dataPath = "./data";
m_language = LANG_ENGLISH;
@@ -439,6 +436,8 @@ bool CApplication::CreateVideoSurface()
void CApplication::Destroy()
{
+ m_joystickEnabled = false;
+
if (m_robotMain != nullptr)
{
delete m_robotMain;
@@ -810,15 +809,32 @@ Event CApplication::ParseEvent()
else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) ||
(m_private->currentEvent.type == SDL_MOUSEBUTTONUP) )
{
- if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
- event.type = EVENT_MOUSE_BUTTON_DOWN;
+ if ((m_private->currentEvent.button.button == SDL_BUTTON_WHEELUP) ||
+ (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN))
+ {
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) // ignore the following up event
+ {
+ event.type = EVENT_MOUSE_WHEEL;
+ if (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN)
+ event.mouseWheel.dir = WHEEL_DOWN;
+ else
+ event.mouseWheel.dir = WHEEL_UP;
+ event.mouseWheel.pos = m_engine->WindowToInterfaceCoords(
+ Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ }
+ }
else
- event.type = EVENT_MOUSE_BUTTON_UP;
+ {
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
+ event.type = EVENT_MOUSE_BUTTON_DOWN;
+ else
+ event.type = EVENT_MOUSE_BUTTON_UP;
- event.mouseButton.button = m_private->currentEvent.button.button;
- event.mouseButton.state = TranslatePressState(m_private->currentEvent.button.state);
- event.mouseButton.pos = m_engine->WindowToInterfaceCoords(
- Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ event.mouseButton.button = m_private->currentEvent.button.button;
+ event.mouseButton.state = TranslatePressState(m_private->currentEvent.button.state);
+ event.mouseButton.pos = m_engine->WindowToInterfaceCoords(
+ Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ }
}
else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
{
@@ -878,8 +894,6 @@ bool CApplication::ProcessEvent(Event &event)
else
event.mousePos = m_engine->GetMousePos();
- // TODO: mouse pos
-
if (event.type == EVENT_ACTIVE)
{
if (m_debugMode)
@@ -980,6 +994,11 @@ bool CApplication::ProcessEvent(Event &event)
l->Info(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
l->Info(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
break;
+ case EVENT_MOUSE_WHEEL:
+ l->Info("EVENT_MOUSE_WHEEL:\n");
+ l->Info(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
+ l->Info(" pos = (%f, %f)\n", event.mouseWheel.pos.x, event.mouseWheel.pos.y);
+ break;
case EVENT_JOY_AXIS:
l->Info("EVENT_JOY_AXIS:\n");
l->Info(" axis = %d\n", event.joyAxis.axis);
@@ -1235,8 +1254,7 @@ void CApplication::ResetKeyStates()
{
m_trackedKeys = 0;
m_kmodState = 0;
- m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
- m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_robotMain->ResetKeyStates();
}
void CApplication::SetGrabInput(bool grab)
diff --git a/src/app/app.h b/src/app/app.h
index 8429e0e..33be5a5 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -112,7 +112,7 @@ struct ApplicationPrivate;
* \section Creation Creation of other main objects
*
* The class creates the only instance of CInstanceManager, CEventQueue, CEngine,
- * CRobotMain and CSound classes.
+ * CRobotMain and CSoundInterface classes.
*
* \section Window Window management
*
@@ -241,7 +241,7 @@ public:
//! Returns whether the mouse button is pressed
bool GetMouseButtonState(int index);
- //! Resets tracked key states, modifiers and motion vectors
+ //! Resets tracked key states and modifiers
void ResetKeyStates();
//! Management of the grab mode for input (keyboard & mouse)
@@ -307,7 +307,7 @@ protected:
//! Graphics device
Gfx::CDevice* m_device;
//! Sound subsystem
- CSoundInterface* m_sound;
+ CSoundInterface* m_sound;
//! Main class of the proper game engine
CRobotMain* m_robotMain;
@@ -357,11 +357,6 @@ protected:
//! Current state of mouse buttons (mask of button indexes)
unsigned int m_mouseButtonsState;
- //! Motion vector set by keyboard
- Math::Vector m_keyMotion;
- //! Motion vector set by joystick
- Math::Vector m_joyMotion;
-
//! Current system mouse position
Math::Point m_systemMousePos;