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/GameLogic
parentc02c2dfdd911fd1c92236e810f26da13f79cf8a5 (diff)
Fix T38110: GameEngine keyboard sensor ignores unicode characters
Diffstat (limited to 'source/gameengine/GameLogic')
-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
3 files changed, 26 insertions, 26 deletions
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.