Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-03 03:45:03 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-03 03:45:03 +0400
commit08c14c7ca0398d792e3a2676b1afd66666674dae (patch)
treeca57b8c1d929031f4290da7d94a14ec502001918 /source/gameengine/GamePlayer
parent45a240260e5545a2fe04121f76cb7c10982cf123 (diff)
Mouse Wheel Support for the Game Engine.
This adds "Wheel Up" and "Wheel Down" as choices to the Mouse sensor brick.
Diffstat (limited to 'source/gameengine/GamePlayer')
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp6
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.h4
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp22
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.h1
4 files changed, 32 insertions, 1 deletions
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
index bfd1acaf65d..7e57aa1ee40 100644
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
@@ -107,6 +107,12 @@ bool GPC_MouseDevice::ConvertButtonEvent(TButtonId button, bool isDown)
case buttonRight:
result = ConvertEvent(KX_RIGHTMOUSE, isDown);
break;
+ case buttonWheelUp:
+ result = ConvertEvent(KX_WHEELUPMOUSE, isDown);
+ break;
+ case buttonWheelDown:
+ result = ConvertEvent(KX_WHEELDOWNMOUSE, isDown);
+ break;
default:
// Should not happen!
break;
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
index 150b7808e4b..da5098b06d6 100644
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
@@ -53,7 +53,9 @@ public:
typedef enum {
buttonLeft,
buttonMiddle,
- buttonRight
+ buttonRight,
+ buttonWheelUp,
+ buttonWheelDown
} TButtonId;
GPC_MouseDevice();
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index c33114c423a..13848cecc62 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -228,6 +228,10 @@ bool GPG_Application::processEvent(GHOST_IEvent* event)
case GHOST_kEventButtonUp:
handled = handleButton(event, false);
break;
+
+ case GHOST_kEventWheel:
+ handled = handleWheel(event);
+ break;
case GHOST_kEventCursorMove:
handled = handleCursorMove(event);
@@ -562,6 +566,24 @@ void GPG_Application::exitEngine()
m_engineInitialized = false;
}
+bool GPG_Application::handleWheel(GHOST_IEvent* event)
+{
+ bool handled = false;
+ assert(event);
+ if (m_mouse)
+ {
+ GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
+ GHOST_TEventWheelData* wheelData = static_cast<GHOST_TEventWheelData*>(eventData);
+ GPC_MouseDevice::TButtonId button;
+ if (wheelData->z > 0)
+ button = GPC_MouseDevice::buttonWheelUp;
+ else
+ button = GPC_MouseDevice::buttonWheelDown;
+ m_mouse->ConvertButtonEvent(button, true);
+ handled = true;
+ }
+ return handled;
+}
bool GPG_Application::handleButton(GHOST_IEvent* event, bool isDown)
{
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h
index 010e976f83c..4fcd66e64e0 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h
@@ -67,6 +67,7 @@ public:
void StopGameEngine();
protected:
+ bool handleWheel(GHOST_IEvent* event);
bool handleButton(GHOST_IEvent* event, bool isDown);
bool handleCursorMove(GHOST_IEvent* event);
bool handleKey(GHOST_IEvent* event, bool isDown);