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:
authorCampbell Barton <ideasman42@gmail.com>2014-01-23 07:58:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-23 07:58:04 +0400
commit3b71cab420c642df30d9f9addee166444ce5b85b (patch)
tree50b3a4dfc9fcbb9473e65d5ab7d78b67c38c423c /source/gameengine
parentc02c2dfdd911fd1c92236e810f26da13f79cf8a5 (diff)
Fix T38110: GameEngine keyboard sensor ignores unicode characters
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp9
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h2
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp3
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h2
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp2
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h2
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.h6
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp44
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp3
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp16
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.h2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp3
14 files changed, 51 insertions, 47 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 2b1c8a10cce..d136131e82f 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -151,8 +151,9 @@ static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWind
while (wmEvent *event= (wmEvent *)win->queue.first) {
short val = 0;
//unsigned short event = 0; //XXX extern_qread(&val);
+ unsigned int unicode = event->utf8_buf[0] ? BLI_str_utf8_as_unicode(event->utf8_buf) : event->ascii;
- if (keyboarddevice->ConvertBlenderEvent(event->type,event->val))
+ if (keyboarddevice->ConvertBlenderEvent(event->type, event->val, unicode))
exitrequested = KX_EXIT_REQUEST_BLENDER_ESC;
/* Coordinate conversion... where
@@ -161,13 +162,13 @@ static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWind
if (event->type == MOUSEMOVE) {
/* Note, not nice! XXX 2.5 event hack */
val = event->x - ar->winrct.xmin;
- mousedevice->ConvertBlenderEvent(MOUSEX, val);
+ mousedevice->ConvertBlenderEvent(MOUSEX, val, 0);
val = ar->winy - (event->y - ar->winrct.ymin) - 1;
- mousedevice->ConvertBlenderEvent(MOUSEY, val);
+ mousedevice->ConvertBlenderEvent(MOUSEY, val, 0);
}
else {
- mousedevice->ConvertBlenderEvent(event->type,event->val);
+ mousedevice->ConvertBlenderEvent(event->type, event->val, 0);
}
BLI_remlink(&win->queue, event);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
index 0ce479cad6f..a936f328545 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
@@ -69,7 +69,7 @@ public:
virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
- virtual bool ConvertBlenderEvent(unsigned short incode,short val)=0;
+ virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)=0;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
index 5917ce40440..ea78d2d389e 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
@@ -91,7 +91,7 @@ void KX_BlenderKeyboardDevice::NextFrame()
* ConvertBlenderEvent translates blender keyboard events into ketsji kbd events
* extra event information is stored, like ramp-mode (just released/pressed)
*/
-bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode, short val)
+bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
{
bool result = false;
@@ -112,6 +112,7 @@ bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode, short
// todo: convert val ??
m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
+ m_eventStatusTables[m_currentTable][kxevent].m_unicode = unicode;
switch (m_eventStatusTables[previousTable][kxevent].m_status)
{
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
index dec70203ecb..10a5b00937d 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
@@ -47,7 +47,7 @@ public:
virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual bool ConvertBlenderEvent(unsigned short incode,short val);
+ virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode);
virtual void NextFrame();
virtual void HookEscape();
private:
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp
index 0cdc10264a5..9df06e83b92 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp
@@ -108,7 +108,7 @@ void KX_BlenderMouseDevice::NextFrame()
* ConvertBlenderEvent translates blender mouse events into ketsji kbd events
* extra event information is stored, like ramp-mode (just released/pressed)
*/
-bool KX_BlenderMouseDevice::ConvertBlenderEvent(unsigned short incode, short val)
+bool KX_BlenderMouseDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
{
bool result = false;
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h
index 8746da83a81..04b78aff05c 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h
@@ -46,7 +46,7 @@ public:
virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual bool ConvertBlenderEvent(unsigned short incode,short val);
+ virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode);
virtual void NextFrame();
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h
index ce7c8650ee5..23346c29601 100644
--- a/source/gameengine/GameLogic/SCA_IInputDevice.h
+++ b/source/gameengine/GameLogic/SCA_IInputDevice.h
@@ -51,15 +51,17 @@ public:
KX_JUSTRELEASED,
};
- SCA_InputEvent(SCA_EnumInputs status=KX_NO_INPUTSTATUS,int eventval=0)
+ SCA_InputEvent(SCA_EnumInputs status=KX_NO_INPUTSTATUS,int eventval=0, int unicode=0)
: m_status(status),
- m_eventval(eventval)
+ m_eventval(eventval),
+ m_unicode(unicode)
{
}
SCA_EnumInputs m_status;
int m_eventval;
+ unsigned int m_unicode;
};
/* Originally from wm_event_types.h, now only used by GameEngine */
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index 7005ea1ba5b..cc203880f94 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -40,6 +40,7 @@
#include "SCA_IInputDevice.h"
extern "C" {
+ #include "BLI_string_utf8.h"
#include "BLI_string_cursor_utf8.h"
}
@@ -331,14 +332,15 @@ bool SCA_KeyboardSensor::Evaluate()
}
-void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
+void SCA_KeyboardSensor::AddToTargetProp(int keyIndex, int unicode)
{
if (IsPrintable(keyIndex)) {
CValue* tprop = GetParent()->GetProperty(m_targetprop);
-
- if (tprop) {
- /* overwrite the old property */
- if (IsDelete(keyIndex)) {
+
+ if (IsDelete(keyIndex)) {
+ /* Make a new property. Deletes can be ignored. */
+ if (tprop) {
+ /* overwrite the old property */
/* strip one char, if possible */
STR_String newprop = tprop->GetText();
int oldlength = newprop.Length();
@@ -352,26 +354,22 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
- } else {
- /* append */
- char pchar = ToCharacter(keyIndex, IsShifted());
- STR_String newprop = tprop->GetText() + pchar;
- CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
- GetParent()->SetProperty(m_targetprop, newstringprop);
- newstringprop->Release();
- }
- } else {
- if (!IsDelete(keyIndex)) {
- /* Make a new property. Deletes can be ignored. */
- char pchar = ToCharacter(keyIndex, IsShifted());
- STR_String newprop = pchar;
- CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
- GetParent()->SetProperty(m_targetprop, newstringprop);
- newstringprop->Release();
}
}
+ else {
+ char utf8_buf[7];
+ size_t utf8_len;
+
+ utf8_len = BLI_str_utf8_from_unicode(unicode, utf8_buf);
+ utf8_buf[utf8_len] = '\0';
+
+ STR_String newprop = tprop ? (tprop->GetText() + utf8_buf) : utf8_buf;
+
+ CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
+ GetParent()->SetProperty(m_targetprop, newstringprop);
+ newstringprop->Release();
+ }
}
-
}
/**
@@ -416,7 +414,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void)
{
if (index < num)
{
- AddToTargetProp(i);
+ AddToTargetProp(i, inevent.m_unicode);
index++;
}
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index c6610d0284e..c9d55280fb7 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -79,7 +79,7 @@ class SCA_KeyboardSensor : public SCA_ISensor
/**
* Adds this key-code to the target prop.
*/
- void AddToTargetProp(int keyIndex);
+ void AddToTargetProp(int keyIndex, int unicode);
/**
* Tests whether shift is pressed.
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
index ecb58eda78e..0821d1d3b23 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
@@ -64,7 +64,7 @@ void GPC_KeyboardDevice::NextFrame()
* ConvertBPEvent translates Windows keyboard events into ketsji kbd events.
* Extra event information is stored, like ramp-mode (just released/pressed)
*/
-bool GPC_KeyboardDevice::ConvertEvent(int incode, int val)
+bool GPC_KeyboardDevice::ConvertEvent(int incode, int val, unsigned int unicode)
{
bool result = false;
@@ -83,6 +83,7 @@ bool GPC_KeyboardDevice::ConvertEvent(int incode, int val)
// todo: convert val ??
m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
+ m_eventStatusTables[m_currentTable][kxevent].m_unicode = unicode ;
switch (m_eventStatusTables[previousTable][kxevent].m_status)
{
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
index c082bc1b82f..d9842a42e0a 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
@@ -82,7 +82,7 @@ public:
return m_reverseKeyTranslateTable[incode];
}
- virtual bool ConvertEvent(int incode, int val);
+ virtual bool ConvertEvent(int incode, int val, unsigned int unicode);
virtual void HookEscape();
};
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
index e38a9e3d6cb..94045d532af 100644
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
@@ -97,19 +97,19 @@ bool GPC_MouseDevice::ConvertButtonEvent(TButtonId button, bool isDown)
switch (button)
{
case buttonLeft:
- result = ConvertEvent(KX_LEFTMOUSE, isDown);
+ result = ConvertEvent(KX_LEFTMOUSE, isDown, 0);
break;
case buttonMiddle:
- result = ConvertEvent(KX_MIDDLEMOUSE, isDown);
+ result = ConvertEvent(KX_MIDDLEMOUSE, isDown, 0);
break;
case buttonRight:
- result = ConvertEvent(KX_RIGHTMOUSE, isDown);
+ result = ConvertEvent(KX_RIGHTMOUSE, isDown, 0);
break;
case buttonWheelUp:
- result = ConvertEvent(KX_WHEELUPMOUSE, isDown);
+ result = ConvertEvent(KX_WHEELUPMOUSE, isDown, 0);
break;
case buttonWheelDown:
- result = ConvertEvent(KX_WHEELDOWNMOUSE, isDown);
+ result = ConvertEvent(KX_WHEELDOWNMOUSE, isDown, 0);
break;
default:
// Should not happen!
@@ -144,16 +144,16 @@ bool GPC_MouseDevice::ConvertMoveEvent(int x, int y)
bool result;
// Convert to local coordinates?
- result = ConvertEvent(KX_MOUSEX, x);
+ result = ConvertEvent(KX_MOUSEX, x, 0);
if (result) {
- result = ConvertEvent(KX_MOUSEY, y);
+ result = ConvertEvent(KX_MOUSEY, y, 0);
}
return result;
}
-bool GPC_MouseDevice::ConvertEvent(KX_EnumInputs kxevent, int eventval)
+bool GPC_MouseDevice::ConvertEvent(KX_EnumInputs kxevent, int eventval, unsigned int unicode)
{
bool result = true;
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
index b092fbd21dd..504df2376bb 100644
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
@@ -99,7 +99,7 @@ protected:
* \param eventval Value for this event.
* \return Indication as to whether the event was processed.
*/
- virtual bool ConvertEvent(KX_EnumInputs kxevent, int eventval);
+ virtual bool ConvertEvent(KX_EnumInputs kxevent, int eventval, unsigned int unicode);
};
#endif /* __GPC_MOUSEDEVICE_H__ */
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index ac96ca097ad..1ce6650831e 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -951,11 +951,12 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown)
{
GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData);
+ unsigned int unicode = keyData->utf8_buf[0] ? BLI_str_utf8_as_unicode(keyData->utf8_buf) : keyData->ascii;
if (m_keyboard->ToNative(keyData->key) == KX_KetsjiEngine::GetExitKey() && !m_keyboard->m_hookesc && !m_isEmbedded) {
m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
}
- m_keyboard->ConvertEvent(keyData->key, isDown);
+ m_keyboard->ConvertEvent(keyData->key, isDown, unicode);
handled = true;
}
return handled;