Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/CMakeLists.txt20
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp20
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerCocoa.h7
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerCocoa.mm6
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerX11.cpp25
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerX11.h7
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm9
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsX11.cpp19
-rwxr-xr-x[-rw-r--r--]intern/ghost/intern/GHOST_SystemSDL.cpp48
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp20
11 files changed, 111 insertions, 72 deletions
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index d7658c50a36..bdda0f3382e 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -149,6 +149,10 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_SystemPathsX11.h
)
+
+ if(NOT WITH_INSTALL_PORTABLE)
+ add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
+ endif()
elseif(WIN32)
list(APPEND SRC
@@ -204,10 +208,6 @@ elseif(APPLE)
elseif(UNIX)
- if(WITH_X11_XINPUT)
- add_definitions(-DWITH_X11_XINPUT)
- endif()
-
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
@@ -224,10 +224,6 @@ elseif(UNIX)
intern/GHOST_WindowX11.h
)
- if(NOT WITH_INSTALL_PORTABLE)
- add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
- endif()
-
if(X11_XF86keysym_INCLUDE_PATH)
add_definitions(-DWITH_XF86KEYSYM)
list(APPEND INC_SYS
@@ -243,6 +239,14 @@ elseif(UNIX)
)
endif()
+ if(NOT WITH_INSTALL_PORTABLE)
+ add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
+ endif()
+
+ if(WITH_X11_XINPUT)
+ add_definitions(-DWITH_X11_XINPUT)
+ endif()
+
elseif(WIN32)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index 855e27b9964..a24ccc3ff6c 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -375,7 +375,7 @@ void GHOST_NDOFManager::setDeadZone(float dz)
static bool atHomePosition(GHOST_TEventNDOFMotionData* ndof)
{
-#define HOME(foo) (ndof->foo == 0)
+#define HOME(foo) (ndof->foo == 0.f)
return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
#undef HOME
}
@@ -386,9 +386,9 @@ static bool nearHomePosition(GHOST_TEventNDOFMotionData* ndof, float threshold)
return atHomePosition(ndof);
}
else {
-#define HOME1(foo) (fabsf(ndof->foo) < threshold)
- return HOME1(tx) && HOME1(ty) && HOME1(tz) && HOME1(rx) && HOME1(ry) && HOME1(rz);
-#undef HOME1
+#define HOME(foo) (fabsf(ndof->foo) < threshold)
+ return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
+#undef HOME
}
}
@@ -423,17 +423,17 @@ bool GHOST_NDOFManager::sendMotionEvent()
data->dt = 0.001f * (m_motionTime - m_prevMotionTime); // in seconds
- bool handMotion = !nearHomePosition(data, m_deadZone);
+ bool weHaveMotion = !nearHomePosition(data, m_deadZone);
// determine what kind of motion event to send (Starting, InProgress, Finishing)
// and where that leaves this NDOF manager (NotStarted, InProgress, Finished)
switch (m_motionState) {
case GHOST_kNotStarted:
case GHOST_kFinished:
- if (handMotion) {
+ if (weHaveMotion) {
data->progress = GHOST_kStarting;
m_motionState = GHOST_kInProgress;
- // prev motion time will be ancient, so just make up something reasonable
+ // prev motion time will be ancient, so just make up a reasonable time delta
data->dt = 0.0125f;
}
else {
@@ -443,9 +443,9 @@ bool GHOST_NDOFManager::sendMotionEvent()
}
break;
case GHOST_kInProgress:
- if (handMotion) {
+ if (weHaveMotion) {
data->progress = GHOST_kInProgress;
- // keep InProgress state
+ // remain 'InProgress'
}
else {
data->progress = GHOST_kFinishing;
@@ -453,7 +453,7 @@ bool GHOST_NDOFManager::sendMotionEvent()
}
break;
default:
- break;
+ ; // will always be one of the above
}
#ifdef DEBUG_NDOF_MOTION
diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
index 27397b711b7..e9897f30104 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
@@ -22,10 +22,12 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
#ifndef _GHOST_NDOFMANAGERCOCOA_H_
#define _GHOST_NDOFMANAGERCOCOA_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
// Event capture is handled within the NDOF manager on Macintosh,
@@ -47,4 +49,5 @@ private:
};
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
index 53a991a7396..1d90b6daa68 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
+++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManagerCocoa.h"
#include "GHOST_SystemCocoa.h"
@@ -170,3 +172,5 @@ bool GHOST_NDOFManagerCocoa::available()
return InstallConnexionHandlers != NULL;
// this means that the driver is installed and dynamically linked to blender
}
+
+#endif // WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
index 099fa15d179..4dd53319039 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManagerX11.h"
#include "GHOST_SystemX11.h"
#include <spnav.h>
@@ -34,14 +36,14 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
GHOST_NDOFManager(sys),
m_available(false)
{
- setDeadZone(0.1f); // how to calibrate on Linux? throw away slight motion!
+ setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */
if (spnav_open() != -1) {
- // determine exactly which device (if any) is plugged in
+ /* determine exactly which device (if any) is plugged in */
#define MAX_LINE_LENGTH 100
- // look for USB devices with Logitech's vendor ID
+ /* look for USB devices with Logitech's vendor ID */
FILE* command_output = popen("lsusb -d 046d:","r");
if (command_output) {
char line[MAX_LINE_LENGTH] = {0};
@@ -50,15 +52,15 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2)
if (setDevice(vendor_id, product_id)) {
m_available = true;
- break; // stop looking once the first 3D mouse is found
+ break; /* stop looking once the first 3D mouse is found */
}
}
pclose(command_output);
}
}
else {
- printf("ndof: spacenavd not found\n");
- // This isn't a hard error, just means the user doesn't have a 3D mouse.
+ puts("ndof: spacenavd not found");
+ /* This isn't a hard error, just means the user doesn't have a 3D mouse. */
}
}
@@ -73,11 +75,6 @@ bool GHOST_NDOFManagerX11::available()
return m_available;
}
-//bool GHOST_NDOFManagerX11::identifyDevice()
-//{
-//
-//}
-
bool GHOST_NDOFManagerX11::processEvents()
{
GHOST_TUns64 now = m_system.getMilliSeconds();
@@ -88,7 +85,7 @@ bool GHOST_NDOFManagerX11::processEvents()
switch (e.type) {
case SPNAV_EVENT_MOTION:
{
- // convert to blender view coords
+ /* convert to blender view coords */
short t[3] = {e.motion.x, e.motion.y, -e.motion.z};
short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz};
@@ -104,3 +101,5 @@ bool GHOST_NDOFManagerX11::processEvents()
}
return anyProcessed;
}
+
+#endif /* WITH_INPUT_NDOF */
diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.h b/intern/ghost/intern/GHOST_NDOFManagerX11.h
index 82bd256c707..0a549753756 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerX11.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerX11.h
@@ -26,6 +26,8 @@
#ifndef _GHOST_NDOFMANAGERX11_H_
#define _GHOST_NDOFMANAGERX11_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
/* Event capture is handled within the NDOF manager on Linux,
@@ -40,10 +42,9 @@ public:
bool processEvents();
private:
- // bool identifyDevice();
-
bool m_available;
};
-#endif
+#endif /* WITH_INPUT_NDOF */
+#endif /* #include guard */
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 17f0f2d6ecd..303c2b24497 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -21,8 +21,8 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): Maarten Gribnau 05/2001
- * Damien Plisson 09/2009
+ * Contributors: Maarten Gribnau 05/2001
+ * Damien Plisson 09/2009
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -43,16 +43,17 @@
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
-#include "GHOST_EventNDOF.h"
#include "GHOST_EventTrackpad.h"
#include "GHOST_EventDragnDrop.h"
#include "GHOST_EventString.h"
-
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowCocoa.h"
+#ifdef WITH_INPUT_NDOF
#include "GHOST_NDOFManagerCocoa.h"
+#endif
+
#include "AssertMacros.h"
#pragma mark KeyMap, mouse converters
diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp
index dd8935732c5..135f5c42dc5 100644
--- a/intern/ghost/intern/GHOST_SystemPathsX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsX11.cpp
@@ -43,7 +43,11 @@
#include <stdio.h> // for fprintf only
#include <cstdlib> // for exit
-using namespace std;
+#ifdef PREFIX
+static const char *static_path= PREFIX "/share" ;
+#else
+static const char *static_path= NULL;
+#endif
GHOST_SystemPathsX11::GHOST_SystemPathsX11()
{
@@ -56,21 +60,12 @@ GHOST_SystemPathsX11::~GHOST_SystemPathsX11()
const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
{
/* no prefix assumes a portable build which only uses bundled scripts */
-#ifdef PREFIX
- return (GHOST_TUns8*) PREFIX "/share";
-#else
- return NULL;
-#endif
+ return (const GHOST_TUns8 *)static_path;
}
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
{
- const char* env = getenv("HOME");
- if(env) {
- return (GHOST_TUns8*) env;
- } else {
- return NULL;
- }
+ return (const GHOST_TUns8 *)getenv("HOME");
}
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 918b37dd905..6f6679b8d8c 100644..100755
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -146,7 +146,7 @@ convertSDLKey(SDL_Scancode key)
if ((key >= SDL_SCANCODE_A) && (key <= SDL_SCANCODE_Z)) {
type= GHOST_TKey( key - SDL_SCANCODE_A + int(GHOST_kKeyA));
} else if ((key >= SDL_SCANCODE_1) && (key <= SDL_SCANCODE_0)) {
- type= GHOST_TKey(key - SDL_SCANCODE_1 + int(GHOST_kKey0));
+ type= (key == SDL_SCANCODE_0) ? GHOST_kKey0 : GHOST_TKey(key - SDL_SCANCODE_1 + int(GHOST_kKey1));
} else if ((key >= SDL_SCANCODE_F1) && (key <= SDL_SCANCODE_F12)) {
type= GHOST_TKey(key - SDL_SCANCODE_F1 + int(GHOST_kKeyF1));
} else if ((key >= SDL_SCANCODE_F13) && (key <= SDL_SCANCODE_F24)) {
@@ -167,6 +167,8 @@ convertSDLKey(SDL_Scancode key)
GXMAP(type,SDL_SCANCODE_APOSTROPHE, GHOST_kKeyQuote);
GXMAP(type,SDL_SCANCODE_GRAVE, GHOST_kKeyAccentGrave);
GXMAP(type,SDL_SCANCODE_MINUS, GHOST_kKeyMinus);
+ GXMAP(type,SDL_SCANCODE_EQUALS, GHOST_kKeyEqual);
+
GXMAP(type,SDL_SCANCODE_SLASH, GHOST_kKeySlash);
GXMAP(type,SDL_SCANCODE_BACKSLASH, GHOST_kKeyBackslash);
GXMAP(type,SDL_SCANCODE_KP_EQUALS, GHOST_kKeyEqual);
@@ -180,6 +182,7 @@ convertSDLKey(SDL_Scancode key)
GXMAP(type,SDL_SCANCODE_RCTRL, GHOST_kKeyRightControl);
GXMAP(type,SDL_SCANCODE_LALT, GHOST_kKeyLeftAlt);
GXMAP(type,SDL_SCANCODE_RALT, GHOST_kKeyRightAlt);
+ GXMAP(type,SDL_SCANCODE_LGUI, GHOST_kKeyOS);
GXMAP(type,SDL_SCANCODE_RGUI, GHOST_kKeyOS);
GXMAP(type,SDL_SCANCODE_INSERT, GHOST_kKeyInsert);
@@ -197,6 +200,7 @@ convertSDLKey(SDL_Scancode key)
GXMAP(type,SDL_SCANCODE_CAPSLOCK, GHOST_kKeyCapsLock);
GXMAP(type,SDL_SCANCODE_SCROLLLOCK, GHOST_kKeyScrollLock);
GXMAP(type,SDL_SCANCODE_NUMLOCKCLEAR, GHOST_kKeyNumLock);
+ GXMAP(type,SDL_SCANCODE_PRINTSCREEN, GHOST_kKeyPrintScreen);
/* keypad events */
@@ -228,6 +232,7 @@ convertSDLKey(SDL_Scancode key)
GXMAP(type,SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast);
default:
+ printf("Unknown\n");
type= GHOST_kKeyUnknown;
break;
}
@@ -372,6 +377,7 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
case SDL_KEYUP:
{
SDL_KeyboardEvent &sdl_sub_evt= sdl_event->key;
+ SDL_Keycode sym= sdl_sub_evt.keysym.sym;
GHOST_TEventType type= (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp;
GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
@@ -379,7 +385,45 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
GHOST_TKey gkey= convertSDLKey(sdl_sub_evt.keysym.scancode);
/* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */
- g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sdl_sub_evt.keysym.sym);
+ if(sym > 127) {
+ sym= 0;
+ }
+ else {
+ if(sdl_sub_evt.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) {
+ /* lame US keyboard assumptions */
+ if(sym >= 'a' && sym <= ('a' + 32)) {
+ sym -= 32;
+ }
+ else {
+ switch(sym) {
+ case '`': sym= '~'; break;
+ case '1': sym= '!'; break;
+ case '2': sym= '@'; break;
+ case '3': sym= '#'; break;
+ case '4': sym= '$'; break;
+ case '5': sym= '%'; break;
+ case '6': sym= '^'; break;
+ case '7': sym= '&'; break;
+ case '8': sym= '*'; break;
+ case '9': sym= '('; break;
+ case '0': sym= ')'; break;
+ case '-': sym= '_'; break;
+ case '=': sym= '+'; break;
+ case '[': sym= '{'; break;
+ case ']': sym= '}'; break;
+ case '\\': sym= '|'; break;
+ case ';': sym= ':'; break;
+ case '\'': sym= '"'; break;
+ case ',': sym= '<'; break;
+ case '.': sym= '>'; break;
+ case '/': sym= '?'; break;
+ default: break;
+ }
+ }
+ }
+ }
+
+ g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym);
}
break;
}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index c5dff27dace..858312b3eb1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -302,6 +302,7 @@ protected:
*/
static void processMinMaxInfo(MINMAXINFO * minmax);
+#ifdef WITH_INPUT_NDOF
/**
* Handles Motion and Button events from a SpaceNavigator or related device.
* Instead of returning an event object, this function communicates directly
@@ -310,6 +311,7 @@ protected:
* @return Whether an event was generated and sent.
*/
bool processNDOF(RAWINPUT const& raw);
+#endif
/**
* Returns the local state of the modifier keys (from the message queue).
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 105f71b514f..d5100e589f2 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -42,8 +42,10 @@
#include "GHOST_EventKey.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventWheel.h"
-#include "GHOST_NDOFManagerX11.h"
#include "GHOST_DisplayManagerX11.h"
+#ifdef WITH_INPUT_NDOF
+#include "GHOST_NDOFManagerX11.h"
+#endif
#include "GHOST_Debug.h"
@@ -815,22 +817,6 @@ GHOST_SystemX11::processEvent(XEvent *xe)
}
}
-#if 0 // obsolete SpaceNav code
-
- void *
-GHOST_SystemX11::
-prepareNdofInfo(volatile GHOST_TEventNDOFData *currentNdofValues)
-{
- const vector<GHOST_IWindow*>& v(m_windowManager->getWindows());
- if (v.size() > 0)
- sNdofInfo.window = static_cast<GHOST_WindowX11*>(v[0])->getXWindow();
- sNdofInfo.display = m_display;
- sNdofInfo.currValues = currentNdofValues;
- return (void*)&sNdofInfo;
-}
-
-#endif
-
GHOST_TSuccess
GHOST_SystemX11::
getModifierKeys(