forked from bartvdbraak/blender
Added mouse wheel support for windows.
Both gears (C and C++) projects contain an example. Maarten
This commit is contained in:
parent
3396a23499
commit
6478b3aa94
@ -40,6 +40,8 @@
|
||||
|
||||
/**
|
||||
* Mouse wheel event.
|
||||
* The displacement of the mouse wheel is counted in ticks.
|
||||
* A positive value means the wheel is turned away from the user.
|
||||
* @author Maarten Gribnau
|
||||
* @date May 11, 2001
|
||||
*/
|
||||
@ -52,8 +54,8 @@ public:
|
||||
* @param type The type of this event.
|
||||
* @param z The displacement of the mouse wheel.
|
||||
*/
|
||||
GHOST_EventWheel(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TInt32 z)
|
||||
: GHOST_Event(msec, type, window)
|
||||
GHOST_EventWheel(GHOST_TUns64 msec, GHOST_IWindow* window, GHOST_TInt32 z)
|
||||
: GHOST_Event(msec, GHOST_kEventWheel, window)
|
||||
{
|
||||
m_wheelEventData.z = z;
|
||||
m_data = &m_wheelEventData;
|
||||
|
@ -41,14 +41,29 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
|
||||
|
||||
#include "GHOST_SystemWin32.h"
|
||||
|
||||
/*
|
||||
* According to the docs the mouse wheel message is supported from windows 98
|
||||
* upwards. Leaving WINVER at default value, the WM_MOUSEWHEEL message and the
|
||||
* wheel detent value are undefined.
|
||||
*/
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL 0x020A
|
||||
#endif // WM_MOUSEWHEEL
|
||||
#ifndef WHEEL_DELTA
|
||||
#define WHEEL_DELTA 120 /* Value for rolling one detent */
|
||||
#endif // WHEEL_DELTA
|
||||
|
||||
|
||||
#include "GHOST_Debug.h"
|
||||
#include "GHOST_DisplayManagerWin32.h"
|
||||
#include "GHOST_EventButton.h"
|
||||
#include "GHOST_EventCursor.h"
|
||||
#include "GHOST_EventKey.h"
|
||||
#include "GHOST_EventWheel.h"
|
||||
#include "GHOST_TimerTask.h"
|
||||
#include "GHOST_TimerManager.h"
|
||||
#include "GHOST_WindowManager.h"
|
||||
@ -455,6 +470,17 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type,
|
||||
}
|
||||
|
||||
|
||||
GHOST_EventWheel* GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// short fwKeys = LOWORD(wParam); // key flags
|
||||
int zDelta = (short) HIWORD(wParam); // wheel rotation
|
||||
zDelta /= WHEEL_DELTA;
|
||||
// short xPos = (short) LOWORD(lParam); // horizontal position of pointer
|
||||
// short yPos = (short) HIWORD(lParam); // vertical position of pointer
|
||||
return new GHOST_EventWheel (getSystem()->getMilliSeconds(), window, zDelta);
|
||||
}
|
||||
|
||||
|
||||
GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, bool keyDown, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GHOST_TKey key = ((GHOST_SystemWin32*)getSystem())->convertKey(wParam, lParam);
|
||||
@ -627,6 +653,16 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
case WM_MOUSEMOVE:
|
||||
event = processCursorEvent(GHOST_kEventCursorMove, window);
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
/* The WM_MOUSEWHEEL message is sent to the focus window
|
||||
* when the mouse wheel is rotated. The DefWindowProc
|
||||
* function propagates the message to the window's parent.
|
||||
* There should be no internal forwarding of the message,
|
||||
* since DefWindowProc propagates it up the parent chain
|
||||
* until it finds a window that processes it.
|
||||
*/
|
||||
event = processWheelEvent(window, wParam, lParam);
|
||||
break;
|
||||
case WM_SETCURSOR:
|
||||
/* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor
|
||||
* to move within a window and mouse input is not captured.
|
||||
|
@ -52,6 +52,7 @@
|
||||
class GHOST_EventButton;
|
||||
class GHOST_EventCursor;
|
||||
class GHOST_EventKey;
|
||||
class GHOST_EventWheel;
|
||||
class GHOST_EventWindow;
|
||||
|
||||
/**
|
||||
@ -196,35 +197,49 @@ protected:
|
||||
* With the modifier keys, we want to distinguish left and right keys.
|
||||
* Sometimes this is not possible (Windows ME for instance). Then, we want
|
||||
* events generated for both keys.
|
||||
* @param window The window receiving the event (the active window).
|
||||
*/
|
||||
void processModifierKeys(GHOST_IWindow *window);
|
||||
|
||||
/**
|
||||
* Creates mouse button event.
|
||||
* @param type The type of event to create.
|
||||
* @param type The button mask of this event.
|
||||
* @param type The type of event to create.
|
||||
* @param window The window receiving the event (the active window).
|
||||
* @param mask The button mask of this event.
|
||||
* @return The event created.
|
||||
*/
|
||||
static GHOST_EventButton* processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask);
|
||||
|
||||
/**
|
||||
* Creates cursor event.
|
||||
* @param type The type of event to create.
|
||||
* @param type The type of event to create.
|
||||
* @param window The window receiving the event (the active window).
|
||||
* @return The event created.
|
||||
*/
|
||||
static GHOST_EventCursor* processCursorEvent(GHOST_TEventType type, GHOST_IWindow *window);
|
||||
|
||||
/**
|
||||
* Creates a mouse wheel event.
|
||||
* @param window The window receiving the event (the active window).
|
||||
* @param wParam The wParam from the wndproc
|
||||
* @param lParam The lParam from the wndproc
|
||||
*/
|
||||
static GHOST_EventWheel* processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* Creates a key event and updates the key data stored locally (m_modifierKeys).
|
||||
* In most cases this is a straightforward conversion of key codes.
|
||||
* For the modifier keys however, we want to distinguish left and right keys.
|
||||
* @param window The window receiving the event (the active window).
|
||||
* @param wParam The wParam from the wndproc
|
||||
* @param lParam The lParam from the wndproc
|
||||
*/
|
||||
static GHOST_EventKey* processKeyEvent(GHOST_IWindow *window, bool keyDown, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* Creates a window event.
|
||||
* @param type The type of event to create.
|
||||
* @param window The window receiving the event.
|
||||
* @param window The window receiving the event (the active window).
|
||||
* @return The event created.
|
||||
*/
|
||||
static GHOST_Event* processWindowEvent(GHOST_TEventType type, GHOST_IWindow* window);
|
||||
|
@ -297,6 +297,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
int cursor;
|
||||
int visibility;
|
||||
GHOST_TEventKeyData* keyData = NULL;
|
||||
GHOST_TEventWheelData* wheelData = NULL;
|
||||
GHOST_DisplaySetting setting;
|
||||
GHOST_WindowHandle window = GHOST_GetEventWindow(hEvent);
|
||||
|
||||
@ -310,6 +311,20 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
case GHOST_kEventCursorMove:
|
||||
break;
|
||||
*/
|
||||
case GHOST_kEventWheel:
|
||||
{
|
||||
wheelData = (GHOST_TEventWheelData*)GHOST_GetEventData(hEvent);
|
||||
if (wheelData->z > 0)
|
||||
{
|
||||
view_rotz += 5.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
view_rotz -= 5.f;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventKeyUp:
|
||||
break;
|
||||
|
||||
@ -347,6 +362,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
*/
|
||||
|
||||
sFullScreenWindow = GHOST_BeginFullScreen(shSystem, &setting,
|
||||
|
||||
FALSE /* stereo flag */);
|
||||
}
|
||||
else
|
||||
|
@ -275,7 +275,7 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0)
|
||||
int verticalBlankingInterval = 32; // hard coded for testing purposes, display device dependant
|
||||
float left, right, bottom, top;
|
||||
float nearplane, farplane, zeroPlane, distance;
|
||||
float eyeSeparation = 0.62;
|
||||
float eyeSeparation = 0.62f;
|
||||
window->getClientBounds(bnds);
|
||||
|
||||
// viewport
|
||||
@ -314,8 +314,8 @@ static void View(GHOST_IWindow* window, bool stereo, int eye = 0)
|
||||
// projection
|
||||
left = -6.0;
|
||||
right = 6.0;
|
||||
bottom = -4.8;
|
||||
top = 4.8;
|
||||
bottom = -4.8f;
|
||||
top = 4.8f;
|
||||
nearplane = 5.0;
|
||||
farplane = 60.0;
|
||||
|
||||
@ -481,6 +481,20 @@ bool Application::processEvent(GHOST_IEvent* event)
|
||||
case GHOST_kEventCursorMove:
|
||||
std::cout << "GHOST_kEventCursorMove"; break;
|
||||
*/
|
||||
case GHOST_kEventWheel:
|
||||
{
|
||||
GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) event->getData();
|
||||
if (wheelData->z > 0)
|
||||
{
|
||||
view_rotz += 5.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
view_rotz -= 5.f;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventKeyUp:
|
||||
break;
|
||||
|
||||
@ -678,10 +692,10 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
LONG lresult;
|
||||
HKEY hkey = 0;
|
||||
DWORD dwd = 0;
|
||||
unsigned char buffer[128];
|
||||
//unsigned char buffer[128];
|
||||
|
||||
CRegKey regkey;
|
||||
DWORD keyValue;
|
||||
//DWORD keyValue;
|
||||
// lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable");
|
||||
lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
|
||||
KEY_ALL_ACCESS );
|
||||
|
Loading…
Reference in New Issue
Block a user