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:
authorJoerg Mueller <nexyon@gmail.com>2011-08-07 19:25:06 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-08-07 19:25:06 +0400
commitdaab78bc614fdf19d1e56558972347121e82e06e (patch)
tree39c919901b6add092817f6c87861030aab97578e /intern
parentb057cf1bb118a070e2eeb3b2029aa80fad00a9b2 (diff)
parentbf23acf3bb8ae43e6a50108a00e7572fe35edea4 (diff)
Merging trunk up to r39145.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.cpp6
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.h8
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.cpp43
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp43
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h2
5 files changed, 79 insertions, 23 deletions
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
index 57d84ec14d4..fd62e845f7d 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF // use contents of this file
+
#include "GHOST_NDOFManagerWin32.h"
@@ -39,3 +41,5 @@ bool GHOST_NDOFManagerWin32::available()
// always available since RawInput is built into Windows
return true;
}
+
+#endif // WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.h b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
index 31f7e074cd6..9f3eddeb3c8 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
@@ -22,10 +22,13 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+
#ifndef _GHOST_NDOFMANAGERWIN32_H_
#define _GHOST_NDOFMANAGERWIN32_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
@@ -37,4 +40,5 @@ public:
};
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 2c61acc2d93..69a9f936cf6 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -180,6 +180,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);
@@ -228,6 +229,7 @@ convertSDLKey(SDL_Scancode key)
GXMAP(type,SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast);
default:
+ printf("Unknown\n");
type= GHOST_kKeyUnknown;
break;
}
@@ -372,6 +374,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 +382,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.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index bbf8efeaee3..38f3985b139 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -62,7 +62,6 @@
#endif
#endif
-#include "GHOST_Debug.h"
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
@@ -72,7 +71,10 @@
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
+
+#ifdef WITH_INPUT_NDOF
#include "GHOST_NDOFManagerWin32.h"
+#endif
// Key code values not found in winuser.h
#ifndef VK_MINUS
@@ -127,22 +129,32 @@
static void initRawInput()
{
- RAWINPUTDEVICE devices[2];
- memset(devices, 0, 2 * sizeof(RAWINPUTDEVICE));
+#ifdef WITH_INPUT_NDOF
+#define DEVICE_COUNT 2
+#else
+#define DEVICE_COUNT 1
+#endif
- // multi-axis mouse (SpaceNavigator, etc.)
- devices[0].usUsagePage = 0x01;
- devices[0].usUsage = 0x08;
+ RAWINPUTDEVICE devices[DEVICE_COUNT];
+ memset(devices, 0, DEVICE_COUNT * sizeof(RAWINPUTDEVICE));
// Initiates WM_INPUT messages from keyboard
// That way GHOST can retrieve true keys
+ devices[0].usUsagePage = 0x01;
+ devices[0].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+
+#ifdef WITH_INPUT_NDOF
+ // multi-axis mouse (SpaceNavigator, etc.)
devices[1].usUsagePage = 0x01;
- devices[1].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+ devices[1].usUsage = 0x08;
+#endif
- if (RegisterRawInputDevices(devices, 2, sizeof(RAWINPUTDEVICE)))
- puts("registered for RawInput (spacenav & keyboard)");
+ if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE)))
+ ; // yay!
else
printf("could not register for RawInput: %d\n", (int)GetLastError());
+
+#undef DEVICE_COUNT
}
GHOST_SystemWin32::GHOST_SystemWin32()
@@ -808,6 +820,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
case 1: // translation
{
short* axis = (short*)(data + 1);
+ // massage into blender view coords (same goes for rotation)
short t[3] = {axis[0], -axis[2], axis[1]};
m_ndofManager->updateTranslation(t, now);
@@ -830,14 +843,6 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
}
case 3: // buttons
{
-#if 0
- // I'm getting garbage bits -- examine whole report:
- printf("ndof: HID report for buttons [");
- for (int i = 0; i < raw.data.hid.dwSizeHid; ++i)
- printf(" %02X", data[i]);
- printf(" ]\n");
-#endif
-
int button_bits;
memcpy(&button_bits, data + 1, sizeof(button_bits));
m_ndofManager->updateButtons(button_bits, now);
@@ -892,12 +897,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_PRINT(" key ignored\n")
}
break;
- case RIM_TYPEHID:
#ifdef WITH_INPUT_NDOF
+ case RIM_TYPEHID:
if (system->processNDOF(raw))
eventHandled = true;
-#endif
break;
+#endif
}
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).