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
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/GHOST_Types.h4
-rw-r--r--intern/ghost/intern/GHOST_Debug.h4
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp5
-rw-r--r--intern/ghost/intern/GHOST_ModifierKeys.cpp14
-rw-r--r--intern/ghost/intern/GHOST_ModifierKeys.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp4
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm8
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp249
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h33
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp10
-rw-r--r--intern/ghost/test/multitest/EventToBuf.c2
11 files changed, 146 insertions, 191 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index f926e72119f..20b69611bfb 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -96,7 +96,7 @@ typedef enum {
GHOST_kModifierKeyRightAlt,
GHOST_kModifierKeyLeftControl,
GHOST_kModifierKeyRightControl,
- GHOST_kModifierKeyCommand, // APPLE only
+ GHOST_kModifierKeyOS,
GHOST_kModifierKeyNumMasks
} GHOST_TModifierKeyMask;
@@ -283,7 +283,7 @@ typedef enum {
GHOST_kKeyRightControl,
GHOST_kKeyLeftAlt,
GHOST_kKeyRightAlt,
- GHOST_kKeyCommand, // Command key on Apple, Windows key(s) on Windows
+ GHOST_kKeyOS, // Command key on Apple, Windows key(s) on Windows
GHOST_kKeyGrLess , // German PC only!
GHOST_kKeyCapsLock,
diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h
index d402aed63db..927ecfc88a5 100644
--- a/intern/ghost/intern/GHOST_Debug.h
+++ b/intern/ghost/intern/GHOST_Debug.h
@@ -35,10 +35,10 @@
#define _GHOST_DEBUG_H_
#if defined(WIN32) && !defined(FREE_WINDOWS)
- #ifdef _DEBUG
+ #ifdef DEBUG
#pragma warning (disable:4786) // suppress stl-MSVC debug info warning
// #define GHOST_DEBUG
- #endif // _DEBUG
+ #endif // DEBUG
#endif // WIN32
#ifdef BF_GHOST_DEBUG
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index 645a33ab8c5..697ced64a70 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -255,9 +255,8 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, STR_String& str) const
case GHOST_kKeyRightAlt:
str = "RightAlt";
break;
- case GHOST_kKeyCommand:
- // APPLE only!
- str = "Command";
+ case GHOST_kKeyOS:
+ str = "OS";
break;
case GHOST_kKeyGrLess:
// PC german!
diff --git a/intern/ghost/intern/GHOST_ModifierKeys.cpp b/intern/ghost/intern/GHOST_ModifierKeys.cpp
index ed884966cb3..361329532f9 100644
--- a/intern/ghost/intern/GHOST_ModifierKeys.cpp
+++ b/intern/ghost/intern/GHOST_ModifierKeys.cpp
@@ -55,7 +55,7 @@ GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask)
case GHOST_kModifierKeyRightAlt: key = GHOST_kKeyRightAlt; break;
case GHOST_kModifierKeyLeftControl: key = GHOST_kKeyLeftControl; break;
case GHOST_kModifierKeyRightControl: key = GHOST_kKeyRightControl; break;
- case GHOST_kModifierKeyCommand: key = GHOST_kKeyCommand; break;
+ case GHOST_kModifierKeyOS: key = GHOST_kKeyOS; break;
default:
// Should not happen
key = GHOST_kKeyUnknown;
@@ -80,8 +80,8 @@ bool GHOST_ModifierKeys::get(GHOST_TModifierKeyMask mask) const
return m_LeftControl;
case GHOST_kModifierKeyRightControl:
return m_RightControl;
- case GHOST_kModifierKeyCommand:
- return m_Command;
+ case GHOST_kModifierKeyOS:
+ return m_OS;
default:
return false;
}
@@ -103,8 +103,8 @@ void GHOST_ModifierKeys::set(GHOST_TModifierKeyMask mask, bool down)
m_LeftControl = down; break;
case GHOST_kModifierKeyRightControl:
m_RightControl = down; break;
- case GHOST_kModifierKeyCommand:
- m_Command = down; break;
+ case GHOST_kModifierKeyOS:
+ m_OS = down; break;
default:
break;
}
@@ -119,7 +119,7 @@ void GHOST_ModifierKeys::clear()
m_RightAlt = false;
m_LeftControl = false;
m_RightControl = false;
- m_Command = false;
+ m_OS = false;
}
@@ -131,5 +131,5 @@ bool GHOST_ModifierKeys::equals(const GHOST_ModifierKeys& keys) const
(m_RightAlt == keys.m_RightAlt) &&
(m_LeftControl == keys.m_LeftControl) &&
(m_RightControl == keys.m_RightControl) &&
- (m_Command == keys.m_Command);
+ (m_OS == keys.m_OS);
}
diff --git a/intern/ghost/intern/GHOST_ModifierKeys.h b/intern/ghost/intern/GHOST_ModifierKeys.h
index e18899bc939..77d6d5757d9 100644
--- a/intern/ghost/intern/GHOST_ModifierKeys.h
+++ b/intern/ghost/intern/GHOST_ModifierKeys.h
@@ -96,8 +96,8 @@ struct GHOST_ModifierKeys
GHOST_TUns8 m_LeftControl : 1;
/** Bitfield that stores the appropriate key state. */
GHOST_TUns8 m_RightControl : 1;
- /** Bitfield that stores the appropriate key state. APPLE only! */
- GHOST_TUns8 m_Command : 1;
+ /** Bitfield that stores the appropriate key state. */
+ GHOST_TUns8 m_OS : 1;
};
#endif // _GHOST_MODIFIER_KEYS_H_
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index ecdc03b4347..75cbe5db574 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -553,7 +553,7 @@ GHOST_TSuccess GHOST_SystemCarbon::getModifierKeys(GHOST_ModifierKeys& keys) con
{
UInt32 modifiers = ::GetCurrentKeyModifiers();
- keys.set(GHOST_kModifierKeyCommand, (modifiers & cmdKey) ? true : false);
+ keys.set(GHOST_kModifierKeyOS, (modifiers & cmdKey) ? true : false);
keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false);
keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false);
keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false);
@@ -941,7 +941,7 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event)
pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
}
if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) {
- pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
+ pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
}
m_modifierMask = modifiers;
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 286c4eda675..80356c19c9b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -853,7 +853,7 @@ GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_T
GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys(GHOST_ModifierKeys& keys) const
{
- keys.set(GHOST_kModifierKeyCommand, (m_modifierMask & NSCommandKeyMask) ? true : false);
+ keys.set(GHOST_kModifierKeyOS, (m_modifierMask & NSCommandKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftAlt, (m_modifierMask & NSAlternateKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftShift, (m_modifierMask & NSShiftKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftControl, (m_modifierMask & NSControlKeyMask) ? true : false);
@@ -1018,7 +1018,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent()
pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSAlternateKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
}
if ((modifiers & NSCommandKeyMask) != (m_modifierMask & NSCommandKeyMask)) {
- pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
+ pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
}
m_modifierMask = modifiers;
@@ -1163,7 +1163,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
NSEnumerator *enumerator;
NSImageRep *representation;
- ibuf = IMB_allocImBuf (imgSize.width , imgSize.height, 32, IB_rect, 0);
+ ibuf = IMB_allocImBuf (imgSize.width , imgSize.height, 32, IB_rect);
if (!ibuf) {
[droppedImg release];
return GHOST_kFailure;
@@ -1698,7 +1698,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSAlternateKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
}
if ((modifiers & NSCommandKeyMask) != (m_modifierMask & NSCommandKeyMask)) {
- pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
}
m_modifierMask = modifiers;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index dceecb53dd2..da333ce4f08 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -34,6 +34,8 @@
* @date May 7, 2001
*/
+#include <iostream>
+
#include "GHOST_SystemWin32.h"
#include "GHOST_EventDragnDrop.h"
@@ -136,14 +138,15 @@
GHOST_SystemWin32::GHOST_SystemWin32()
-: m_hasPerformanceCounter(false), m_freq(0), m_start(0),
- m_separateLeftRight(false),
- m_separateLeftRightInitialized(false)
+: m_hasPerformanceCounter(false), m_freq(0), m_start(0)
{
m_displayManager = new GHOST_DisplayManagerWin32 ();
GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n");
m_displayManager->initialize();
+ // Check if current keyboard layout uses AltGr
+ this->keyboardAltGr();
+
// Require COM for GHOST_DropTargetWin32 created in GHOST_WindowWin32.
OleInitialize(0);
}
@@ -287,43 +290,24 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) const
{
- if (m_separateLeftRight && m_separateLeftRightInitialized) {
- bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0;
- keys.set(GHOST_kModifierKeyLeftShift, down);
- down = HIBYTE(::GetKeyState(VK_RSHIFT)) != 0;
- keys.set(GHOST_kModifierKeyRightShift, down);
- down = HIBYTE(::GetKeyState(VK_LMENU)) != 0;
- keys.set(GHOST_kModifierKeyLeftAlt, down);
- down = HIBYTE(::GetKeyState(VK_RMENU)) != 0;
- keys.set(GHOST_kModifierKeyRightAlt, down);
- down = HIBYTE(::GetKeyState(VK_LCONTROL)) != 0;
- keys.set(GHOST_kModifierKeyLeftControl, down);
- down = HIBYTE(::GetKeyState(VK_RCONTROL)) != 0;
- keys.set(GHOST_kModifierKeyRightControl, down);
- bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
- bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
- if(lwindown || rwindown)
- keys.set(GHOST_kModifierKeyCommand, true);
- else
- keys.set(GHOST_kModifierKeyCommand, false);
- }
- else {
- bool down = HIBYTE(::GetKeyState(VK_SHIFT)) != 0;
- keys.set(GHOST_kModifierKeyLeftShift, down);
- keys.set(GHOST_kModifierKeyRightShift, down);
- down = HIBYTE(::GetKeyState(VK_MENU)) != 0;
- keys.set(GHOST_kModifierKeyLeftAlt, down);
- keys.set(GHOST_kModifierKeyRightAlt, down);
- down = HIBYTE(::GetKeyState(VK_CONTROL)) != 0;
- keys.set(GHOST_kModifierKeyLeftControl, down);
- keys.set(GHOST_kModifierKeyRightControl, down);
- bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
- bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
- if(lwindown || rwindown)
- keys.set(GHOST_kModifierKeyCommand, true);
- else
- keys.set(GHOST_kModifierKeyCommand, false);
- }
+ bool down = HIBYTE(::GetKeyState(VK_SHIFT)) != 0;
+ keys.set(GHOST_kModifierKeyLeftShift, down);
+ keys.set(GHOST_kModifierKeyRightShift, down);
+
+ down = HIBYTE(::GetKeyState(VK_MENU)) != 0;
+ keys.set(GHOST_kModifierKeyLeftAlt, down);
+ keys.set(GHOST_kModifierKeyRightAlt, down);
+
+ down = HIBYTE(::GetKeyState(VK_CONTROL)) != 0;
+ keys.set(GHOST_kModifierKeyLeftControl, down);
+ keys.set(GHOST_kModifierKeyRightControl, down);
+
+ bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
+ bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
+ if(lwindown || rwindown)
+ keys.set(GHOST_kModifierKeyOS, true);
+ else
+ keys.set(GHOST_kModifierKeyOS, false);
return GHOST_kSuccess;
}
@@ -386,7 +370,7 @@ GHOST_TSuccess GHOST_SystemWin32::init()
wc.hbrBackground= (HBRUSH)::GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName= GHOST_WindowWin32::getWindowClassName();
-
+
// Use RegisterClassEx for setting small icon
if (::RegisterClass(&wc) == 0) {
success = GHOST_kFailure;
@@ -402,10 +386,14 @@ GHOST_TSuccess GHOST_SystemWin32::exit()
}
-GHOST_TKey GHOST_SystemWin32::convertKey(WPARAM wParam, LPARAM lParam) const
+GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) const
{
- GHOST_TKey key;
bool isExtended = (lParam&(1<<24))?true:false;
+
+ GHOST_TKey key;
+ GHOST_ModifierKeys oldModifiers, newModifiers;
+ ((GHOST_SystemWin32*)getSystem())->retrieveModifierKeys(oldModifiers);
+ ((GHOST_SystemWin32*)getSystem())->getModifierKeys(newModifiers);
if ((wParam >= '0') && (wParam <= '9')) {
// VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
@@ -469,55 +457,62 @@ GHOST_TKey GHOST_SystemWin32::convertKey(WPARAM wParam, LPARAM lParam) const
case VK_QUOTE: key = GHOST_kKeyQuote; break;
case VK_GR_LESS: key = GHOST_kKeyGrLess; break;
- // Process these keys separately because we need to distinguish right from left modifier keys
case VK_SHIFT:
+ {
+ bool lchanged = oldModifiers.get(GHOST_kModifierKeyLeftShift) != newModifiers.get(GHOST_kModifierKeyLeftShift);
+ if(lchanged) {
+ key = GHOST_kKeyLeftShift;
+ } else {
+ key = GHOST_kKeyRightShift;
+ }
+ }
+ break;
case VK_CONTROL:
+ {
+ bool lchanged = oldModifiers.get(GHOST_kModifierKeyLeftControl) != newModifiers.get(GHOST_kModifierKeyLeftControl);
+ if(lchanged) {
+ key = GHOST_kKeyLeftControl;
+ } else {
+ key = GHOST_kKeyRightControl;
+ }
+ }
+ break;
case VK_MENU:
-
- // Ignore these keys
- case VK_NUMLOCK:
- case VK_SCROLL:
- case VK_CAPITAL:
+ {
+ if(m_hasAltGr && isExtended) {
+ // We have here an extended RAlt, which is AltGr. The keyboard driver on Windows sends before this a LControl, so
+ // to be able to input characters created with AltGr (normal on German, French, Finnish and other keyboards) we
+ // push an extra LControl up event. This ensures we don't have a 'hanging' ctrl event in Blender windowmanager
+ // when typing in Text editor or Console.
+ GHOST_Event *extra = new GHOST_EventKey(getSystem()->getMilliSeconds(), GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl, '\0');
+ ((GHOST_SystemWin32*)getSystem())->pushEvent(extra);
+ newModifiers.set(GHOST_kModifierKeyRightControl, false);
+ newModifiers.set(GHOST_kModifierKeyLeftControl, false);
+ }
+ bool lchanged = oldModifiers.get(GHOST_kModifierKeyLeftAlt) != newModifiers.get(GHOST_kModifierKeyLeftAlt);
+ if(lchanged) {
+ key = GHOST_kKeyLeftAlt;
+ } else {
+ key = GHOST_kKeyRightAlt;
+ }
+ }
+ break;
+ case VK_LWIN:
+ case VK_RWIN:
+ key = GHOST_kKeyOS;
+ break;
+ case VK_NUMLOCK: key = GHOST_kKeyNumLock; break;
+ case VK_SCROLL: key = GHOST_kKeyScrollLock; break;
+ case VK_CAPITAL: key = GHOST_kKeyCapsLock; break;
default:
key = GHOST_kKeyUnknown;
break;
}
}
- return key;
-}
-
-
-void GHOST_SystemWin32::processModifierKeys(GHOST_IWindow *window)
-{
- GHOST_ModifierKeys oldModifiers, newModifiers;
- // Retrieve old state of the modifier keys
- ((GHOST_SystemWin32*)getSystem())->retrieveModifierKeys(oldModifiers);
- // Retrieve current state of the modifier keys
- ((GHOST_SystemWin32*)getSystem())->getModifierKeys(newModifiers);
-
- // Compare the old and the new
- if (!newModifiers.equals(oldModifiers)) {
- // Create events for the masks that changed
- for (int i = 0; i < GHOST_kModifierKeyNumMasks; i++) {
- if (newModifiers.get((GHOST_TModifierKeyMask)i) != oldModifiers.get((GHOST_TModifierKeyMask)i)) {
- // Convert the mask to a key code
- GHOST_TKey key = GHOST_ModifierKeys::getModifierKeyCode((GHOST_TModifierKeyMask)i);
- bool keyDown = newModifiers.get((GHOST_TModifierKeyMask)i);
- GHOST_EventKey* event;
- if (key != GHOST_kKeyUnknown) {
- // Create an event
- event = new GHOST_EventKey(getSystem()->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key);
- pushEvent(event);
- }
- }
- }
- }
-
- // Store new modifier keys state
((GHOST_SystemWin32*)getSystem())->storeModifierKeys(newModifiers);
+ return key;
}
-
GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask)
{
return new GHOST_EventButton (getSystem()->getMilliSeconds(), type, window, mask);
@@ -594,7 +589,7 @@ GHOST_EventWheel* GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WP
GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, bool keyDown, WPARAM wParam, LPARAM lParam)
{
- GHOST_TKey key = ((GHOST_SystemWin32*)getSystem())->convertKey(wParam, lParam);
+ GHOST_TKey key = ((GHOST_SystemWin32*)getSystem())->convertKey(window, wParam, lParam);
GHOST_EventKey* event;
if (key != GHOST_kKeyUnknown) {
MSG keyMsg;
@@ -603,6 +598,7 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, bool k
/* Eat any character related messages */
if (::PeekMessage(&keyMsg, NULL, WM_CHAR, WM_SYSDEADCHAR, PM_REMOVE)) {
ascii = (char) keyMsg.wParam;
+
}
event = new GHOST_EventKey(getSystem()->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii);
@@ -651,89 +647,30 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_WindowWin32* window = (GHOST_WindowWin32*)::GetWindowLong(hwnd, GWL_USERDATA);
if (window) {
switch (msg) {
+ // we need to check if new key layout has AltGr
+ case WM_INPUTLANGCHANGE:
+ system->keyboardAltGr();
+ break;
////////////////////////////////////////////////////////////////////////
// Keyboard events, processed
////////////////////////////////////////////////////////////////////////
case WM_KEYDOWN:
- /* The WM_KEYDOWN message is posted to the window with the keyboard focus when a
- * nonsystem key is pressed. A nonsystem key is a key that is pressed when the alt
- * key is not pressed.
- */
case WM_SYSKEYDOWN:
- /* The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when
- * the user presses the F10 key (which activates the menu bar) or holds down the
- * alt key and then presses another key. It also occurs when no window currently
- * has the keyboard focus; in this case, the WM_SYSKEYDOWN message is sent to the
- * active window. The window that receives the message can distinguish between these
- * two contexts by checking the context code in the lKeyData parameter.
- */
- switch (wParam) {
- case VK_SHIFT:
- case VK_CONTROL:
- case VK_MENU:
- case VK_LWIN:
- case VK_RWIN:
- if (!system->m_separateLeftRightInitialized) {
- // Check whether this system supports separate left and right keys
- switch (wParam) {
- case VK_SHIFT:
- system->m_separateLeftRight =
- (HIBYTE(::GetKeyState(VK_LSHIFT)) != 0) ||
- (HIBYTE(::GetKeyState(VK_RSHIFT)) != 0) ?
- true : false;
- break;
- case VK_CONTROL:
- system->m_separateLeftRight =
- (HIBYTE(::GetKeyState(VK_LCONTROL)) != 0) ||
- (HIBYTE(::GetKeyState(VK_RCONTROL)) != 0) ?
- true : false;
- break;
- case VK_MENU:
- system->m_separateLeftRight =
- (HIBYTE(::GetKeyState(VK_LMENU)) != 0) ||
- (HIBYTE(::GetKeyState(VK_RMENU)) != 0) ?
- true : false;
- break;
- case VK_LWIN:
- case VK_RWIN:
- system->m_separateLeftRight = true;
- break;
- }
- system->m_separateLeftRightInitialized = true;
- }
- system->processModifierKeys(window);
- // Bypass call to DefWindowProc
- return 0;
- default:
- event = processKeyEvent(window, true, wParam, lParam);
- if (!event) {
- GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ")
- GHOST_PRINT(msg)
- GHOST_PRINT(" key ignored\n")
- }
- break;
- }
+ event = processKeyEvent(window, true, wParam, lParam);
+ if (!event) {
+ GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ")
+ GHOST_PRINT(msg)
+ GHOST_PRINT(" key ignored\n")
+ }
break;
case WM_KEYUP:
case WM_SYSKEYUP:
- switch (wParam) {
- case VK_SHIFT:
- case VK_CONTROL:
- case VK_MENU:
- case VK_LWIN:
- case VK_RWIN:
- system->processModifierKeys(window);
- // Bypass call to DefWindowProc
- return 0;
- default:
- event = processKeyEvent(window, false, wParam, lParam);
- if (!event) {
- GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ")
- GHOST_PRINT(msg)
- GHOST_PRINT(" key ignored\n")
- }
- break;
+ event = processKeyEvent(window, false, wParam, lParam);
+ if (!event) {
+ GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ")
+ GHOST_PRINT(msg)
+ GHOST_PRINT(" key ignored\n")
}
break;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 35b8debf6b4..3cd1deefda0 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -239,7 +239,7 @@ protected:
* @param lParam The lParam from the wndproc
* @return The GHOST key (GHOST_kKeyUnknown if no match).
*/
- virtual GHOST_TKey convertKey(WPARAM wParam, LPARAM lParam) const;
+ virtual GHOST_TKey convertKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) const;
/**
* Creates modifier key event(s) and updates the key data stored locally (m_modifierKeys).
@@ -248,7 +248,7 @@ protected:
* events generated for both keys.
* @param window The window receiving the event (the active window).
*/
- void processModifierKeys(GHOST_IWindow *window);
+ GHOST_EventKey* processModifierKeys(GHOST_IWindow *window);
/**
* Creates mouse button event.
@@ -310,6 +310,11 @@ protected:
* @param keys The new state of the modifier keys.
*/
inline virtual void storeModifierKeys(const GHOST_ModifierKeys& keys);
+
+ /**
+ * Check current key layout for AltGr
+ */
+ inline virtual void keyboardAltGr();
/**
* Windows call back routine for our window class.
@@ -324,11 +329,8 @@ protected:
__int64 m_freq;
/** High frequency timer variable. */
__int64 m_start;
- /** Stores the capability of this system to distinguish left and right modifier keys. */
- bool m_separateLeftRight;
- /** Stores the initialization state of the member m_leftRightDistinguishable. */
- bool m_separateLeftRightInitialized;
-
+ /** AltGr on current keyboard layout. */
+ bool m_hasAltGr;
};
inline void GHOST_SystemWin32::retrieveModifierKeys(GHOST_ModifierKeys& keys) const
@@ -341,5 +343,22 @@ inline void GHOST_SystemWin32::storeModifierKeys(const GHOST_ModifierKeys& keys)
m_modifierKeys = keys;
}
+inline void GHOST_SystemWin32::keyboardAltGr()
+{
+ HKL keylayout = GetKeyboardLayout(0); // get keylayout for current thread
+ int i;
+ SHORT s;
+ for(m_hasAltGr = false, i = 32; i < 256; ++i) {
+ s = VkKeyScanEx((char)i, keylayout);
+ // s == -1 means no key that translates passed char code
+ // high byte contains shift state. bit 2 ctrl pressed, bit 4 alt pressed
+ // if both are pressed, we have AltGr keycombo on keylayout
+ if(s!=-1 && (s & 0x600) == 0x600) {
+ m_hasAltGr = true;
+ break;
+ }
+ }
+}
+
#endif // _GHOST_SYSTEM_WIN32_H_
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index b07dba7319f..393761566ba 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -891,13 +891,13 @@ getModifierKeys(
keys.set(GHOST_kModifierKeyRightAlt,false);
}
- // Super (Windows) - only one GHOST-kModifierKeyCommand, so mapping
+ // Super (Windows) - only one GHOST-kModifierKeyOS, so mapping
// to either
if ( ((m_keyboard_vector[super_l >> 3] >> (super_l & 7)) & 1) ||
((m_keyboard_vector[super_r >> 3] >> (super_r & 7)) & 1) ) {
- keys.set(GHOST_kModifierKeyCommand,true);
+ keys.set(GHOST_kModifierKeyOS,true);
} else {
- keys.set(GHOST_kModifierKeyCommand,false);
+ keys.set(GHOST_kModifierKeyOS,false);
}
return GHOST_kSuccess;
}
@@ -1106,8 +1106,8 @@ convertXKey(
GXMAP(type,XK_Control_R, GHOST_kKeyRightControl);
GXMAP(type,XK_Alt_L, GHOST_kKeyLeftAlt);
GXMAP(type,XK_Alt_R, GHOST_kKeyRightAlt);
- GXMAP(type,XK_Super_L, GHOST_kKeyCommand);
- GXMAP(type,XK_Super_R, GHOST_kKeyCommand);
+ GXMAP(type,XK_Super_L, GHOST_kKeyOS);
+ GXMAP(type,XK_Super_R, GHOST_kKeyOS);
GXMAP(type,XK_Insert, GHOST_kKeyInsert);
GXMAP(type,XK_Delete, GHOST_kKeyDelete);
diff --git a/intern/ghost/test/multitest/EventToBuf.c b/intern/ghost/test/multitest/EventToBuf.c
index 1dbaad35994..859600bb783 100644
--- a/intern/ghost/test/multitest/EventToBuf.c
+++ b/intern/ghost/test/multitest/EventToBuf.c
@@ -125,7 +125,7 @@ static char *keytype_to_string(GHOST_TKey key) {
K(KeyRightControl);
K(KeyLeftAlt);
K(KeyRightAlt);
- K(KeyCommand);
+ K(KeyOS);
K(KeyCapsLock);
K(KeyNumLock);