From bfa38b51663d59cfaec7aa469565c09a4ec05275 Mon Sep 17 00:00:00 2001 From: Vinzenz Feenstra Date: Wed, 26 Feb 2014 15:47:22 +0100 Subject: Fix string version of begins_with Signed-off-by: Vinzenz Feenstra --- core/ustring.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/ustring.cpp b/core/ustring.cpp index b0f06c6ab6..2384ce5bd6 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2491,19 +2491,21 @@ bool String::begins_with(const String& p_string) const { const CharType *src=&p_string[0]; const CharType *str=&operator[](0); - for (int i=0;i Date: Wed, 26 Feb 2014 16:18:05 +0100 Subject: Adding unit tests for begins_with Signed-off-by: Vinzenz Feenstra --- bin/tests/test_string.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp index 78fb9a9ddb..66238b066d 100644 --- a/bin/tests/test_string.cpp +++ b/bin/tests/test_string.cpp @@ -479,6 +479,36 @@ bool test_26() { return captures.size(); }; +struct test_27_data { + char const * data; + char const * begin; + bool expected; +}; + +bool test_27() { + + OS::get_singleton()->print("\n\nTest 26: begins_with\n"); + test_27_data tc[] = { + {"res://foobar", "res://", true}, + {"res", "res://", false}, + {"abc", "abc", true} + }; + size_t count = sizeof(tc) / sizeof(tc[0]); + bool state = true; + for (size_t i = 0;state && i < count; ++i) { + String s = tc[i].data; + state = s.begins_with(tc[i].begin) == tc[i].expected; + if (state) { + String sb = tc[i].begin; + state = s.begins_with(sb) == tc[i].expected; + } + if (!state) { + OS::get_singleton()->print("\n\t Failure on:\n\t\tstring: ", tc[i].data, "\n\t\tbegin: ", tc[i].begin, "\n\t\texpected: ", tc[i].expected ? "true" : "false", "\n"); + } + }; + return state; +}; + typedef bool (*TestFunc)(void); TestFunc test_funcs[] = { @@ -509,6 +539,7 @@ TestFunc test_funcs[] = { test_24, test_25, test_26, + test_27, 0 }; -- cgit v1.2.3 From 9593e9ddae32349bb08485a6fcdb30e69ea3b825 Mon Sep 17 00:00:00 2001 From: marynate Date: Thu, 27 Feb 2014 17:24:11 +0800 Subject: Export linear/angular velocity sleep threshold;Change default linear velocity sleep threshold to 0.1;Fixed type treshold --- servers/physics/space_sw.cpp | 69 ++++++++++++++++++++++---------------------- servers/physics/space_sw.h | 64 ++++++++++++++++++++-------------------- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index ca3aa7e1f5..ad86a62280 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -1,31 +1,32 @@ -/*************************************************************************/ -/* space_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ +/*************************************************************************/ +/* space_sw.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "globals.h" #include "space_sw.h" #include "collision_solver_sw.h" #include "physics_server_sw.h" @@ -351,8 +352,8 @@ void SpaceSW::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) { case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius=p_value; break; case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation=p_value; break; case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration=p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_treshold=p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_treshold=p_value; break; + case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_threshold=p_value; break; + case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_threshold=p_value; break; case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep=p_value; break; case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio=p_value; break; case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias=p_value; break; @@ -366,8 +367,8 @@ real_t SpaceSW::get_param(PhysicsServer::SpaceParameter p_param) const { case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_treshold; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_treshold; + case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_threshold; + case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_threshold; case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio; case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; @@ -404,8 +405,8 @@ SpaceSW::SpaceSW() { contact_max_allowed_penetration= 0.01; constraint_bias = 0.01; - body_linear_velocity_sleep_treshold=0.01; - body_angular_velocity_sleep_treshold=(8.0 / 180.0 * Math_PI); + body_linear_velocity_sleep_threshold=GLOBAL_DEF("physics/sleep_threshold_linear",0.1); + body_angular_velocity_sleep_threshold=GLOBAL_DEF("physics/sleep_threshold_angular", (8.0 / 180.0 * Math_PI) ); body_time_to_sleep=0.5; body_angular_velocity_damp_ratio=10; diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 202c7ccbd2..cec1053400 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -1,31 +1,31 @@ -/*************************************************************************/ -/* space_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ +/*************************************************************************/ +/* space_sw.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef SPACE_SW_H #define SPACE_SW_H @@ -87,8 +87,8 @@ class SpaceSW { CollisionObjectSW *intersection_query_results[INTERSECTION_QUERY_MAX]; int intersection_query_subindex_results[INTERSECTION_QUERY_MAX]; - float body_linear_velocity_sleep_treshold; - float body_angular_velocity_sleep_treshold; + float body_linear_velocity_sleep_threshold; + float body_angular_velocity_sleep_threshold; float body_time_to_sleep; float body_angular_velocity_damp_ratio; @@ -129,8 +129,8 @@ public: _FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; } _FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; } _FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; } - _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_treshold; } - _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_treshold; } + _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_threshold; } + _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_threshold; } _FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; } _FORCE_INLINE_ real_t get_body_angular_velocity_damp_ratio() const { return body_angular_velocity_damp_ratio; } -- cgit v1.2.3 From 3985660ca441a339c6dee7076c6186f107e3c06a Mon Sep 17 00:00:00 2001 From: marynate Date: Thu, 27 Feb 2014 21:39:31 +0800 Subject: Fix LineEdit select method binding --- scene/gui/line_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ad1b7fd66b..baa163558a 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -786,7 +786,7 @@ void LineEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_editable"),&LineEdit::is_editable); ObjectTypeDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret); ObjectTypeDB::bind_method(_MD("is_secret"),&LineEdit::is_secret); - ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::is_secret,DEFVAL(0),DEFVAL(-1)); + ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1)); ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) ); ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) ); -- cgit v1.2.3 From 8fb19e58433d5b132590b804a7a573f5e616f745 Mon Sep 17 00:00:00 2001 From: marynate Date: Thu, 27 Feb 2014 22:16:00 +0800 Subject: Auto select custom property value field when pop up, user can start typing to change value right away. --- scene/gui/line_edit.cpp | 5 ++++ tools/editor/property_editor.cpp | 53 +++++++++++++++++++++++++++++++++++++++- tools/editor/property_editor.h | 2 ++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ad1b7fd66b..bd19adf079 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -748,6 +748,11 @@ bool LineEdit::is_secret() const { void LineEdit::select(int p_from, int p_to) { + if (p_from==0 && p_to==0) { + selection_clear(); + return; + } + int len = text.length(); if (p_from<0) p_from=0; diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 6b34e3f555..1cce161d08 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -51,7 +51,7 @@ void CustomPropertyEditor::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v ); }*/ - } + } } @@ -1397,6 +1397,53 @@ void CustomPropertyEditor::_modified(String p_string) { updating=false; } +void CustomPropertyEditor::_focus_enter() { + switch(type) { + case Variant::REAL: + case Variant::STRING: + case Variant::VECTOR2: + case Variant::RECT2: + case Variant::VECTOR3: + case Variant::PLANE: + case Variant::QUAT: + case Variant::_AABB: + case Variant::MATRIX32: + case Variant::MATRIX3: + case Variant::TRANSFORM: { + for (int i=0;ihas_focus()) { + value_editor[i]->select_all(); + break; + } + } + } break; + default: {} + } + +} + +void CustomPropertyEditor::_focus_exit() { + switch(type) { + case Variant::REAL: + case Variant::STRING: + case Variant::VECTOR2: + case Variant::RECT2: + case Variant::VECTOR3: + case Variant::PLANE: + case Variant::QUAT: + case Variant::_AABB: + case Variant::MATRIX32: + case Variant::MATRIX3: + case Variant::TRANSFORM: { + for (int i=0;iselect(0, 0); + } + } break; + default: {} + } + +} + void CustomPropertyEditor::config_action_buttons(const List& p_strings) { int w=100; @@ -1456,6 +1503,8 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns,int void CustomPropertyEditor::_bind_methods() { + ObjectTypeDB::bind_method("_focus_enter", &CustomPropertyEditor::_focus_enter); + ObjectTypeDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit); ObjectTypeDB::bind_method("_modified",&CustomPropertyEditor::_modified); ObjectTypeDB::bind_method("_scroll_modified",&CustomPropertyEditor::_scroll_modified); ObjectTypeDB::bind_method("_action_pressed",&CustomPropertyEditor::_action_pressed); @@ -1487,6 +1536,8 @@ CustomPropertyEditor::CustomPropertyEditor() { value_editor[i]->hide(); value_label[i]->hide(); value_editor[i]->connect("text_entered", this,"_modified"); + value_editor[i]->connect("focus_enter", this, "_focus_enter"); + value_editor[i]->connect("focus_exit", this, "_focus_exit"); } for(int i=0;i<4;i++) { diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index fc0330c25d..7ee14679c1 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -105,6 +105,8 @@ class CustomPropertyEditor : public Popup { void _file_selected(String p_file); void _scroll_modified(double p_value); void _modified(String p_string); + void _focus_enter(); + void _focus_exit(); void _action_pressed(int p_which); void _type_create_selected(int p_idx); -- cgit v1.2.3 From 9d463a89144c1623fba7125c023623eac5229dff Mon Sep 17 00:00:00 2001 From: mogemimi Date: Wed, 5 Mar 2014 23:09:41 +0900 Subject: Fix if statement with empty body. --- modules/multiscript/register_types.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/multiscript/register_types.cpp b/modules/multiscript/register_types.cpp index 4b25656723..2f2fb53c40 100644 --- a/modules/multiscript/register_types.cpp +++ b/modules/multiscript/register_types.cpp @@ -27,6 +27,7 @@ void register_multiscript_types() { } void unregister_multiscript_types() { - if (script_multi_script); + if (script_multi_script) { memdelete(script_multi_script); + } } -- cgit v1.2.3 From 141b3135954737ee5be5ad2c7371796d20940719 Mon Sep 17 00:00:00 2001 From: bibby Date: Wed, 5 Mar 2014 07:53:33 -0800 Subject: Closes bb-code tags, allowing make_doc.sh to finish --- .gitignore | 3 +++ doc/base/classes.xml | 4 ++-- doc/make_doc.sh | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) mode change 100644 => 100755 doc/make_doc.sh diff --git a/.gitignore b/.gitignore index de9eed200a..96f7a6ea91 100644 --- a/.gitignore +++ b/.gitignore @@ -151,6 +151,9 @@ AutoTest.Net/ # Installshield output folder [Ee]xpress/ +# dumpdoc generated files +doc/html/class_list + # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 46bc8997ff..25278f2444 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -20966,7 +20966,7 @@ - Set the body linear velocity. Can be used sporadically, but[b] DONT SET THIS IN EVERY FRAME [b], because physics may be running in another thread and definitely runs at a different granularity. Use [_integrate_forces] as your process loop if you want to have precise control of the body state. + Set the body linear velocity. Can be used sporadically, but[b] DONT SET THIS IN EVERY FRAME [/b], because physics may be running in another thread and definitely runs at a different granularity. Use [_integrate_forces] as your process loop if you want to have precise control of the body state. @@ -20980,7 +20980,7 @@ - Set the body angular velocity. Can be used sporadically, but[b] DONT SET THIS IN EVERY FRAME [b], because physics may be running in another thread and definitely runs at a different granularity. Use [_integrate_forces] as your process loop if you want to have precise control of the body state. + Set the body angular velocity. Can be used sporadically, but[b] DONT SET THIS IN EVERY FRAME [/b], because physics may be running in another thread and definitely runs at a different granularity. Use [_integrate_forces] as your process loop if you want to have precise control of the body state. diff --git a/doc/make_doc.sh b/doc/make_doc.sh old mode 100644 new mode 100755 index aa9b47cd46..a76f568bfc --- a/doc/make_doc.sh +++ b/doc/make_doc.sh @@ -1,5 +1,17 @@ #! /bin/bash -cd html/class_list -python ../../../tools/docdump/makehtml.py -multipage ../../base/classes.xml -cd ../.. +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +godotHome=$(dirname "$here") +docTarget=${here}/html/class_list +toolsRoot=${godotHome}/tools + +throw() { + echo "$@" >&2 + exit 1 +} + +[ -d "$docTarget" ] || mkdir -p "$docTarget" || throw "Could not create doc target $docTarget" + +cd "$docTarget" +python ${toolsRoot}/docdump/makehtml.py -multipage ${here}/base/classes.xml +cd "$here" -- cgit v1.2.3 From 3ba00567c5a033625bd5789fcd83056c06edb300 Mon Sep 17 00:00:00 2001 From: sasori Date: Wed, 5 Mar 2014 18:52:57 +0100 Subject: Solved bug to select external editor url https://github.com/okamstudio/godot/issues/145 --- tools/editor/plugins/script_editor_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 1a17916394..a01565a046 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1507,7 +1507,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_FILE)); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("external_editor/exec_flags",""); } -- cgit v1.2.3 From 76b1d421f6ddbe8856b40dcec8fc468e6dc043d6 Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Thu, 6 Mar 2014 20:46:15 +0100 Subject: Addinf basic makefile to support many C/C++ IDEs out there Make file is configured by default to act identically as a default SCons build. Baseic actions such as all and clean will be supported by default by quite all IDE for building and rebuilding. Additionaly you can configure your targets for release, debug or profile mode. --- makefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000000..d24bd0cd32 --- /dev/null +++ b/makefile @@ -0,0 +1,30 @@ +#*************************************************************************/ +#* This file is part of: */ +#* GODOT ENGINE */ +#* http://www.godotengine.org */ +#*************************************************************************/ +# Simple makefile to give support for external C/C++ IDEs */ +#*************************************************************************/ + +# Default build +all: debug + +# Release Build +release: + scons target="release" bin/godot + +# Profile Build +profile: + scons target="profile" bin/godot + +# Debug Build +debug: + # Debug information (code size gets severely affected): + # g: Default (same as g2) + # g0: no debug info + # g1: minimal info + # g3: maximal info + scons target="debug" CCFLAGS="-g" bin/godot + +clean: + scons -c bin/godot -- cgit v1.2.3 From 12a3989cd7b645f271c8b297a09cb0a4a7d8d2d4 Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Fri, 7 Mar 2014 20:20:06 +0100 Subject: Speed build time up by 6 using multiple jobs Adding aggresive build mode that spawns num_core+1 jobs. This speeds up build time by 6. On my 8 core machine I'm down from 6m:16s to 1m:34s. --- SConstruct | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SConstruct b/SConstruct index ed65f2b89f..1b4ee5ab96 100644 --- a/SConstruct +++ b/SConstruct @@ -6,6 +6,13 @@ import os.path import glob import sys import methods +import multiprocessing + +# Enable aggresive compile mode if building on amulti core box +if ARGUMENTS.get('spawn_jobs', 'yes') == 'yes': + NUM_JOBS = multiprocessing.cpu_count() + if NUM_JOBS > 1: + SetOption('num_jobs', multiprocessing.cpu_count()+1) methods.update_version() -- cgit v1.2.3 From 1fd08ad1ac543830bc908d5caa34d7f5371b26c1 Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Fri, 7 Mar 2014 20:31:17 +0100 Subject: Fixed typo --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 1b4ee5ab96..2b83cb67cf 100644 --- a/SConstruct +++ b/SConstruct @@ -8,7 +8,7 @@ import sys import methods import multiprocessing -# Enable aggresive compile mode if building on amulti core box +# Enable aggresive compile mode if building on a multi core box if ARGUMENTS.get('spawn_jobs', 'yes') == 'yes': NUM_JOBS = multiprocessing.cpu_count() if NUM_JOBS > 1: -- cgit v1.2.3 From f1b1a38af95c28e8b08e97ca25cc7cf638ef6da3 Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Sat, 8 Mar 2014 18:50:24 +0100 Subject: Do not set number of jobs if already specified --- SConstruct | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 2b83cb67cf..a9739ca604 100644 --- a/SConstruct +++ b/SConstruct @@ -9,10 +9,13 @@ import methods import multiprocessing # Enable aggresive compile mode if building on a multi core box -if ARGUMENTS.get('spawn_jobs', 'yes') == 'yes': +# only is we have not set the number of jobs already or we do +# not want it +if ARGUMENTS.get('spawn_jobs', 'yes') == 'yes' and \ + int(GetOption('num_jobs')) <= 1: NUM_JOBS = multiprocessing.cpu_count() if NUM_JOBS > 1: - SetOption('num_jobs', multiprocessing.cpu_count()+1) + SetOption('num_jobs', NUM_JOBS+1) methods.update_version() -- cgit v1.2.3 From 5634da99342deb17ffa3253cd5bf1494bec65001 Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Sat, 8 Mar 2014 20:44:18 +0100 Subject: Adding CodeLite and KDE files to .gitignore --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index abe1a234f5..8c36422675 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,11 @@ ipch/ *.vsp *.vspx +# CodeLite project files +*.project +*.workspace +*.codelite + # TFS 2012 Local Workspace $tf/ @@ -198,6 +203,9 @@ ClientBin/ *.publishsettings node_modules/ +# KDE +.directory + # RIA/Silverlight projects Generated_Code/ -- cgit v1.2.3 From caa1586480bb9105a43e6790a9025c931af7452f Mon Sep 17 00:00:00 2001 From: Moritz Wundke Date: Sat, 8 Mar 2014 20:46:04 +0100 Subject: Adding CodeLite hidden folder to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8c36422675..dc7b118c79 100644 --- a/.gitignore +++ b/.gitignore @@ -119,7 +119,7 @@ ipch/ # CodeLite project files *.project *.workspace -*.codelite +.codelite/ # TFS 2012 Local Workspace $tf/ -- cgit v1.2.3 From 0552b76475bcc09fcbe33a0ebeedcc84158c7ea0 Mon Sep 17 00:00:00 2001 From: marynate Date: Fri, 21 Feb 2014 19:00:23 +0800 Subject: Convert windows main entry arguments to UTF8; Set locale to system default for locale-awared console output; memery clearnup --- platform/windows/godot_win.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 2999a9beae..ddfadf98ca 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -29,6 +29,7 @@ #include "os_windows.h" #include "main/main.h" #include +#include PCHAR* CommandLineToArgvA( @@ -114,15 +115,45 @@ PCHAR* return argv; } +char* mb_to_utf8(const char* mbs) { + int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); + if (wlen < 0) + wlen = 0; + wchar_t *wbuf = new wchar_t[wlen + 1]; + MultiByteToWideChar(CP_ACP,0,mbs,-1,wbuf,wlen); + wbuf[wlen]=0; + + int ulen = WideCharToMultiByte(CP_UTF8,0,wbuf,-1,NULL,0,NULL,NULL); + if (ulen < 0) + ulen = 0; + char * ubuf = new char[ulen + 1]; + WideCharToMultiByte(CP_UTF8,0,wbuf,-1,ubuf,ulen,NULL,NULL); + ubuf[ulen] = 0; + return ubuf; +} + int main(int argc, char** argv) { OS_Windows os(NULL); - Main::setup(argv[0], argc - 1, &argv[1]); + setlocale(LC_CTYPE, ""); + + char ** argv_utf8 = new char*[argc]; + for(int i=0; i Date: Fri, 21 Feb 2014 19:48:04 +0800 Subject: remove unnecessary error check when converting ascii to unicode --- platform/windows/godot_win.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index ddfadf98ca..fa573b9421 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -116,16 +116,13 @@ PCHAR* } char* mb_to_utf8(const char* mbs) { - int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); - if (wlen < 0) - wlen = 0; + + int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); // returns 0 if failed wchar_t *wbuf = new wchar_t[wlen + 1]; MultiByteToWideChar(CP_ACP,0,mbs,-1,wbuf,wlen); wbuf[wlen]=0; int ulen = WideCharToMultiByte(CP_UTF8,0,wbuf,-1,NULL,0,NULL,NULL); - if (ulen < 0) - ulen = 0; char * ubuf = new char[ulen + 1]; WideCharToMultiByte(CP_UTF8,0,wbuf,-1,ubuf,ulen,NULL,NULL); ubuf[ulen] = 0; -- cgit v1.2.3 From 1be5d6f665b51cb0d1532971783345c5e81d4638 Mon Sep 17 00:00:00 2001 From: marynate Date: Tue, 11 Mar 2014 09:40:37 +0800 Subject: Fix Compression bug: wrong premature return. --- core/io/compression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 67ba5de0fa..ea2f5d2d9c 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -55,7 +55,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,M strm.zfree = zipio_free; strm.opaque = Z_NULL; int err = deflateInit(&strm,Z_DEFAULT_COMPRESSION); - if (err==Z_OK) + if (err!=Z_OK) return -1; strm.avail_in=p_src_size; @@ -93,7 +93,7 @@ int Compression::get_max_compressed_buffer_size(int p_src_size,Mode p_mode){ strm.zfree = zipio_free; strm.opaque = Z_NULL; int err = deflateInit(&strm,Z_DEFAULT_COMPRESSION); - if (err==Z_OK) + if (err!=Z_OK) return -1; int aout = deflateBound(&strm,p_src_size); deflateEnd(&strm); -- cgit v1.2.3 From 101112d6fddee3d6dc4abd8b3f43de24a91cb0a7 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 11 Mar 2014 13:21:18 +0800 Subject: fix-multi-char-ime-input-chinese --- platform/windows/os_windows.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 090fe64b19..801bb9332a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -608,6 +608,28 @@ void OS_Windows::process_key_events() { switch(ke.uMsg) { case WM_CHAR: { + if ((i==0 && ke.uMsg==WM_CHAR) || (i>0 && key_event_buffer[i-1].uMsg==WM_CHAR)) + { + InputEvent event; + event.type=InputEvent::KEY; + event.ID=++last_id; + InputEventKey &k=event.key; + + + k.mod=ke.mod_state; + k.pressed=true; + k.scancode=KeyMappingWindows::get_keysym(ke.wParam); + k.unicode=ke.wParam; + if (k.unicode && gr_mem) { + k.mod.alt=false; + k.mod.control=false; + } + + if (k.unicode<32) + k.unicode=0; + + input->parse_input_event(event); + } //do nothing } break; -- cgit v1.2.3 From cde48d0c9c16867edbb4fc4e3c186933564b6da0 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 11 Mar 2014 13:30:33 +0800 Subject: fix gdscript path parse error --- modules/gdscript/gd_parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index fb4f56aa8f..f962f8c5fb 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -215,6 +215,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ String path = tokenizer->get_token_constant(); if (!path.is_abs_path() && base_path!="") path=base_path+"/"+path; + path = path.replace("///","//"); Ref res = ResourceLoader::load(path); if (!res.is_valid()) { -- cgit v1.2.3 From 87fd1532159c18efc06524f2715ed74b3e32ddee Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 11 Mar 2014 13:38:30 +0800 Subject: fixed editor NodePath property --- tools/editor/editor_node.h | 2 ++ tools/editor/scene_tree_editor.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 87f17247c3..e35467e788 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -410,6 +410,8 @@ public: static void add_editor_plugin(EditorPlugin *p_editor); static void remove_editor_plugin(EditorPlugin *p_editor); + static EditorNode * get_singleton() { return singleton; } + void edit_node(Node *p_node); void edit_resource(const Ref& p_resource); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 89b7e54195..1d2c864c99 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -706,7 +706,8 @@ void SceneTreeDialog::_cancel() { void SceneTreeDialog::_select() { if (tree->get_selected()) { - emit_signal("selected",tree->get_selected()->get_path()); + Node *scene = EditorNode::get_singleton()->get_edited_scene(); + emit_signal("selected","/root/" + scene->get_parent()->get_path_to(tree->get_selected())); hide(); } } -- cgit v1.2.3 From 4927acd7ad718cb7b3f720bb48742928393160e3 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 11 Mar 2014 13:57:59 +0800 Subject: export a unicode font may crash because chunks out of range... set MemoryPoolDynamicStatic::MAX_CHUNKS to 65536 --- core/os/memory_pool_dynamic_static.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/memory_pool_dynamic_static.h b/core/os/memory_pool_dynamic_static.h index ce038bc00a..d10cdb3d0a 100644 --- a/core/os/memory_pool_dynamic_static.h +++ b/core/os/memory_pool_dynamic_static.h @@ -38,7 +38,7 @@ class MemoryPoolDynamicStatic : public MemoryPoolDynamic { _THREAD_SAFE_CLASS_ enum { - MAX_CHUNKS=16384 + MAX_CHUNKS=65536 }; -- cgit v1.2.3 From cf9d97018f7d2c89628a651f79551754ea8ea228 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 12 Mar 2014 20:41:09 +0800 Subject: fix android input doe's not work(line edit/text edit) --- .../android/java/src/com/android/godot/Godot.java | 35 ++- .../java/src/com/android/godot/GodotLib.java | 2 +- platform/android/java_glue.cpp | 271 ++++++++++++++++++++- platform/android/java_glue.h | 2 +- 4 files changed, 304 insertions(+), 6 deletions(-) diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index cf1545df82..5260f6149c 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -283,13 +283,44 @@ public class Godot extends Activity implements SensorEventListener return true; } + @Override public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) { + String s = event.getCharacters(); + if (s == null || s.length() == 0) + return super.onKeyMultiple(inKeyCode, repeatCount, event); + + final char[] cc = s.toCharArray(); + int cnt = 0; + for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0); + if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event); + final Activity me = this; + queueEvent(new Runnable() { + // This method will be called on the rendering thread: + public void run() { + for (int i = 0, n = cc.length; i < n; i++) { + int keyCode; + if ((keyCode = cc[i]) != 0) { + // Simulate key down and up... + GodotLib.key(0, keyCode, true); + GodotLib.key(0, keyCode, false); + } + } + } + }); + return true; + } + + private void queueEvent(Runnable runnable) { + // TODO Auto-generated method stub + + } + @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - GodotLib.key(event.getUnicodeChar(0), false); + GodotLib.key(keyCode, event.getUnicodeChar(0), false); return super.onKeyUp(keyCode, event); }; @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - GodotLib.key(event.getUnicodeChar(0), true); + GodotLib.key(keyCode, event.getUnicodeChar(0), true); return super.onKeyDown(keyCode, event); }; diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index f0ec3e97c6..4e6374ed4f 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -51,7 +51,7 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); - public static native void key(int p_unicode_char, boolean p_pressed); + public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed); public static native void focusin(); public static native void focusout(); public static native void audio(); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index cbe17f2f73..0f05992112 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -38,6 +38,7 @@ #include "globals.h" #include "thread_jandroid.h" #include "core/os/keyboard.h" + static OS_Android *os_android=NULL; @@ -924,14 +925,280 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_touch(JNIEnv * env, jobje } -JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject obj, jint ev, jint p_unicode_char, jboolean p_pressed) { +/* + * Android Key codes. + */ +enum { + AKEYCODE_UNKNOWN = 0, + AKEYCODE_SOFT_LEFT = 1, + AKEYCODE_SOFT_RIGHT = 2, + AKEYCODE_HOME = 3, + AKEYCODE_BACK = 4, + AKEYCODE_CALL = 5, + AKEYCODE_ENDCALL = 6, + AKEYCODE_0 = 7, + AKEYCODE_1 = 8, + AKEYCODE_2 = 9, + AKEYCODE_3 = 10, + AKEYCODE_4 = 11, + AKEYCODE_5 = 12, + AKEYCODE_6 = 13, + AKEYCODE_7 = 14, + AKEYCODE_8 = 15, + AKEYCODE_9 = 16, + AKEYCODE_STAR = 17, + AKEYCODE_POUND = 18, + AKEYCODE_DPAD_UP = 19, + AKEYCODE_DPAD_DOWN = 20, + AKEYCODE_DPAD_LEFT = 21, + AKEYCODE_DPAD_RIGHT = 22, + AKEYCODE_DPAD_CENTER = 23, + AKEYCODE_VOLUME_UP = 24, + AKEYCODE_VOLUME_DOWN = 25, + AKEYCODE_POWER = 26, + AKEYCODE_CAMERA = 27, + AKEYCODE_CLEAR = 28, + AKEYCODE_A = 29, + AKEYCODE_B = 30, + AKEYCODE_C = 31, + AKEYCODE_D = 32, + AKEYCODE_E = 33, + AKEYCODE_F = 34, + AKEYCODE_G = 35, + AKEYCODE_H = 36, + AKEYCODE_I = 37, + AKEYCODE_J = 38, + AKEYCODE_K = 39, + AKEYCODE_L = 40, + AKEYCODE_M = 41, + AKEYCODE_N = 42, + AKEYCODE_O = 43, + AKEYCODE_P = 44, + AKEYCODE_Q = 45, + AKEYCODE_R = 46, + AKEYCODE_S = 47, + AKEYCODE_T = 48, + AKEYCODE_U = 49, + AKEYCODE_V = 50, + AKEYCODE_W = 51, + AKEYCODE_X = 52, + AKEYCODE_Y = 53, + AKEYCODE_Z = 54, + AKEYCODE_COMMA = 55, + AKEYCODE_PERIOD = 56, + AKEYCODE_ALT_LEFT = 57, + AKEYCODE_ALT_RIGHT = 58, + AKEYCODE_SHIFT_LEFT = 59, + AKEYCODE_SHIFT_RIGHT = 60, + AKEYCODE_TAB = 61, + AKEYCODE_SPACE = 62, + AKEYCODE_SYM = 63, + AKEYCODE_EXPLORER = 64, + AKEYCODE_ENVELOPE = 65, + AKEYCODE_ENTER = 66, + AKEYCODE_DEL = 67, + AKEYCODE_GRAVE = 68, + AKEYCODE_MINUS = 69, + AKEYCODE_EQUALS = 70, + AKEYCODE_LEFT_BRACKET = 71, + AKEYCODE_RIGHT_BRACKET = 72, + AKEYCODE_BACKSLASH = 73, + AKEYCODE_SEMICOLON = 74, + AKEYCODE_APOSTROPHE = 75, + AKEYCODE_SLASH = 76, + AKEYCODE_AT = 77, + AKEYCODE_NUM = 78, + AKEYCODE_HEADSETHOOK = 79, + AKEYCODE_FOCUS = 80, // *Camera* focus + AKEYCODE_PLUS = 81, + AKEYCODE_MENU = 82, + AKEYCODE_NOTIFICATION = 83, + AKEYCODE_SEARCH = 84, + AKEYCODE_MEDIA_PLAY_PAUSE= 85, + AKEYCODE_MEDIA_STOP = 86, + AKEYCODE_MEDIA_NEXT = 87, + AKEYCODE_MEDIA_PREVIOUS = 88, + AKEYCODE_MEDIA_REWIND = 89, + AKEYCODE_MEDIA_FAST_FORWARD = 90, + AKEYCODE_MUTE = 91, + AKEYCODE_PAGE_UP = 92, + AKEYCODE_PAGE_DOWN = 93, + AKEYCODE_PICTSYMBOLS = 94, + AKEYCODE_SWITCH_CHARSET = 95, + AKEYCODE_BUTTON_A = 96, + AKEYCODE_BUTTON_B = 97, + AKEYCODE_BUTTON_C = 98, + AKEYCODE_BUTTON_X = 99, + AKEYCODE_BUTTON_Y = 100, + AKEYCODE_BUTTON_Z = 101, + AKEYCODE_BUTTON_L1 = 102, + AKEYCODE_BUTTON_R1 = 103, + AKEYCODE_BUTTON_L2 = 104, + AKEYCODE_BUTTON_R2 = 105, + AKEYCODE_BUTTON_THUMBL = 106, + AKEYCODE_BUTTON_THUMBR = 107, + AKEYCODE_BUTTON_START = 108, + AKEYCODE_BUTTON_SELECT = 109, + AKEYCODE_BUTTON_MODE = 110, + + // NOTE: If you add a new keycode here you must also add it to several other files. + // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. +}; + +struct _WinTranslatePair { + + unsigned int keysym; + unsigned int keycode; +}; + + +static _WinTranslatePair _ak_to_keycode[]={ +{ KEY_TAB, AKEYCODE_TAB }, +{ KEY_ENTER, AKEYCODE_ENTER }, +{ KEY_SHIFT, AKEYCODE_SHIFT_LEFT }, +{ KEY_SHIFT, AKEYCODE_SHIFT_RIGHT }, +{ KEY_ALT, AKEYCODE_ALT_LEFT }, +{ KEY_ALT, AKEYCODE_ALT_RIGHT }, +{ KEY_MENU, AKEYCODE_MENU }, +{ KEY_PAUSE, AKEYCODE_MEDIA_PLAY_PAUSE }, +{ KEY_ESCAPE, AKEYCODE_BACK }, +{ KEY_SPACE, AKEYCODE_SPACE }, +{ KEY_PAGEUP, AKEYCODE_PAGE_UP }, +{ KEY_PAGEDOWN, AKEYCODE_PAGE_DOWN }, +{ KEY_HOME, AKEYCODE_HOME },//(0x24) +{ KEY_LEFT, AKEYCODE_DPAD_LEFT }, +{ KEY_UP, AKEYCODE_DPAD_UP }, +{ KEY_RIGHT, AKEYCODE_DPAD_RIGHT }, +{ KEY_DOWN, AKEYCODE_DPAD_DOWN}, +{ KEY_PERIODCENTERED, AKEYCODE_DPAD_CENTER }, +{ KEY_BACKSPACE, AKEYCODE_DEL}, +{ KEY_0, AKEYCODE_0 },////0 key +{ KEY_1, AKEYCODE_1 },////1 key +{ KEY_2, AKEYCODE_2 },////2 key +{ KEY_3, AKEYCODE_3 },////3 key +{ KEY_4, AKEYCODE_4 },////4 key +{ KEY_5, AKEYCODE_5 },////5 key +{ KEY_6, AKEYCODE_6 },////6 key +{ KEY_7, AKEYCODE_7 },////7 key +{ KEY_8, AKEYCODE_8 },////8 key +{ KEY_9, AKEYCODE_9 },////9 key +{ KEY_A, AKEYCODE_A },////A key +{ KEY_B, AKEYCODE_B },////B key +{ KEY_C, AKEYCODE_C },////C key +{ KEY_D, AKEYCODE_D },////D key +{ KEY_E, AKEYCODE_E },////E key +{ KEY_F, AKEYCODE_F },////F key +{ KEY_G, AKEYCODE_G },////G key +{ KEY_H, AKEYCODE_H },////H key +{ KEY_I, AKEYCODE_I },////I key +{ KEY_J, AKEYCODE_J },////J key +{ KEY_K, AKEYCODE_K },////K key +{ KEY_L, AKEYCODE_L },////L key +{ KEY_M, AKEYCODE_M },////M key +{ KEY_N, AKEYCODE_N },////N key +{ KEY_O, AKEYCODE_O },////O key +{ KEY_P, AKEYCODE_P },////P key +{ KEY_Q, AKEYCODE_Q },////Q key +{ KEY_R, AKEYCODE_R },////R key +{ KEY_S, AKEYCODE_S },////S key +{ KEY_T, AKEYCODE_T },////T key +{ KEY_U, AKEYCODE_U },////U key +{ KEY_V, AKEYCODE_V },////V key +{ KEY_W, AKEYCODE_W },////W key +{ KEY_X, AKEYCODE_X },////X key +{ KEY_Y, AKEYCODE_Y },////Y key +{ KEY_Z, AKEYCODE_Z },////Z key +{ KEY_HOMEPAGE, AKEYCODE_EXPLORER}, +{ KEY_LAUNCH0, AKEYCODE_BUTTON_A}, +{ KEY_LAUNCH1, AKEYCODE_BUTTON_B}, +{ KEY_LAUNCH2, AKEYCODE_BUTTON_C}, +{ KEY_LAUNCH3, AKEYCODE_BUTTON_X}, +{ KEY_LAUNCH4, AKEYCODE_BUTTON_Y}, +{ KEY_LAUNCH5, AKEYCODE_BUTTON_Z}, +{ KEY_LAUNCH6, AKEYCODE_BUTTON_L1}, +{ KEY_LAUNCH7, AKEYCODE_BUTTON_R1}, +{ KEY_LAUNCH8, AKEYCODE_BUTTON_L2}, +{ KEY_LAUNCH9, AKEYCODE_BUTTON_R2}, +{ KEY_LAUNCHA, AKEYCODE_BUTTON_THUMBL}, +{ KEY_LAUNCHB, AKEYCODE_BUTTON_THUMBR}, +{ KEY_LAUNCHC, AKEYCODE_BUTTON_START}, +{ KEY_LAUNCHD, AKEYCODE_BUTTON_SELECT}, +{ KEY_LAUNCHE, AKEYCODE_BUTTON_MODE}, +{ KEY_VOLUMEMUTE, AKEYCODE_MUTE}, +{ KEY_VOLUMEDOWN, AKEYCODE_VOLUME_DOWN}, +{ KEY_VOLUMEUP, AKEYCODE_VOLUME_UP}, +{ KEY_BACK, AKEYCODE_MEDIA_REWIND }, +{ KEY_FORWARD, AKEYCODE_MEDIA_FAST_FORWARD }, +{ KEY_MEDIANEXT, AKEYCODE_MEDIA_NEXT }, +{ KEY_MEDIAPREVIOUS, AKEYCODE_MEDIA_PREVIOUS }, +{ KEY_MEDIASTOP, AKEYCODE_MEDIA_STOP }, +{ KEY_PLUS, AKEYCODE_PLUS }, +{ KEY_EQUAL, AKEYCODE_EQUALS},// the '+' key +{ KEY_COMMA, AKEYCODE_COMMA},// the ',' key +{ KEY_MINUS, AKEYCODE_MINUS},// the '-' key +{ KEY_SLASH, AKEYCODE_SLASH},// the '/?' key +{ KEY_BACKSLASH, AKEYCODE_BACKSLASH}, +{ KEY_BRACKETLEFT, AKEYCODE_LEFT_BRACKET}, +{ KEY_BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET}, +{ KEY_UNKNOWN, 0} }; +/* +TODO: map these android key: + AKEYCODE_SOFT_LEFT = 1, + AKEYCODE_SOFT_RIGHT = 2, + AKEYCODE_CALL = 5, + AKEYCODE_ENDCALL = 6, + AKEYCODE_STAR = 17, + AKEYCODE_POUND = 18, + AKEYCODE_POWER = 26, + AKEYCODE_CAMERA = 27, + AKEYCODE_CLEAR = 28, + AKEYCODE_SYM = 63, + AKEYCODE_ENVELOPE = 65, + AKEYCODE_GRAVE = 68, + AKEYCODE_SEMICOLON = 74, + AKEYCODE_APOSTROPHE = 75, + AKEYCODE_AT = 77, + AKEYCODE_NUM = 78, + AKEYCODE_HEADSETHOOK = 79, + AKEYCODE_FOCUS = 80, // *Camera* focus + AKEYCODE_NOTIFICATION = 83, + AKEYCODE_SEARCH = 84, + AKEYCODE_PICTSYMBOLS = 94, + AKEYCODE_SWITCH_CHARSET = 95, +*/ + +static unsigned int android_get_keysym(unsigned int p_code) { + for(int i=0;_ak_to_keycode[i].keysym!=KEY_UNKNOWN;i++) { + + if (_ak_to_keycode[i].keycode==p_code) { + //print_line("outcode: " + _ak_to_keycode[i].keysym); + + return _ak_to_keycode[i].keysym; + } + } + + + return KEY_UNKNOWN; +} + +JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { InputEvent ievent; ievent.type = InputEvent::KEY; ievent.device = 0; int val = p_unicode_char; - ievent.key.scancode = val; + int scancode = android_get_keysym(p_scancode); + ievent.key.scancode = scancode; ievent.key.unicode = val; + ievent.key.pressed = p_pressed; + + print_line("Scancode: " + String::num(p_scancode) + ":" + String::num(ievent.key.scancode) + " Unicode: " + String::num(val)); + + ievent.key.mod.shift=false; + ievent.key.mod.alt=false; + ievent.key.mod.control=false; + ievent.key.echo=false; + if (val == 61448) { ievent.key.scancode = KEY_BACKSPACE; ievent.key.unicode = KEY_BACKSPACE; diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index 4b3c14d0db..a519122726 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -42,7 +42,7 @@ extern "C" { JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_step(JNIEnv * env, jobject obj); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_quit(JNIEnv * env, jobject obj); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_touch(JNIEnv * env, jobject obj, jint ev,jint pointer, jint count, jintArray positions); - JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject obj, jint ev, jint p_unicode_char, jboolean p_pressed); + JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_audio(JNIEnv * env, jobject obj); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_accelerometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_focusin(JNIEnv * env, jobject obj); -- cgit v1.2.3