Commit 2573257f authored by cutealien's avatar cutealien

Double and triple click events now for each mouse-button. Old events for that got removed.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2914 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 883db0f0
...@@ -99,13 +99,29 @@ namespace irr ...@@ -99,13 +99,29 @@ namespace irr
//! in what direction and how fast. //! in what direction and how fast.
EMIE_MOUSE_WHEEL, EMIE_MOUSE_WHEEL,
//! Mouse double click. //! Left mouse button double click.
//! This event is generated after the second EMIE_LMOUSE_PRESSED_DOWN event. //! This event is generated after the second EMIE_LMOUSE_PRESSED_DOWN event.
EMIE_MOUSE_DOUBLE_CLICK, EMIE_LMOUSE_DOUBLE_CLICK,
//! Mouse triple click. //! Right mouse button double click.
//! This event is generated after the second EMIE_RMOUSE_PRESSED_DOWN event.
EMIE_RMOUSE_DOUBLE_CLICK,
//! Middle mouse button double click.
//! This event is generated after the second EMIE_MMOUSE_PRESSED_DOWN event.
EMIE_MMOUSE_DOUBLE_CLICK,
//! Left mouse button triple click.
//! This event is generated after the third EMIE_LMOUSE_PRESSED_DOWN event. //! This event is generated after the third EMIE_LMOUSE_PRESSED_DOWN event.
EMIE_MOUSE_TRIPLE_CLICK, EMIE_LMOUSE_TRIPLE_CLICK,
//! Right mouse button triple click.
//! This event is generated after the third EMIE_RMOUSE_PRESSED_DOWN event.
EMIE_RMOUSE_TRIPLE_CLICK,
//! Middle mouse button triple click.
//! This event is generated after the third EMIE_MMOUSE_PRESSED_DOWN event.
EMIE_MMOUSE_TRIPLE_CLICK,
//! No real event. Just for convenience to get number of events //! No real event. Just for convenience to get number of events
EMIE_COUNT EMIE_COUNT
......
...@@ -905,17 +905,17 @@ bool CIrrDeviceLinux::run() ...@@ -905,17 +905,17 @@ bool CIrrDeviceLinux::run()
{ {
postEventFromUser(irrevent); postEventFromUser(irrevent);
if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ) if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
{ {
u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y); u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event);
if ( clicks == 2 ) if ( clicks == 2 )
{ {
irrevent.MouseInput.Event = EMIE_MOUSE_DOUBLE_CLICK; irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
postEventFromUser(irrevent); postEventFromUser(irrevent);
} }
else if ( clicks == 3 ) else if ( clicks == 3 )
{ {
irrevent.MouseInput.Event = EMIE_MOUSE_TRIPLE_CLICK; irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
postEventFromUser(irrevent); postEventFromUser(irrevent);
} }
} }
......
...@@ -380,17 +380,17 @@ bool CIrrDeviceSDL::run() ...@@ -380,17 +380,17 @@ bool CIrrDeviceSDL::run()
{ {
postEventFromUser(irrevent); postEventFromUser(irrevent);
if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ) if ( irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
{ {
u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y); u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event);
if ( clicks == 2 ) if ( clicks == 2 )
{ {
irrevent.MouseInput.Event = EMIE_MOUSE_DOUBLE_CLICK; irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
postEventFromUser(irrevent); postEventFromUser(irrevent);
} }
else if ( clicks == 3 ) else if ( clicks == 3 )
{ {
irrevent.MouseInput.Event = EMIE_MOUSE_TRIPLE_CLICK; irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
postEventFromUser(irrevent); postEventFromUser(irrevent);
} }
} }
......
...@@ -172,7 +172,7 @@ bool CIrrDeviceStub::checkVersion(const char* version) ...@@ -172,7 +172,7 @@ bool CIrrDeviceStub::checkVersion(const char* version)
//! Compares to the last call of this function to return double and triple clicks. //! Compares to the last call of this function to return double and triple clicks.
u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY) u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent )
{ {
const s32 MAX_MOUSEMOVE = 3; const s32 MAX_MOUSEMOVE = 3;
...@@ -181,7 +181,9 @@ u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY) ...@@ -181,7 +181,9 @@ u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY)
if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime
&& core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE && core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE
&& core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE && core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE
&& MouseMultiClicks.CountSuccessiveClicks < 3 ) && MouseMultiClicks.CountSuccessiveClicks < 3
&& MouseMultiClicks.LastMouseInputEvent == inputEvent
)
{ {
++MouseMultiClicks.CountSuccessiveClicks; ++MouseMultiClicks.CountSuccessiveClicks;
} }
...@@ -190,6 +192,7 @@ u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY) ...@@ -190,6 +192,7 @@ u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY)
MouseMultiClicks.CountSuccessiveClicks = 1; MouseMultiClicks.CountSuccessiveClicks = 1;
} }
MouseMultiClicks.LastMouseInputEvent = inputEvent;
MouseMultiClicks.LastClickTime = clickTime; MouseMultiClicks.LastClickTime = clickTime;
MouseMultiClicks.LastClick.X = mouseX; MouseMultiClicks.LastClick.X = mouseX;
MouseMultiClicks.LastClick.Y = mouseY; MouseMultiClicks.LastClick.Y = mouseY;
......
...@@ -132,7 +132,7 @@ namespace irr ...@@ -132,7 +132,7 @@ namespace irr
//! Compares to the last call of this function to return double and triple clicks. //! Compares to the last call of this function to return double and triple clicks.
//! \return Returns only 1,2 or 3. A 4th click will start with 1 again. //! \return Returns only 1,2 or 3. A 4th click will start with 1 again.
virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY); virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent );
void calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ); void calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast );
void calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ); void calculateGammaFromRamp ( f32 &gamma, const u16 *ramp );
...@@ -151,13 +151,14 @@ namespace irr ...@@ -151,13 +151,14 @@ namespace irr
struct SMouseMultiClicks struct SMouseMultiClicks
{ {
SMouseMultiClicks() SMouseMultiClicks()
: DoubleClickTime(500), CountSuccessiveClicks(0), LastClickTime(0) : DoubleClickTime(500), CountSuccessiveClicks(0), LastClickTime(0), LastMouseInputEvent(EMIE_COUNT)
{} {}
u32 DoubleClickTime; u32 DoubleClickTime;
u32 CountSuccessiveClicks; u32 CountSuccessiveClicks;
u32 LastClickTime; u32 LastClickTime;
core::position2di LastClick; core::position2di LastClick;
EMOUSE_INPUT_EVENT LastMouseInputEvent;
}; };
SMouseMultiClicks MouseMultiClicks; SMouseMultiClicks MouseMultiClicks;
video::CVideoModeList VideoModeList; video::CVideoModeList VideoModeList;
......
...@@ -166,17 +166,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -166,17 +166,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
dev->postEventFromUser(event); dev->postEventFromUser(event);
if ( event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN ) if ( event.MouseInput.Event >= irr::EMIE_LMOUSE_PRESSED_DOWN && event.MouseInput.Event <= irr::EMIE_MMOUSE_PRESSED_DOWN )
{ {
irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y); irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Event);
if ( clicks == 2 ) if ( clicks == 2 )
{ {
event.MouseInput.Event = irr::EMIE_MOUSE_DOUBLE_CLICK; event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_DOUBLE_CLICK + event.MouseInput.Event-irr::EMIE_LMOUSE_PRESSED_DOWN);
dev->postEventFromUser(event); dev->postEventFromUser(event);
} }
else if ( clicks == 3 ) else if ( clicks == 3 )
{ {
event.MouseInput.Event = irr::EMIE_MOUSE_TRIPLE_CLICK; event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_TRIPLE_CLICK + event.MouseInput.Event-irr::EMIE_LMOUSE_PRESSED_DOWN);
dev->postEventFromUser(event); dev->postEventFromUser(event);
} }
} }
......
...@@ -95,10 +95,10 @@ namespace irr ...@@ -95,10 +95,10 @@ namespace irr
//! Compares to the last call of this function to return double and triple clicks. //! Compares to the last call of this function to return double and triple clicks.
//! \return Returns only 1,2 or 3. A 4th click will start with 1 again. //! \return Returns only 1,2 or 3. A 4th click will start with 1 again.
virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY) virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent )
{ {
// we just have to make it public // we just have to make it public
return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY); return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY, inputEvent );
} }
//! switchs to fullscreen //! switchs to fullscreen
......
...@@ -75,8 +75,12 @@ bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event) ...@@ -75,8 +75,12 @@ bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event)
MousePos = CursorControl->getRelativePosition(); MousePos = CursorControl->getRelativePosition();
break; break;
case EMIE_MOUSE_WHEEL: case EMIE_MOUSE_WHEEL:
case EMIE_MOUSE_DOUBLE_CLICK: case EMIE_LMOUSE_DOUBLE_CLICK:
case EMIE_MOUSE_TRIPLE_CLICK: case EMIE_RMOUSE_DOUBLE_CLICK:
case EMIE_MMOUSE_DOUBLE_CLICK:
case EMIE_LMOUSE_TRIPLE_CLICK:
case EMIE_RMOUSE_TRIPLE_CLICK:
case EMIE_MMOUSE_TRIPLE_CLICK:
case EMIE_COUNT: case EMIE_COUNT:
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment