Refactored Input, create DisplayServer and DisplayServerX11
This commit is contained in:
parent
a2da99f40c
commit
4396e98834
@ -166,6 +166,7 @@ SConscript('math/SCsub')
|
|||||||
SConscript('crypto/SCsub')
|
SConscript('crypto/SCsub')
|
||||||
SConscript('io/SCsub')
|
SConscript('io/SCsub')
|
||||||
SConscript('debugger/SCsub')
|
SConscript('debugger/SCsub')
|
||||||
|
SConscript('input/SCsub')
|
||||||
SConscript('bind/SCsub')
|
SConscript('bind/SCsub')
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/debugger/debugger_marshalls.h"
|
#include "core/debugger/debugger_marshalls.h"
|
||||||
#include "core/debugger/engine_debugger.h"
|
#include "core/debugger/engine_debugger.h"
|
||||||
#include "core/debugger/script_debugger.h"
|
#include "core/debugger/script_debugger.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/script_language.h"
|
#include "core/script_language.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "global_constants.h"
|
#include "global_constants.h"
|
||||||
|
|
||||||
|
#include "core/input/input_event.h"
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#include "core/os/input_event.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
|
|
||||||
|
20
core/input/SCsub
Normal file
20
core/input/SCsub
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
Import('env')
|
||||||
|
|
||||||
|
from platform_methods import run_in_subprocess
|
||||||
|
import input_builders
|
||||||
|
|
||||||
|
|
||||||
|
# Order matters here. Higher index controller database files write on top of lower index database files.
|
||||||
|
controller_databases = ["#core/input/gamecontrollerdb_204.txt", "#core/input/gamecontrollerdb_205.txt", "#core/input/gamecontrollerdb.txt", "#core/input/godotcontrollerdb.txt"]
|
||||||
|
|
||||||
|
env.Depends("#core/input/default_controller_mappings.gen.cpp", controller_databases)
|
||||||
|
env.CommandNoCache("#core/input/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(input_builders.make_default_controller_mappings))
|
||||||
|
|
||||||
|
env.add_source_files(env.core_sources, "*.cpp")
|
||||||
|
|
||||||
|
# Don't warn about duplicate entry here, we need it registered manually for first build,
|
||||||
|
# even if later builds will pick it up twice due to above *.cpp globbing.
|
||||||
|
env.add_source_files(env.core_sources, "#core/input/default_controller_mappings.gen.cpp", warn_duplicates=False)
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* input_default.cpp */
|
/* input.cpp */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -28,15 +28,129 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "input_default.h"
|
#include "input.h"
|
||||||
|
|
||||||
#include "core/input_map.h"
|
#include "core/input/default_controller_mappings.h"
|
||||||
|
#include "core/input/input_map.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "main/default_controller_mappings.h"
|
#include "core/project_settings.h"
|
||||||
#include "scene/resources/texture.h"
|
|
||||||
#include "servers/visual_server.h"
|
|
||||||
|
|
||||||
void InputDefault::SpeedTrack::update(const Vector2 &p_delta_p) {
|
#ifdef TOOLS_ENABLED
|
||||||
|
#include "editor/editor_settings.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Input *Input::singleton = NULL;
|
||||||
|
|
||||||
|
Input *Input::get_singleton() {
|
||||||
|
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::set_mouse_mode(MouseMode p_mode) {
|
||||||
|
ERR_FAIL_INDEX((int)p_mode, 4);
|
||||||
|
OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
Input::MouseMode Input::get_mouse_mode() const {
|
||||||
|
|
||||||
|
return (MouseMode)OS::get_singleton()->get_mouse_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::_bind_methods() {
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &Input::is_action_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &Input::is_action_just_pressed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &Input::get_action_strength);
|
||||||
|
ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
|
||||||
|
ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_guid", "device"), &Input::get_joy_guid);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
|
||||||
|
ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
|
||||||
|
ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
|
||||||
|
ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_gravity"), &Input::get_gravity);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope);
|
||||||
|
//ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want
|
||||||
|
ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
|
||||||
|
ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
|
||||||
|
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_current_cursor_shape"), &Input::get_current_cursor_shape);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
|
||||||
|
ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_use_accumulated_input", "enable"), &Input::set_use_accumulated_input);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_ARROW);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_IBEAM);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_CROSS);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_WAIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_BUSY);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_DRAG);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_VSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_MOVE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HELP);
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
|
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
|
||||||
|
|
||||||
|
String pf = p_function;
|
||||||
|
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
|
||||||
|
|
||||||
|
List<PropertyInfo> pinfo;
|
||||||
|
ProjectSettings::get_singleton()->get_property_list(&pinfo);
|
||||||
|
|
||||||
|
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
||||||
|
const PropertyInfo &pi = E->get();
|
||||||
|
|
||||||
|
if (!pi.name.begins_with("input/"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
||||||
|
r_options->push_back(quote_style + name + quote_style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
|
||||||
|
|
||||||
uint64_t tick = OS::get_singleton()->get_ticks_usec();
|
uint64_t tick = OS::get_singleton()->get_ticks_usec();
|
||||||
uint32_t tdiff = tick - last_tick;
|
uint32_t tdiff = tick - last_tick;
|
||||||
@ -60,26 +174,26 @@ void InputDefault::SpeedTrack::update(const Vector2 &p_delta_p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::SpeedTrack::reset() {
|
void Input::SpeedTrack::reset() {
|
||||||
last_tick = OS::get_singleton()->get_ticks_usec();
|
last_tick = OS::get_singleton()->get_ticks_usec();
|
||||||
speed = Vector2();
|
speed = Vector2();
|
||||||
accum_t = 0;
|
accum_t = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDefault::SpeedTrack::SpeedTrack() {
|
Input::SpeedTrack::SpeedTrack() {
|
||||||
|
|
||||||
min_ref_frame = 0.1;
|
min_ref_frame = 0.1;
|
||||||
max_ref_frame = 0.3;
|
max_ref_frame = 0.3;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_key_pressed(int p_keycode) const {
|
bool Input::is_key_pressed(int p_keycode) const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return keys_pressed.has(p_keycode);
|
return keys_pressed.has(p_keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_mouse_button_pressed(int p_button) const {
|
bool Input::is_mouse_button_pressed(int p_button) const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
|
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
|
||||||
@ -90,18 +204,18 @@ static int _combine_device(int p_value, int p_device) {
|
|||||||
return p_value | (p_device << 20);
|
return p_value | (p_device << 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_joy_button_pressed(int p_device, int p_button) const {
|
bool Input::is_joy_button_pressed(int p_device, int p_button) const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
|
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_action_pressed(const StringName &p_action) const {
|
bool Input::is_action_pressed(const StringName &p_action) const {
|
||||||
|
|
||||||
return action_state.has(p_action) && action_state[p_action].pressed;
|
return action_state.has(p_action) && action_state[p_action].pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_action_just_pressed(const StringName &p_action) const {
|
bool Input::is_action_just_pressed(const StringName &p_action) const {
|
||||||
|
|
||||||
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
||||||
if (!E)
|
if (!E)
|
||||||
@ -114,7 +228,7 @@ bool InputDefault::is_action_just_pressed(const StringName &p_action) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_action_just_released(const StringName &p_action) const {
|
bool Input::is_action_just_released(const StringName &p_action) const {
|
||||||
|
|
||||||
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
||||||
if (!E)
|
if (!E)
|
||||||
@ -127,7 +241,7 @@ bool InputDefault::is_action_just_released(const StringName &p_action) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float InputDefault::get_action_strength(const StringName &p_action) const {
|
float Input::get_action_strength(const StringName &p_action) const {
|
||||||
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
const Map<StringName, Action>::Element *E = action_state.find(p_action);
|
||||||
if (!E)
|
if (!E)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -135,7 +249,7 @@ float InputDefault::get_action_strength(const StringName &p_action) const {
|
|||||||
return E->get().strength;
|
return E->get().strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
float InputDefault::get_joy_axis(int p_device, int p_axis) const {
|
float Input::get_joy_axis(int p_device, int p_axis) const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
int c = _combine_device(p_axis, p_device);
|
int c = _combine_device(p_axis, p_device);
|
||||||
@ -146,13 +260,13 @@ float InputDefault::get_joy_axis(int p_device, int p_axis) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String InputDefault::get_joy_name(int p_idx) {
|
String Input::get_joy_name(int p_idx) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return joy_names[p_idx].name;
|
return joy_names[p_idx].name;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector2 InputDefault::get_joy_vibration_strength(int p_device) {
|
Vector2 Input::get_joy_vibration_strength(int p_device) {
|
||||||
if (joy_vibration.has(p_device)) {
|
if (joy_vibration.has(p_device)) {
|
||||||
return Vector2(joy_vibration[p_device].weak_magnitude, joy_vibration[p_device].strong_magnitude);
|
return Vector2(joy_vibration[p_device].weak_magnitude, joy_vibration[p_device].strong_magnitude);
|
||||||
} else {
|
} else {
|
||||||
@ -160,7 +274,7 @@ Vector2 InputDefault::get_joy_vibration_strength(int p_device) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t InputDefault::get_joy_vibration_timestamp(int p_device) {
|
uint64_t Input::get_joy_vibration_timestamp(int p_device) {
|
||||||
if (joy_vibration.has(p_device)) {
|
if (joy_vibration.has(p_device)) {
|
||||||
return joy_vibration[p_device].timestamp;
|
return joy_vibration[p_device].timestamp;
|
||||||
} else {
|
} else {
|
||||||
@ -168,7 +282,7 @@ uint64_t InputDefault::get_joy_vibration_timestamp(int p_device) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float InputDefault::get_joy_vibration_duration(int p_device) {
|
float Input::get_joy_vibration_duration(int p_device) {
|
||||||
if (joy_vibration.has(p_device)) {
|
if (joy_vibration.has(p_device)) {
|
||||||
return joy_vibration[p_device].duration;
|
return joy_vibration[p_device].duration;
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +302,7 @@ static String _hex_str(uint8_t p_byte) {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
|
void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
Joypad js;
|
Joypad js;
|
||||||
@ -230,36 +344,47 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_
|
|||||||
emit_signal("joy_connection_changed", p_idx, p_connected);
|
emit_signal("joy_connection_changed", p_idx, p_connected);
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector3 InputDefault::get_gravity() const {
|
Vector3 Input::get_gravity() const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 InputDefault::get_accelerometer() const {
|
Vector3 Input::get_accelerometer() const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return accelerometer;
|
return accelerometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 InputDefault::get_magnetometer() const {
|
Vector3 Input::get_magnetometer() const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return magnetometer;
|
return magnetometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 InputDefault::get_gyroscope() const {
|
Vector3 Input::get_gyroscope() const {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
return gyroscope;
|
return gyroscope;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::parse_input_event(const Ref<InputEvent> &p_event) {
|
void Input::parse_drop_files(const Vector<String> &p_files) {
|
||||||
|
if (main_loop) {
|
||||||
|
main_loop->drop_files(p_files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Input::parse_notification(int p_notification) {
|
||||||
|
if (main_loop) {
|
||||||
|
main_loop->notification(p_notification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::parse_input_event(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
_parse_input_event_impl(p_event, false);
|
_parse_input_event_impl(p_event, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
|
void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
|
||||||
|
|
||||||
// Notes on mouse-touch emulation:
|
// Notes on mouse-touch emulation:
|
||||||
// - Emulated mouse events are parsed, that is, re-routed to this method, so they make the same effects
|
// - Emulated mouse events are parsed, that is, re-routed to this method, so they make the same effects
|
||||||
@ -442,14 +567,14 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
|
|||||||
main_loop->input_event(p_event);
|
main_loop->input_event(p_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_joy_axis(int p_device, int p_axis, float p_value) {
|
void Input::set_joy_axis(int p_device, int p_axis, float p_value) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
int c = _combine_device(p_axis, p_device);
|
int c = _combine_device(p_axis, p_device);
|
||||||
_joy_axis[c] = p_value;
|
_joy_axis[c] = p_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) {
|
void Input::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
if (p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
|
if (p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
|
||||||
return;
|
return;
|
||||||
@ -462,7 +587,7 @@ void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, flo
|
|||||||
joy_vibration[p_device] = vibration;
|
joy_vibration[p_device] = vibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::stop_joy_vibration(int p_device) {
|
void Input::stop_joy_vibration(int p_device) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
VibrationInfo vibration;
|
VibrationInfo vibration;
|
||||||
vibration.weak_magnitude = 0;
|
vibration.weak_magnitude = 0;
|
||||||
@ -472,68 +597,68 @@ void InputDefault::stop_joy_vibration(int p_device) {
|
|||||||
joy_vibration[p_device] = vibration;
|
joy_vibration[p_device] = vibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::vibrate_handheld(int p_duration_ms) {
|
void Input::vibrate_handheld(int p_duration_ms) {
|
||||||
OS::get_singleton()->vibrate_handheld(p_duration_ms);
|
OS::get_singleton()->vibrate_handheld(p_duration_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_gravity(const Vector3 &p_gravity) {
|
void Input::set_gravity(const Vector3 &p_gravity) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
gravity = p_gravity;
|
gravity = p_gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_accelerometer(const Vector3 &p_accel) {
|
void Input::set_accelerometer(const Vector3 &p_accel) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
accelerometer = p_accel;
|
accelerometer = p_accel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_magnetometer(const Vector3 &p_magnetometer) {
|
void Input::set_magnetometer(const Vector3 &p_magnetometer) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
magnetometer = p_magnetometer;
|
magnetometer = p_magnetometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_gyroscope(const Vector3 &p_gyroscope) {
|
void Input::set_gyroscope(const Vector3 &p_gyroscope) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
gyroscope = p_gyroscope;
|
gyroscope = p_gyroscope;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_main_loop(MainLoop *p_main_loop) {
|
void Input::set_main_loop(MainLoop *p_main_loop) {
|
||||||
main_loop = p_main_loop;
|
main_loop = p_main_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_mouse_position(const Point2 &p_posf) {
|
void Input::set_mouse_position(const Point2 &p_posf) {
|
||||||
|
|
||||||
mouse_speed_track.update(p_posf - mouse_pos);
|
mouse_speed_track.update(p_posf - mouse_pos);
|
||||||
mouse_pos = p_posf;
|
mouse_pos = p_posf;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2 InputDefault::get_mouse_position() const {
|
Point2 Input::get_mouse_position() const {
|
||||||
|
|
||||||
return mouse_pos;
|
return mouse_pos;
|
||||||
}
|
}
|
||||||
Point2 InputDefault::get_last_mouse_speed() const {
|
Point2 Input::get_last_mouse_speed() const {
|
||||||
|
|
||||||
return mouse_speed_track.speed;
|
return mouse_speed_track.speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputDefault::get_mouse_button_mask() const {
|
int Input::get_mouse_button_mask() const {
|
||||||
|
|
||||||
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
|
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::warp_mouse_position(const Vector2 &p_to) {
|
void Input::warp_mouse_position(const Vector2 &p_to) {
|
||||||
|
|
||||||
OS::get_singleton()->warp_mouse_position(p_to);
|
OS::get_singleton()->warp_mouse_position(p_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2i InputDefault::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
|
Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
|
||||||
|
|
||||||
// The relative distance reported for the next event after a warp is in the boundaries of the
|
// The relative distance reported for the next event after a warp is in the boundaries of the
|
||||||
// size of the rect on that axis, but it may be greater, in which case there's not problem as fmod()
|
// size of the rect on that axis, but it may be greater, in which case there's not problem as fmod()
|
||||||
@ -559,10 +684,10 @@ Point2i InputDefault::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_moti
|
|||||||
return rel_warped;
|
return rel_warped;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::iteration(float p_step) {
|
void Input::iteration(float p_step) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::action_press(const StringName &p_action, float p_strength) {
|
void Input::action_press(const StringName &p_action, float p_strength) {
|
||||||
|
|
||||||
Action action;
|
Action action;
|
||||||
|
|
||||||
@ -574,7 +699,7 @@ void InputDefault::action_press(const StringName &p_action, float p_strength) {
|
|||||||
action_state[p_action] = action;
|
action_state[p_action] = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::action_release(const StringName &p_action) {
|
void Input::action_release(const StringName &p_action) {
|
||||||
|
|
||||||
Action action;
|
Action action;
|
||||||
|
|
||||||
@ -586,19 +711,19 @@ void InputDefault::action_release(const StringName &p_action) {
|
|||||||
action_state[p_action] = action;
|
action_state[p_action] = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_emulate_touch_from_mouse(bool p_emulate) {
|
void Input::set_emulate_touch_from_mouse(bool p_emulate) {
|
||||||
|
|
||||||
emulate_touch_from_mouse = p_emulate;
|
emulate_touch_from_mouse = p_emulate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_emulating_touch_from_mouse() const {
|
bool Input::is_emulating_touch_from_mouse() const {
|
||||||
|
|
||||||
return emulate_touch_from_mouse;
|
return emulate_touch_from_mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calling this whenever the game window is focused helps unstucking the "touch mouse"
|
// Calling this whenever the game window is focused helps unstucking the "touch mouse"
|
||||||
// if the OS or its abstraction class hasn't properly reported that touch pointers raised
|
// if the OS or its abstraction class hasn't properly reported that touch pointers raised
|
||||||
void InputDefault::ensure_touch_mouse_raised() {
|
void Input::ensure_touch_mouse_raised() {
|
||||||
|
|
||||||
if (mouse_from_touch_index != -1) {
|
if (mouse_from_touch_index != -1) {
|
||||||
mouse_from_touch_index = -1;
|
mouse_from_touch_index = -1;
|
||||||
@ -617,22 +742,22 @@ void InputDefault::ensure_touch_mouse_raised() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_emulate_mouse_from_touch(bool p_emulate) {
|
void Input::set_emulate_mouse_from_touch(bool p_emulate) {
|
||||||
|
|
||||||
emulate_mouse_from_touch = p_emulate;
|
emulate_mouse_from_touch = p_emulate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputDefault::is_emulating_mouse_from_touch() const {
|
bool Input::is_emulating_mouse_from_touch() const {
|
||||||
|
|
||||||
return emulate_mouse_from_touch;
|
return emulate_mouse_from_touch;
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::CursorShape InputDefault::get_default_cursor_shape() const {
|
Input::CursorShape Input::get_default_cursor_shape() const {
|
||||||
|
|
||||||
return default_shape;
|
return default_shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_default_cursor_shape(CursorShape p_shape) {
|
void Input::set_default_cursor_shape(CursorShape p_shape) {
|
||||||
|
|
||||||
if (default_shape == p_shape)
|
if (default_shape == p_shape)
|
||||||
return;
|
return;
|
||||||
@ -647,19 +772,19 @@ void InputDefault::set_default_cursor_shape(CursorShape p_shape) {
|
|||||||
parse_input_event(mm);
|
parse_input_event(mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::CursorShape InputDefault::get_current_cursor_shape() const {
|
Input::CursorShape Input::get_current_cursor_shape() const {
|
||||||
|
|
||||||
return (Input::CursorShape)OS::get_singleton()->get_cursor_shape();
|
return (Input::CursorShape)OS::get_singleton()->get_cursor_shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
|
void Input::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
|
||||||
if (Engine::get_singleton()->is_editor_hint())
|
if (Engine::get_singleton()->is_editor_hint())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot);
|
OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) {
|
void Input::accumulate_input_event(const Ref<InputEvent> &p_event) {
|
||||||
ERR_FAIL_COND(p_event.is_null());
|
ERR_FAIL_COND(p_event.is_null());
|
||||||
|
|
||||||
if (!use_accumulated_input) {
|
if (!use_accumulated_input) {
|
||||||
@ -672,7 +797,7 @@ void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
accumulated_events.push_back(p_event);
|
accumulated_events.push_back(p_event);
|
||||||
}
|
}
|
||||||
void InputDefault::flush_accumulated_events() {
|
void Input::flush_accumulated_events() {
|
||||||
|
|
||||||
while (accumulated_events.front()) {
|
while (accumulated_events.front()) {
|
||||||
parse_input_event(accumulated_events.front()->get());
|
parse_input_event(accumulated_events.front()->get());
|
||||||
@ -680,12 +805,12 @@ void InputDefault::flush_accumulated_events() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_use_accumulated_input(bool p_enable) {
|
void Input::set_use_accumulated_input(bool p_enable) {
|
||||||
|
|
||||||
use_accumulated_input = p_enable;
|
use_accumulated_input = p_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::release_pressed_events() {
|
void Input::release_pressed_events() {
|
||||||
|
|
||||||
flush_accumulated_events(); // this is needed to release actions strengths
|
flush_accumulated_events(); // this is needed to release actions strengths
|
||||||
|
|
||||||
@ -693,61 +818,13 @@ void InputDefault::release_pressed_events() {
|
|||||||
joy_buttons_pressed.clear();
|
joy_buttons_pressed.clear();
|
||||||
_joy_axis.clear();
|
_joy_axis.clear();
|
||||||
|
|
||||||
for (Map<StringName, InputDefault::Action>::Element *E = action_state.front(); E; E = E->next()) {
|
for (Map<StringName, Input::Action>::Element *E = action_state.front(); E; E = E->next()) {
|
||||||
if (E->get().pressed)
|
if (E->get().pressed)
|
||||||
action_release(E->key());
|
action_release(E->key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDefault::InputDefault() {
|
void Input::joy_button(int p_device, int p_button, bool p_pressed) {
|
||||||
|
|
||||||
use_accumulated_input = true;
|
|
||||||
mouse_button_mask = 0;
|
|
||||||
emulate_touch_from_mouse = false;
|
|
||||||
emulate_mouse_from_touch = false;
|
|
||||||
mouse_from_touch_index = -1;
|
|
||||||
main_loop = NULL;
|
|
||||||
default_shape = CURSOR_ARROW;
|
|
||||||
|
|
||||||
hat_map_default[HAT_UP].type = TYPE_BUTTON;
|
|
||||||
hat_map_default[HAT_UP].index = JOY_DPAD_UP;
|
|
||||||
hat_map_default[HAT_UP].value = 0;
|
|
||||||
|
|
||||||
hat_map_default[HAT_RIGHT].type = TYPE_BUTTON;
|
|
||||||
hat_map_default[HAT_RIGHT].index = JOY_DPAD_RIGHT;
|
|
||||||
hat_map_default[HAT_RIGHT].value = 0;
|
|
||||||
|
|
||||||
hat_map_default[HAT_DOWN].type = TYPE_BUTTON;
|
|
||||||
hat_map_default[HAT_DOWN].index = JOY_DPAD_DOWN;
|
|
||||||
hat_map_default[HAT_DOWN].value = 0;
|
|
||||||
|
|
||||||
hat_map_default[HAT_LEFT].type = TYPE_BUTTON;
|
|
||||||
hat_map_default[HAT_LEFT].index = JOY_DPAD_LEFT;
|
|
||||||
hat_map_default[HAT_LEFT].value = 0;
|
|
||||||
|
|
||||||
fallback_mapping = -1;
|
|
||||||
|
|
||||||
// Parse default mappings.
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
while (DefaultControllerMappings::mappings[i]) {
|
|
||||||
parse_mapping(DefaultControllerMappings::mappings[i++]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides.
|
|
||||||
String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG");
|
|
||||||
if (env_mapping != "") {
|
|
||||||
Vector<String> entries = env_mapping.split("\n");
|
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
|
||||||
if (entries[i] == "")
|
|
||||||
continue;
|
|
||||||
parse_mapping(entries[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
Joypad &joy = joy_names[p_device];
|
Joypad &joy = joy_names[p_device];
|
||||||
@ -786,7 +863,7 @@ void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
|
|||||||
// no event?
|
// no event?
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
|
void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
|
|
||||||
@ -901,7 +978,7 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
|
|||||||
//printf("invalid mapping\n");
|
//printf("invalid mapping\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::joy_hat(int p_device, int p_val) {
|
void Input::joy_hat(int p_device, int p_val) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
const Joypad &joy = joy_names[p_device];
|
const Joypad &joy = joy_names[p_device];
|
||||||
@ -933,7 +1010,7 @@ void InputDefault::joy_hat(int p_device, int p_val) {
|
|||||||
joy_names[p_device].hat_current = p_val;
|
joy_names[p_device].hat_current = p_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
|
void Input::_button_event(int p_device, int p_index, bool p_pressed) {
|
||||||
|
|
||||||
Ref<InputEventJoypadButton> ievent;
|
Ref<InputEventJoypadButton> ievent;
|
||||||
ievent.instance();
|
ievent.instance();
|
||||||
@ -944,7 +1021,7 @@ void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
|
|||||||
parse_input_event(ievent);
|
parse_input_event(ievent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::_axis_event(int p_device, int p_axis, float p_value) {
|
void Input::_axis_event(int p_device, int p_axis, float p_value) {
|
||||||
|
|
||||||
Ref<InputEventJoypadMotion> ievent;
|
Ref<InputEventJoypadMotion> ievent;
|
||||||
ievent.instance();
|
ievent.instance();
|
||||||
@ -955,7 +1032,7 @@ void InputDefault::_axis_event(int p_device, int p_axis, float p_value) {
|
|||||||
parse_input_event(ievent);
|
parse_input_event(ievent);
|
||||||
};
|
};
|
||||||
|
|
||||||
InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
|
Input::JoyEvent Input::_find_to_event(String p_to) {
|
||||||
|
|
||||||
// string names of the SDL buttons in the same order as input_event.h godot buttons
|
// string names of the SDL buttons in the same order as input_event.h godot buttons
|
||||||
static const char *buttons[] = { "a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL };
|
static const char *buttons[] = { "a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL };
|
||||||
@ -993,7 +1070,7 @@ InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InputDefault::parse_mapping(String p_mapping) {
|
void Input::parse_mapping(String p_mapping) {
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
JoyDeviceMapping mapping;
|
JoyDeviceMapping mapping;
|
||||||
@ -1058,7 +1135,7 @@ void InputDefault::parse_mapping(String p_mapping) {
|
|||||||
//printf("added mapping with uuid %ls\n", mapping.uid.c_str());
|
//printf("added mapping with uuid %ls\n", mapping.uid.c_str());
|
||||||
};
|
};
|
||||||
|
|
||||||
void InputDefault::add_joy_mapping(String p_mapping, bool p_update_existing) {
|
void Input::add_joy_mapping(String p_mapping, bool p_update_existing) {
|
||||||
parse_mapping(p_mapping);
|
parse_mapping(p_mapping);
|
||||||
if (p_update_existing) {
|
if (p_update_existing) {
|
||||||
Vector<String> entry = p_mapping.split(",");
|
Vector<String> entry = p_mapping.split(",");
|
||||||
@ -1071,7 +1148,7 @@ void InputDefault::add_joy_mapping(String p_mapping, bool p_update_existing) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::remove_joy_mapping(String p_guid) {
|
void Input::remove_joy_mapping(String p_guid) {
|
||||||
for (int i = map_db.size() - 1; i >= 0; i--) {
|
for (int i = map_db.size() - 1; i >= 0; i--) {
|
||||||
if (p_guid == map_db[i].uid) {
|
if (p_guid == map_db[i].uid) {
|
||||||
map_db.remove(i);
|
map_db.remove(i);
|
||||||
@ -1084,7 +1161,7 @@ void InputDefault::remove_joy_mapping(String p_guid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDefault::set_fallback_mapping(String p_guid) {
|
void Input::set_fallback_mapping(String p_guid) {
|
||||||
|
|
||||||
for (int i = 0; i < map_db.size(); i++) {
|
for (int i = 0; i < map_db.size(); i++) {
|
||||||
if (map_db[i].uid == p_guid) {
|
if (map_db[i].uid == p_guid) {
|
||||||
@ -1095,27 +1172,27 @@ void InputDefault::set_fallback_mapping(String p_guid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Defaults to simple implementation for platforms with a fixed gamepad layout, like consoles.
|
//Defaults to simple implementation for platforms with a fixed gamepad layout, like consoles.
|
||||||
bool InputDefault::is_joy_known(int p_device) {
|
bool Input::is_joy_known(int p_device) {
|
||||||
|
|
||||||
return OS::get_singleton()->is_joy_known(p_device);
|
return OS::get_singleton()->is_joy_known(p_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
String InputDefault::get_joy_guid(int p_device) const {
|
String Input::get_joy_guid(int p_device) const {
|
||||||
return OS::get_singleton()->get_joy_guid(p_device);
|
return OS::get_singleton()->get_joy_guid(p_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
//platforms that use the remapping system can override and call to these ones
|
//platforms that use the remapping system can override and call to these ones
|
||||||
bool InputDefault::is_joy_mapped(int p_device) {
|
bool Input::is_joy_mapped(int p_device) {
|
||||||
int mapping = joy_names[p_device].mapping;
|
int mapping = joy_names[p_device].mapping;
|
||||||
return mapping != -1 ? (mapping != fallback_mapping) : false;
|
return mapping != -1 ? (mapping != fallback_mapping) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String InputDefault::get_joy_guid_remapped(int p_device) const {
|
String Input::get_joy_guid_remapped(int p_device) const {
|
||||||
ERR_FAIL_COND_V(!joy_names.has(p_device), "");
|
ERR_FAIL_COND_V(!joy_names.has(p_device), "");
|
||||||
return joy_names[p_device].uid;
|
return joy_names[p_device].uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array InputDefault::get_connected_joypads() {
|
Array Input::get_connected_joypads() {
|
||||||
Array ret;
|
Array ret;
|
||||||
Map<int, Joypad>::Element *elem = joy_names.front();
|
Map<int, Joypad>::Element *elem = joy_names.front();
|
||||||
while (elem) {
|
while (elem) {
|
||||||
@ -1159,12 +1236,12 @@ static const char *_axes[JOY_AXIS_MAX] = {
|
|||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
String InputDefault::get_joy_button_string(int p_button) {
|
String Input::get_joy_button_string(int p_button) {
|
||||||
ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, "");
|
ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, "");
|
||||||
return _buttons[p_button];
|
return _buttons[p_button];
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputDefault::get_joy_button_index_from_string(String p_button) {
|
int Input::get_joy_button_index_from_string(String p_button) {
|
||||||
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
||||||
if (p_button == _buttons[i]) {
|
if (p_button == _buttons[i]) {
|
||||||
return i;
|
return i;
|
||||||
@ -1173,7 +1250,7 @@ int InputDefault::get_joy_button_index_from_string(String p_button) {
|
|||||||
ERR_FAIL_V(-1);
|
ERR_FAIL_V(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputDefault::get_unused_joy_id() {
|
int Input::get_unused_joy_id() {
|
||||||
for (int i = 0; i < JOYPADS_MAX; i++) {
|
for (int i = 0; i < JOYPADS_MAX; i++) {
|
||||||
if (!joy_names.has(i) || !joy_names[i].connected) {
|
if (!joy_names.has(i) || !joy_names[i].connected) {
|
||||||
return i;
|
return i;
|
||||||
@ -1182,12 +1259,12 @@ int InputDefault::get_unused_joy_id() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
String InputDefault::get_joy_axis_string(int p_axis) {
|
String Input::get_joy_axis_string(int p_axis) {
|
||||||
ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "");
|
ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "");
|
||||||
return _axes[p_axis];
|
return _axes[p_axis];
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputDefault::get_joy_axis_index_from_string(String p_axis) {
|
int Input::get_joy_axis_index_from_string(String p_axis) {
|
||||||
for (int i = 0; i < JOY_AXIS_MAX; i++) {
|
for (int i = 0; i < JOY_AXIS_MAX; i++) {
|
||||||
if (p_axis == _axes[i]) {
|
if (p_axis == _axes[i]) {
|
||||||
return i;
|
return i;
|
||||||
@ -1195,3 +1272,55 @@ int InputDefault::get_joy_axis_index_from_string(String p_axis) {
|
|||||||
}
|
}
|
||||||
ERR_FAIL_V(-1);
|
ERR_FAIL_V(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Input::Input() {
|
||||||
|
|
||||||
|
singleton = this;
|
||||||
|
use_accumulated_input = true;
|
||||||
|
mouse_button_mask = 0;
|
||||||
|
mouse_window = 0;
|
||||||
|
emulate_touch_from_mouse = false;
|
||||||
|
emulate_mouse_from_touch = false;
|
||||||
|
mouse_from_touch_index = -1;
|
||||||
|
main_loop = NULL;
|
||||||
|
default_shape = CURSOR_ARROW;
|
||||||
|
|
||||||
|
hat_map_default[HAT_UP].type = TYPE_BUTTON;
|
||||||
|
hat_map_default[HAT_UP].index = JOY_DPAD_UP;
|
||||||
|
hat_map_default[HAT_UP].value = 0;
|
||||||
|
|
||||||
|
hat_map_default[HAT_RIGHT].type = TYPE_BUTTON;
|
||||||
|
hat_map_default[HAT_RIGHT].index = JOY_DPAD_RIGHT;
|
||||||
|
hat_map_default[HAT_RIGHT].value = 0;
|
||||||
|
|
||||||
|
hat_map_default[HAT_DOWN].type = TYPE_BUTTON;
|
||||||
|
hat_map_default[HAT_DOWN].index = JOY_DPAD_DOWN;
|
||||||
|
hat_map_default[HAT_DOWN].value = 0;
|
||||||
|
|
||||||
|
hat_map_default[HAT_LEFT].type = TYPE_BUTTON;
|
||||||
|
hat_map_default[HAT_LEFT].index = JOY_DPAD_LEFT;
|
||||||
|
hat_map_default[HAT_LEFT].value = 0;
|
||||||
|
|
||||||
|
fallback_mapping = -1;
|
||||||
|
|
||||||
|
// Parse default mappings.
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (DefaultControllerMappings::mappings[i]) {
|
||||||
|
parse_mapping(DefaultControllerMappings::mappings[i++]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides.
|
||||||
|
String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG");
|
||||||
|
if (env_mapping != "") {
|
||||||
|
Vector<String> entries = env_mapping.split("\n");
|
||||||
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
|
if (entries[i] == "")
|
||||||
|
continue;
|
||||||
|
parse_mapping(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* input_default.h */
|
/* input.h */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -28,16 +28,76 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#ifndef INPUT_DEFAULT_H
|
#ifndef INPUT_H
|
||||||
#define INPUT_DEFAULT_H
|
#define INPUT_H
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/object.h"
|
||||||
|
#include "core/os/main_loop.h"
|
||||||
|
#include "core/os/thread_safe.h"
|
||||||
|
|
||||||
class InputDefault : public Input {
|
class Input : public Object {
|
||||||
|
|
||||||
GDCLASS(InputDefault, Input);
|
GDCLASS(Input, Object);
|
||||||
_THREAD_SAFE_CLASS_
|
_THREAD_SAFE_CLASS_
|
||||||
|
|
||||||
|
static Input *singleton;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum MouseMode {
|
||||||
|
MOUSE_MODE_VISIBLE,
|
||||||
|
MOUSE_MODE_HIDDEN,
|
||||||
|
MOUSE_MODE_CAPTURED,
|
||||||
|
MOUSE_MODE_CONFINED
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef CursorShape
|
||||||
|
enum CursorShape {
|
||||||
|
CURSOR_ARROW,
|
||||||
|
CURSOR_IBEAM,
|
||||||
|
CURSOR_POINTING_HAND,
|
||||||
|
CURSOR_CROSS,
|
||||||
|
CURSOR_WAIT,
|
||||||
|
CURSOR_BUSY,
|
||||||
|
CURSOR_DRAG,
|
||||||
|
CURSOR_CAN_DROP,
|
||||||
|
CURSOR_FORBIDDEN,
|
||||||
|
CURSOR_VSIZE,
|
||||||
|
CURSOR_HSIZE,
|
||||||
|
CURSOR_BDIAGSIZE,
|
||||||
|
CURSOR_FDIAGSIZE,
|
||||||
|
CURSOR_MOVE,
|
||||||
|
CURSOR_VSPLIT,
|
||||||
|
CURSOR_HSPLIT,
|
||||||
|
CURSOR_HELP,
|
||||||
|
CURSOR_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum HatMask {
|
||||||
|
HAT_MASK_CENTER = 0,
|
||||||
|
HAT_MASK_UP = 1,
|
||||||
|
HAT_MASK_RIGHT = 2,
|
||||||
|
HAT_MASK_DOWN = 4,
|
||||||
|
HAT_MASK_LEFT = 8,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum HatDir {
|
||||||
|
HAT_UP,
|
||||||
|
HAT_RIGHT,
|
||||||
|
HAT_DOWN,
|
||||||
|
HAT_LEFT,
|
||||||
|
HAT_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JOYPADS_MAX = 16,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct JoyAxis {
|
||||||
|
int min;
|
||||||
|
float value;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
int mouse_button_mask;
|
int mouse_button_mask;
|
||||||
|
|
||||||
Set<int> keys_pressed;
|
Set<int> keys_pressed;
|
||||||
@ -49,6 +109,7 @@ class InputDefault : public Input {
|
|||||||
Vector3 magnetometer;
|
Vector3 magnetometer;
|
||||||
Vector3 gyroscope;
|
Vector3 gyroscope;
|
||||||
Vector2 mouse_pos;
|
Vector2 mouse_pos;
|
||||||
|
int64_t mouse_window;
|
||||||
MainLoop *main_loop;
|
MainLoop *main_loop;
|
||||||
|
|
||||||
struct Action {
|
struct Action {
|
||||||
@ -123,33 +184,6 @@ class InputDefault : public Input {
|
|||||||
|
|
||||||
CursorShape default_shape;
|
CursorShape default_shape;
|
||||||
|
|
||||||
public:
|
|
||||||
enum HatMask {
|
|
||||||
HAT_MASK_CENTER = 0,
|
|
||||||
HAT_MASK_UP = 1,
|
|
||||||
HAT_MASK_RIGHT = 2,
|
|
||||||
HAT_MASK_DOWN = 4,
|
|
||||||
HAT_MASK_LEFT = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum HatDir {
|
|
||||||
HAT_UP,
|
|
||||||
HAT_RIGHT,
|
|
||||||
HAT_DOWN,
|
|
||||||
HAT_LEFT,
|
|
||||||
HAT_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
JOYPADS_MAX = 16,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JoyAxis {
|
|
||||||
int min;
|
|
||||||
float value;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum JoyType {
|
enum JoyType {
|
||||||
TYPE_BUTTON,
|
TYPE_BUTTON,
|
||||||
TYPE_AXIS,
|
TYPE_AXIS,
|
||||||
@ -186,37 +220,48 @@ private:
|
|||||||
List<Ref<InputEvent>> accumulated_events;
|
List<Ref<InputEvent>> accumulated_events;
|
||||||
bool use_accumulated_input;
|
bool use_accumulated_input;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
virtual bool is_key_pressed(int p_keycode) const;
|
static void _bind_methods();
|
||||||
virtual bool is_mouse_button_pressed(int p_button) const;
|
|
||||||
virtual bool is_joy_button_pressed(int p_device, int p_button) const;
|
|
||||||
virtual bool is_action_pressed(const StringName &p_action) const;
|
|
||||||
virtual bool is_action_just_pressed(const StringName &p_action) const;
|
|
||||||
virtual bool is_action_just_released(const StringName &p_action) const;
|
|
||||||
virtual float get_action_strength(const StringName &p_action) const;
|
|
||||||
|
|
||||||
virtual float get_joy_axis(int p_device, int p_axis) const;
|
public:
|
||||||
|
void set_mouse_mode(MouseMode p_mode);
|
||||||
|
MouseMode get_mouse_mode() const;
|
||||||
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
||||||
|
|
||||||
|
static Input *get_singleton();
|
||||||
|
|
||||||
|
bool is_key_pressed(int p_keycode) const;
|
||||||
|
bool is_mouse_button_pressed(int p_button) const;
|
||||||
|
bool is_joy_button_pressed(int p_device, int p_button) const;
|
||||||
|
bool is_action_pressed(const StringName &p_action) const;
|
||||||
|
bool is_action_just_pressed(const StringName &p_action) const;
|
||||||
|
bool is_action_just_released(const StringName &p_action) const;
|
||||||
|
float get_action_strength(const StringName &p_action) const;
|
||||||
|
|
||||||
|
float get_joy_axis(int p_device, int p_axis) const;
|
||||||
String get_joy_name(int p_idx);
|
String get_joy_name(int p_idx);
|
||||||
virtual Array get_connected_joypads();
|
Array get_connected_joypads();
|
||||||
virtual Vector2 get_joy_vibration_strength(int p_device);
|
Vector2 get_joy_vibration_strength(int p_device);
|
||||||
virtual float get_joy_vibration_duration(int p_device);
|
float get_joy_vibration_duration(int p_device);
|
||||||
virtual uint64_t get_joy_vibration_timestamp(int p_device);
|
uint64_t get_joy_vibration_timestamp(int p_device);
|
||||||
void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = "");
|
void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = "");
|
||||||
void parse_joypad_mapping(String p_mapping, bool p_update_existing);
|
void parse_joypad_mapping(String p_mapping, bool p_update_existing);
|
||||||
|
|
||||||
virtual Vector3 get_gravity() const;
|
Vector3 get_gravity() const;
|
||||||
virtual Vector3 get_accelerometer() const;
|
Vector3 get_accelerometer() const;
|
||||||
virtual Vector3 get_magnetometer() const;
|
Vector3 get_magnetometer() const;
|
||||||
virtual Vector3 get_gyroscope() const;
|
Vector3 get_gyroscope() const;
|
||||||
|
|
||||||
virtual Point2 get_mouse_position() const;
|
Point2 get_mouse_position() const;
|
||||||
virtual Point2 get_last_mouse_speed() const;
|
Point2 get_last_mouse_speed() const;
|
||||||
virtual int get_mouse_button_mask() const;
|
int get_mouse_button_mask() const;
|
||||||
|
|
||||||
virtual void warp_mouse_position(const Vector2 &p_to);
|
void warp_mouse_position(const Vector2 &p_to);
|
||||||
virtual Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
|
Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
|
||||||
|
|
||||||
virtual void parse_input_event(const Ref<InputEvent> &p_event);
|
void parse_drop_files(const Vector<String> &p_files);
|
||||||
|
void parse_notification(int p_notification);
|
||||||
|
void parse_input_event(const Ref<InputEvent> &p_event);
|
||||||
|
|
||||||
void set_gravity(const Vector3 &p_gravity);
|
void set_gravity(const Vector3 &p_gravity);
|
||||||
void set_accelerometer(const Vector3 &p_accel);
|
void set_accelerometer(const Vector3 &p_accel);
|
||||||
@ -224,9 +269,9 @@ public:
|
|||||||
void set_gyroscope(const Vector3 &p_gyroscope);
|
void set_gyroscope(const Vector3 &p_gyroscope);
|
||||||
void set_joy_axis(int p_device, int p_axis, float p_value);
|
void set_joy_axis(int p_device, int p_axis, float p_value);
|
||||||
|
|
||||||
virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
|
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
|
||||||
virtual void stop_joy_vibration(int p_device);
|
void stop_joy_vibration(int p_device);
|
||||||
virtual void vibrate_handheld(int p_duration_ms = 500);
|
void vibrate_handheld(int p_duration_ms = 500);
|
||||||
|
|
||||||
void set_main_loop(MainLoop *p_main_loop);
|
void set_main_loop(MainLoop *p_main_loop);
|
||||||
void set_mouse_position(const Point2 &p_posf);
|
void set_mouse_position(const Point2 &p_posf);
|
||||||
@ -237,31 +282,31 @@ public:
|
|||||||
void iteration(float p_step);
|
void iteration(float p_step);
|
||||||
|
|
||||||
void set_emulate_touch_from_mouse(bool p_emulate);
|
void set_emulate_touch_from_mouse(bool p_emulate);
|
||||||
virtual bool is_emulating_touch_from_mouse() const;
|
bool is_emulating_touch_from_mouse() const;
|
||||||
void ensure_touch_mouse_raised();
|
void ensure_touch_mouse_raised();
|
||||||
|
|
||||||
void set_emulate_mouse_from_touch(bool p_emulate);
|
void set_emulate_mouse_from_touch(bool p_emulate);
|
||||||
virtual bool is_emulating_mouse_from_touch() const;
|
bool is_emulating_mouse_from_touch() const;
|
||||||
|
|
||||||
virtual CursorShape get_default_cursor_shape() const;
|
CursorShape get_default_cursor_shape() const;
|
||||||
virtual void set_default_cursor_shape(CursorShape p_shape);
|
void set_default_cursor_shape(CursorShape p_shape);
|
||||||
virtual CursorShape get_current_cursor_shape() const;
|
CursorShape get_current_cursor_shape() const;
|
||||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
|
void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
|
||||||
|
|
||||||
void parse_mapping(String p_mapping);
|
void parse_mapping(String p_mapping);
|
||||||
void joy_button(int p_device, int p_button, bool p_pressed);
|
void joy_button(int p_device, int p_button, bool p_pressed);
|
||||||
void joy_axis(int p_device, int p_axis, const JoyAxis &p_value);
|
void joy_axis(int p_device, int p_axis, const JoyAxis &p_value);
|
||||||
void joy_hat(int p_device, int p_val);
|
void joy_hat(int p_device, int p_val);
|
||||||
|
|
||||||
virtual void add_joy_mapping(String p_mapping, bool p_update_existing = false);
|
void add_joy_mapping(String p_mapping, bool p_update_existing = false);
|
||||||
virtual void remove_joy_mapping(String p_guid);
|
void remove_joy_mapping(String p_guid);
|
||||||
virtual bool is_joy_known(int p_device);
|
bool is_joy_known(int p_device);
|
||||||
virtual String get_joy_guid(int p_device) const;
|
String get_joy_guid(int p_device) const;
|
||||||
|
|
||||||
virtual String get_joy_button_string(int p_button);
|
String get_joy_button_string(int p_button);
|
||||||
virtual String get_joy_axis_string(int p_axis);
|
String get_joy_axis_string(int p_axis);
|
||||||
virtual int get_joy_axis_index_from_string(String p_axis);
|
int get_joy_axis_index_from_string(String p_axis);
|
||||||
virtual int get_joy_button_index_from_string(String p_button);
|
int get_joy_button_index_from_string(String p_button);
|
||||||
|
|
||||||
int get_unused_joy_id();
|
int get_unused_joy_id();
|
||||||
|
|
||||||
@ -269,12 +314,16 @@ public:
|
|||||||
String get_joy_guid_remapped(int p_device) const;
|
String get_joy_guid_remapped(int p_device) const;
|
||||||
void set_fallback_mapping(String p_guid);
|
void set_fallback_mapping(String p_guid);
|
||||||
|
|
||||||
virtual void accumulate_input_event(const Ref<InputEvent> &p_event);
|
void accumulate_input_event(const Ref<InputEvent> &p_event);
|
||||||
virtual void flush_accumulated_events();
|
void flush_accumulated_events();
|
||||||
virtual void set_use_accumulated_input(bool p_enable);
|
void set_use_accumulated_input(bool p_enable);
|
||||||
|
|
||||||
virtual void release_pressed_events();
|
void release_pressed_events();
|
||||||
InputDefault();
|
|
||||||
|
Input();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INPUT_DEFAULT_H
|
VARIANT_ENUM_CAST(Input::MouseMode);
|
||||||
|
VARIANT_ENUM_CAST(Input::CursorShape);
|
||||||
|
|
||||||
|
#endif // INPUT_H
|
73
core/input/input_builders.py
Normal file
73
core/input/input_builders.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
"""Functions used to generate source files during build time
|
||||||
|
|
||||||
|
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from platform_methods import subprocess_main
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
|
def make_default_controller_mappings(target, source, env):
|
||||||
|
dst = target[0]
|
||||||
|
g = open(dst, "w")
|
||||||
|
|
||||||
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
||||||
|
g.write("#include \"core/typedefs.h\"\n")
|
||||||
|
g.write("#include \"core/input/default_controller_mappings.h\"\n")
|
||||||
|
|
||||||
|
# ensure mappings have a consistent order
|
||||||
|
platform_mappings = OrderedDict()
|
||||||
|
for src_path in source:
|
||||||
|
with open(src_path, "r") as f:
|
||||||
|
# read mapping file and skip header
|
||||||
|
mapping_file_lines = f.readlines()[2:]
|
||||||
|
|
||||||
|
current_platform = None
|
||||||
|
for line in mapping_file_lines:
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
line = line.strip()
|
||||||
|
if len(line) == 0:
|
||||||
|
continue
|
||||||
|
if line[0] == "#":
|
||||||
|
current_platform = line[1:].strip()
|
||||||
|
if current_platform not in platform_mappings:
|
||||||
|
platform_mappings[current_platform] = {}
|
||||||
|
elif current_platform:
|
||||||
|
line_parts = line.split(",")
|
||||||
|
guid = line_parts[0]
|
||||||
|
if guid in platform_mappings[current_platform]:
|
||||||
|
g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
|
||||||
|
valid_mapping = True
|
||||||
|
for input_map in line_parts[2:]:
|
||||||
|
if "+" in input_map or "-" in input_map or "~" in input_map:
|
||||||
|
g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
|
||||||
|
valid_mapping = False
|
||||||
|
break
|
||||||
|
if valid_mapping:
|
||||||
|
platform_mappings[current_platform][guid] = line
|
||||||
|
|
||||||
|
platform_variables = {
|
||||||
|
"Linux": "#if X11_ENABLED",
|
||||||
|
"Windows": "#ifdef WINDOWS_ENABLED",
|
||||||
|
"Mac OS X": "#ifdef OSX_ENABLED",
|
||||||
|
"Android": "#if defined(__ANDROID__)",
|
||||||
|
"iOS": "#ifdef IPHONE_ENABLED",
|
||||||
|
"Javascript": "#ifdef JAVASCRIPT_ENABLED",
|
||||||
|
"UWP": "#ifdef UWP_ENABLED",
|
||||||
|
}
|
||||||
|
|
||||||
|
g.write("const char* DefaultControllerMappings::mappings[] = {\n")
|
||||||
|
for platform, mappings in platform_mappings.items():
|
||||||
|
variable = platform_variables[platform]
|
||||||
|
g.write("{}\n".format(variable))
|
||||||
|
for mapping in mappings.values():
|
||||||
|
g.write("\t\"{}\",\n".format(mapping))
|
||||||
|
g.write("#endif\n")
|
||||||
|
|
||||||
|
g.write("\tNULL\n};\n")
|
||||||
|
g.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
subprocess_main(globals())
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "input_event.h"
|
#include "input_event.h"
|
||||||
|
|
||||||
#include "core/input_map.h"
|
#include "core/input/input_map.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
|
|
||||||
const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
|
const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
|
||||||
@ -136,6 +136,25 @@ InputEvent::InputEvent() {
|
|||||||
|
|
||||||
device = 0;
|
device = 0;
|
||||||
}
|
}
|
||||||
|
////////////////
|
||||||
|
|
||||||
|
void InputEventFromWindow::_bind_methods() {
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_id", "id"), &InputEventFromWindow::set_window_id);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_window_id"), &InputEventFromWindow::get_window_id);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "window_id"), "set_window_id", "get_window_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputEventFromWindow::set_window_id(int64_t p_id) {
|
||||||
|
window_id = p_id;
|
||||||
|
}
|
||||||
|
int64_t InputEventFromWindow::get_window_id() const {
|
||||||
|
return window_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputEventFromWindow::InputEventFromWindow() {
|
||||||
|
window_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
@ -499,7 +518,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
|
|||||||
mb.instance();
|
mb.instance();
|
||||||
|
|
||||||
mb->set_device(get_device());
|
mb->set_device(get_device());
|
||||||
|
mb->set_window_id(get_window_id());
|
||||||
mb->set_modifiers_from_event(this);
|
mb->set_modifiers_from_event(this);
|
||||||
|
|
||||||
mb->set_position(l);
|
mb->set_position(l);
|
||||||
@ -650,6 +669,7 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
|
|||||||
mm.instance();
|
mm.instance();
|
||||||
|
|
||||||
mm->set_device(get_device());
|
mm->set_device(get_device());
|
||||||
|
mm->set_window_id(get_window_id());
|
||||||
|
|
||||||
mm->set_modifiers_from_event(this);
|
mm->set_modifiers_from_event(this);
|
||||||
|
|
||||||
@ -697,6 +717,10 @@ bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
|
|||||||
if (motion.is_null())
|
if (motion.is_null())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (get_window_id() != motion->get_window_id()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_pressed() != motion->is_pressed()) {
|
if (is_pressed() != motion->is_pressed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -948,6 +972,7 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
|
|||||||
Ref<InputEventScreenTouch> st;
|
Ref<InputEventScreenTouch> st;
|
||||||
st.instance();
|
st.instance();
|
||||||
st->set_device(get_device());
|
st->set_device(get_device());
|
||||||
|
st->set_window_id(get_window_id());
|
||||||
st->set_index(index);
|
st->set_index(index);
|
||||||
st->set_position(p_xform.xform(pos + p_local_ofs));
|
st->set_position(p_xform.xform(pos + p_local_ofs));
|
||||||
st->set_pressed(pressed);
|
st->set_pressed(pressed);
|
||||||
@ -1028,6 +1053,7 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
|
|||||||
sd.instance();
|
sd.instance();
|
||||||
|
|
||||||
sd->set_device(get_device());
|
sd->set_device(get_device());
|
||||||
|
sd->set_window_id(get_window_id());
|
||||||
|
|
||||||
sd->set_index(index);
|
sd->set_index(index);
|
||||||
sd->set_position(p_xform.xform(pos + p_local_ofs));
|
sd->set_position(p_xform.xform(pos + p_local_ofs));
|
||||||
@ -1186,6 +1212,8 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
|
|||||||
ev.instance();
|
ev.instance();
|
||||||
|
|
||||||
ev->set_device(get_device());
|
ev->set_device(get_device());
|
||||||
|
ev->set_window_id(get_window_id());
|
||||||
|
|
||||||
ev->set_modifiers_from_event(this);
|
ev->set_modifiers_from_event(this);
|
||||||
|
|
||||||
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
|
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
|
||||||
@ -1228,6 +1256,8 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
|
|||||||
ev.instance();
|
ev.instance();
|
||||||
|
|
||||||
ev->set_device(get_device());
|
ev->set_device(get_device());
|
||||||
|
ev->set_window_id(get_window_id());
|
||||||
|
|
||||||
ev->set_modifiers_from_event(this);
|
ev->set_modifiers_from_event(this);
|
||||||
|
|
||||||
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
|
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
|
@ -205,8 +205,24 @@ public:
|
|||||||
InputEvent();
|
InputEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputEventWithModifiers : public InputEvent {
|
class InputEventFromWindow : public InputEvent {
|
||||||
GDCLASS(InputEventWithModifiers, InputEvent);
|
|
||||||
|
GDCLASS(InputEventFromWindow, InputEvent);
|
||||||
|
|
||||||
|
int64_t window_id;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set_window_id(int64_t p_id);
|
||||||
|
int64_t get_window_id() const;
|
||||||
|
|
||||||
|
InputEventFromWindow();
|
||||||
|
};
|
||||||
|
|
||||||
|
class InputEventWithModifiers : public InputEventFromWindow {
|
||||||
|
GDCLASS(InputEventWithModifiers, InputEventFromWindow);
|
||||||
|
|
||||||
bool shift;
|
bool shift;
|
||||||
bool alt;
|
bool alt;
|
||||||
@ -440,8 +456,8 @@ public:
|
|||||||
InputEventJoypadButton();
|
InputEventJoypadButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputEventScreenTouch : public InputEvent {
|
class InputEventScreenTouch : public InputEventFromWindow {
|
||||||
GDCLASS(InputEventScreenTouch, InputEvent);
|
GDCLASS(InputEventScreenTouch, InputEventFromWindow);
|
||||||
int index;
|
int index;
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
@ -465,9 +481,9 @@ public:
|
|||||||
InputEventScreenTouch();
|
InputEventScreenTouch();
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputEventScreenDrag : public InputEvent {
|
class InputEventScreenDrag : public InputEventFromWindow {
|
||||||
|
|
||||||
GDCLASS(InputEventScreenDrag, InputEvent);
|
GDCLASS(InputEventScreenDrag, InputEventFromWindow);
|
||||||
int index;
|
int index;
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
Vector2 relative;
|
Vector2 relative;
|
@ -31,8 +31,8 @@
|
|||||||
#ifndef INPUT_MAP_H
|
#ifndef INPUT_MAP_H
|
||||||
#define INPUT_MAP_H
|
#define INPUT_MAP_H
|
||||||
|
|
||||||
|
#include "core/input/input_event.h"
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#include "core/os/input_event.h"
|
|
||||||
|
|
||||||
class InputMap : public Object {
|
class InputMap : public Object {
|
||||||
|
|
@ -118,6 +118,9 @@ MAKE_PTRARG(String);
|
|||||||
MAKE_PTRARG(Vector2);
|
MAKE_PTRARG(Vector2);
|
||||||
MAKE_PTRARG(Rect2);
|
MAKE_PTRARG(Rect2);
|
||||||
MAKE_PTRARG_BY_REFERENCE(Vector3);
|
MAKE_PTRARG_BY_REFERENCE(Vector3);
|
||||||
|
MAKE_PTRARG(Vector2i);
|
||||||
|
MAKE_PTRARG(Rect2i);
|
||||||
|
MAKE_PTRARG_BY_REFERENCE(Vector3i);
|
||||||
MAKE_PTRARG(Transform2D);
|
MAKE_PTRARG(Transform2D);
|
||||||
MAKE_PTRARG_BY_REFERENCE(Plane);
|
MAKE_PTRARG_BY_REFERENCE(Plane);
|
||||||
MAKE_PTRARG(Quat);
|
MAKE_PTRARG(Quat);
|
||||||
|
@ -1,157 +0,0 @@
|
|||||||
/*************************************************************************/
|
|
||||||
/* input.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* 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 "input.h"
|
|
||||||
|
|
||||||
#include "core/input_map.h"
|
|
||||||
#include "core/os/os.h"
|
|
||||||
#include "core/project_settings.h"
|
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Input *Input::singleton = NULL;
|
|
||||||
|
|
||||||
Input *Input::get_singleton() {
|
|
||||||
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::set_mouse_mode(MouseMode p_mode) {
|
|
||||||
ERR_FAIL_INDEX((int)p_mode, 4);
|
|
||||||
OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
Input::MouseMode Input::get_mouse_mode() const {
|
|
||||||
|
|
||||||
return (MouseMode)OS::get_singleton()->get_mouse_mode();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::_bind_methods() {
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &Input::is_action_pressed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &Input::is_action_just_pressed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &Input::get_action_strength);
|
|
||||||
ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
|
|
||||||
ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
|
|
||||||
ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
|
|
||||||
ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_guid", "device"), &Input::get_joy_guid);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
|
|
||||||
ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
|
|
||||||
ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
|
|
||||||
ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
|
|
||||||
ClassDB::bind_method(D_METHOD("get_gravity"), &Input::get_gravity);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope);
|
|
||||||
//ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want
|
|
||||||
ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
|
|
||||||
ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
|
|
||||||
ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
|
|
||||||
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
|
|
||||||
ClassDB::bind_method(D_METHOD("get_current_cursor_shape"), &Input::get_current_cursor_shape);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
|
|
||||||
ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_use_accumulated_input", "enable"), &Input::set_use_accumulated_input);
|
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
|
|
||||||
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
|
|
||||||
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
|
|
||||||
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
|
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_ARROW);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_IBEAM);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_CROSS);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_WAIT);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_BUSY);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_DRAG);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_VSIZE);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_HSIZE);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_MOVE);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
|
|
||||||
BIND_ENUM_CONSTANT(CURSOR_HELP);
|
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
|
|
||||||
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
|
|
||||||
|
|
||||||
String pf = p_function;
|
|
||||||
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
|
|
||||||
|
|
||||||
List<PropertyInfo> pinfo;
|
|
||||||
ProjectSettings::get_singleton()->get_property_list(&pinfo);
|
|
||||||
|
|
||||||
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
|
||||||
const PropertyInfo &pi = E->get();
|
|
||||||
|
|
||||||
if (!pi.name.begins_with("input/"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
|
||||||
r_options->push_back(quote_style + name + quote_style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Input::Input() {
|
|
||||||
|
|
||||||
singleton = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
|
146
core/os/input.h
146
core/os/input.h
@ -1,146 +0,0 @@
|
|||||||
/*************************************************************************/
|
|
||||||
/* input.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* 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 INPUT_H
|
|
||||||
#define INPUT_H
|
|
||||||
|
|
||||||
#include "core/object.h"
|
|
||||||
#include "core/os/main_loop.h"
|
|
||||||
#include "core/os/thread_safe.h"
|
|
||||||
|
|
||||||
class Input : public Object {
|
|
||||||
|
|
||||||
GDCLASS(Input, Object);
|
|
||||||
|
|
||||||
static Input *singleton;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum MouseMode {
|
|
||||||
MOUSE_MODE_VISIBLE,
|
|
||||||
MOUSE_MODE_HIDDEN,
|
|
||||||
MOUSE_MODE_CAPTURED,
|
|
||||||
MOUSE_MODE_CONFINED
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef CursorShape
|
|
||||||
enum CursorShape {
|
|
||||||
CURSOR_ARROW,
|
|
||||||
CURSOR_IBEAM,
|
|
||||||
CURSOR_POINTING_HAND,
|
|
||||||
CURSOR_CROSS,
|
|
||||||
CURSOR_WAIT,
|
|
||||||
CURSOR_BUSY,
|
|
||||||
CURSOR_DRAG,
|
|
||||||
CURSOR_CAN_DROP,
|
|
||||||
CURSOR_FORBIDDEN,
|
|
||||||
CURSOR_VSIZE,
|
|
||||||
CURSOR_HSIZE,
|
|
||||||
CURSOR_BDIAGSIZE,
|
|
||||||
CURSOR_FDIAGSIZE,
|
|
||||||
CURSOR_MOVE,
|
|
||||||
CURSOR_VSPLIT,
|
|
||||||
CURSOR_HSPLIT,
|
|
||||||
CURSOR_HELP,
|
|
||||||
CURSOR_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
void set_mouse_mode(MouseMode p_mode);
|
|
||||||
MouseMode get_mouse_mode() const;
|
|
||||||
|
|
||||||
static Input *get_singleton();
|
|
||||||
|
|
||||||
virtual bool is_key_pressed(int p_keycode) const = 0;
|
|
||||||
virtual bool is_mouse_button_pressed(int p_button) const = 0;
|
|
||||||
virtual bool is_joy_button_pressed(int p_device, int p_button) const = 0;
|
|
||||||
virtual bool is_action_pressed(const StringName &p_action) const = 0;
|
|
||||||
virtual bool is_action_just_pressed(const StringName &p_action) const = 0;
|
|
||||||
virtual bool is_action_just_released(const StringName &p_action) const = 0;
|
|
||||||
virtual float get_action_strength(const StringName &p_action) const = 0;
|
|
||||||
|
|
||||||
virtual float get_joy_axis(int p_device, int p_axis) const = 0;
|
|
||||||
virtual String get_joy_name(int p_idx) = 0;
|
|
||||||
virtual Array get_connected_joypads() = 0;
|
|
||||||
virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) = 0;
|
|
||||||
virtual void add_joy_mapping(String p_mapping, bool p_update_existing = false) = 0;
|
|
||||||
virtual void remove_joy_mapping(String p_guid) = 0;
|
|
||||||
virtual bool is_joy_known(int p_device) = 0;
|
|
||||||
virtual String get_joy_guid(int p_device) const = 0;
|
|
||||||
virtual Vector2 get_joy_vibration_strength(int p_device) = 0;
|
|
||||||
virtual float get_joy_vibration_duration(int p_device) = 0;
|
|
||||||
virtual uint64_t get_joy_vibration_timestamp(int p_device) = 0;
|
|
||||||
virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0) = 0;
|
|
||||||
virtual void stop_joy_vibration(int p_device) = 0;
|
|
||||||
virtual void vibrate_handheld(int p_duration_ms = 500) = 0;
|
|
||||||
|
|
||||||
virtual Point2 get_mouse_position() const = 0;
|
|
||||||
virtual Point2 get_last_mouse_speed() const = 0;
|
|
||||||
virtual int get_mouse_button_mask() const = 0;
|
|
||||||
|
|
||||||
virtual void warp_mouse_position(const Vector2 &p_to) = 0;
|
|
||||||
virtual Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) = 0;
|
|
||||||
|
|
||||||
virtual Vector3 get_gravity() const = 0;
|
|
||||||
virtual Vector3 get_accelerometer() const = 0;
|
|
||||||
virtual Vector3 get_magnetometer() const = 0;
|
|
||||||
virtual Vector3 get_gyroscope() const = 0;
|
|
||||||
|
|
||||||
virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
|
|
||||||
virtual void action_release(const StringName &p_action) = 0;
|
|
||||||
|
|
||||||
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
|
||||||
|
|
||||||
virtual bool is_emulating_touch_from_mouse() const = 0;
|
|
||||||
virtual bool is_emulating_mouse_from_touch() const = 0;
|
|
||||||
|
|
||||||
virtual CursorShape get_default_cursor_shape() const = 0;
|
|
||||||
virtual void set_default_cursor_shape(CursorShape p_shape) = 0;
|
|
||||||
virtual CursorShape get_current_cursor_shape() const = 0;
|
|
||||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) = 0;
|
|
||||||
|
|
||||||
virtual String get_joy_button_string(int p_button) = 0;
|
|
||||||
virtual String get_joy_axis_string(int p_axis) = 0;
|
|
||||||
virtual int get_joy_button_index_from_string(String p_button) = 0;
|
|
||||||
virtual int get_joy_axis_index_from_string(String p_axis) = 0;
|
|
||||||
|
|
||||||
virtual void parse_input_event(const Ref<InputEvent> &p_event) = 0;
|
|
||||||
virtual void accumulate_input_event(const Ref<InputEvent> &p_event) = 0;
|
|
||||||
virtual void flush_accumulated_events() = 0;
|
|
||||||
virtual void set_use_accumulated_input(bool p_enable) = 0;
|
|
||||||
|
|
||||||
Input();
|
|
||||||
};
|
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(Input::MouseMode);
|
|
||||||
VARIANT_ENUM_CAST(Input::CursorShape);
|
|
||||||
|
|
||||||
#endif // INPUT_H
|
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef MAIN_LOOP_H
|
#ifndef MAIN_LOOP_H
|
||||||
#define MAIN_LOOP_H
|
#define MAIN_LOOP_H
|
||||||
|
|
||||||
#include "core/os/input_event.h"
|
#include "core/input/input_event.h"
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
#include "core/script_language.h"
|
#include "core/script_language.h"
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "midi_driver.h"
|
#include "midi_driver.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
|
|
||||||
uint8_t MIDIDriver::last_received_message = 0x00;
|
uint8_t MIDIDriver::last_received_message = 0x00;
|
||||||
MIDIDriver *MIDIDriver::singleton = NULL;
|
MIDIDriver *MIDIDriver::singleton = NULL;
|
||||||
@ -117,7 +117,7 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
|
Input *id = Input::get_singleton();
|
||||||
id->parse_input_event(event);
|
id->parse_input_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/dir_access.h"
|
#include "core/os/dir_access.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/midi_driver.h"
|
#include "core/os/midi_driver.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/version_generated.gen.h"
|
#include "core/version_generated.gen.h"
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
#include "core/crypto/hashing_context.h"
|
#include "core/crypto/hashing_context.h"
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/func_ref.h"
|
#include "core/func_ref.h"
|
||||||
#include "core/input_map.h"
|
#include "core/input/input.h"
|
||||||
|
#include "core/input/input_map.h"
|
||||||
#include "core/io/config_file.h"
|
#include "core/io/config_file.h"
|
||||||
#include "core/io/dtls_server.h"
|
#include "core/io/dtls_server.h"
|
||||||
#include "core/io/http_client.h"
|
#include "core/io/http_client.h"
|
||||||
@ -62,7 +63,6 @@
|
|||||||
#include "core/math/geometry.h"
|
#include "core/math/geometry.h"
|
||||||
#include "core/math/random_number_generator.h"
|
#include "core/math/random_number_generator.h"
|
||||||
#include "core/math/triangle_mesh.h"
|
#include "core/math/triangle_mesh.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/main_loop.h"
|
#include "core/os/main_loop.h"
|
||||||
#include "core/packed_data_container.h"
|
#include "core/packed_data_container.h"
|
||||||
#include "core/path_remap.h"
|
#include "core/path_remap.h"
|
||||||
|
@ -144,6 +144,9 @@ MAKE_TYPE_INFO(String, Variant::STRING)
|
|||||||
MAKE_TYPE_INFO(Vector2, Variant::VECTOR2)
|
MAKE_TYPE_INFO(Vector2, Variant::VECTOR2)
|
||||||
MAKE_TYPE_INFO(Rect2, Variant::RECT2)
|
MAKE_TYPE_INFO(Rect2, Variant::RECT2)
|
||||||
MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
|
MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
|
||||||
|
MAKE_TYPE_INFO(Vector2i, Variant::VECTOR2I)
|
||||||
|
MAKE_TYPE_INFO(Rect2i, Variant::RECT2I)
|
||||||
|
MAKE_TYPE_INFO(Vector3i, Variant::VECTOR3I)
|
||||||
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
|
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
|
||||||
MAKE_TYPE_INFO(Plane, Variant::PLANE)
|
MAKE_TYPE_INFO(Plane, Variant::PLANE)
|
||||||
MAKE_TYPE_INFO(Quat, Variant::QUAT)
|
MAKE_TYPE_INFO(Quat, Variant::QUAT)
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "variant_parser.h"
|
#include "variant_parser.h"
|
||||||
|
|
||||||
|
#include "core/input/input_event.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/os/input_event.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/string_buffer.h"
|
#include "core/string_buffer.h"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "animation_track_editor.h"
|
#include "animation_track_editor.h"
|
||||||
|
|
||||||
#include "animation_track_editor_plugins.h"
|
#include "animation_track_editor_plugins.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/animation_bezier_editor.h"
|
#include "editor/animation_bezier_editor.h"
|
||||||
#include "editor/plugins/animation_player_editor_plugin.h"
|
#include "editor/plugins/animation_player_editor_plugin.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "code_editor.h"
|
#include "code_editor.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/string_builder.h"
|
#include "core/string_builder.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "editor_audio_buses.h"
|
#include "editor_audio_buses.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor_node.h"
|
#include "editor_node.h"
|
||||||
#include "editor_scale.h"
|
#include "editor_scale.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "editor_help.h"
|
#include "editor_help.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "doc_data_compressed.gen.h"
|
#include "doc_data_compressed.gen.h"
|
||||||
#include "editor/plugins/script_editor_plugin.h"
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "core/bind/core_bind.h"
|
#include "core/bind/core_bind.h"
|
||||||
#include "core/class_db.h"
|
#include "core/class_db.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/config_file.h"
|
#include "core/io/config_file.h"
|
||||||
#include "core/io/image_loader.h"
|
#include "core/io/image_loader.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
@ -39,7 +40,6 @@
|
|||||||
#include "core/io/stream_peer_ssl.h"
|
#include "core/io/stream_peer_ssl.h"
|
||||||
#include "core/message_queue.h"
|
#include "core/message_queue.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/path_remap.h"
|
#include "core/path_remap.h"
|
||||||
@ -47,7 +47,6 @@
|
|||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/translation.h"
|
#include "core/translation.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "scene/gui/center_container.h"
|
#include "scene/gui/center_container.h"
|
||||||
#include "scene/gui/control.h"
|
#include "scene/gui/control.h"
|
||||||
@ -5482,7 +5481,7 @@ EditorNode::EditorNode() {
|
|||||||
ResourceLoader::clear_translation_remaps(); //no remaps using during editor
|
ResourceLoader::clear_translation_remaps(); //no remaps using during editor
|
||||||
ResourceLoader::clear_path_remaps();
|
ResourceLoader::clear_path_remaps();
|
||||||
|
|
||||||
InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
|
Input *id = Input::get_singleton();
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "editor_spin_slider.h"
|
#include "editor_spin_slider.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/expression.h"
|
#include "core/math/expression.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "editor_node.h"
|
#include "editor_node.h"
|
||||||
#include "editor_scale.h"
|
#include "editor_scale.h"
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
#include "export_template_manager.h"
|
#include "export_template_manager.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/json.h"
|
#include "core/io/json.h"
|
||||||
#include "core/io/zip_io.h"
|
#include "core/io/zip_io.h"
|
||||||
#include "core/os/dir_access.h"
|
#include "core/os/dir_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "editor_node.h"
|
#include "editor_node.h"
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "animation_blend_space_2d_editor.h"
|
#include "animation_blend_space_2d_editor.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/math/delaunay.h"
|
#include "core/math/delaunay.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "animation_blend_tree_editor_plugin.h"
|
#include "animation_blend_tree_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/editor_inspector.h"
|
#include "editor/editor_inspector.h"
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "animation_player_editor_plugin.h"
|
#include "animation_player_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/animation_track_editor.h"
|
#include "editor/animation_track_editor.h"
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "animation_state_machine_editor.h"
|
#include "animation_state_machine_editor.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/math/delaunay.h"
|
#include "core/math/delaunay.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
#include "animation_blend_space_2d_editor.h"
|
#include "animation_blend_space_2d_editor.h"
|
||||||
#include "animation_blend_tree_editor_plugin.h"
|
#include "animation_blend_tree_editor_plugin.h"
|
||||||
#include "animation_state_machine_editor.h"
|
#include "animation_state_machine_editor.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/math/delaunay.h"
|
#include "core/math/delaunay.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "asset_library_editor_plugin.h"
|
#include "asset_library_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/json.h"
|
#include "core/io/json.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "collision_polygon_editor_plugin.h"
|
#include "collision_polygon_editor_plugin.h"
|
||||||
|
|
||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "scene/3d/camera.h"
|
#include "scene/3d/camera.h"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "polygon_2d_editor_plugin.h"
|
#include "polygon_2d_editor_plugin.h"
|
||||||
|
|
||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "script_editor_plugin.h"
|
#include "script_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "spatial_editor_plugin.h"
|
#include "spatial_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/camera_matrix.h"
|
#include "core/math/camera_matrix.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "texture_region_editor_plugin.h"
|
#include "texture_region_editor_plugin.h"
|
||||||
|
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "scene/gui/check_box.h"
|
#include "scene/gui/check_box.h"
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "tile_map_editor_plugin.h"
|
#include "tile_map_editor_plugin.h"
|
||||||
|
|
||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/math_funcs.h"
|
#include "core/math/math_funcs.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "tile_set_editor_plugin.h"
|
#include "tile_set_editor_plugin.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "visual_shader_editor_plugin.h"
|
#include "visual_shader_editor_plugin.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/math/math_defs.h"
|
#include "core/math/math_defs.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "project_settings_editor.h"
|
#include "project_settings_editor.h"
|
||||||
|
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/input_map.h"
|
#include "core/input/input_map.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/translation.h"
|
#include "core/translation.h"
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
#include "property_editor.h"
|
#include "property_editor.h"
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/class_db.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/image_loader.h"
|
#include "core/io/image_loader.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/math/expression.h"
|
#include "core/math/expression.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/pair.h"
|
#include "core/pair.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "scene_tree_dock.h"
|
#include "scene_tree_dock.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "editor/debugger/editor_debugger_node.h"
|
#include "editor/debugger/editor_debugger_node.h"
|
||||||
|
@ -9,15 +9,6 @@ env.main_sources = []
|
|||||||
|
|
||||||
env.add_source_files(env.main_sources, "*.cpp")
|
env.add_source_files(env.main_sources, "*.cpp")
|
||||||
|
|
||||||
# Order matters here. Higher index controller database files write on top of lower index database files.
|
|
||||||
controller_databases = ["#main/gamecontrollerdb_204.txt", "#main/gamecontrollerdb_205.txt", "#main/gamecontrollerdb.txt", "#main/godotcontrollerdb.txt"]
|
|
||||||
|
|
||||||
env.Depends("#main/default_controller_mappings.gen.cpp", controller_databases)
|
|
||||||
env.CommandNoCache("#main/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(main_builders.make_default_controller_mappings))
|
|
||||||
|
|
||||||
# Don't warn about duplicate entry here, we need it registered manually for first build,
|
|
||||||
# even if later builds will pick it up twice due to above *.cpp globbing.
|
|
||||||
env.add_source_files(env.main_sources, "#main/default_controller_mappings.gen.cpp", warn_duplicates=False)
|
|
||||||
|
|
||||||
env.Depends("#main/splash.gen.h", "#main/splash.png")
|
env.Depends("#main/splash.gen.h", "#main/splash.png")
|
||||||
env.CommandNoCache("#main/splash.gen.h", "#main/splash.png", run_in_subprocess(main_builders.make_splash))
|
env.CommandNoCache("#main/splash.gen.h", "#main/splash.png", run_in_subprocess(main_builders.make_splash))
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
#include "core/crypto/crypto.h"
|
#include "core/crypto/crypto.h"
|
||||||
#include "core/debugger/engine_debugger.h"
|
#include "core/debugger/engine_debugger.h"
|
||||||
#include "core/input_map.h"
|
#include "core/input/input.h"
|
||||||
|
#include "core/input/input_map.h"
|
||||||
#include "core/io/file_access_network.h"
|
#include "core/io/file_access_network.h"
|
||||||
#include "core/io/file_access_pack.h"
|
#include "core/io/file_access_pack.h"
|
||||||
#include "core/io/file_access_zip.h"
|
#include "core/io/file_access_zip.h"
|
||||||
@ -49,7 +50,6 @@
|
|||||||
#include "core/version_hash.gen.h"
|
#include "core/version_hash.gen.h"
|
||||||
#include "drivers/register_driver_types.h"
|
#include "drivers/register_driver_types.h"
|
||||||
#include "main/app_icon.gen.h"
|
#include "main/app_icon.gen.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "main/main_timer_sync.h"
|
#include "main/main_timer_sync.h"
|
||||||
#include "main/performance.h"
|
#include "main/performance.h"
|
||||||
#include "main/splash.gen.h"
|
#include "main/splash.gen.h"
|
||||||
@ -1294,7 +1294,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
|||||||
GLOBAL_DEF("application/config/windows_native_icon", String());
|
GLOBAL_DEF("application/config/windows_native_icon", String());
|
||||||
ProjectSettings::get_singleton()->set_custom_property_info("application/config/windows_native_icon", PropertyInfo(Variant::STRING, "application/config/windows_native_icon", PROPERTY_HINT_FILE, "*.ico"));
|
ProjectSettings::get_singleton()->set_custom_property_info("application/config/windows_native_icon", PropertyInfo(Variant::STRING, "application/config/windows_native_icon", PROPERTY_HINT_FILE, "*.ico"));
|
||||||
|
|
||||||
InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
|
Input *id = Input::get_singleton();
|
||||||
if (id) {
|
if (id) {
|
||||||
if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) {
|
if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) {
|
||||||
if (!OS::get_singleton()->has_touchscreen_ui_hint()) {
|
if (!OS::get_singleton()->has_touchscreen_ui_hint()) {
|
||||||
|
@ -63,67 +63,5 @@ def make_app_icon(target, source, env):
|
|||||||
g.write("#endif")
|
g.write("#endif")
|
||||||
|
|
||||||
|
|
||||||
def make_default_controller_mappings(target, source, env):
|
|
||||||
dst = target[0]
|
|
||||||
g = open(dst, "w")
|
|
||||||
|
|
||||||
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
||||||
g.write("#include \"core/typedefs.h\"\n")
|
|
||||||
g.write("#include \"main/default_controller_mappings.h\"\n")
|
|
||||||
|
|
||||||
# ensure mappings have a consistent order
|
|
||||||
platform_mappings = OrderedDict()
|
|
||||||
for src_path in source:
|
|
||||||
with open(src_path, "r") as f:
|
|
||||||
# read mapping file and skip header
|
|
||||||
mapping_file_lines = f.readlines()[2:]
|
|
||||||
|
|
||||||
current_platform = None
|
|
||||||
for line in mapping_file_lines:
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
line = line.strip()
|
|
||||||
if len(line) == 0:
|
|
||||||
continue
|
|
||||||
if line[0] == "#":
|
|
||||||
current_platform = line[1:].strip()
|
|
||||||
if current_platform not in platform_mappings:
|
|
||||||
platform_mappings[current_platform] = {}
|
|
||||||
elif current_platform:
|
|
||||||
line_parts = line.split(",")
|
|
||||||
guid = line_parts[0]
|
|
||||||
if guid in platform_mappings[current_platform]:
|
|
||||||
g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
|
|
||||||
valid_mapping = True
|
|
||||||
for input_map in line_parts[2:]:
|
|
||||||
if "+" in input_map or "-" in input_map or "~" in input_map:
|
|
||||||
g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
|
|
||||||
valid_mapping = False
|
|
||||||
break
|
|
||||||
if valid_mapping:
|
|
||||||
platform_mappings[current_platform][guid] = line
|
|
||||||
|
|
||||||
platform_variables = {
|
|
||||||
"Linux": "#if X11_ENABLED",
|
|
||||||
"Windows": "#ifdef WINDOWS_ENABLED",
|
|
||||||
"Mac OS X": "#ifdef OSX_ENABLED",
|
|
||||||
"Android": "#if defined(__ANDROID__)",
|
|
||||||
"iOS": "#ifdef IPHONE_ENABLED",
|
|
||||||
"Javascript": "#ifdef JAVASCRIPT_ENABLED",
|
|
||||||
"UWP": "#ifdef UWP_ENABLED",
|
|
||||||
}
|
|
||||||
|
|
||||||
g.write("const char* DefaultControllerMappings::mappings[] = {\n")
|
|
||||||
for platform, mappings in platform_mappings.items():
|
|
||||||
variable = platform_variables[platform]
|
|
||||||
g.write("{}\n".format(variable))
|
|
||||||
for mapping in mappings.values():
|
|
||||||
g.write("\t\"{}\",\n".format(mapping))
|
|
||||||
g.write("#endif\n")
|
|
||||||
|
|
||||||
g.write("\tNULL\n};\n")
|
|
||||||
g.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
subprocess_main(globals())
|
subprocess_main(globals())
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "scene/resources/surface_tool.h"
|
#include "scene/resources/surface_tool.h"
|
||||||
#include "servers/visual/visual_server_globals.h"
|
#include "servers/visual/visual_server_globals.h"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "arvr_interface_gdnative.h"
|
#include "arvr_interface_gdnative.h"
|
||||||
#include "main/input_default.h"
|
#include "core/input/input.h"
|
||||||
#include "servers/arvr/arvr_positional_tracker.h"
|
#include "servers/arvr/arvr_positional_tracker.h"
|
||||||
#include "servers/visual/visual_server_globals.h"
|
#include "servers/visual/visual_server_globals.h"
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand,
|
|||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||||
ERR_FAIL_NULL_V(arvr_server, 0);
|
ERR_FAIL_NULL_V(arvr_server, 0);
|
||||||
|
|
||||||
InputDefault *input = (InputDefault *)Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
ERR_FAIL_NULL_V(input, 0);
|
ERR_FAIL_NULL_V(input, 0);
|
||||||
|
|
||||||
ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
|
ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
|
||||||
@ -356,7 +356,7 @@ void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) {
|
|||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||||
ERR_FAIL_NULL(arvr_server);
|
ERR_FAIL_NULL(arvr_server);
|
||||||
|
|
||||||
InputDefault *input = (InputDefault *)Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
ERR_FAIL_NULL(input);
|
ERR_FAIL_NULL(input);
|
||||||
|
|
||||||
ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||||
@ -394,7 +394,7 @@ void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int
|
|||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||||
ERR_FAIL_NULL(arvr_server);
|
ERR_FAIL_NULL(arvr_server);
|
||||||
|
|
||||||
InputDefault *input = (InputDefault *)Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
ERR_FAIL_NULL(input);
|
ERR_FAIL_NULL(input);
|
||||||
|
|
||||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||||
@ -410,14 +410,14 @@ void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p
|
|||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||||
ERR_FAIL_NULL(arvr_server);
|
ERR_FAIL_NULL(arvr_server);
|
||||||
|
|
||||||
InputDefault *input = (InputDefault *)Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
ERR_FAIL_NULL(input);
|
ERR_FAIL_NULL(input);
|
||||||
|
|
||||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||||
if (tracker != NULL) {
|
if (tracker != NULL) {
|
||||||
int joyid = tracker->get_joy_id();
|
int joyid = tracker->get_joy_id();
|
||||||
if (joyid != -1) {
|
if (joyid != -1) {
|
||||||
InputDefault::JoyAxis jx;
|
Input::JoyAxis jx;
|
||||||
jx.min = p_can_be_negative ? -1 : 0;
|
jx.min = p_can_be_negative ? -1 : 0;
|
||||||
jx.value = p_value;
|
jx.value = p_value;
|
||||||
input->joy_axis(joyid, p_axis, jx);
|
input->joy_axis(joyid, p_axis, jx);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "grid_map_editor_plugin.h"
|
#include "grid_map_editor_plugin.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/plugins/spatial_editor_plugin.h"
|
#include "editor/plugins/spatial_editor_plugin.h"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "mobile_vr_interface.h"
|
#include "mobile_vr_interface.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "servers/visual/visual_server_globals.h"
|
#include "servers/visual/visual_server_globals.h"
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "visual_script_editor.h"
|
#include "visual_script_editor.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/script_language.h"
|
#include "core/script_language.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
|
@ -37,12 +37,12 @@
|
|||||||
#include "api/java_class_wrapper.h"
|
#include "api/java_class_wrapper.h"
|
||||||
#include "audio_driver_jandroid.h"
|
#include "audio_driver_jandroid.h"
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "dir_access_jandroid.h"
|
#include "dir_access_jandroid.h"
|
||||||
#include "file_access_android.h"
|
#include "file_access_android.h"
|
||||||
#include "file_access_jandroid.h"
|
#include "file_access_jandroid.h"
|
||||||
#include "jni_utils.h"
|
#include "jni_utils.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "net_socket_android.h"
|
#include "net_socket_android.h"
|
||||||
#include "os_android.h"
|
#include "os_android.h"
|
||||||
|
@ -33,10 +33,9 @@
|
|||||||
|
|
||||||
#include "audio_driver_jandroid.h"
|
#include "audio_driver_jandroid.h"
|
||||||
#include "audio_driver_opensl.h"
|
#include "audio_driver_opensl.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/main_loop.h"
|
#include "core/os/main_loop.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
|
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
|
|
||||||
#include "haiku_gl_view.h"
|
#include "haiku_gl_view.h"
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
#include "audio_driver_media_kit.h"
|
#include "audio_driver_media_kit.h"
|
||||||
#include "context_gl_haiku.h"
|
#include "context_gl_haiku.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "haiku_application.h"
|
#include "haiku_application.h"
|
||||||
#include "haiku_direct_window.h"
|
#include "haiku_direct_window.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@
|
|||||||
#ifndef OS_IPHONE_H
|
#ifndef OS_IPHONE_H
|
||||||
#define OS_IPHONE_H
|
#define OS_IPHONE_H
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "game_center.h"
|
#include "game_center.h"
|
||||||
#include "icloud.h"
|
#include "icloud.h"
|
||||||
#include "in_app_store.h"
|
#include "in_app_store.h"
|
||||||
#include "ios.h"
|
#include "ios.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#define OS_JAVASCRIPT_H
|
#define OS_JAVASCRIPT_H
|
||||||
|
|
||||||
#include "audio_driver_javascript.h"
|
#include "audio_driver_javascript.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include <ForceFeedback/ForceFeedbackConstants.h>
|
#include <ForceFeedback/ForceFeedbackConstants.h>
|
||||||
#include <IOKit/hid/IOHIDLib.h>
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
|
|
||||||
#include "main/input_default.h"
|
#include "core/input/input.h"
|
||||||
|
|
||||||
struct rec_element {
|
struct rec_element {
|
||||||
IOHIDElementRef ref;
|
IOHIDElementRef ref;
|
||||||
|
@ -33,13 +33,12 @@
|
|||||||
|
|
||||||
#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
|
#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "crash_handler_osx.h"
|
#include "crash_handler_osx.h"
|
||||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||||
#include "drivers/coremidi/midi_driver_coremidi.h"
|
#include "drivers/coremidi/midi_driver_coremidi.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "joypad_osx.h"
|
#include "joypad_osx.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
#include "servers/visual/visual_server_wrap_mt.h"
|
#include "servers/visual/visual_server_wrap_mt.h"
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
#ifndef OS_SERVER_H
|
#ifndef OS_SERVER_H
|
||||||
#define OS_SERVER_H
|
#define OS_SERVER_H
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "drivers/dummy/texture_loader_dummy.h"
|
#include "drivers/dummy/texture_loader_dummy.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "platform/osx/crash_handler_osx.h"
|
#include "platform/osx/crash_handler_osx.h"
|
||||||
#include "platform/osx/semaphore_osx.h"
|
#include "platform/osx/semaphore_osx.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef JOYPAD_UWP_H
|
#ifndef JOYPAD_UWP_H
|
||||||
#define JOYPAD_UWP_H
|
#define JOYPAD_UWP_H
|
||||||
|
|
||||||
#include "main/input_default.h"
|
#include "core/input/input.h"
|
||||||
|
|
||||||
ref class JoypadUWP sealed {
|
ref class JoypadUWP sealed {
|
||||||
|
|
||||||
|
@ -32,13 +32,12 @@
|
|||||||
#define OS_UWP_H
|
#define OS_UWP_H
|
||||||
|
|
||||||
#include "context_egl_uwp.h"
|
#include "context_egl_uwp.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/transform_2d.h"
|
#include "core/math/transform_2d.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#include "drivers/xaudio2/audio_driver_xaudio2.h"
|
#include "drivers/xaudio2/audio_driver_xaudio2.h"
|
||||||
#include "joypad_uwp.h"
|
#include "joypad_uwp.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef OS_WINDOWS_H
|
#ifndef OS_WINDOWS_H
|
||||||
#define OS_WINDOWS_H
|
#define OS_WINDOWS_H
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "crash_handler_windows.h"
|
#include "crash_handler_windows.h"
|
||||||
@ -39,7 +39,6 @@
|
|||||||
#include "drivers/wasapi/audio_driver_wasapi.h"
|
#include "drivers/wasapi/audio_driver_wasapi.h"
|
||||||
#include "drivers/winmidi/midi_driver_winmidi.h"
|
#include "drivers/winmidi/midi_driver_winmidi.h"
|
||||||
#include "key_mapping_windows.h"
|
#include "key_mapping_windows.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
|
@ -11,6 +11,7 @@ common_x11 = [
|
|||||||
"crash_handler_x11.cpp",
|
"crash_handler_x11.cpp",
|
||||||
"os_x11.cpp",
|
"os_x11.cpp",
|
||||||
"key_mapping_x11.cpp",
|
"key_mapping_x11.cpp",
|
||||||
|
"display_server_x11.cpp",
|
||||||
"joypad_linux.cpp",
|
"joypad_linux.cpp",
|
||||||
"detect_prime.cpp"
|
"detect_prime.cpp"
|
||||||
]
|
]
|
||||||
|
3216
platform/x11/display_server_x11.cpp
Normal file
3216
platform/x11/display_server_x11.cpp
Normal file
File diff suppressed because it is too large
Load Diff
315
platform/x11/display_server_x11.h
Normal file
315
platform/x11/display_server_x11.h
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* display_server_x11.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* 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 DISPLAY_SERVER_X11_H
|
||||||
|
#define DISPLAY_SERVER_X11_H
|
||||||
|
|
||||||
|
#ifdef X11_ENABLED
|
||||||
|
|
||||||
|
#include "servers/display_server.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
|
#include "crash_handler_x11.h"
|
||||||
|
#include "drivers/alsa/audio_driver_alsa.h"
|
||||||
|
#include "drivers/alsamidi/midi_driver_alsamidi.h"
|
||||||
|
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
|
||||||
|
#include "drivers/unix/os_unix.h"
|
||||||
|
#include "joypad_linux.h"
|
||||||
|
#include "servers/audio_server.h"
|
||||||
|
#include "servers/visual/rasterizer.h"
|
||||||
|
#include "servers/visual_server.h"
|
||||||
|
|
||||||
|
#if defined(OPENGL_ENABLED)
|
||||||
|
#include "context_gl_x11.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VULKAN_ENABLED)
|
||||||
|
#include "drivers/vulkan/rendering_device_vulkan.h"
|
||||||
|
#include "platform/x11/vulkan_context_x11.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <X11/Xcursor/Xcursor.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/XInput2.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
|
// Hints for X11 fullscreen
|
||||||
|
typedef struct {
|
||||||
|
unsigned long flags;
|
||||||
|
unsigned long functions;
|
||||||
|
unsigned long decorations;
|
||||||
|
long inputMode;
|
||||||
|
unsigned long status;
|
||||||
|
} Hints;
|
||||||
|
|
||||||
|
typedef struct _xrr_monitor_info {
|
||||||
|
Atom name;
|
||||||
|
Bool primary;
|
||||||
|
Bool automatic;
|
||||||
|
int noutput;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int mwidth;
|
||||||
|
int mheight;
|
||||||
|
RROutput *outputs;
|
||||||
|
} xrr_monitor_info;
|
||||||
|
|
||||||
|
#undef CursorShape
|
||||||
|
|
||||||
|
class DisplayServerX11 : public DisplayServer {
|
||||||
|
//No need to register, it's platform-specific and nothing is added
|
||||||
|
//GDCLASS(DisplayServerX11, DisplayServer)
|
||||||
|
|
||||||
|
Atom wm_delete;
|
||||||
|
Atom xdnd_enter;
|
||||||
|
Atom xdnd_position;
|
||||||
|
Atom xdnd_status;
|
||||||
|
Atom xdnd_action_copy;
|
||||||
|
Atom xdnd_drop;
|
||||||
|
Atom xdnd_finished;
|
||||||
|
Atom xdnd_selection;
|
||||||
|
Atom xdnd_aware;
|
||||||
|
Atom requested;
|
||||||
|
int xdnd_version;
|
||||||
|
|
||||||
|
#if defined(OPENGL_ENABLED)
|
||||||
|
ContextGL_X11 *context_gles2;
|
||||||
|
#endif
|
||||||
|
#if defined(VULKAN_ENABLED)
|
||||||
|
VulkanContextX11 *context_vulkan;
|
||||||
|
RenderingDeviceVulkan *rendering_device_vulkan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Rasterizer *rasterizer;
|
||||||
|
VisualServer *visual_server;
|
||||||
|
|
||||||
|
struct WindowData {
|
||||||
|
Window x11_window;
|
||||||
|
::XIC xic;
|
||||||
|
#if defined(VULKAN_ENABLED)
|
||||||
|
int vulkan_window;
|
||||||
|
#endif
|
||||||
|
Size2i min_size;
|
||||||
|
Size2i max_size;
|
||||||
|
Size2i size;
|
||||||
|
Size2i im_position;
|
||||||
|
bool im_active = false;
|
||||||
|
|
||||||
|
//better to guess on the fly, given WM can change it
|
||||||
|
//WindowMode mode;
|
||||||
|
bool fullscreen = false; //OS can't exit from this mode
|
||||||
|
bool on_top = false;
|
||||||
|
bool borderless = false;
|
||||||
|
bool resize_disabled = false;
|
||||||
|
Vector2i last_position_before_fs;
|
||||||
|
};
|
||||||
|
|
||||||
|
Map<WindowID, WindowData> windows;
|
||||||
|
|
||||||
|
WindowID window_id_counter = MAIN_WINDOW_ID;
|
||||||
|
WindowID _create_window(WindowMode p_mode, const Vector2i &p_resolution);
|
||||||
|
|
||||||
|
String internal_clipboard;
|
||||||
|
Window xdnd_source_window;
|
||||||
|
::Display *x11_display;
|
||||||
|
char *xmbstring;
|
||||||
|
int xmblen;
|
||||||
|
unsigned long last_timestamp;
|
||||||
|
::Time last_keyrelease_time;
|
||||||
|
::XIM xim;
|
||||||
|
::XIMStyle xim_style;
|
||||||
|
static void _xim_destroy_callback(::XIM im, ::XPointer client_data,
|
||||||
|
::XPointer call_data);
|
||||||
|
|
||||||
|
Point2i last_mouse_pos;
|
||||||
|
bool last_mouse_pos_valid;
|
||||||
|
Point2i last_click_pos;
|
||||||
|
uint64_t last_click_ms;
|
||||||
|
int last_click_button_index;
|
||||||
|
uint32_t last_button_state;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int opcode;
|
||||||
|
Vector<int> touch_devices;
|
||||||
|
Map<int, Vector2> absolute_devices;
|
||||||
|
Map<int, Vector3> pen_devices;
|
||||||
|
XIEventMask all_event_mask;
|
||||||
|
Map<int, Vector2> state;
|
||||||
|
double pressure;
|
||||||
|
Vector2 tilt;
|
||||||
|
Vector2 mouse_pos_to_filter;
|
||||||
|
Vector2 relative_motion;
|
||||||
|
Vector2 raw_pos;
|
||||||
|
Vector2 old_raw_pos;
|
||||||
|
::Time last_relative_time;
|
||||||
|
} xi;
|
||||||
|
|
||||||
|
bool _refresh_device_info();
|
||||||
|
|
||||||
|
unsigned int _get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
|
||||||
|
void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
|
||||||
|
void _flush_mouse_motion();
|
||||||
|
|
||||||
|
MouseMode mouse_mode;
|
||||||
|
Point2i center;
|
||||||
|
|
||||||
|
void _handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo = false);
|
||||||
|
|
||||||
|
bool force_quit;
|
||||||
|
bool minimized;
|
||||||
|
bool window_has_focus;
|
||||||
|
bool do_mouse_warp;
|
||||||
|
|
||||||
|
const char *cursor_theme;
|
||||||
|
int cursor_size;
|
||||||
|
XcursorImage *img[CURSOR_MAX];
|
||||||
|
Cursor cursors[CURSOR_MAX];
|
||||||
|
Cursor null_cursor;
|
||||||
|
CursorShape current_cursor;
|
||||||
|
Map<CursorShape, Vector<Variant>> cursors_cache;
|
||||||
|
|
||||||
|
bool layered_window;
|
||||||
|
|
||||||
|
String video_driver;
|
||||||
|
bool window_focused;
|
||||||
|
//void set_wm_border(bool p_enabled);
|
||||||
|
void set_wm_fullscreen(bool p_enabled);
|
||||||
|
void set_wm_above(bool p_enabled);
|
||||||
|
|
||||||
|
typedef xrr_monitor_info *(*xrr_get_monitors_t)(Display *dpy, Window window, Bool get_active, int *nmonitors);
|
||||||
|
typedef void (*xrr_free_monitors_t)(xrr_monitor_info *monitors);
|
||||||
|
xrr_get_monitors_t xrr_get_monitors;
|
||||||
|
xrr_free_monitors_t xrr_free_monitors;
|
||||||
|
void *xrandr_handle;
|
||||||
|
Bool xrandr_ext_ok;
|
||||||
|
|
||||||
|
struct Property {
|
||||||
|
unsigned char *data;
|
||||||
|
int format, nitems;
|
||||||
|
Atom type;
|
||||||
|
};
|
||||||
|
static Property _read_property(Display *p_display, Window p_window, Atom p_property);
|
||||||
|
|
||||||
|
void _update_real_mouse_position(const WindowData &wd);
|
||||||
|
void _set_wm_fullscreen(WindowID p_window, bool p_enabled);
|
||||||
|
void _set_wm_maximized(WindowID p_window, bool p_enabled);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void _window_changed(XEvent *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool has_feature(Feature p_feature) const;
|
||||||
|
virtual String get_name() const;
|
||||||
|
|
||||||
|
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
||||||
|
|
||||||
|
virtual void mouse_set_mode(MouseMode p_mode);
|
||||||
|
virtual MouseMode mouse_get_mode() const;
|
||||||
|
|
||||||
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
|
virtual Point2i mouse_get_position() const;
|
||||||
|
virtual int mouse_get_button_state() const;
|
||||||
|
|
||||||
|
virtual void clipboard_set(const String &p_text);
|
||||||
|
virtual String clipboard_get() const;
|
||||||
|
|
||||||
|
virtual int get_screen_count() const;
|
||||||
|
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
|
||||||
|
virtual Vector<int> get_window_list() const;
|
||||||
|
|
||||||
|
virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i());
|
||||||
|
virtual void delete_sub_window(WindowID p_id);
|
||||||
|
|
||||||
|
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
|
||||||
|
|
||||||
|
virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual void cursor_set_shape(CursorShape p_shape);
|
||||||
|
virtual CursorShape cursor_get_shape() const;
|
||||||
|
virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
|
||||||
|
|
||||||
|
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||||
|
|
||||||
|
virtual void process_events();
|
||||||
|
|
||||||
|
virtual void release_rendering_thread();
|
||||||
|
virtual void make_rendering_thread();
|
||||||
|
virtual void swap_buffers();
|
||||||
|
|
||||||
|
virtual void set_native_icon(const String &p_filename);
|
||||||
|
virtual void set_icon(const Ref<Image> &p_icon);
|
||||||
|
|
||||||
|
static DisplayServer *create_func(const String &p_video_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
|
|
||||||
|
DisplayServerX11(const String &p_video_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
|
~DisplayServerX11();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // X11 enabled
|
||||||
|
|
||||||
|
#endif // DISPLAY_SERVER_X11_H
|
@ -71,7 +71,7 @@ void JoypadLinux::Joypad::reset() {
|
|||||||
dpad = 0;
|
dpad = 0;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
|
||||||
InputDefault::JoyAxis jx;
|
Input::JoyAxis jx;
|
||||||
jx.min = -1;
|
jx.min = -1;
|
||||||
jx.value = 0.0f;
|
jx.value = 0.0f;
|
||||||
for (int i = 0; i < MAX_ABS; i++) {
|
for (int i = 0; i < MAX_ABS; i++) {
|
||||||
@ -80,7 +80,7 @@ void JoypadLinux::Joypad::reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JoypadLinux::JoypadLinux(InputDefault *in) {
|
JoypadLinux::JoypadLinux(Input *in) {
|
||||||
exit_udev = false;
|
exit_udev = false;
|
||||||
input = in;
|
input = in;
|
||||||
joy_thread = Thread::create(joy_thread_func, this);
|
joy_thread = Thread::create(joy_thread_func, this);
|
||||||
@ -436,11 +436,11 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
|
|||||||
joy.ff_effect_timestamp = p_timestamp;
|
joy.ff_effect_timestamp = p_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
|
Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
|
||||||
|
|
||||||
int min = p_abs->minimum;
|
int min = p_abs->minimum;
|
||||||
int max = p_abs->maximum;
|
int max = p_abs->maximum;
|
||||||
InputDefault::JoyAxis jx;
|
Input::JoyAxis jx;
|
||||||
|
|
||||||
if (min < 0) {
|
if (min < 0) {
|
||||||
jx.min = -1;
|
jx.min = -1;
|
||||||
@ -492,11 +492,11 @@ void JoypadLinux::process_joypads() {
|
|||||||
case ABS_HAT0X:
|
case ABS_HAT0X:
|
||||||
if (ev.value != 0) {
|
if (ev.value != 0) {
|
||||||
if (ev.value < 0)
|
if (ev.value < 0)
|
||||||
joy->dpad |= InputDefault::HAT_MASK_LEFT;
|
joy->dpad |= Input::HAT_MASK_LEFT;
|
||||||
else
|
else
|
||||||
joy->dpad |= InputDefault::HAT_MASK_RIGHT;
|
joy->dpad |= Input::HAT_MASK_RIGHT;
|
||||||
} else
|
} else
|
||||||
joy->dpad &= ~(InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_RIGHT);
|
joy->dpad &= ~(Input::HAT_MASK_LEFT | Input::HAT_MASK_RIGHT);
|
||||||
|
|
||||||
input->joy_hat(i, joy->dpad);
|
input->joy_hat(i, joy->dpad);
|
||||||
break;
|
break;
|
||||||
@ -504,11 +504,11 @@ void JoypadLinux::process_joypads() {
|
|||||||
case ABS_HAT0Y:
|
case ABS_HAT0Y:
|
||||||
if (ev.value != 0) {
|
if (ev.value != 0) {
|
||||||
if (ev.value < 0)
|
if (ev.value < 0)
|
||||||
joy->dpad |= InputDefault::HAT_MASK_UP;
|
joy->dpad |= Input::HAT_MASK_UP;
|
||||||
else
|
else
|
||||||
joy->dpad |= InputDefault::HAT_MASK_DOWN;
|
joy->dpad |= Input::HAT_MASK_DOWN;
|
||||||
} else
|
} else
|
||||||
joy->dpad &= ~(InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_DOWN);
|
joy->dpad &= ~(Input::HAT_MASK_UP | Input::HAT_MASK_DOWN);
|
||||||
|
|
||||||
input->joy_hat(i, joy->dpad);
|
input->joy_hat(i, joy->dpad);
|
||||||
break;
|
break;
|
||||||
@ -517,7 +517,7 @@ void JoypadLinux::process_joypads() {
|
|||||||
if (ev.code >= MAX_ABS)
|
if (ev.code >= MAX_ABS)
|
||||||
return;
|
return;
|
||||||
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
|
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
|
||||||
InputDefault::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
|
Input::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
|
||||||
joy->curr_axis[joy->abs_map[ev.code]] = value;
|
joy->curr_axis[joy->abs_map[ev.code]] = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -33,15 +33,15 @@
|
|||||||
#define JOYPAD_LINUX_H
|
#define JOYPAD_LINUX_H
|
||||||
|
|
||||||
#ifdef JOYDEV_ENABLED
|
#ifdef JOYDEV_ENABLED
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/os/mutex.h"
|
#include "core/os/mutex.h"
|
||||||
#include "core/os/thread.h"
|
#include "core/os/thread.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
|
|
||||||
struct input_absinfo;
|
struct input_absinfo;
|
||||||
|
|
||||||
class JoypadLinux {
|
class JoypadLinux {
|
||||||
public:
|
public:
|
||||||
JoypadLinux(InputDefault *in);
|
JoypadLinux(Input *in);
|
||||||
~JoypadLinux();
|
~JoypadLinux();
|
||||||
void process_joypads();
|
void process_joypads();
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Joypad {
|
struct Joypad {
|
||||||
InputDefault::JoyAxis curr_axis[MAX_ABS];
|
Input::JoyAxis curr_axis[MAX_ABS];
|
||||||
int key_map[MAX_KEY];
|
int key_map[MAX_KEY];
|
||||||
int abs_map[MAX_ABS];
|
int abs_map[MAX_ABS];
|
||||||
int dpad;
|
int dpad;
|
||||||
@ -74,7 +74,7 @@ private:
|
|||||||
bool exit_udev;
|
bool exit_udev;
|
||||||
Mutex joy_mutex;
|
Mutex joy_mutex;
|
||||||
Thread *joy_thread;
|
Thread *joy_thread;
|
||||||
InputDefault *input;
|
Input *input;
|
||||||
Joypad joypads[JOYPADS_MAX];
|
Joypad joypads[JOYPADS_MAX];
|
||||||
Vector<String> attached_devices;
|
Vector<String> attached_devices;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ private:
|
|||||||
void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
|
void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
|
||||||
void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
|
void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
|
||||||
|
|
||||||
InputDefault::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const;
|
Input::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -651,7 +651,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
|
||||||
input = memnew(InputDefault);
|
input = memnew(Input);
|
||||||
|
|
||||||
window_has_focus = true; // Set focus to true at init
|
window_has_focus = true; // Set focus to true at init
|
||||||
#ifdef JOYDEV_ENABLED
|
#ifdef JOYDEV_ENABLED
|
||||||
|
@ -31,14 +31,13 @@
|
|||||||
#ifndef OS_X11_H
|
#ifndef OS_X11_H
|
||||||
#define OS_X11_H
|
#define OS_X11_H
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "crash_handler_x11.h"
|
#include "crash_handler_x11.h"
|
||||||
#include "drivers/alsa/audio_driver_alsa.h"
|
#include "drivers/alsa/audio_driver_alsa.h"
|
||||||
#include "drivers/alsamidi/midi_driver_alsamidi.h"
|
#include "drivers/alsamidi/midi_driver_alsamidi.h"
|
||||||
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
|
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
|
||||||
#include "drivers/unix/os_unix.h"
|
#include "drivers/unix/os_unix.h"
|
||||||
#include "joypad_linux.h"
|
#include "joypad_linux.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
#include "servers/visual/rasterizer.h"
|
#include "servers/visual/rasterizer.h"
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
@ -181,7 +180,7 @@ class OS_X11 : public OS_Unix {
|
|||||||
CursorShape current_cursor;
|
CursorShape current_cursor;
|
||||||
Map<CursorShape, Vector<Variant>> cursors_cache;
|
Map<CursorShape, Vector<Variant>> cursors_cache;
|
||||||
|
|
||||||
InputDefault *input;
|
Input *input;
|
||||||
|
|
||||||
#ifdef JOYDEV_ENABLED
|
#ifdef JOYDEV_ENABLED
|
||||||
JoypadLinux *joypad;
|
JoypadLinux *joypad;
|
||||||
|
@ -29,9 +29,10 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "canvas_item.h"
|
#include "canvas_item.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/message_queue.h"
|
#include "core/message_queue.h"
|
||||||
#include "core/method_bind_ext.gen.inc"
|
#include "core/method_bind_ext.gen.inc"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "scene/main/canvas_layer.h"
|
#include "scene/main/canvas_layer.h"
|
||||||
#include "scene/main/viewport.h"
|
#include "scene/main/viewport.h"
|
||||||
#include "scene/resources/font.h"
|
#include "scene/resources/font.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "touch_screen_button.h"
|
#include "touch_screen_button.h"
|
||||||
|
|
||||||
#include "core/input_map.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input_map.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
|
||||||
void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) {
|
void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "arvr_nodes.h"
|
#include "arvr_nodes.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "servers/arvr/arvr_interface.h"
|
#include "servers/arvr/arvr_interface.h"
|
||||||
#include "servers/arvr_server.h"
|
#include "servers/arvr_server.h"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "color_picker.h"
|
#include "color_picker.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "graph_edit.h"
|
#include "graph_edit.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "popup_menu.h"
|
#include "popup_menu.h"
|
||||||
|
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef SHORTCUT_H
|
#ifndef SHORTCUT_H
|
||||||
#define SHORTCUT_H
|
#define SHORTCUT_H
|
||||||
|
|
||||||
#include "core/os/input_event.h"
|
#include "core/input/input_event.h"
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
|
|
||||||
class ShortCut : public Resource {
|
class ShortCut : public Resource {
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "spin_box.h"
|
#include "spin_box.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/expression.h"
|
#include "core/math/expression.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
|
|
||||||
Size2 SpinBox::get_minimum_size() const {
|
Size2 SpinBox::get_minimum_size() const {
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "text_edit.h"
|
#include "text_edit.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/message_queue.h"
|
#include "core/message_queue.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/math/math_funcs.h"
|
#include "core/math/math_funcs.h"
|
||||||
#include "core/os/input.h"
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "scene_tree.h"
|
#include "scene_tree.h"
|
||||||
|
|
||||||
#include "core/debugger/engine_debugger.h"
|
#include "core/debugger/engine_debugger.h"
|
||||||
|
#include "core/input/input.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/message_queue.h"
|
#include "core/message_queue.h"
|
||||||
@ -39,7 +40,6 @@
|
|||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "scene/debugger/scene_debugger.h"
|
#include "scene/debugger/scene_debugger.h"
|
||||||
#include "scene/resources/dynamic_font.h"
|
#include "scene/resources/dynamic_font.h"
|
||||||
@ -668,7 +668,7 @@ void SceneTree::_notification(int p_notification) {
|
|||||||
|
|
||||||
case NOTIFICATION_WM_FOCUS_IN: {
|
case NOTIFICATION_WM_FOCUS_IN: {
|
||||||
|
|
||||||
InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
|
Input *id = Input::get_singleton();
|
||||||
if (id) {
|
if (id) {
|
||||||
id->ensure_touch_mouse_raised();
|
id->ensure_touch_mouse_raised();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "core/debugger/engine_debugger.h"
|
#include "core/debugger/engine_debugger.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "scene/2d/collision_object_2d.h"
|
#include "scene/2d/collision_object_2d.h"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "arvr_positional_tracker.h"
|
#include "arvr_positional_tracker.h"
|
||||||
#include "core/os/input.h"
|
#include "core/input/input.h"
|
||||||
|
|
||||||
void ARVRPositionalTracker::_bind_methods() {
|
void ARVRPositionalTracker::_bind_methods() {
|
||||||
BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
|
BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
|
||||||
|
374
servers/display_server.cpp
Normal file
374
servers/display_server.cpp
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* display_server.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* 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 "display_server.h"
|
||||||
|
|
||||||
|
DisplayServer *DisplayServer::singleton = nullptr;
|
||||||
|
|
||||||
|
void DisplayServer::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::global_menu_add_separator(const String &p_menu) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::global_menu_remove_item(const String &p_menu, int p_idx) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::global_menu_clear(const String &p_menu) {
|
||||||
|
WARN_PRINT("Global menus not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::mouse_set_mode(MouseMode p_mode) {
|
||||||
|
WARN_PRINT("Mouse is not supported by this display server.");
|
||||||
|
}
|
||||||
|
DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
|
||||||
|
return MOUSE_MODE_VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
|
||||||
|
WARN_PRINT("Mouse warping is not supported by this display server.");
|
||||||
|
}
|
||||||
|
Point2i DisplayServer::mouse_get_position() const {
|
||||||
|
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
|
||||||
|
}
|
||||||
|
int DisplayServer::mouse_get_button_state() const {
|
||||||
|
ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::clipboard_set(const String &p_text) {
|
||||||
|
WARN_PRINT("Clipboard is not supported by this display server.");
|
||||||
|
}
|
||||||
|
String DisplayServer::clipboard_get() const {
|
||||||
|
ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
|
||||||
|
WARN_PRINT("Orientation not supported by this display server.");
|
||||||
|
}
|
||||||
|
DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_screen) const {
|
||||||
|
return SCREEN_LANDSCAPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayServer::WindowID DisplayServer::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i) {
|
||||||
|
ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Sub-windows not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::delete_sub_window(WindowID p_id) {
|
||||||
|
ERR_FAIL_MSG("Sub-windows not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) {
|
||||||
|
WARN_PRINT("IME not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
|
||||||
|
WARN_PRINT("IME not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Point2i DisplayServer::ime_get_selection() const {
|
||||||
|
ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
|
||||||
|
}
|
||||||
|
String DisplayServer::ime_get_text() const {
|
||||||
|
ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::console_set_visible(bool p_enabled) {
|
||||||
|
WARN_PRINT("Console window not supported by this display server.");
|
||||||
|
}
|
||||||
|
bool DisplayServer::is_console_visible() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect) {
|
||||||
|
WARN_PRINT("Virtual keyboard not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::virtual_keyboard_hide() {
|
||||||
|
WARN_PRINT("Virtual keyboard not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns height of the currently shown keyboard (0 if keyboard is hidden)
|
||||||
|
int DisplayServer::virtual_keyboard_get_height() const {
|
||||||
|
ERR_FAIL_V_MSG(0, "Virtual keyboad not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::cursor_set_shape(CursorShape p_shape) {
|
||||||
|
WARN_PRINT("Cursor shape not supported by this display server.");
|
||||||
|
}
|
||||||
|
DisplayServer::CursorShape DisplayServer::cursor_get_shape() const {
|
||||||
|
return CURSOR_ARROW;
|
||||||
|
}
|
||||||
|
void DisplayServer::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
|
||||||
|
WARN_PRINT("Custom cursor shape not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayServer::get_swap_ok_cancel() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
|
||||||
|
Error DisplayServer::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen) {
|
||||||
|
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Native video not supported by this display server.");
|
||||||
|
}
|
||||||
|
bool DisplayServer::native_video_is_playing() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void DisplayServer::native_video_pause() {
|
||||||
|
WARN_PRINT("Native video not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::native_video_unpause() {
|
||||||
|
WARN_PRINT("Native video not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::native_video_stop() {
|
||||||
|
WARN_PRINT("Native video not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Error DisplayServer::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
|
||||||
|
WARN_PRINT("Native dialogs not supported by this display server.");
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
Error DisplayServer::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
|
||||||
|
WARN_PRINT("Native dialogs not supported by this display server.");
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayServer::LatinKeyboardVariant DisplayServer::get_latin_keyboard_variant() const {
|
||||||
|
return LATIN_KEYBOARD_QWERTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::force_process_and_drop_events() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::release_rendering_thread() {
|
||||||
|
WARN_PRINT("Rendering thread not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::make_rendering_thread() {
|
||||||
|
WARN_PRINT("Rendering thread not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::swap_buffers() {
|
||||||
|
WARN_PRINT("Swap buffers not supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::set_native_icon(const String &p_filename) {
|
||||||
|
WARN_PRINT("Native icon not supported by this display server.");
|
||||||
|
}
|
||||||
|
void DisplayServer::set_icon(const Ref<Image> &p_icon) {
|
||||||
|
WARN_PRINT("Iconnot supported by this display server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServer::_bind_methods() {
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_name"), &DisplayServer::get_name);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu", "label", "id", "meta"), &DisplayServer::global_menu_add_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu"), &DisplayServer::global_menu_add_separator);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu", "idx"), &DisplayServer::global_menu_remove_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("global_menu_clear", "menu"), &DisplayServer::global_menu_clear);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!"));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode);
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_warp_to_position", "position"), &DisplayServer::mouse_warp_to_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_get_position"), &DisplayServer::mouse_get_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
|
||||||
|
ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_count"), &DisplayServer::get_screen_count);
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_get_position", "screen"), &DisplayServer::screen_get_position, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_get_size", "screen"), &DisplayServer::screen_get_size, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_is_touchscreen", "screen"), &DisplayServer::screen_is_touchscreen, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
ClassDB::bind_method(D_METHOD("screen_get_orientation", "screen"), &DisplayServer::screen_get_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_window_list"), &DisplayServer::get_window_list);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("create_sub_window", "mode", "rect"), &DisplayServer::create_sub_window, DEFVAL(Rect2i()));
|
||||||
|
ClassDB::bind_method(D_METHOD("delete_sub_window", "window_id"), &DisplayServer::delete_sub_window);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_title", "title", "window_id"), &DisplayServer::window_set_title, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_current_screen", "window_id"), &DisplayServer::window_get_current_screen, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_current_screen", "screen", "window_id"), &DisplayServer::window_set_current_screen, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_position", "window_id"), &DisplayServer::window_get_position, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_position", "position", "window_id"), &DisplayServer::window_set_position, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_size", "window_id"), &DisplayServer::window_get_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_size", "size", "window_id"), &DisplayServer::window_set_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_max_size", "window_id"), &DisplayServer::window_get_max_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_max_size", "max_size", "window_id"), &DisplayServer::window_set_max_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_min_size", "window_id"), &DisplayServer::window_get_min_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_min_size", "min_size", "window_id"), &DisplayServer::window_set_min_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_real_size", "window_id"), &DisplayServer::window_get_real_size, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_mode", "window_id"), &DisplayServer::window_get_mode, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_mode", "mode", "window_id"), &DisplayServer::window_set_mode, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_flag", "flag", "enabled", "window_id"), &DisplayServer::window_set_flag, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_get_flag", "flag", "window_id"), &DisplayServer::window_get_flag, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_request_attention", "window_id"), &DisplayServer::window_request_attention, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_move_to_foreground", "window_id"), &DisplayServer::window_move_to_foreground, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_can_draw", "window_id"), &DisplayServer::window_can_draw, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_ime_active", "active", "window_id"), &DisplayServer::window_set_ime_active, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
ClassDB::bind_method(D_METHOD("window_set_ime_position", "position", "window_id"), &DisplayServer::window_set_ime_position, DEFVAL(MAIN_WINDOW_ID));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
|
||||||
|
ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("console_set_visible", "console_visible"), &DisplayServer::console_set_visible);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_console_visible"), &DisplayServer::is_console_visible);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()));
|
||||||
|
ClassDB::bind_method(D_METHOD("virtual_keyboard_hide"), &DisplayServer::virtual_keyboard_hide);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
|
||||||
|
ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
|
||||||
|
ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_swap_ok_cancel"), &DisplayServer::get_swap_ok_cancel);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("native_video_play", "path", "volume", "audio_track", "subtitle_track"), &DisplayServer::native_video_play);
|
||||||
|
ClassDB::bind_method(D_METHOD("native_video_is_playing"), &DisplayServer::native_video_is_playing);
|
||||||
|
ClassDB::bind_method(D_METHOD("native_video_stop"), &DisplayServer::native_video_stop);
|
||||||
|
ClassDB::bind_method(D_METHOD("native_video_pause"), &DisplayServer::native_video_pause);
|
||||||
|
ClassDB::bind_method(D_METHOD("native_video_unpause"), &DisplayServer::native_video_unpause);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show);
|
||||||
|
ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_show);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
|
||||||
|
ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &DisplayServer::set_native_icon);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_icon", "image"), &DisplayServer::set_icon);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_GLOBAL_MENU);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_SUBWINDOWS);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_TOUCHSCREEN);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_MOUSE);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_MOUSE_WARP);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_CLIPBOARD);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_VIRTUAL_KEYBOARD);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_CURSOR_SHAPE);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_CUSTOM_CURSOR_SHAPE);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_NATIVE_VIDEO);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_CONSOLE_WINDOW);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_IME);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_WINDOW_TRANSPARENCY);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_HIDPI);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_ICON);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_NATIVE_ICON);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_ORIENTATION);
|
||||||
|
BIND_ENUM_CONSTANT(FEATURE_SWAP_BUFFERS);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
|
||||||
|
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
|
||||||
|
|
||||||
|
BIND_CONSTANT(SCREEN_OF_MAIN_WINDOW);
|
||||||
|
BIND_CONSTANT(MAIN_WINDOW_ID);
|
||||||
|
BIND_CONSTANT(INVALID_WINDOW_ID);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_LANDSCAPE);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_PORTRAIT);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_REVERSE_LANDSCAPE);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_REVERSE_PORTRAIT);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_SENSOR_LANDSCAPE);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_SENSOR_PORTRAIT);
|
||||||
|
BIND_ENUM_CONSTANT(SCREEN_SENSOR);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_ARROW);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_IBEAM);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_CROSS);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_WAIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_BUSY);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_DRAG);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_VSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_MOVE);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_HELP);
|
||||||
|
BIND_ENUM_CONSTANT(CURSOR_MAX);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_MODE_WINDOWED);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_MODE_MINIMIZED);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_MODE_MAXIMIZED);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_MODE_FULLSCREEN);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED_BIT);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS_BIT);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP_BIT);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT_BIT);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTY);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTZ);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_AZERTY);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QZERTY);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_DVORAK);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_NEO);
|
||||||
|
BIND_ENUM_CONSTANT(LATIN_KEYBOARD_COLEMAK);
|
||||||
|
}
|
||||||
|
DisplayServer::DisplayServer() {
|
||||||
|
singleton = this;
|
||||||
|
}
|
||||||
|
DisplayServer::~DisplayServer() {
|
||||||
|
}
|
273
servers/display_server.h
Normal file
273
servers/display_server.h
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* display_server.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* 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 DISPLAY_SERVER_H
|
||||||
|
#define DISPLAY_SERVER_H
|
||||||
|
|
||||||
|
#include "core/os/os.h"
|
||||||
|
#include "core/resource.h"
|
||||||
|
|
||||||
|
class DisplayServer : public Object {
|
||||||
|
GDCLASS(DisplayServer, Object)
|
||||||
|
|
||||||
|
static DisplayServer *singleton;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Feature {
|
||||||
|
FEATURE_GLOBAL_MENU,
|
||||||
|
FEATURE_SUBWINDOWS,
|
||||||
|
FEATURE_TOUCHSCREEN,
|
||||||
|
FEATURE_MOUSE,
|
||||||
|
FEATURE_MOUSE_WARP,
|
||||||
|
FEATURE_CLIPBOARD,
|
||||||
|
FEATURE_VIRTUAL_KEYBOARD,
|
||||||
|
FEATURE_CURSOR_SHAPE,
|
||||||
|
FEATURE_CUSTOM_CURSOR_SHAPE,
|
||||||
|
FEATURE_NATIVE_VIDEO,
|
||||||
|
FEATURE_NATIVE_DIALOG,
|
||||||
|
FEATURE_CONSOLE_WINDOW,
|
||||||
|
FEATURE_IME,
|
||||||
|
FEATURE_WINDOW_TRANSPARENCY,
|
||||||
|
FEATURE_HIDPI,
|
||||||
|
FEATURE_ICON,
|
||||||
|
FEATURE_NATIVE_ICON,
|
||||||
|
FEATURE_ORIENTATION,
|
||||||
|
FEATURE_SWAP_BUFFERS
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual bool has_feature(Feature p_feature) const = 0;
|
||||||
|
virtual String get_name() const = 0;
|
||||||
|
|
||||||
|
virtual void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
|
||||||
|
virtual void global_menu_add_separator(const String &p_menu);
|
||||||
|
virtual void global_menu_remove_item(const String &p_menu, int p_idx);
|
||||||
|
virtual void global_menu_clear(const String &p_menu);
|
||||||
|
|
||||||
|
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
|
||||||
|
|
||||||
|
enum MouseMode {
|
||||||
|
MOUSE_MODE_VISIBLE,
|
||||||
|
MOUSE_MODE_HIDDEN,
|
||||||
|
MOUSE_MODE_CAPTURED,
|
||||||
|
MOUSE_MODE_CONFINED
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void mouse_set_mode(MouseMode p_mode);
|
||||||
|
virtual MouseMode mouse_get_mode() const;
|
||||||
|
|
||||||
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
|
virtual Point2i mouse_get_position() const;
|
||||||
|
virtual int mouse_get_button_state() const;
|
||||||
|
|
||||||
|
virtual void clipboard_set(const String &p_text);
|
||||||
|
virtual String clipboard_get() const;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SCREEN_OF_MAIN_WINDOW = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual int get_screen_count() const = 0;
|
||||||
|
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
|
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
|
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
|
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
|
||||||
|
|
||||||
|
enum ScreenOrientation {
|
||||||
|
|
||||||
|
SCREEN_LANDSCAPE,
|
||||||
|
SCREEN_PORTRAIT,
|
||||||
|
SCREEN_REVERSE_LANDSCAPE,
|
||||||
|
SCREEN_REVERSE_PORTRAIT,
|
||||||
|
SCREEN_SENSOR_LANDSCAPE,
|
||||||
|
SCREEN_SENSOR_PORTRAIT,
|
||||||
|
SCREEN_SENSOR,
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
|
||||||
|
ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MAIN_WINDOW_ID = 0,
|
||||||
|
INVALID_WINDOW_ID = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int WindowID;
|
||||||
|
|
||||||
|
virtual Vector<int> get_window_list() const = 0;
|
||||||
|
|
||||||
|
enum WindowMode {
|
||||||
|
WINDOW_MODE_WINDOWED,
|
||||||
|
WINDOW_MODE_MINIMIZED,
|
||||||
|
WINDOW_MODE_MAXIMIZED,
|
||||||
|
WINDOW_MODE_FULLSCREEN
|
||||||
|
};
|
||||||
|
|
||||||
|
enum WindowFlags {
|
||||||
|
WINDOW_FLAG_RESIZE_DISABLED,
|
||||||
|
WINDOW_FLAG_BORDERLESS,
|
||||||
|
WINDOW_FLAG_ALWAYS_ON_TOP,
|
||||||
|
WINDOW_FLAG_TRANSPARENT,
|
||||||
|
WINDOW_FLAG_MAX,
|
||||||
|
WINDOW_FLAG_RESIZE_DISABLED_BIT = (1 << WINDOW_FLAG_RESIZE_DISABLED),
|
||||||
|
WINDOW_FLAG_BORDERLESS_BIT = (1 << WINDOW_FLAG_BORDERLESS),
|
||||||
|
WINDOW_FLAG_ALWAYS_ON_TOP_BIT = (1 << WINDOW_FLAG_ALWAYS_ON_TOP),
|
||||||
|
WINDOW_FLAG_TRANSPARENT_BIT = (1 << WINDOW_FLAG_TRANSPARENT)
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i = Rect2i());
|
||||||
|
virtual void delete_sub_window(WindowID p_id);
|
||||||
|
|
||||||
|
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
|
||||||
|
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
|
||||||
|
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
|
||||||
|
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const = 0; // FIXME: Find clearer name for this.
|
||||||
|
|
||||||
|
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) = 0;
|
||||||
|
|
||||||
|
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const = 0;
|
||||||
|
|
||||||
|
virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
|
||||||
|
|
||||||
|
virtual Point2i ime_get_selection() const;
|
||||||
|
virtual String ime_get_text() const;
|
||||||
|
|
||||||
|
virtual void console_set_visible(bool p_enabled);
|
||||||
|
virtual bool is_console_visible() const;
|
||||||
|
|
||||||
|
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2());
|
||||||
|
virtual void virtual_keyboard_hide();
|
||||||
|
|
||||||
|
// returns height of the currently shown virtual keyboard (0 if keyboard is hidden)
|
||||||
|
virtual int virtual_keyboard_get_height() const;
|
||||||
|
|
||||||
|
enum CursorShape {
|
||||||
|
CURSOR_ARROW,
|
||||||
|
CURSOR_IBEAM,
|
||||||
|
CURSOR_POINTING_HAND,
|
||||||
|
CURSOR_CROSS,
|
||||||
|
CURSOR_WAIT,
|
||||||
|
CURSOR_BUSY,
|
||||||
|
CURSOR_DRAG,
|
||||||
|
CURSOR_CAN_DROP,
|
||||||
|
CURSOR_FORBIDDEN,
|
||||||
|
CURSOR_VSIZE,
|
||||||
|
CURSOR_HSIZE,
|
||||||
|
CURSOR_BDIAGSIZE,
|
||||||
|
CURSOR_FDIAGSIZE,
|
||||||
|
CURSOR_MOVE,
|
||||||
|
CURSOR_VSPLIT,
|
||||||
|
CURSOR_HSPLIT,
|
||||||
|
CURSOR_HELP,
|
||||||
|
CURSOR_MAX
|
||||||
|
};
|
||||||
|
virtual void cursor_set_shape(CursorShape p_shape);
|
||||||
|
virtual CursorShape cursor_get_shape() const;
|
||||||
|
virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
|
||||||
|
|
||||||
|
virtual bool get_swap_ok_cancel();
|
||||||
|
|
||||||
|
virtual void enable_for_stealing_focus(OS::ProcessID pid);
|
||||||
|
|
||||||
|
//plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
|
||||||
|
virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen = SCREEN_OF_MAIN_WINDOW);
|
||||||
|
virtual bool native_video_is_playing() const;
|
||||||
|
virtual void native_video_pause();
|
||||||
|
virtual void native_video_unpause();
|
||||||
|
virtual void native_video_stop();
|
||||||
|
|
||||||
|
virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback);
|
||||||
|
virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback);
|
||||||
|
|
||||||
|
enum LatinKeyboardVariant {
|
||||||
|
LATIN_KEYBOARD_QWERTY,
|
||||||
|
LATIN_KEYBOARD_QWERTZ,
|
||||||
|
LATIN_KEYBOARD_AZERTY,
|
||||||
|
LATIN_KEYBOARD_QZERTY,
|
||||||
|
LATIN_KEYBOARD_DVORAK,
|
||||||
|
LATIN_KEYBOARD_NEO,
|
||||||
|
LATIN_KEYBOARD_COLEMAK,
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||||
|
|
||||||
|
virtual void process_events() = 0;
|
||||||
|
|
||||||
|
virtual void force_process_and_drop_events();
|
||||||
|
|
||||||
|
virtual void release_rendering_thread();
|
||||||
|
virtual void make_rendering_thread();
|
||||||
|
virtual void swap_buffers();
|
||||||
|
|
||||||
|
virtual void set_native_icon(const String &p_filename);
|
||||||
|
virtual void set_icon(const Ref<Image> &p_icon);
|
||||||
|
|
||||||
|
typedef Vector<String> *(*GetSupportedVideoDriversFunction)();
|
||||||
|
typedef DisplayServer *(*CreateFunction)(const String &, WindowMode, uint32_t, const Size2i &, Error &r_error); //video driver, window mode, resolution
|
||||||
|
|
||||||
|
DisplayServer();
|
||||||
|
~DisplayServer();
|
||||||
|
};
|
||||||
|
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::Feature)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::MouseMode)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::ScreenOrientation)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::WindowMode)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::WindowFlags)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::CursorShape)
|
||||||
|
VARIANT_ENUM_CAST(DisplayServer::LatinKeyboardVariant)
|
||||||
|
|
||||||
|
#endif // DISPLAY_SERVER_H
|
@ -29,6 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "register_server_types.h"
|
#include "register_server_types.h"
|
||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
|
||||||
@ -56,6 +57,7 @@
|
|||||||
#include "audio_server.h"
|
#include "audio_server.h"
|
||||||
#include "camera/camera_feed.h"
|
#include "camera/camera_feed.h"
|
||||||
#include "camera_server.h"
|
#include "camera_server.h"
|
||||||
|
#include "display_server.h"
|
||||||
#include "navigation_2d_server.h"
|
#include "navigation_2d_server.h"
|
||||||
#include "navigation_server.h"
|
#include "navigation_server.h"
|
||||||
#include "physics/physics_server_sw.h"
|
#include "physics/physics_server_sw.h"
|
||||||
@ -95,6 +97,7 @@ void register_server_types() {
|
|||||||
|
|
||||||
OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
|
OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
|
||||||
|
|
||||||
|
ClassDB::register_virtual_class<DisplayServer>();
|
||||||
ClassDB::register_virtual_class<VisualServer>();
|
ClassDB::register_virtual_class<VisualServer>();
|
||||||
ClassDB::register_class<AudioServer>();
|
ClassDB::register_class<AudioServer>();
|
||||||
ClassDB::register_virtual_class<PhysicsServer>();
|
ClassDB::register_virtual_class<PhysicsServer>();
|
||||||
|
Loading…
Reference in New Issue
Block a user