diff options
Diffstat (limited to 'intern')
54 files changed, 2789 insertions, 33 deletions
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index cb2fc239859..576c048288e 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -65,6 +65,10 @@ if(WITH_CYCLES) add_subdirectory(cycles) endif() +if(WITH_INPUT_TOUCH) + add_subdirectory(touch) +endif() + # only windows needs utf16 converter if(WIN32) add_subdirectory(utfconv) diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index 0071bbe5cdc..fe2368b7ea8 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -18,11 +18,16 @@ set(SRC device_cpu.cpp device_cuda.cpp device_multi.cpp - device_network.cpp device_opencl.cpp device_task.cpp ) +if(WITH_NETWORK) + list(APPEND SRC + device_network.cpp + ) +endif() + set(SRC_HEADERS device.h device_memory.h diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index c6a2c678bac..721c262f094 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -57,7 +57,7 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w if(transparent) { glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */ } glPixelZoom((float)width/(float)w, (float)height/(float)h); @@ -74,8 +74,10 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w glRasterPos2f(0.0f, 0.0f); glPixelZoom(1.0f, 1.0f); - if(transparent) + if(transparent) { glDisable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */ + } } Device *Device::create(DeviceInfo& info, Stats &stats, bool background) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index d797c0f09ca..440971e2663 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -796,12 +796,12 @@ public: glBindTexture(GL_TEXTURE_2D, pmem.cuTexId); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, (void*)offset); glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); - + glEnable(GL_TEXTURE_2D); - + if(transparent) { glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */ } glColor3f(1.0f, 1.0f, 1.0f); @@ -824,9 +824,11 @@ public: glPopMatrix(); - if(transparent) + if(transparent) { glDisable(GL_BLEND); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */ + } + glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index bf5f791a245..4e6ecdeb5d6 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -70,3 +70,5 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) add_library(cycles_util ${SRC} ${SRC_HEADERS}) + +add_definitions(-DGLEW_STATIC) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index ea09987c564..8771929c14d 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -75,6 +75,7 @@ set(SRC intern/GHOST_EventString.h intern/GHOST_EventTrackpad.h intern/GHOST_EventWheel.h + intern/GHOST_EventSensor.h intern/GHOST_ModifierKeys.h intern/GHOST_System.h intern/GHOST_SystemPaths.h @@ -108,7 +109,40 @@ if(WITH_INPUT_NDOF) ) endif() -if(WITH_HEADLESS OR WITH_GHOST_SDL) +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_ANDROID AND NOT WITH_GHOST_SDL) + +list(APPEND SRC + intern/GHOST_DisplayManagerAndroid.cpp + intern/GHOST_SystemAndroid.cpp + intern/GHOST_WindowAndroid.cpp + intern/GHOST_SystemPathsAndroid.cpp + + intern/GHOST_DisplayManagerAndroid.h + intern/GHOST_SystemAndroid.h + intern/GHOST_WindowAndroid.h + intern/GHOST_SystemPathsAndroid.h +) + +list(APPEND INC_SYS + ${ANDROID_APP_INCLUDE_DIR} +) + +elseif(WITH_HEADLESS OR WITH_GHOST_SDL) if(WITH_HEADLESS) list(APPEND SRC intern/GHOST_DisplayManagerNULL.h @@ -310,6 +344,14 @@ elseif(WIN32) ) 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}") diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 87ab3c013c6..d1d5fc048ce 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -420,6 +420,30 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, GHOST_TButtonMask mask, int *isDown); +/*************************************************************************************** + * Hardware Sensor operations + ***************************************************************************************/ + +/** + * Returns the availability of sensor. + * @param systemhandle The handle to the system + * @param type The type of sensor. + * @return Indication of availability. + */ +extern GHOST_TSuccess GHOST_getSensorsAvailability(GHOST_SystemHandle systemhandle, + GHOST_TSensorTypes type); + +/** + * Enables or disables specific sensor. + * @param systemhandle The handle to the system + * @param type The type of sensor. + * @param enable 1 = enable, 0 = disable + * @return Indication of success. + */ +extern GHOST_TSuccess GHOST_setSensorsState(GHOST_SystemHandle systemhandle, + GHOST_TSensorTypes type, + int enable); + /*************************************************************************************** * Drag'n'drop operations diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index ad5d2379787..69f44ee6bcb 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -367,6 +367,26 @@ public: */ virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0; + + /*************************************************************************************** + * Hardware Sensor operations + ***************************************************************************************/ + + /** + * Returns the availability of sensor. + * @param type The type of sensor. + * @return Indication of availability. + */ + virtual GHOST_TSuccess getSensorsAvailability(GHOST_TSensorTypes type) = 0; + + /** + * Enables or disables specific sensor. + * @param type The type of sensor. + * @param enable 1 = enable, 0 = disable + * @return Indication of success. + */ + virtual GHOST_TSuccess setSensorsState(GHOST_TSensorTypes type, int enable) = 0; + /** * Toggles console * \param action diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 868d787b5f9..4fe3f10d23e 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -164,10 +164,14 @@ typedef enum { 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, + GHOST_kEventSensor, + GHOST_kEventQuit, GHOST_kEventWindowClose, @@ -466,6 +470,16 @@ typedef struct { } GHOST_TEventNDOFButtonData; typedef struct { + GHOST_TProgress 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; @@ -484,6 +498,19 @@ typedef struct { char utf8_buf[6]; } GHOST_TEventKeyData; +typedef enum { + GHOST_kSensorAccelerometer = 1, + GHOST_kSensorGyroscope, + GHOST_kSensorMagnetic + +} GHOST_TSensorTypes; + +typedef struct { + GHOST_TSensorTypes type; + float dv[3]; + +} GHOST_TEventSensorData; + typedef struct { /** Number of pixels on a line. */ GHOST_TUns32 xPixels; @@ -496,6 +523,7 @@ typedef struct { } GHOST_DisplaySetting; + #ifdef _WIN32 typedef long GHOST_TEmbedderWindowID; #endif // _WIN32 diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 88d02c46f61..5f2e47b11ec 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -413,6 +413,23 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, } +extern GHOST_TSuccess GHOST_getSensorsAvailability(GHOST_SystemHandle systemhandle, + GHOST_TSensorTypes type) +{ + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + + return system->getSensorsAvailability(type); +} + +extern GHOST_TSuccess GHOST_setSensorsState(GHOST_SystemHandle systemhandle, + GHOST_TSensorTypes type, + int enable) +{ + GHOST_ISystem *system = (GHOST_ISystem *) systemhandle; + + return system->setSensorsState(type, enable && 1); +} + void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept) { GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; diff --git a/intern/ghost/intern/GHOST_DisplayManagerAndroid.cpp b/intern/ghost/intern/GHOST_DisplayManagerAndroid.cpp new file mode 100644 index 00000000000..c6d67926bc3 --- /dev/null +++ b/intern/ghost/intern/GHOST_DisplayManagerAndroid.cpp @@ -0,0 +1,82 @@ +/* + * ***** 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): Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_DisplayManagerAndroid.cpp + * \ingroup GHOST + */ + +#include "GHOST_SystemAndroid.h" +#include "GHOST_DisplayManagerAndroid.h" + +#include "GHOST_WindowManager.h" + +GHOST_DisplayManagerAndroid::GHOST_DisplayManagerAndroid(GHOST_SystemAndroid *system) + : + GHOST_DisplayManager() +{ + //memset(&m_mode, 0, sizeof m_mode); +} + +GHOST_TSuccess +GHOST_DisplayManagerAndroid::getNumDisplays(GHOST_TUns8& numDisplays) const +{ + + //numDisplays = 1; + return GHOST_kSuccess; +} + + +GHOST_TSuccess GHOST_DisplayManagerAndroid::getNumDisplaySettings(GHOST_TUns8 display, + GHOST_TInt32& numSettings) const +{ + + return GHOST_kFailure; +} + + +GHOST_TSuccess +GHOST_DisplayManagerAndroid::getDisplaySetting(GHOST_TUns8 display, + GHOST_TInt32 index, + GHOST_DisplaySetting& setting) const +{ + + + + + return GHOST_kFailure; +} + +GHOST_TSuccess +GHOST_DisplayManagerAndroid::getCurrentDisplaySetting(GHOST_TUns8 display, + GHOST_DisplaySetting& setting) const +{ + + return GHOST_kFailure; +} + + +GHOST_TSuccess +GHOST_DisplayManagerAndroid:: setCurrentDisplaySetting(GHOST_TUns8 display, + const GHOST_DisplaySetting& setting) +{ +return GHOST_kFailure; +} diff --git a/intern/ghost/intern/GHOST_DisplayManagerAndroid.h b/intern/ghost/intern/GHOST_DisplayManagerAndroid.h new file mode 100644 index 00000000000..fedcab34480 --- /dev/null +++ b/intern/ghost/intern/GHOST_DisplayManagerAndroid.h @@ -0,0 +1,67 @@ +/* + * ***** 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): Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_DisplayManagerAndroid.h + * \ingroup GHOST + * Declaration of GHOST_DisplayManagerAndroid class. + */ + +#ifndef __GHOST_DISPLAYMANAGERANDROID_H__ +#define __GHOST_DISPLAYMANAGERANDROID_H__ + +#include "GHOST_DisplayManager.h" + + +class GHOST_SystemAndroid; + +class GHOST_DisplayManagerAndroid : public GHOST_DisplayManager +{ +public: + GHOST_DisplayManagerAndroid(GHOST_SystemAndroid *system); + + GHOST_TSuccess + getNumDisplays(GHOST_TUns8& numDisplays) const; + + GHOST_TSuccess + getNumDisplaySettings(GHOST_TUns8 display, + GHOST_TInt32& numSettings) const; + + GHOST_TSuccess + getDisplaySetting(GHOST_TUns8 display, + GHOST_TInt32 index, + GHOST_DisplaySetting& setting) const; + + GHOST_TSuccess + getCurrentDisplaySetting(GHOST_TUns8 display, + GHOST_DisplaySetting& setting) const; + + + + GHOST_TSuccess + setCurrentDisplaySetting(GHOST_TUns8 display, + const GHOST_DisplaySetting& setting); + +private: + +}; + +#endif /* __GHOST_DISPLAYMANAGERANDROID_H__ */ diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.h b/intern/ghost/intern/GHOST_DisplayManagerSDL.h index 2139e2d5e7b..e86cf22efc5 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerSDL.h +++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.h @@ -34,7 +34,8 @@ extern "C" { #include "SDL.h" } -#if !SDL_VERSION_ATLEAST(2, 0, 0) + +#if !SDL_VERSION_ATLEAST(2, 0, 0) && !defined(WITH_ANDROID) # error "SDL 2.0 or newer is needed to build with Ghost" #endif diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp index 4b7be84ac81..a0c18b72b71 100644 --- a/intern/ghost/intern/GHOST_EventPrinter.cpp +++ b/intern/ghost/intern/GHOST_EventPrinter.cpp @@ -95,6 +95,36 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) std::cout << "GHOST_kEventKeyDown, key: " << str; } break; + +#ifdef WITH_INPUT_TOUCH + case GHOST_kEventTouch: + { + GHOST_TEventTouchData *touchData = (GHOST_TEventTouchData *)((GHOST_IEvent *)event)->getData(); + char index[32] = {'\0'}; + char state[32] = {'\0'}; + float x = (float)touchData->x / 100; + float y = (float)touchData->y / 100; + + sprintf(index, "%u", touchData->index); + switch (touchData->state) { + case GHOST_kDown: + sprintf(state, "%s", "down"); + break; + case GHOST_kMove: + sprintf(state, "%s", "move"); + break; + case GHOST_kUp: + sprintf(state, "%s", "up"); + break; + default: + break; + } + + std::cout << "GHOST_kEventTouch, index: " << index << " state: " << state + << " (x,y): (" << x << "," << y << ")"; + } + break; +#endif // WITH_INPUT_TOUCH case GHOST_kEventDraggingEntered: { diff --git a/intern/ghost/intern/GHOST_EventSensor.h b/intern/ghost/intern/GHOST_EventSensor.h new file mode 100644 index 00000000000..ad89b317af2 --- /dev/null +++ b/intern/ghost/intern/GHOST_EventSensor.h @@ -0,0 +1,91 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_EventSensor.h + * \ingroup GHOST + * Declaration of GHOST_EventSensor class. + */ + +#ifndef __GHOST_EVENTSENSOR_H__ +#define __GHOST_EVENTSENSOR_H__ + +#include "GHOST_Event.h" +#include "GHOST_Types.h" + +/** + * Hardware sensor event. + * Like Acclerometer and gyroscope. + * Acceleromoter and gyroscope have 3D vector + * While others have 1D vectors (and data for other fields is not specified) + */ +class GHOST_EventSensor : public GHOST_Event +{ +public: + GHOST_EventSensor(GHOST_TUns64 msec, GHOST_IWindow *window, GHOST_TSensorTypes subtype, float *v) + : GHOST_Event(msec, GHOST_kEventSensor, window) + { + m_SensorEventData.type = subtype; + + m_SensorEventData.dv[0] = v[0]; + m_SensorEventData.dv[1] = v[1]; + m_SensorEventData.dv[2] = v[2]; + + m_data = &m_SensorEventData; + } + + + GHOST_EventSensor(GHOST_TUns64 msec, GHOST_IWindow *window, GHOST_TSensorTypes subtype, float v) + : GHOST_Event(msec, GHOST_kEventSensor, window) + { + m_SensorEventData.type = subtype; + + m_SensorEventData.dv[0] = v; + + m_data = &m_SensorEventData; + } + + + GHOST_EventSensor(GHOST_TUns64 msec, GHOST_IWindow *window, GHOST_TSensorTypes subtype, float v1, float v2, float v3) + : GHOST_Event(msec, GHOST_kEventSensor, window) + { + m_SensorEventData.type = subtype; + + m_SensorEventData.dv[0] = v1; + m_SensorEventData.dv[1] = v2; + m_SensorEventData.dv[2] = v3; + + m_data = &m_SensorEventData; + } + + +protected: + + GHOST_TEventSensorData m_SensorEventData; +}; + + +#endif // __GHOST_EVENTSENSOR_H__ + diff --git a/intern/ghost/intern/GHOST_EventTouch.h b/intern/ghost/intern/GHOST_EventTouch.h new file mode 100644 index 00000000000..3ab2639d043 --- /dev/null +++ b/intern/ghost/intern/GHOST_EventTouch.h @@ -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_kEventTouch, window) + { + m_data = &m_touchData; + } +}; + +#endif // __GHOST_EVENTTOUCH_H__ diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index f6973caad03..df70a9e8167 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -42,6 +42,8 @@ # include "GHOST_SystemNULL.h" #elif defined(WITH_GHOST_SDL) # include "GHOST_SystemSDL.h" +#elif defined(WITH_ANDROID) +# include "GHOST_SystemAndroid.h" #elif defined(WIN32) # include "GHOST_SystemWin32.h" #else @@ -68,6 +70,8 @@ GHOST_TSuccess GHOST_ISystem::createSystem() m_system = new GHOST_SystemNULL(); #elif defined(WITH_GHOST_SDL) m_system = new GHOST_SystemSDL(); +#elif defined(WITH_ANDROID) + m_system = new GHOST_SystemAndroid(); #elif defined(WIN32) m_system = new GHOST_SystemWin32(); #else diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index ae9a8e49057..2fb2acafb3e 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -40,6 +40,8 @@ #ifdef WIN32 # include "GHOST_SystemPathsWin32.h" +#elif defined(WITH_ANDROID) && !defined(WITH_GHOST_SDL) +# include "GHOST_SystemPathsAndroid.h" #else # ifdef __APPLE__ # ifdef GHOST_COCOA @@ -62,6 +64,8 @@ GHOST_TSuccess GHOST_ISystemPaths::create() if (!m_systemPaths) { #ifdef WIN32 m_systemPaths = new GHOST_SystemPathsWin32(); +#elif defined(WITH_ANDROID) && !defined(WITH_GHOST_SDL) + m_systemPaths = new GHOST_SystemPathsAndroid(); #else # ifdef __APPLE__ # ifdef GHOST_COCOA diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 8c6491bcbfd..f0b88392e04 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -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 @@ GHOST_System::GHOST_System() #ifdef WITH_INPUT_NDOF , m_ndofManager(0) #endif +#ifdef WITH_INPUT_TOUCH + , m_touchManager(0) +#endif // WITH_INPUT_TOUCH { } @@ -294,6 +298,16 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown return success; } +GHOST_TSuccess GHOST_System::getSensorsAvailability(GHOST_TSensorTypes type) +{ + return GHOST_kFailure; +} + +GHOST_TSuccess GHOST_System::setSensorsState(GHOST_TSensorTypes type, int enable) +{ + return GHOST_kFailure; +} + GHOST_TSuccess GHOST_System::init() { m_timerManager = new GHOST_TimerManager(); @@ -343,6 +357,12 @@ GHOST_TSuccess GHOST_System::exit() m_ndofManager = 0; } #endif +#ifdef WITH_TOUCH_INPUT + if (m_touchManager) { + delete m_touchManager; + m_touchManager = 0; + } +#endif // WITH_TOUCH_INPUT return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index d2e3377f6ce..f8c930a4824 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -49,6 +49,7 @@ class GHOST_TimerManager; class GHOST_Window; class GHOST_WindowManager; class GHOST_NDOFManager; +class GHOST_TouchManager; /** * Implementation of platform independent functionality of the GHOST_ISystem @@ -229,6 +230,25 @@ public: * \return Indication of success. */ virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const; + + /*************************************************************************************** + * Hardware Sensor operations + ***************************************************************************************/ + + /** + * Returns the availability of sensor. + * @param type The type of sensor. + * @return Indication of availability. + */ + virtual GHOST_TSuccess getSensorsAvailability(GHOST_TSensorTypes type); + + /** + * Enables or disables specific sensor. + * @param type The type of sensor. + * @param enable 1 = enable, 0 = disable + * @return Indication of success. + */ + virtual GHOST_TSuccess setSensorsState(GHOST_TSensorTypes type, int enable); /*************************************************************************************** * Other (internal) functionality. @@ -268,6 +288,14 @@ public: 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). @@ -342,6 +370,11 @@ protected: /** 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 +407,12 @@ inline GHOST_NDOFManager *GHOST_System::getNDOFManager() const } #endif +#ifdef WITH_INPUT_TOUCH +inline GHOST_TouchManager *GHOST_System::getTouchManager() const +{ + return m_touchManager; +} +#endif + #endif // __GHOST_SYSTEM_H__ diff --git a/intern/ghost/intern/GHOST_SystemAndroid.cpp b/intern/ghost/intern/GHOST_SystemAndroid.cpp new file mode 100644 index 00000000000..780da16109e --- /dev/null +++ b/intern/ghost/intern/GHOST_SystemAndroid.cpp @@ -0,0 +1,402 @@ +/* + * ***** 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): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_SystemAndroid.cpp + * \ingroup GHOST + */ + +#include <assert.h> + +#include "GHOST_SystemAndroid.h" + +#include "GHOST_WindowManager.h" + +#include "GHOST_EventCursor.h" +#include "GHOST_EventKey.h" +#include "GHOST_EventButton.h" +#include "GHOST_EventWheel.h" +#include "GHOST_EventSensor.h" + +#include <sys/time.h> + +#include <unistd.h> +#include <GLES/gl.h> +#include <android/log.h> +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "blender", __VA_ARGS__)) +#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "blender", __VA_ARGS__)) + + +GHOST_SystemAndroid::GHOST_SystemAndroid() + : + GHOST_System(), + mainwindow(NULL) +{ + + // compute the initial time + timeval tv; + if (gettimeofday(&tv, NULL) == -1) { + GHOST_ASSERT(false, "Could not instantiate timer!"); + } + + // Taking care not to overflow the tv.tv_sec*1000 + m_start_time = GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000; + +} + +GHOST_SystemAndroid::~GHOST_SystemAndroid() +{ + +} + +GHOST_IWindow * +GHOST_SystemAndroid::createWindow(const STR_String& title, + GHOST_TInt32 left, + GHOST_TInt32 top, + GHOST_TUns32 width, + GHOST_TUns32 height, + GHOST_TWindowState state, + GHOST_TDrawingContextType type, + bool stereoVisual, + const GHOST_TUns16 numOfAASamples, + const GHOST_TEmbedderWindowID parentWindow + ) +{ + GHOST_WindowAndroid *window = NULL; + + LOGI("New window is created"); + mainwindow = window = new GHOST_WindowAndroid(this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1); + + if (window) { + if (window->getValid()) { + m_windowManager->addWindow(window); + pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window)); + } + + } + return window; +} + +GHOST_TSuccess +GHOST_SystemAndroid::init() { + GHOST_TSuccess success = GHOST_System::init(); + + if (success) { + m_displayManager = new GHOST_DisplayManagerAndroid(this); + + if (m_displayManager) { + return GHOST_kSuccess; + } + } + + return GHOST_kFailure; +} + +void +GHOST_SystemAndroid::getMainDisplayDimensions(GHOST_TUns32& width, + GHOST_TUns32& height) const +{ + + width = 200; + height = 200; + // Almost all android have this resolution, so we can hardcode it :) + //change +} + +GHOST_TUns8 +GHOST_SystemAndroid::getNumDisplays() const +{ + return 1; +} + +GHOST_TSuccess +GHOST_SystemAndroid::getModifierKeys(GHOST_ModifierKeys& keys) const +{ + int mod = 0; + +/* keys.set(GHOST_kModifierKeyLeftShift, (mod & KMOD_LSHIFT) != 0); + keys.set(GHOST_kModifierKeyRightShift, (mod & KMOD_RSHIFT) != 0); + keys.set(GHOST_kModifierKeyLeftControl, (mod & KMOD_LCTRL) != 0); + keys.set(GHOST_kModifierKeyRightControl, (mod & KMOD_RCTRL) != 0); + keys.set(GHOST_kModifierKeyLeftAlt, (mod & KMOD_LALT) != 0); + keys.set(GHOST_kModifierKeyRightAlt, (mod & KMOD_RALT) != 0); + keys.set(GHOST_kModifierKeyOS, (mod & (KMOD_LGUI | KMOD_RGUI)) != 0); +*/ + return GHOST_kSuccess; +} + + + + + + +GHOST_TSuccess +GHOST_SystemAndroid::getCursorPosition(GHOST_TInt32& x, + GHOST_TInt32& y) const +{ + + LOGW("Get Cursor"); + return GHOST_kFailure; +} + +GHOST_TSuccess +GHOST_SystemAndroid::setCursorPosition(GHOST_TInt32 x, + GHOST_TInt32 y) +{ + + return GHOST_kSuccess; +} + +void GHOST_SystemAndroid::processEvent(eEventAllTypes *ae) +{ + GHOST_WindowAndroid *window = mainwindow; + GHOST_Event *g_event = NULL; + + if (!window) { + + return; + + + + } + switch (ae->eb.aeventype) { + case ET_APP: + { + switch(ae->app.action) + { + case ET_APP_CLOSE: + LOGW("Close event"); + + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window); + break; + } + break; + } + + case ET_WINDOW: + { + switch(ae->Window.type) + { + case ET_WS_FOCUS: + LOGW("Update"); + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window); + break; + case ET_WS_DEFOCUS: + LOGW("Update"); + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window); + break; + case ET_WS_UPDATE: + LOGW("Update"); + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window); + break; + } + + break; + } + case ET_WINDOWSIZE: + { + + window->storeWindowSize(ae->WindowSize.pos[0], ae->WindowSize.pos[1], + ae->WindowSize.size[0], ae->WindowSize.size[1] + ); + g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window); + + break; + } + + case ET_MOUSE: + { + if(ae->Mouse.mouseevent == 2) + { + g_event = new + GHOST_EventCursor( + getMilliSeconds(), + GHOST_kEventCursorMove, + window, + ae->Mouse.coord[0], + ae->Mouse.coord[1] + ); + + + LOGW(" Cursor %i x %i", (int)ae->Mouse.coord[0], (int)ae->Mouse.coord[1]); + + } + else if(ae->Mouse.mouseevent < 2) + { + GHOST_TEventType type = ae->Mouse.mouseevent ? GHOST_kEventButtonUp : GHOST_kEventButtonDown; + + + g_event = new GHOST_EventButton( + getMilliSeconds(), + type, + window, + GHOST_kButtonMaskLeft + ); + + } + break; + } + case ET_SENSOR: + { + g_event = new GHOST_EventSensor(getMilliSeconds(), window, (GHOST_TSensorTypes)ae->Sensor.type, ae->Sensor.sv); + break; + } + + + default: { + //pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window)); + LOGW("Unknown type %i", ae->eb.aeventype); + break; + } + } + + if (g_event) { + pushEvent(g_event); + } +} + +void +GHOST_SystemAndroid:: +addDirtyWindow( + GHOST_WindowAndroid *bad_wind) +{ + GHOST_ASSERT((bad_wind != NULL), "addDirtyWindow() NULL ptr trapped (window)"); + + m_dirty_windows.push_back(bad_wind); +} + +bool +GHOST_SystemAndroid::generateWindowExposeEvents() +{ + std::vector<GHOST_WindowAndroid *>::iterator w_start = m_dirty_windows.begin(); + std::vector<GHOST_WindowAndroid *>::const_iterator w_end = m_dirty_windows.end(); + bool anyProcessed = false; + + for (; w_start != w_end; ++w_start) { + GHOST_Event *g_event = new + GHOST_Event( + getMilliSeconds(), + GHOST_kEventWindowUpdate, + *w_start + ); + + (*w_start)->validate(); + + if (g_event) { + pushEvent(g_event); + anyProcessed = true; + } + } + + m_dirty_windows.clear(); + return anyProcessed; +} + + +bool +GHOST_SystemAndroid::processEvents(bool waitForEvent) +{ + // Get all the current events -- translate them into + // ghost events and call base class pushEvent() method. + + bool anyProcessed = false; + + do { + GHOST_TimerManager *timerMgr = getTimerManager(); + + //LOGW("Processing"); + + if (waitForEvent && m_dirty_windows.empty() && !::aEventGQueueCheck()) { + ::usleep(1*1000); + + } + + if (timerMgr->fireTimers(getMilliSeconds())) { + anyProcessed = true; + } + anyProcessed = true; + //glClearColor(0.0f, 1.0f, 1.0f, 0.5f); + //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + //aSwapBuffers(); + // Process all the events waiting for us + eEventAllTypes event; + while (aEventGQueueRead(&event)) { + + //DoEvent + processEvent(&event); + //pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, mainwindow)); + + anyProcessed = true; + } + + if (generateWindowExposeEvents()) { + anyProcessed = true; + } + + + + } while (waitForEvent && !anyProcessed); + + return anyProcessed; +} + + + +GHOST_TSuccess GHOST_SystemAndroid::getSensorsAvailability(GHOST_TSensorTypes type) +{ + return aGetSensorsAvailability(type) ? GHOST_kSuccess : GHOST_kFailure; +} + +GHOST_TSuccess GHOST_SystemAndroid::setSensorsState(GHOST_TSensorTypes type, int enable) +{ + return aSetSensorsState(type, enable) ? GHOST_kSuccess : GHOST_kFailure; +} + +GHOST_TSuccess GHOST_SystemAndroid::getButtons(GHOST_Buttons& buttons) const +{ + + + return GHOST_kFailure; +} + +GHOST_TUns8 * +GHOST_SystemAndroid::getClipboard(bool selection) const +{ + return (GHOST_TUns8 *)""; +} + +void +GHOST_SystemAndroid::putClipboard(GHOST_TInt8 *buffer, bool selection) const +{ + +} + +GHOST_TUns64 +GHOST_SystemAndroid::getMilliSeconds() +{ + timeval tv; + if (gettimeofday(&tv, NULL) == -1) { + GHOST_ASSERT(false, "Could not compute time!"); + } + + // Taking care not to overflow the tv.tv_sec*1000 + return GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000 - m_start_time; +} diff --git a/intern/ghost/intern/GHOST_SystemAndroid.h b/intern/ghost/intern/GHOST_SystemAndroid.h new file mode 100644 index 00000000000..6fd35f30142 --- /dev/null +++ b/intern/ghost/intern/GHOST_SystemAndroid.h @@ -0,0 +1,127 @@ +/* + * ***** 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): Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_SystemAndroid.h + * \ingroup GHOST + * Declaration of GHOST_SystemAndroid class. + */ + +#ifndef __GHOST_SYSTEMANDROID_H__ +#define __GHOST_SYSTEMANDROID_H__ + +#include "GHOST_System.h" +#include "GHOST_DisplayManagerAndroid.h" +#include "GHOST_TimerManager.h" +#include "GHOST_WindowAndroid.h" +#include "GHOST_Event.h" + +#include <aEvent.h> + +class GHOST_WindowAndroid; + + +class GHOST_SystemAndroid : public GHOST_System { +public: + + void addDirtyWindow(GHOST_WindowAndroid *bad_wind); + + GHOST_SystemAndroid(); + ~GHOST_SystemAndroid(); + + bool + processEvents(bool waitForEvent); + + int + toggleConsole(int action) { return 0; } + + GHOST_TSuccess + getModifierKeys(GHOST_ModifierKeys& keys) const; + + GHOST_TSuccess + getButtons(GHOST_Buttons& buttons) const; + + GHOST_TUns8 * + getClipboard(bool selection) const; + + void + putClipboard(GHOST_TInt8 *buffer, bool selection) const; + + GHOST_TUns64 + getMilliSeconds(); + + GHOST_TUns8 + getNumDisplays() const; + + GHOST_TSuccess + getCursorPosition(GHOST_TInt32& x, + GHOST_TInt32& y) const; + + GHOST_TSuccess + setCursorPosition(GHOST_TInt32 x, + GHOST_TInt32 y); + + void + getMainDisplayDimensions(GHOST_TUns32& width, + GHOST_TUns32& height) const; + + + + + GHOST_TSuccess getSensorsAvailability(GHOST_TSensorTypes type); + + GHOST_TSuccess setSensorsState(GHOST_TSensorTypes type, int enable); + +private: + + /// The vector of windows that need to be updated. + std::vector<GHOST_WindowAndroid *> m_dirty_windows; + + GHOST_TSuccess + init(); + + GHOST_IWindow * + createWindow(const STR_String& title, + GHOST_TInt32 left, + GHOST_TInt32 top, + GHOST_TUns32 width, + GHOST_TUns32 height, + GHOST_TWindowState state, + GHOST_TDrawingContextType type, + bool stereoVisual, + const GHOST_TUns16 numOfAASamples, + const GHOST_TEmbedderWindowID parentWindow + ); + + + + bool + generateWindowExposeEvents(); + + /// Start time at initialization. + GHOST_TUns64 m_start_time; + + void processEvent(eEventAllTypes *ae); + + GHOST_WindowAndroid *mainwindow; +}; + +#endif diff --git a/intern/ghost/intern/GHOST_SystemPathsAndroid.cpp b/intern/ghost/intern/GHOST_SystemPathsAndroid.cpp new file mode 100644 index 00000000000..8b42fc92487 --- /dev/null +++ b/intern/ghost/intern/GHOST_SystemPathsAndroid.cpp @@ -0,0 +1,62 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_SystemPathsAndroid.cpp + * \ingroup GHOST + */ + + +#include "GHOST_SystemPathsAndroid.h" + + + +GHOST_SystemPathsAndroid::GHOST_SystemPathsAndroid() +{ +} + +GHOST_SystemPathsAndroid::~GHOST_SystemPathsAndroid() +{ +} + +const GHOST_TUns8 *GHOST_SystemPathsAndroid::getSystemDir(int, const char *versionstr) const +{ + return (GHOST_TUns8 *)""; +} + +const GHOST_TUns8 *GHOST_SystemPathsAndroid::getUserDir(int, const char *versionstr) const +{ + return (GHOST_TUns8 *)""; +} + +const GHOST_TUns8 *GHOST_SystemPathsAndroid::getBinaryDir() const +{ + return (GHOST_TUns8 *)""; +} + +void GHOST_SystemPathsAndroid::addToSystemRecentFiles(const char *filename) const +{ + +} diff --git a/intern/ghost/intern/GHOST_SystemPathsAndroid.h b/intern/ghost/intern/GHOST_SystemPathsAndroid.h new file mode 100644 index 00000000000..dd80541b222 --- /dev/null +++ b/intern/ghost/intern/GHOST_SystemPathsAndroid.h @@ -0,0 +1,83 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __GHOST_SYSTEMPATHSANDROID_H__ +#define __GHOST_SYSTEMPATHSANDROID_H__ + +#include "GHOST_SystemPaths.h" + +/** \file ghost/intern/GHOST_SystemPathsAndroid.h + * \ingroup GHOST + */ + + +/** + * Android Implementation of GHOST_SystemPaths class. + * @see GHOST_SystemPaths. + * @author Alexandr Kuznetsov + * @date 2012 + */ +class GHOST_SystemPathsAndroid : public GHOST_SystemPaths { +public: + /** + * Constructor. + */ + GHOST_SystemPathsAndroid(); + + /** + * Destructor. + */ + virtual ~GHOST_SystemPathsAndroid(); + + /** + * Determine the base dir in which shared resources are located. It will first try to use + * "unpack and run" path, then look for properly installed path, including versioning. + * @return Unsigned char string pointing to system dir (eg /usr/share/). + */ + const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const; + + /** + * Determine the base dir in which user configuration is stored, including versioning. + * If needed, it will create the base directory. + * @return Unsigned char string pointing to user dir (eg ~/). + */ + const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const; + + /** + * Determine the directory of the current binary + * @return Unsigned char string pointing to the binary dir + */ + const GHOST_TUns8 *getBinaryDir() const; + + /** + * Add the file to the operating system most recently used files + */ + void addToSystemRecentFiles(const char *filename) const; +}; + +#endif // __GHOST_SYSTEMPATHSANDROID_H__ + diff --git a/intern/ghost/intern/GHOST_SystemSDL.h b/intern/ghost/intern/GHOST_SystemSDL.h index 43c9129fdd8..9464cb8948f 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.h +++ b/intern/ghost/intern/GHOST_SystemSDL.h @@ -39,7 +39,7 @@ extern "C" { #include "SDL.h" } -#if !SDL_VERSION_ATLEAST(2, 0, 0) +#if !SDL_VERSION_ATLEAST(2, 0, 0) && !defined(WITH_ANDROID) # error "SDL 2.0 or newer is needed to build with Ghost" #endif diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 46c71f57c6f..430569823ab 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -71,6 +71,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 @@ -122,6 +126,14 @@ #define VK_MEDIA_PLAY_PAUSE 0xB3 #endif // VK_MEDIA_PLAY_PAUSE +// Corrects MinGW defines +#ifdef FREE_WINDOWS +# undef TOUCHEVENTF_DOWN +# define TOUCHEVENTF_DOWN 0x0002 +# undef TOUCHEVENTF_MOVE +# define TOUCHEVENTF_MOVE 0x0001 +#endif // FREE_WINDOWS + static void initRawInput() { #ifdef WITH_INPUT_NDOF @@ -171,6 +183,10 @@ GHOST_SystemWin32::GHOST_SystemWin32() #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() @@ -871,6 +887,43 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw) } #endif // WITH_INPUT_NDOF +#ifdef WITH_INPUT_TOUCH +void GHOST_SystemWin32::processTouch(WPARAM wParam, LPARAM lParam) +{ + UINT cInputs = LOWORD(wParam); + PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs]; + GHOST_TProgress state; + + if (NULL != pInputs) { +# if defined(_MSC_VER) || defined(FREE_WINDOWS64) // MSVC or MinGW-w64 defines + if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) { +# else // MinGW defines + if (GetTouchInputInfo((HANDLE)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) { +# endif + for (UINT i = 0; i < cInputs; i++) { + if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN) { + state = GHOST_kStarting; + } + else if (pInputs[i].dwFlags & TOUCHEVENTF_MOVE) { + state = GHOST_kInProgress; + } + else if (pInputs[i].dwFlags & TOUCHEVENTF_UP) { + state = GHOST_kFinishing; + } + + // Windows returns first ID as 2, then 3, 4... subtract 1 to begin at 1 + // Otherwise, Windows system touch functions as described in Pixar's Proton Chi + m_touchManager->sendTouchEvent((GHOST_TUns8) (pInputs[i].dwID - 1), 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; @@ -979,6 +1032,30 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, ((GHOST_WindowWin32 *)window)->processWin32TabletInitEvent(); break; //////////////////////////////////////////////////////////////////////// + // 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: +# endif + system->processTouch(wParam, lParam); + +# if defined(_MSC_VER) || defined(FREE_WINDOWS64) // MSVC or MinGW-w64 defines + CloseTouchInputHandle((HTOUCHINPUT) lParam); +# else // MinGW defines + CloseTouchInputHandle((HANDLE) lParam); +# endif + + eventHandled = true; + break; + +#endif + //////////////////////////////////////////////////////////////////////// // Mouse events, processed //////////////////////////////////////////////////////////////////////// case WM_LBUTTONDOWN: diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 6a756d35872..2eb50688009 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -37,11 +37,43 @@ #error WIN32 only! #endif // WIN32 -#define _WIN32_WINNT 0x501 // require Windows XP or newer +// Windows dependency for system touch, replace later? +#ifdef WITH_INPUT_TOUCH +# define _WIN32_WINNT 0x0601 // require Windows 7 or newer +#else +# define _WIN32_WINNT 0x501 // require Windows XP or newer +#endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <ole2.h> // for drag-n-drop +#ifdef WITH_INPUT_TOUCH +# ifndef SM_DIGITIZER +# define SM_DIGITIZER 94 +# endif // SM_DIGITIZER +# ifndef TABLET_CONFIG_NONE +# define TABLET_CONFIG_NONE 0x00000000 +# endif // TABLET_CONFIG_NONE +# ifndef NID_INTEGRATED_TOUCH +# define NID_INTEGRATED_TOUCH 0x00000001 +# endif // NID_INTEGRATED_TOUCH +# ifndef NID_EXTERNAL_TOUCH +# define NID_EXTERNAL_TOUCH 0x00000002 +# endif // NID_EXTERNAL_TOUCH +# ifndef NID_INTEGRATED_PEN +# define NID_INTEGRATED_PEN 0x00000004 +# endif // NID_INTEGRATED_PEN +# ifndef NID_EXTERNAL_PEN +# define NID_EXTERNAL_PEN 0x00000008 +# endif // NID_EXTERNAL_PEN +# ifndef NID_MULTI_INPUT +# define NID_MULTI_INPUT 0x00000040 +# endif // NID_MULTI_INPUT +# ifndef NID_READY +# define NID_READY 0x00000080 +# endif // NID_READY +#endif //WITH_INPUT_TOUCH + #include "GHOST_System.h" #if defined(__CYGWIN32__) @@ -318,6 +350,13 @@ protected: bool processNDOF(RAWINPUT const& raw); #endif +#ifdef WITH_INPUT_TOUCH + /** + * Handles Touch events, communicates directly with GHOST_TouchManager. + */ + void processTouch(WPARAM wParam, LPARAM lParam); +#endif + /** * Returns the local state of the modifier keys (from the message queue). * \param keys The state of the keys. diff --git a/intern/ghost/intern/GHOST_TaskbarWin32.h b/intern/ghost/intern/GHOST_TaskbarWin32.h index 34908a59b3a..c798bc36f4b 100644 --- a/intern/ghost/intern/GHOST_TaskbarWin32.h +++ b/intern/ghost/intern/GHOST_TaskbarWin32.h @@ -8,7 +8,13 @@ #error WIN32 only! #endif // WIN32 -#define _WIN32_WINNT 0x501 // require Windows XP or newer +// Windows dependency for system touch, replace later? +#ifdef WITH_INPUT_TOUCH +# define _WIN32_WINNT 0x0601 // require Windows 7 or newer +#else +# define _WIN32_WINNT 0x501 // require Windows XP or newer +#endif + #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shlobj.h> diff --git a/intern/ghost/intern/GHOST_TouchManager.cpp b/intern/ghost/intern/GHOST_TouchManager.cpp new file mode 100644 index 00000000000..f98c6a8e0c8 --- /dev/null +++ b/intern/ghost/intern/GHOST_TouchManager.cpp @@ -0,0 +1,51 @@ +/* + * ***** 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 ***** + */ + +#include "GHOST_TouchManager.h" +#include "GHOST_EventTouch.h" +#include "GHOST_WindowManager.h" + +GHOST_TouchManager::GHOST_TouchManager(GHOST_System& sys) + : m_system(sys) +{ +} + +void GHOST_TouchManager::sendTouchEvent(GHOST_TUns8 index, GHOST_TProgress state, GHOST_TInt32 x, + GHOST_TInt32 y, GHOST_TUns64 time) +{ + GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); + + if (window == NULL) { + return; + } + + GHOST_EventTouch *event = new GHOST_EventTouch(time, window); + GHOST_TEventTouchData *data = (GHOST_TEventTouchData *) event->getData(); + + data->index = index; + data->state = state; + data->x = x; + data->y = y; + + m_system.pushEvent(event); +} diff --git a/intern/ghost/intern/GHOST_TouchManager.h b/intern/ghost/intern/GHOST_TouchManager.h new file mode 100644 index 00000000000..425d274a269 --- /dev/null +++ b/intern/ghost/intern/GHOST_TouchManager.h @@ -0,0 +1,43 @@ +/* + * ***** 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_TOUCHMANAGER_H__ +#define __GHOST_TOUCHMANAGER_H__ + +#include "GHOST_System.h" + +class GHOST_TouchManager +{ +public: + GHOST_TouchManager(GHOST_System&); + + virtual ~GHOST_TouchManager() {}; + + void sendTouchEvent(GHOST_TUns8 index, GHOST_TProgress state, GHOST_TInt32 x, + GHOST_TInt32 y, GHOST_TUns64 time); + +protected: + GHOST_System& m_system; +}; + +#endif // GHOST_TOUCHMANAGER_H diff --git a/intern/ghost/intern/GHOST_TouchManagerWin32.cpp b/intern/ghost/intern/GHOST_TouchManagerWin32.cpp new file mode 100644 index 00000000000..405c8a0042c --- /dev/null +++ b/intern/ghost/intern/GHOST_TouchManagerWin32.cpp @@ -0,0 +1,33 @@ +/* + * ***** 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 ***** + */ + +#ifdef WITH_INPUT_TOUCH + +#include "GHOST_TouchManagerWin32.h" + +GHOST_TouchManagerWin32::GHOST_TouchManagerWin32(GHOST_System& sys) + : GHOST_TouchManager(sys) +{ +} + +#endif //WITH_INPUT_TOUCH diff --git a/intern/ghost/intern/GHOST_TouchManagerWin32.h b/intern/ghost/intern/GHOST_TouchManagerWin32.h new file mode 100644 index 00000000000..d1a3c274022 --- /dev/null +++ b/intern/ghost/intern/GHOST_TouchManagerWin32.h @@ -0,0 +1,35 @@ +/* + * ***** 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_TOUCHMANAGERWIN32_H__ +#define __GHOST_TOUCHMANAGERWIN32_H__ + +#include "GHOST_TouchManager.h" + +class GHOST_TouchManagerWin32 : public GHOST_TouchManager +{ +public: + GHOST_TouchManagerWin32(GHOST_System&); +}; + +#endif // __GHOST_TOUCHMANAGERWIN32_H__ diff --git a/intern/ghost/intern/GHOST_WindowAndroid.cpp b/intern/ghost/intern/GHOST_WindowAndroid.cpp new file mode 100644 index 00000000000..aa75fe86d23 --- /dev/null +++ b/intern/ghost/intern/GHOST_WindowAndroid.cpp @@ -0,0 +1,276 @@ +/* + * ***** 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): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_WindowAndroid.cpp + * \ingroup GHOST + */ +#include <EGL/egl.h> +#include <GLES/gl.h> +#include "GHOST_WindowAndroid.h" +#include <assert.h> +#include <aEvent.h> +#include <android/log.h> + +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "blender", __VA_ARGS__)) +#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "blender", __VA_ARGS__)) + +GHOST_WindowAndroid::GHOST_WindowAndroid(GHOST_SystemAndroid *system, + const STR_String& title, + GHOST_TInt32 left, + GHOST_TInt32 top, + GHOST_TUns32 width, + GHOST_TUns32 height, + GHOST_TWindowState state, + const GHOST_TEmbedderWindowID parentWindow, + GHOST_TDrawingContextType type, + const bool stereoVisual, + const GHOST_TUns16 numOfAASamples + ) + : + GHOST_Window(width, height, state, type, stereoVisual, numOfAASamples), + m_invalid_window(false), + m_system(system) +{ + int size[2]; + if(aGetWindowSize(size)) + { + winrect.m_t = 0; + winrect.m_l = 0; + winrect.m_r = size[0]; + winrect.m_b = size[1]; + } else + { + /* Cannot get correct size */ + /* shouldn't happend */ + + winrect.m_t = 0; + winrect.m_l = 0; + winrect.m_r = 400; + winrect.m_b = 400; + } + + setTitle(title); +} + +bool GHOST_WindowAndroid::getValid() const +{ + return 1; +} + + +GHOST_WindowAndroid::~GHOST_WindowAndroid() +{ + +} + + +GHOST_TSuccess +GHOST_WindowAndroid::installDrawingContext(GHOST_TDrawingContextType type) +{ + + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::invalidate(void) +{ + + if (m_invalid_window == false) { + m_system->addDirtyWindow(this); + m_invalid_window = true; + } + return GHOST_kSuccess; +} + +void +GHOST_WindowAndroid:: +validate() +{ + m_invalid_window = false; +} + +GHOST_TSuccess +GHOST_WindowAndroid::swapBuffers() +{ + aSwapBuffers(); + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::activateDrawingContext() +{ + + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::removeDrawingContext() +{ + + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setState(GHOST_TWindowState state) +{ + + + return GHOST_kSuccess; +} + + +GHOST_TWindowState +GHOST_WindowAndroid::getState() const +{ + return GHOST_kWindowStateFullScreen; +} + + +void +GHOST_WindowAndroid::setTitle(const STR_String& title) +{ + +} + + +void +GHOST_WindowAndroid::getTitle(STR_String& title) const +{ + +} + + +void +GHOST_WindowAndroid::getWindowBounds(GHOST_Rect& bounds) const +{ + bounds.m_t = winrect.m_t; + bounds.m_l = winrect.m_l; + bounds.m_r = winrect.m_r; + bounds.m_b = winrect.m_b; +} + + +void +GHOST_WindowAndroid::getClientBounds(GHOST_Rect& bounds) const +{ + bounds.m_t = winrect.m_t; + bounds.m_l = winrect.m_l; + bounds.m_r = winrect.m_r; + bounds.m_b = winrect.m_b; + +} + +GHOST_TSuccess +GHOST_WindowAndroid::setClientWidth(GHOST_TUns32 width) +{ + + return GHOST_kSuccess; +} + +GHOST_TSuccess +GHOST_WindowAndroid::setClientHeight(GHOST_TUns32 height) +{ + return GHOST_kSuccess; +} + +GHOST_TSuccess +GHOST_WindowAndroid::setClientSize(GHOST_TUns32 width, + GHOST_TUns32 height) +{ + return GHOST_kSuccess; +} + +void +GHOST_WindowAndroid::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const +{ + + outX = winrect.m_l + inX; + outY = winrect.m_t + inY; + + + +} +void +GHOST_WindowAndroid::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const +{ + +} + +void GHOST_WindowAndroid::storeWindowSize(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 width, GHOST_TInt32 height) +{ + + winrect.m_r = width; + winrect.m_b = height; + winrect.m_l = x; + winrect.m_t = y; + + LOGW("Win Pos %ix%i %ix%i", winrect.m_l, winrect.m_t, winrect.m_r, winrect.m_b); + +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setWindowCursorGrab(GHOST_TGrabCursorMode mode) +{ + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setWindowCursorShape(GHOST_TStandardCursor shape) +{ + + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], + GHOST_TUns8 mask[16][2], + int hotX, + int hotY) +{ + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, + GHOST_TUns8 *mask, + int sizex, int sizey, + int hotX, int hotY, + int fg_color, int bg_color) +{ + + return GHOST_kSuccess; +} + + +GHOST_TSuccess +GHOST_WindowAndroid::setWindowCursorVisibility(bool visible) +{ + return GHOST_kSuccess; +} diff --git a/intern/ghost/intern/GHOST_WindowAndroid.h b/intern/ghost/intern/GHOST_WindowAndroid.h new file mode 100644 index 00000000000..3ce00e00e0d --- /dev/null +++ b/intern/ghost/intern/GHOST_WindowAndroid.h @@ -0,0 +1,157 @@ +/* + * ***** 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): Alexandr Kuznetsov + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ghost/intern/GHOST_WindowAndroid.h + * \ingroup GHOST + * Declaration of GHOST_WindowAndroid class. + */ + +#ifndef __GHOST_WINDOWANDROID_H__ +#define __GHOST_WINDOWANDROID_H__ + +#include "GHOST_Window.h" +#include "GHOST_SystemAndroid.h" + + + +class STR_String; + +class GHOST_WindowAndroid : public GHOST_Window +{ +private: + /** Used to concatenate calls to invalidate() on this window. */ + bool m_invalid_window; + + /// A pointer to the typed system class. + + GHOST_SystemAndroid *m_system; +public: + + const GHOST_TabletData *GetTabletData() { + return NULL; + } + + GHOST_WindowAndroid(GHOST_SystemAndroid *system, + const STR_String& title, + GHOST_TInt32 left, GHOST_TInt32 top, + GHOST_TUns32 width, GHOST_TUns32 height, + GHOST_TWindowState state, + const GHOST_TEmbedderWindowID parentWindow, + GHOST_TDrawingContextType type, + const bool stereoVisual, + const GHOST_TUns16 numOfAASamples + ); + + ~GHOST_WindowAndroid(); + + + + GHOST_TSuccess invalidate(void); + void validate(); + + /** + * called by the X11 system implementation when expose events + * for the window have been pushed onto the GHOST queue + */ + + bool getValid() const; + + void getWindowBounds(GHOST_Rect& bounds) const; + void getClientBounds(GHOST_Rect& bounds) const; + + + void storeWindowSize(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 width, GHOST_TInt32 height); +protected: + GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type); + GHOST_TSuccess removeDrawingContext(); + + GHOST_TSuccess + setWindowCursorGrab(GHOST_TGrabCursorMode mode); + + GHOST_TSuccess + setWindowCursorShape(GHOST_TStandardCursor shape); + + GHOST_TSuccess + setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], + GHOST_TUns8 mask[16][2], + int hotX, int hotY); + + GHOST_TSuccess + setWindowCustomCursorShape(GHOST_TUns8 *bitmap, + GHOST_TUns8 *mask, + int sizex, int sizey, + int hotX, int hotY, + int fg_color, int bg_color); + + GHOST_TSuccess + setWindowCursorVisibility(bool visible); + + void + setTitle(const STR_String& title); + + void + getTitle(STR_String& title) const; + + GHOST_TSuccess + setClientWidth(GHOST_TUns32 width); + + GHOST_TSuccess + setClientHeight(GHOST_TUns32 height); + + GHOST_TSuccess + setClientSize(GHOST_TUns32 width, + GHOST_TUns32 height); + + void + screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, + GHOST_TInt32& outX, GHOST_TInt32& outY) const; + + void + clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, + GHOST_TInt32& outX, GHOST_TInt32& outY) const; + + GHOST_TSuccess + swapBuffers(); + + GHOST_TSuccess + activateDrawingContext(); + + GHOST_TSuccess + setState(GHOST_TWindowState state); + + GHOST_TWindowState + getState() const; + + GHOST_TSuccess setOrder(GHOST_TWindowOrder order) + { + // TODO + return GHOST_kSuccess; + } + + + + GHOST_Rect winrect; + +}; + + +#endif // __GHOST_WINDOWANDROID_H__ diff --git a/intern/ghost/intern/GHOST_WindowSDL.h b/intern/ghost/intern/GHOST_WindowSDL.h index a39d9878ddd..72a8978c4e2 100644 --- a/intern/ghost/intern/GHOST_WindowSDL.h +++ b/intern/ghost/intern/GHOST_WindowSDL.h @@ -36,7 +36,7 @@ extern "C" { #include "SDL.h" } -#if !SDL_VERSION_ATLEAST(2, 0, 0) +#if !SDL_VERSION_ATLEAST(2, 0, 0) && !defined(WITH_ANDROID) # error "SDL 2.0 or newer is needed to build with Ghost" #endif diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index dded7dc256d..61bee046103 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -271,6 +271,12 @@ GHOST_WindowWin32::GHOST_WindowWin32( // Store a pointer to this class in the window structure ::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR) this); +#ifdef WITH_INPUT_TOUCH + if (GetSystemMetrics(SM_DIGITIZER) & NID_MULTI_INPUT){ + RegisterTouchWindow(m_hWnd, 0); + } +#endif + // Store the device context m_hDC = ::GetDC(m_hWnd); diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index 9e4377b8225..f095de2346d 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -40,7 +40,13 @@ #include "GHOST_Window.h" #include "GHOST_TaskbarWin32.h" -#define _WIN32_WINNT 0x501 // require Windows XP or newer +// Windows dependency for system touch, replace later? +#ifdef WITH_INPUT_TOUCH +# define _WIN32_WINNT 0x0601 // require Windows 7 or newer +#else +# define _WIN32_WINNT 0x501 // require Windows XP or newer +#endif + #define WIN32_LEAN_AND_MEAN #include <windows.h> diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index dd1930a241b..fa9e00f82a1 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -47,6 +47,10 @@ #include <strings.h> #endif +#ifdef GLES +#include <GLES2/gl2.h> +#endif + #include <cstring> #include <cstdio> @@ -149,8 +153,11 @@ static unsigned char BLENDER_ICON_48x48x24[] = { 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x3, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0xff, }; - +#ifdef GLES +EGLContext GHOST_WindowX11::s_firstContext = NULL; +#else GLXContext GHOST_WindowX11::s_firstContext = NULL; +#endif GHOST_WindowX11:: GHOST_WindowX11( @@ -184,16 +191,17 @@ GHOST_WindowX11( int attributes[40], i, samples; Atom atoms[2]; int natom; - int glxVersionMajor, glxVersionMinor; /* As in GLX major.minor */ + int major, minor; /* As in GLX major.minor */ #ifdef WITH_X11_XINPUT /* initialize incase X11 fails to load */ memset(&m_xtablet, 0, sizeof(m_xtablet)); #endif - m_visual = NULL; + m_visual= NULL; - if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) { +#ifndef GLES + if (!glXQueryVersion(m_display, &major, &minor)) { printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__); /* exit if this is the first window */ @@ -219,7 +227,7 @@ GHOST_WindowX11( attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1; attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1; /* GLX >= 1.4 required for multi-sample */ - if (samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) { + if(samples && (major >= 1) && (minor >= 4)) { attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1; attributes[i++] = GLX_SAMPLES; attributes[i++] = samples; } @@ -250,21 +258,25 @@ GHOST_WindowX11( break; } } +#else + m_visual = (XVisualInfo*)calloc(1,sizeof(XVisualInfo)); +#endif /* Create a bunch of attributes needed to create an X window. */ - /* First create a colormap for the window and visual. * This seems pretty much a legacy feature as we are in rgba mode anyway. */ XSetWindowAttributes xattributes; memset(&xattributes, 0, sizeof(xattributes)); - + +#ifndef GLES xattributes.colormap = XCreateColormap(m_display, - RootWindow(m_display, m_visual->screen), - m_visual->visual, + RootWindow(m_display, m_visual->screen), + m_visual->visual, AllocNone ); +#endif xattributes.border_pixel = 0; @@ -877,7 +889,7 @@ clientToScreen( XTranslateCoordinates( m_display, m_window, - RootWindow(m_display, m_visual->screen), + RootWindow(m_display, /*m_visual->screen*/0), inX, inY, &ax, &ay, &temp); @@ -1251,7 +1263,11 @@ GHOST_WindowX11:: swapBuffers() { if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) { - glXSwapBuffers(m_display, m_window); +#ifdef GLES + eglSwapBuffers(gl_display, gl_surface); +#else + glXSwapBuffers(m_display, m_window); +#endif return GHOST_kSuccess; } else { @@ -1264,9 +1280,13 @@ GHOST_WindowX11:: activateDrawingContext() { if (m_context != NULL) { - glXMakeCurrent(m_display, m_window, m_context); +#ifdef GLES + // eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context); +#else + glXMakeCurrent(m_display, m_window, m_context); +#endif return GHOST_kSuccess; - } + } return GHOST_kFailure; } @@ -1347,8 +1367,12 @@ GHOST_WindowX11:: #endif /* WITH_X11_XINPUT */ if (m_context != s_firstContext) { +#ifdef GLES + eglDestroyContext(gl_display, m_context); +#else glXDestroyContext(m_display, m_context); - } +#endif + } if (p_owner == m_window) { XSetSelectionOwner(m_display, Primary_atom, None, CurrentTime); @@ -1368,7 +1392,12 @@ GHOST_WindowX11:: #endif XDestroyWindow(m_display, m_window); - XFree(m_visual); + +#ifdef GLES + free(m_visual); +#else + XFree(m_visual); +#endif } @@ -1388,6 +1417,7 @@ installDrawingContext( GHOST_TSuccess success; switch (type) { case GHOST_kDrawingContextTypeOpenGL: +#ifndef GLES m_context = glXCreateContext(m_display, m_visual, s_firstContext, True); if (m_context != NULL) { if (!s_firstContext) { @@ -1401,9 +1431,74 @@ installDrawingContext( else { success = GHOST_kFailure; } +#else + { + EGLint ver[2]; + EGLint num_config; + EGLConfig config; + EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; + - break; + EGLint attribList[] = + { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_DEPTH_SIZE, 8, + //EGL_ALPHA_SIZE, 8, + /*EGL_ALPHA_SIZE, 8, + + EGL_STENCIL_SIZE, 8, + EGL_SAMPLE_BUFFERS, 1,*/ + EGL_NONE + }; + gl_display = eglGetDisplay((EGLNativeDisplayType)m_display); + if(gl_display == EGL_NO_DISPLAY) + { + success = GHOST_kFailure; + break; + } + if(!eglInitialize(gl_display, &ver[0], &ver[1])) + { + success = GHOST_kFailure; + break; + } + if(!eglGetConfigs(gl_display, NULL, 0, &num_config)) + { + success = GHOST_kFailure; + break; + } + if(!eglChooseConfig(gl_display, attribList, &config, 1, &num_config)) + { + success = GHOST_kFailure; + break; + } + gl_surface = eglCreateWindowSurface(gl_display, config, (EGLNativeWindowType)m_window, NULL); + if (gl_surface == EGL_NO_SURFACE ) + { + success = GHOST_kFailure; + break; + } + m_context = eglCreateContext(gl_display, config, EGL_NO_CONTEXT, attribs); + if(m_context == EGL_NO_CONTEXT) + { + success = GHOST_kFailure; + break; + } + if(!eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context)) + { + success = GHOST_kFailure; + break; + } + glClearColor(0.447, 0.447, 0.447, 0); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_DITHER); + eglSwapBuffers(gl_display, gl_surface); + success = GHOST_kSuccess; + break; + } +#endif case GHOST_kDrawingContextTypeNone: success = GHOST_kSuccess; break; @@ -1424,8 +1519,9 @@ GHOST_TSuccess GHOST_WindowX11:: removeDrawingContext() { - GHOST_TSuccess success; + GHOST_TSuccess success = GHOST_kFailure; +#ifndef GLES if (m_context != NULL) { glXDestroyContext(m_display, m_context); success = GHOST_kSuccess; @@ -1433,6 +1529,8 @@ removeDrawingContext() else { success = GHOST_kFailure; } + +#endif return success; } diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h index 5b2ffced29c..81a5c6bc9ba 100644 --- a/intern/ghost/intern/GHOST_WindowX11.h +++ b/intern/ghost/intern/GHOST_WindowX11.h @@ -35,7 +35,14 @@ #include "GHOST_Window.h" #include <X11/Xlib.h> +#include <X11/Xutil.h> + #include <GL/glx.h> + +#ifdef GLES +#include <EGL/egl.h> +#endif + // For tablets #ifdef WITH_X11_XINPUT # include <X11/extensions/XInput.h> @@ -355,14 +362,25 @@ private: void initXInputDevices(); #endif +#ifdef GLES + EGLContext m_context; + EGLSurface gl_surface; + EGLDisplay gl_display; +#else GLXContext m_context; +#endif + Window m_window; Display *m_display; XVisualInfo *m_visual; GHOST_TWindowState m_normal_state; /** The first created OpenGL context (for sharing display lists) */ +#ifdef GLES + static EGLContext s_firstContext; +#else static GLXContext s_firstContext; +#endif /// A pointer to the typed system class. diff --git a/intern/opennl/CMakeLists.txt b/intern/opennl/CMakeLists.txt index b7a24839e38..2f15bbb907c 100644 --- a/intern/opennl/CMakeLists.txt +++ b/intern/opennl/CMakeLists.txt @@ -28,7 +28,7 @@ remove_strict_flags() # remove debug flag here since this is not a blender maintained library # and debug gives a lot of prints on UV unwrapping. developers can enable if they need to. -add_definitions(-UDEBUG) +remove_definitions(-DDEBUG) # quiet compiler warnings about undefined defines diff --git a/intern/touch/CMakeLists.txt b/intern/touch/CMakeLists.txt new file mode 100644 index 00000000000..4dbbd3c5771 --- /dev/null +++ b/intern/touch/CMakeLists.txt @@ -0,0 +1,55 @@ +# ***** 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. +# +# The Original Code is Copyright (C) 2012, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Nicholas Rishel +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + ../string +) + +set(INC_SYS + +) + +set(SRC + intern/TOUCH_API.cpp + + intern/TOUCH_Manager.cpp + intern/TOUCH_Context.cpp + intern/TOUCH_ContextBlender.cpp + intern/TOUCH_ContextGameEngine.cpp + + TOUCH_API.h + TOUCH_Types.h + TOUCH_TypesBlender.h + TOUCH_TypesGameEngine.h + + TOUCH_Manager.h + TOUCH_Context.h + TOUCH_ContextBlender.h + TOUCH_ContextGameEngine.h + +) + +blender_add_lib(bf_intern_touch "${SRC}" "${INC}" "${INC_SYS}") diff --git a/intern/touch/TOUCH_API.h b/intern/touch/TOUCH_API.h new file mode 100644 index 00000000000..dbfca4ec846 --- /dev/null +++ b/intern/touch/TOUCH_API.h @@ -0,0 +1,53 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_API.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_API_H__ +#define __TOUCH_API_H__ + +#include "TOUCH_Types.h" + +TOUCH_DECLARE_HANDLE(TOUCH_Handle); + +#ifdef __cplusplus +extern "C" { +#endif + +extern TOUCH_Handle TOUCH_InitManager(); + +extern void TOUCH_DestoryManager(TOUCH_Handle * handle); + +extern void TOUCH_AddTouchEvent(TOUCH_Handle * handle, void * event); + +#ifdef __cplusplus +} +#endif + +#endif /* __TOUCH_API_H__ */ diff --git a/intern/touch/TOUCH_Context.h b/intern/touch/TOUCH_Context.h new file mode 100644 index 00000000000..ac9e756c2a7 --- /dev/null +++ b/intern/touch/TOUCH_Context.h @@ -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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_Context.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_CONTEXT_H__ +#define __TOUCH_CONTEXT_H__ + +class TOUCH_Context { +protected: + TOUCH_Context(); + virtual ~TOUCH_Context(); +public: +}; + +#endif // __TOUCH_CONTEXT_H__ diff --git a/intern/touch/TOUCH_ContextBlender.h b/intern/touch/TOUCH_ContextBlender.h new file mode 100644 index 00000000000..c5db338467e --- /dev/null +++ b/intern/touch/TOUCH_ContextBlender.h @@ -0,0 +1,49 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_ContextBlender.h + * \ingroup TOUCH + */ + +/* + * Touch Context for Blender assumes that a known Area and Region have been provided + */ + +#ifndef __TOUCH_CONTEXTBLENDER_H__ +#define __TOUCH_CONTEXTBLENDER_H__ + +#include "TOUCH_TypesBlender.h" +#include "TOUCH_Context.h" + +class TOUCH_ContextBlender : TOUCH_Context { +public: + TOUCH_ContextBlender(); + ~TOUCH_ContextBlender(); +protected: +}; + +#endif // __TOUCH_CONTEXTBLENDER_H__ diff --git a/intern/touch/TOUCH_ContextGameEngine.h b/intern/touch/TOUCH_ContextGameEngine.h new file mode 100644 index 00000000000..c53c4f622a1 --- /dev/null +++ b/intern/touch/TOUCH_ContextGameEngine.h @@ -0,0 +1,45 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_ContextGameEngine.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_CONTEXTGAMEENGINE_H__ +#define __TOUCH_CONTEXTGAMEENGINE_H__ + +#include "TOUCH_TypesGameEngine.h" +#include "TOUCH_Context.h" + +class TOUCH_ContextGameEngine : TOUCH_Context { +public: + TOUCH_ContextGameEngine(); + ~TOUCH_ContextGameEngine(); +protected: +}; + +#endif // __TOUCH_CONTEXTGAMEENGINE_H__ diff --git a/intern/touch/TOUCH_Manager.h b/intern/touch/TOUCH_Manager.h new file mode 100644 index 00000000000..0ae75a6cc7f --- /dev/null +++ b/intern/touch/TOUCH_Manager.h @@ -0,0 +1,75 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_Manager.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_TOUCH_H__ +#define __TOUCH_TOUCH_H__ + +#include <vector> +#include "STR_String.h" + +#include "TOUCH_Types.h" +#if 1 +# include "TOUCH_ContextBlender.h" +#else +# include "TOUCH_ContextGameEngine.h" +#endif + +#ifdef INPUT_TOUCH_DEBUG +#include <stdio.h> +#endif + +class TOUCH_Manager +{ +public: + /** + * Constructor + */ + TOUCH_Manager(); + + /** + * Destructor + */ + ~TOUCH_Manager(); + + void AddTouchEvent(void * event); + + static void CreateManager(); + static void DestroyManager(); + static TOUCH_Manager * GetManager(); + +private: + STR_String input_string; + + static TOUCH_Manager * manager; + +}; + +#endif /* __TOUCH_TOUCH_H__ */ diff --git a/intern/touch/TOUCH_Types.h b/intern/touch/TOUCH_Types.h new file mode 100644 index 00000000000..c7ef108e229 --- /dev/null +++ b/intern/touch/TOUCH_Types.h @@ -0,0 +1,58 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_Types.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_TYPES_H__ +#define __TOUCH_TYPES_H__ + +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + +#if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus) +# define TOUCH_DECLARE_HANDLE(name) typedef struct name##__ { int unused; MEM_CXX_CLASS_ALLOC_FUNCS(#name) } *name +#else +# define TOUCH_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#endif + +typedef enum TOUCH_state { + TOUCH_DOWN = 0, + TOUCH_MOVE = 1, + TOUCH_UP = 2 +} TOUCH_state; + +typedef struct TOUCH_event_base { + char index; + int position_x; + int position_y; + TOUCH_state state; +} TOUCH_event_base; + +#endif /* __TOUCH_TYPES_H__ */ diff --git a/intern/touch/TOUCH_TypesBlender.h b/intern/touch/TOUCH_TypesBlender.h new file mode 100644 index 00000000000..a2b7b514b10 --- /dev/null +++ b/intern/touch/TOUCH_TypesBlender.h @@ -0,0 +1,47 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_TypesBlender.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_TYPESBLENDER_H__ +#define __TOUCH_TYPESBLENDER_H__ + +#include "TOUCH_Types.h" + +typedef struct TOUCH_event_blender { + TOUCH_event_base base; +#if 0 + area + id + region + mode + data under touch +#endif +} TOUCH_event_blender; + +#endif /* __TOUCH_TYPESBLENDER_H__ */ diff --git a/intern/touch/TOUCH_TypesGameEngine.h b/intern/touch/TOUCH_TypesGameEngine.h new file mode 100644 index 00000000000..d1caa102bd2 --- /dev/null +++ b/intern/touch/TOUCH_TypesGameEngine.h @@ -0,0 +1,39 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/TOUCH_TypesGameEngine.h + * \ingroup TOUCH + */ + +#ifndef __TOUCH_TYPESGAMEENGINE_H__ +#define __TOUCH_TYPESGAMEENGINE_H__ + +#include "TOUCH_Types.h" + + + +#endif /* __TOUCH_TYPESGAMEENGINE_H__ */ diff --git a/intern/touch/intern/TOUCH_API.cpp b/intern/touch/intern/TOUCH_API.cpp new file mode 100644 index 00000000000..8fe2e543b43 --- /dev/null +++ b/intern/touch/intern/TOUCH_API.cpp @@ -0,0 +1,56 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/intern/TOUCH_API.cpp + * \ingroup TOUCH + */ + +#include "TOUCH_API.h" +#include "TOUCH_Manager.h" + +extern TOUCH_Handle TOUCH_InitManager() +{ + TOUCH_Manager::CreateManager(); + TOUCH_Manager * manager = TOUCH_Manager::GetManager(); + + return (TOUCH_Handle)manager; +} + +extern TOUCH_Handle TOUCH_GetManager() +{ + return (TOUCH_Handle)TOUCH_Manager::GetManager(); +} + +extern void TOUCH_DestroyManager(TOUCH_Handle* handle) { + delete handle; +} + +extern void TOUCH_AddTouchEvent(TOUCH_Handle* handle, void * event) +{ + TOUCH_Manager * manager = (TOUCH_Manager *) handle; + manager->AddTouchEvent(event); +} diff --git a/intern/touch/intern/TOUCH_Context.cpp b/intern/touch/intern/TOUCH_Context.cpp new file mode 100644 index 00000000000..4e10456f0ac --- /dev/null +++ b/intern/touch/intern/TOUCH_Context.cpp @@ -0,0 +1,35 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/intern/TOUCH_Context.cpp + * \ingroup TOUCH + */ + +#include "TOUCH_Context.h" + +TOUCH_Context::TOUCH_Context(){} +TOUCH_Context::~TOUCH_Context(){} diff --git a/intern/touch/intern/TOUCH_ContextBlender.cpp b/intern/touch/intern/TOUCH_ContextBlender.cpp new file mode 100644 index 00000000000..d8a97804fcf --- /dev/null +++ b/intern/touch/intern/TOUCH_ContextBlender.cpp @@ -0,0 +1,31 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/intern/TOUCH_ContextBlender.cpp + * \ingroup TOUCH + */ + diff --git a/intern/touch/intern/TOUCH_ContextGameEngine.cpp b/intern/touch/intern/TOUCH_ContextGameEngine.cpp new file mode 100644 index 00000000000..a0b43a989cd --- /dev/null +++ b/intern/touch/intern/TOUCH_ContextGameEngine.cpp @@ -0,0 +1,30 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/intern/TOUCH_ContextGameEngine.cpp + * \ingroup TOUCH + */ diff --git a/intern/touch/intern/TOUCH_Manager.cpp b/intern/touch/intern/TOUCH_Manager.cpp new file mode 100644 index 00000000000..f712984c690 --- /dev/null +++ b/intern/touch/intern/TOUCH_Manager.cpp @@ -0,0 +1,95 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Nicholas Rishel + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file touch/intern/TOUCH_Manager.cpp + * \ingroup TOUCH + */ + +#include "TOUCH_Manager.h" + +#define TOUCH_DOWN_ENCODING 'd' +#define TOUCH_MOVE_ENCODING 'm' +#define TOUCH_UP_ENCODING 'u' + +TOUCH_Manager::TOUCH_Manager(){} + +TOUCH_Manager::~TOUCH_Manager(){} + +void TOUCH_Manager::AddTouchEvent(void * event) +{ +#if 0 //instead handle in TOUCH_Context* + for(int i = 0; i < event.size(); i++){ + /* if index 1 is touching down for the first time, clear the input string */ + if(event[i].state == TOUCH_DOWN) { + if(event[i].index == 1) { + input_string.Clear(); + } + //touch_position_begin[i] = event[i].position; XXX + } + + //touch_position_last[i] = event[i].position; XXX + + switch(event[i].state){ + case TOUCH_DOWN: + input_string += TOUCH_DOWN_ENCODING; + break; + case TOUCH_MOVE: + input_string += TOUCH_MOVE_ENCODING; + break; + case TOUCH_UP: + input_string += TOUCH_UP_ENCODING; + break; + default: + break; + } + + input_string += event[i].index; + + input_string += checkRegisteredContext(®istered_area, event[i].area); + input_string += checkRegisteredRegion(event[i].region); + input_string += checkRegisteredData(event[i].data); + } +#endif + +#ifdef INPUT_TOUCH_DEBUG + printf(input_string, std::endl); +#endif + +} + +void TOUCH_Manager::CreateManager() { + manager = new TOUCH_Manager(); +} + +void TOUCH_Manager::DestroyManager() { + delete manager; + manager = 0; +} + +TOUCH_Manager * TOUCH_Manager::GetManager() { + return manager; +} |