|
From: <axl...@us...> - 2009-05-26 01:14:47
|
Revision: 275
http://hgengine.svn.sourceforge.net/hgengine/?rev=275&view=rev
Author: axlecrusher
Date: 2009-05-26 00:28:09 +0000 (Tue, 26 May 2009)
Log Message:
-----------
capture mouse button
Modified Paths:
--------------
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercuryInput.h
Mercury2/src/X11Window.cpp
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2009-05-26 00:27:12 UTC (rev 274)
+++ Mercury2/src/MercuryInput.cpp 2009-05-26 00:28:09 UTC (rev 275)
@@ -6,12 +6,20 @@
{
}
-void MouseInput::ProcessMouseInput(int dx, int dy)
+void MouseInput::ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton)
{
MouseInput* mi = new MouseInput();
mi->dx = dx;
mi->dy = dy;
+ uint8_t buttonMasks = 0;
+ buttonMasks |= (leftButton << MB_LEFT); //enable if true
+ buttonMasks |= (rightButton << MB_RIGHT); //enable if true
+ buttonMasks |= (centerButton << MB_CENTER); //enable if true
+ mi->buttonMasks = buttonMasks;
+
+ currentButtonMasks = buttonMasks;
+
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
}
@@ -57,6 +65,7 @@
uint8_t KeyboardInput::m_keyStates[512];
+uint8_t MouseInput::currentButtonMasks;
/****************************************************************************
Modified: Mercury2/src/MercuryInput.h
===================================================================
--- Mercury2/src/MercuryInput.h 2009-05-26 00:27:12 UTC (rev 274)
+++ Mercury2/src/MercuryInput.h 2009-05-26 00:28:09 UTC (rev 275)
@@ -6,18 +6,24 @@
const MString INPUTEVENT_MOUSE = "MouseInputEvent";
const MString INPUTEVENT_KEYBOARD = "KeyboardInputEvent";
+enum MouseButton
+{
+ MB_NONE = 0,
+ MB_LEFT = 1,
+ MB_RIGHT = 2,
+ MB_CENTER = 3
+};
+
class MouseInput : public MessageData
{
public:
- static const uint8_t LEFTBUTTON = 1;
- static const uint8_t RIGHTBUTTON = 2;
- static const uint8_t CENTERBUTTON = 4;
+ static void ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton);
- static void ProcessMouseInput(int x, int y);
-
MouseInput();
int32_t dx, dy;
uint8_t buttonMasks;
+ private:
+ static uint8_t currentButtonMasks;
};
class KeyboardInput : public MessageData
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-05-26 00:27:12 UTC (rev 274)
+++ Mercury2/src/X11Window.cpp 2009-05-26 00:28:09 UTC (rev 275)
@@ -143,13 +143,10 @@
switch (event.type)
{
case ButtonPress:
- {
- XButtonEvent* e = (XButtonEvent*)&event;
- break;
- }
case ButtonRelease:
{
XButtonEvent* e = (XButtonEvent*)&event;
+ MouseInput::ProcessMouseInput(0, 0, e->button & Button1, e->button & Button3, e->button & Button2);
break;
}
case KeyPress:
@@ -172,11 +169,16 @@
{
XMotionEvent* e = (XMotionEvent*)&event;
int x, y;
+ bool left, right, center;
+ left = e->state & Button1Mask;
+ right = e->state & Button3Mask;
+ center = e->state & Button2Mask;
x = m_width/2 - e->x;
y = m_height/2 - e->y;
if (x!=0 || y!=0) //prevent recursive XWarp
{
- MouseInput::ProcessMouseInput(x, y);
+ MouseInput::ProcessMouseInput(x, y,
+ left, right, center);
XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
}
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|