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:
authorDalai Felinto <dfelinto@gmail.com>2012-06-28 01:57:33 +0400
committerDalai Felinto <dfelinto@gmail.com>2012-06-28 01:57:33 +0400
commit7016538974b546464b9b38330d7f33c170d3977e (patch)
tree459f8714cc644b68f5b0cc4feb9ab8c855c507c8 /source/gameengine/GameLogic
parenta09feb738627abfce71026352214e1512d40bcb8 (diff)
bge.logic.keyboard.getClipboard() and .setClipboard methods
the idea of using methods instead of attributes is to avoid users abusing of the system calls. Thanks Campbell Barton for reviewing and small corrections
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt1
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.cpp21
-rw-r--r--source/gameengine/GameLogic/SConscript2
3 files changed, 23 insertions, 1 deletions
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 64f198f72a0..e511704c7f4 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -32,6 +32,7 @@ set(INC
../../../intern/container
../../../intern/moto/include
../../../intern/string
+ ../../../intern/ghost
)
set(INC_SYS
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
index 46c43b5e339..f83b23f510c 100644
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
@@ -28,6 +28,8 @@
#include "SCA_PythonKeyboard.h"
#include "SCA_IInputDevice.h"
+#include "GHOST_C-api.h"
+
/* ------------------------------------------------------------------------- */
/* Native functions */
/* ------------------------------------------------------------------------- */
@@ -55,6 +57,23 @@ SCA_PythonKeyboard::~SCA_PythonKeyboard()
/* Python functions */
/* ------------------------------------------------------------------------- */
+/* clipboard */
+static PyObject* gPyGetClipboard(PyObject* args, PyObject* kwds)
+{
+ char *buf = (char *)GHOST_getClipboard(0);
+ return PyUnicode_FromString(buf?buf:"");
+}
+
+static PyObject* gPySetClipboard(PyObject* args, PyObject* value)
+{
+ char* buf;
+ if (!PyArg_ParseTuple(value,"s:setClipboard",&buf))
+ Py_RETURN_NONE;
+
+ GHOST_putClipboard((GHOST_TInt8 *)buf, 0);
+ Py_RETURN_NONE;
+}
+
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_PythonKeyboard::Type = {
PyVarObject_HEAD_INIT(NULL, 0)
@@ -79,6 +98,8 @@ PyTypeObject SCA_PythonKeyboard::Type = {
};
PyMethodDef SCA_PythonKeyboard::Methods[] = {
+ {"getClipboard", (PyCFunction) gPyGetClipboard, METH_VARARGS, "getCliboard doc"},
+ {"setClipboard", (PyCFunction) gPySetClipboard, METH_VARARGS, "setCliboard doc"},
{NULL,NULL} //Sentinel
};
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index e33169bada7..da3c0fadb51 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -3,7 +3,7 @@ Import ('env')
sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp')
-incs = '. #/intern/string #intern/container'
+incs = '. #/intern/string #intern/container #intern/ghost'
incs += ' #/source/gameengine/Expressions #/intern/moto/include'
incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph'
incs += ' #/source/blender/blenlib'