[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47758] branches/soc-2012-swiss_cheese/ intern/ghost: * Adds touch type to GHOST
Nicholas Rishel
rishel.nick at gmail.com
Mon Jun 11 21:41:34 CEST 2012
Revision: 47758
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47758
Author: nicholas_rishel
Date: 2012-06-11 19:41:33 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
* Adds touch type to GHOST
* Adds touch event structure to GHOST (not fully implemented)
* Adds generalization of Windows system touch for MinGW and beginnings of support for MinGW-w64 and MSVC
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/intern/ghost/CMakeLists.txt
branches/soc-2012-swiss_cheese/intern/ghost/GHOST_Types.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.cpp
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.cpp
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TaskbarWin32.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_WindowWin32.h
Added Paths:
-----------
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_EventTouch.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TouchManager.cpp
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TouchManager.h
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TouchManagerWin32.cpp
branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TouchManagerWin32.h
Modified: branches/soc-2012-swiss_cheese/intern/ghost/CMakeLists.txt
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/CMakeLists.txt 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/CMakeLists.txt 2012-06-11 19:41:33 UTC (rev 47758)
@@ -110,6 +110,17 @@
if(WITH_INPUT_TOUCH)
add_definitions(-DWITH_INPUT_TOUCH)
+
+ list(APPEND SRC
+ intern/GHOST_TouchManager.cpp
+
+ intern/GHOST_EventTouch.h
+ intern/GHOST_TouchManager.h
+ )
+
+ list(APPEND INC_SYS
+ ${TOUCH_INCLUDE_DIRS}
+ )
endif()
if(WITH_HEADLESS OR WITH_GHOST_SDL)
@@ -310,6 +321,14 @@
)
endif()
+ if(WITH_INPUT_TOUCH)
+ list(APPEND SRC
+ intern/GHOST_TouchManagerWin32.cpp
+
+ intern/GHOST_TouchManagerWin32.h
+ )
+ endif()
+
endif()
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")
Modified: branches/soc-2012-swiss_cheese/intern/ghost/GHOST_Types.h
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/GHOST_Types.h 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/GHOST_Types.h 2012-06-11 19:41:33 UTC (rev 47758)
@@ -161,6 +161,8 @@
GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
GHOST_kEventNDOFButton, /// N degree of freedom device button event
+ GHOST_kEventTouch, /// Touch event
+
GHOST_kEventKeyDown,
GHOST_kEventKeyUp,
// GHOST_kEventKeyAuto,
@@ -462,7 +464,23 @@
short button;
} GHOST_TEventNDOFButtonData;
+typedef enum {
+ GHOST_kDown = 0,
+ GHOST_kMove,
+ GHOST_kUp
+} GHOST_TTouchState;
+
typedef struct {
+ GHOST_TTouchState state;
+ GHOST_TUns8 index;
+ // Coordinates x and y represent position on the screen represented as 1/100th of a pixel
+ // e.g. x = 150, y = 275 represents a position 1.5 pixels to the right
+ // and 2.75 pixels down from top, left of the screen
+ GHOST_TInt32 x;
+ GHOST_TInt32 y;
+} GHOST_TEventTouchData;
+
+typedef struct {
/** The key code. */
GHOST_TKey key;
Added: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_EventTouch.h
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_EventTouch.h (rev 0)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_EventTouch.h 2012-06-11 19:41:33 UTC (rev 47758)
@@ -0,0 +1,42 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s):
+ * Nicholas Rishel
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __GHOST_EVENTTOUCH_H__
+#define __GHOST_EVENTTOUCH_H__
+
+#include "GHOST_Event.h"
+
+class GHOST_EventTouch : public GHOST_Event
+{
+protected:
+ GHOST_TEventTouchData m_touchData;
+
+public:
+ GHOST_EventTouch(GHOST_TUns64 time, GHOST_IWindow *window)
+ : GHOST_Event(time, GHOST_kEventNDOFMotion, window)
+ {
+ m_data = &m_touchData;
+ }
+};
+
+#endif // __GHOST_EVENTTOUCH_H__
Modified: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.cpp 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.cpp 2012-06-11 19:41:33 UTC (rev 47758)
@@ -39,6 +39,7 @@
#include "GHOST_DisplayManager.h"
#include "GHOST_EventManager.h"
#include "GHOST_NDOFManager.h"
+#include "GHOST_TouchManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
@@ -52,6 +53,9 @@
#ifdef WITH_INPUT_NDOF
, m_ndofManager(0)
#endif
+#ifdef WITH_INPUT_TOUCH
+ , m_touchManager(0)
+#endif // WITH_INPUT_TOUCH
{
}
@@ -343,6 +347,12 @@
m_ndofManager = 0;
}
#endif
+#ifdef WITH_TOUCH_INPUT
+ if (m_touchManager) {
+ delete m_touchManager;
+ m_touchManager = 0;
+ }
+#endif // WITH_TOUCH_INPUT
return GHOST_kSuccess;
}
Modified: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.h
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.h 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_System.h 2012-06-11 19:41:33 UTC (rev 47758)
@@ -49,6 +49,7 @@
class GHOST_Window;
class GHOST_WindowManager;
class GHOST_NDOFManager;
+class GHOST_TouchManager;
/**
* Implementation of platform independent functionality of the GHOST_ISystem
@@ -268,7 +269,15 @@
virtual inline GHOST_NDOFManager *getNDOFManager() const;
#endif
+#ifdef WITH_INPUT_TOUCH
/**
+ * Returns a pointer to the touch manager.
+ * @return A pointer to touch manager.
+ */
+ virtual inline GHOST_TouchManager *getTouchManager() const;
+#endif
+
+ /**
* Returns the state of all modifier keys.
* @param keys The state of all modifier keys (true == pressed).
* @return Indication of success.
@@ -342,6 +351,11 @@
/** The N-degree of freedom device manager */
GHOST_NDOFManager *m_ndofManager;
#endif
+
+#ifdef WITH_INPUT_TOUCH
+ /** The touch device manager */
+ GHOST_TouchManager *m_touchManager;
+#endif
/** Prints all the events. */
#ifdef GHOST_DEBUG
@@ -374,5 +388,12 @@
}
#endif
+#ifdef WITH_INPUT_TOUCH
+inline GHOST_TouchManager *GHOST_System::getTouchManager() const
+{
+ return m_touchManager;
+}
+#endif
+
#endif // __GHOST_SYSTEM_H__
Modified: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.cpp 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.cpp 2012-06-11 19:41:33 UTC (rev 47758)
@@ -76,6 +76,10 @@
#include "GHOST_NDOFManagerWin32.h"
#endif
+#ifdef WITH_INPUT_TOUCH
+#include "GHOST_TouchManagerWin32.h"
+#endif
+
// Key code values not found in winuser.h
#ifndef VK_MINUS
#define VK_MINUS 0xBD
@@ -127,6 +131,16 @@
#define VK_MEDIA_PLAY_PAUSE 0xB3
#endif // VK_MEDIA_PLAY_PAUSE
+// Corrects MinGW defines
+#ifdef TOUCHEVENTF_DOWN
+# undef TOUCHEVENTF_DOWN
+# define TOUCHEVENTF_DOWN 0x0002
+#endif //TOUCHEVENTF_DOWN
+#ifdef TOUCHEVENTF_MOVE
+# undef TOUCHEVENTF_MOVE
+# define TOUCHEVENTF_MOVE 0x0001
+#endif //TOUCHEVENTF_UP
+
static void initRawInput()
{
#ifdef WITH_INPUT_NDOF
@@ -176,6 +190,10 @@
#ifdef WITH_INPUT_NDOF
m_ndofManager = new GHOST_NDOFManagerWin32(*this);
#endif
+
+#ifdef WITH_INPUT_TOUCH
+ m_touchManager = new GHOST_TouchManagerWin32(*this);
+#endif
}
GHOST_SystemWin32::~GHOST_SystemWin32()
@@ -878,6 +896,43 @@
}
#endif // WITH_INPUT_NDOF
+#ifdef WITH_INPUT_TOUCH
+void GHOST_SystemWin32::processTouch(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ UINT cInputs = LOWORD(wParam);
+ PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
+ GHOST_TTouchState state;
+
+ if (NULL != pInputs) {
+ if (GetTouchInputInfo((HANDLE)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) {
+ for (UINT i = 0; i < cInputs; i++) {
+
+ switch (msg) {
+ case TOUCHEVENTF_DOWN:
+ state = GHOST_kDown;
+ break;
+ case TOUCHEVENTF_MOVE:
+ state = GHOST_kMove;
+ break;
+ case TOUCHEVENTF_UP:
+ state = GHOST_kUp;
+ break;
+ default:
+ break;
+ }
+
+ // Windows returns first ID as 2, then 3, 4... set to begin at 1
+ m_touchManager->sendTouchEvent((GHOST_TUns8) pInputs[i-1].dwID, state, (GHOST_TInt32) pInputs[i].x,
+ (GHOST_TInt32) pInputs[i].y, (GHOST_TUns64) getMilliSeconds());
+
+ } //end for(display touch)
+ } //end if(got touch info)
+ } //end if(pInputs exists)
+
+ delete [] pInputs;
+}
+#endif
+
LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
GHOST_Event *event = 0;
@@ -989,9 +1044,15 @@
// Touch events, processed
////////////////////////////////////////////////////////////////////////
#ifdef WITH_INPUT_TOUCH
+# if defined(_MSC_VER) || defined(FREE_WINDOWS64) // MSVC or MinGW-w64 defines
+ case WM_TOUCH:
+# else // MinGW defines
case WM_TOUCHDOWN:
+ case WM_TOUCHMOVE:
case WM_TOUCHUP:
- case WM_TOUCHMOVE:
+# endif
+ system->processTouch(msg, wParam, lParam);
+ eventHandled = true;
break;
#endif
////////////////////////////////////////////////////////////////////////
Modified: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.h 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_SystemWin32.h 2012-06-11 19:41:33 UTC (rev 47758)
@@ -37,6 +37,7 @@
#error WIN32 only!
#endif // WIN32
+// Windows dependency for system touch, replace later?
#ifdef WITH_INPUT_TOUCH
# define _WIN32_WINNT 0x0601 // require Windows 7 or newer
#else
@@ -349,7 +350,14 @@
bool processNDOF(RAWINPUT const& raw);
#endif
+#ifdef WITH_INPUT_TOUCH
/**
+ * Handles Touch events, communicates directly with GHOST_TouchManager.
+ */
+ void processTouch(UINT msg, WPARAM wParam, LPARAM lParam);
+#endif
+
+ /**
* Returns the local state of the modifier keys (from the message queue).
* @param keys The state of the keys.
*/
Modified: branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TaskbarWin32.h
===================================================================
--- branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TaskbarWin32.h 2012-06-11 19:31:51 UTC (rev 47757)
+++ branches/soc-2012-swiss_cheese/intern/ghost/intern/GHOST_TaskbarWin32.h 2012-06-11 19:41:33 UTC (rev 47758)
@@ -8,11 +8,13 @@
#error WIN32 only!
#endif // WIN32
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list