Use mouse and joypad enums instead of plain integers
Also MIDIMessage
This commit is contained in:
parent
e919d894f8
commit
0ce49800ac
|
@ -227,7 +227,7 @@ bool Input::is_key_pressed(int p_keycode) const {
|
||||||
return keys_pressed.has(p_keycode);
|
return keys_pressed.has(p_keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::is_mouse_button_pressed(int p_button) const {
|
bool Input::is_mouse_button_pressed(MouseButton 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;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ static int _combine_device(int p_value, int p_device) {
|
||||||
return p_value | (p_device << 20);
|
return p_value | (p_device << 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::is_joy_button_pressed(int p_device, int p_button) const {
|
bool Input::is_joy_button_pressed(int p_device, JoyButton 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));
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Input::get_joy_axis(int p_device, int p_axis) const {
|
float Input::get_joy_axis(int p_device, JoyAxis 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);
|
||||||
if (_joy_axis.has(c)) {
|
if (_joy_axis.has(c)) {
|
||||||
|
@ -433,7 +433,7 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S
|
||||||
joy_buttons_pressed.erase(c);
|
joy_buttons_pressed.erase(c);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < JOY_AXIS_MAX; i++) {
|
for (int i = 0; i < JOY_AXIS_MAX; i++) {
|
||||||
set_joy_axis(p_idx, i, 0.0f);
|
set_joy_axis(p_idx, (JoyAxis)i, 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
joy_names[p_idx] = js;
|
joy_names[p_idx] = js;
|
||||||
|
@ -488,9 +488,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
|
||||||
|
|
||||||
if (mb.is_valid()) {
|
if (mb.is_valid()) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
mouse_button_mask |= (1 << (mb->get_button_index() - 1));
|
mouse_button_mask |= (MouseButton)(1 << (mb->get_button_index() - 1));
|
||||||
} else {
|
} else {
|
||||||
mouse_button_mask &= ~(1 << (mb->get_button_index() - 1));
|
mouse_button_mask &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2 pos = mb->get_global_position();
|
Point2 pos = mb->get_global_position();
|
||||||
|
@ -563,9 +563,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
|
||||||
button_event->set_pressed(st->is_pressed());
|
button_event->set_pressed(st->is_pressed());
|
||||||
button_event->set_button_index(MOUSE_BUTTON_LEFT);
|
button_event->set_button_index(MOUSE_BUTTON_LEFT);
|
||||||
if (st->is_pressed()) {
|
if (st->is_pressed()) {
|
||||||
button_event->set_button_mask(mouse_button_mask | (1 << (MOUSE_BUTTON_LEFT - 1)));
|
button_event->set_button_mask(MouseButton(mouse_button_mask | MOUSE_BUTTON_MASK_LEFT));
|
||||||
} else {
|
} else {
|
||||||
button_event->set_button_mask(mouse_button_mask & ~(1 << (MOUSE_BUTTON_LEFT - 1)));
|
button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
_parse_input_event_impl(button_event, true);
|
_parse_input_event_impl(button_event, true);
|
||||||
|
@ -644,7 +644,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::set_joy_axis(int p_device, int p_axis, float p_value) {
|
void Input::set_joy_axis(int p_device, JoyAxis 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;
|
||||||
|
@ -794,7 +794,7 @@ void Input::ensure_touch_mouse_raised() {
|
||||||
button_event->set_global_position(mouse_pos);
|
button_event->set_global_position(mouse_pos);
|
||||||
button_event->set_pressed(false);
|
button_event->set_pressed(false);
|
||||||
button_event->set_button_index(MOUSE_BUTTON_LEFT);
|
button_event->set_button_index(MOUSE_BUTTON_LEFT);
|
||||||
button_event->set_button_mask(mouse_button_mask & ~(1 << (MOUSE_BUTTON_LEFT - 1)));
|
button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
|
||||||
|
|
||||||
_parse_input_event_impl(button_event, true);
|
_parse_input_event_impl(button_event, true);
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ void Input::set_event_dispatch_function(EventDispatchFunc p_function) {
|
||||||
event_dispatch_function = p_function;
|
event_dispatch_function = p_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::joy_button(int p_device, int p_button, bool p_pressed) {
|
void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
Joypad &joy = joy_names[p_device];
|
Joypad &joy = joy_names[p_device];
|
||||||
//printf("got button %i, mapping is %i\n", p_button, joy.mapping);
|
//printf("got button %i, mapping is %i\n", p_button, joy.mapping);
|
||||||
|
@ -898,17 +898,17 @@ void Input::joy_button(int p_device, int p_button, bool p_pressed) {
|
||||||
JoyEvent map = _get_mapped_button_event(map_db[joy.mapping], p_button);
|
JoyEvent map = _get_mapped_button_event(map_db[joy.mapping], p_button);
|
||||||
|
|
||||||
if (map.type == TYPE_BUTTON) {
|
if (map.type == TYPE_BUTTON) {
|
||||||
_button_event(p_device, map.index, p_pressed);
|
_button_event(p_device, (JoyButton)map.index, p_pressed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.type == TYPE_AXIS) {
|
if (map.type == TYPE_AXIS) {
|
||||||
_axis_event(p_device, map.index, p_pressed ? map.value : 0.0);
|
_axis_event(p_device, (JoyAxis)map.index, p_pressed ? map.value : 0.0);
|
||||||
}
|
}
|
||||||
// no event?
|
// no event?
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
|
void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value) {
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
|
|
||||||
ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
|
ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
|
||||||
|
@ -949,7 +949,7 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
|
||||||
// Button already pressed or released; so ignore.
|
// Button already pressed or released; so ignore.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_button_event(p_device, map.index, pressed);
|
_button_event(p_device, (JoyButton)map.index, pressed);
|
||||||
|
|
||||||
// Ensure opposite D-Pad button is also released.
|
// Ensure opposite D-Pad button is also released.
|
||||||
switch (map.index) {
|
switch (map.index) {
|
||||||
|
@ -981,7 +981,7 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.type == TYPE_AXIS) {
|
if (map.type == TYPE_AXIS) {
|
||||||
_axis_event(p_device, map.index, map.value);
|
_axis_event(p_device, (JoyAxis)map.index, map.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//printf("invalid mapping\n");
|
//printf("invalid mapping\n");
|
||||||
|
@ -1010,7 +1010,7 @@ void Input::joy_hat(int p_device, int p_val) {
|
||||||
map[HatDir::HAT_LEFT].value = 0;
|
map[HatDir::HAT_LEFT].value = 0;
|
||||||
|
|
||||||
if (joy.mapping != -1) {
|
if (joy.mapping != -1) {
|
||||||
_get_mapped_hat_events(map_db[joy.mapping], 0, map);
|
_get_mapped_hat_events(map_db[joy.mapping], (HatDir)0, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cur_val = joy_names[p_device].hat_current;
|
int cur_val = joy_names[p_device].hat_current;
|
||||||
|
@ -1018,10 +1018,10 @@ void Input::joy_hat(int p_device, int p_val) {
|
||||||
for (int hat_direction = 0, hat_mask = 1; hat_direction < HAT_MAX; hat_direction++, hat_mask <<= 1) {
|
for (int hat_direction = 0, hat_mask = 1; hat_direction < HAT_MAX; hat_direction++, hat_mask <<= 1) {
|
||||||
if ((p_val & hat_mask) != (cur_val & hat_mask)) {
|
if ((p_val & hat_mask) != (cur_val & hat_mask)) {
|
||||||
if (map[hat_direction].type == TYPE_BUTTON) {
|
if (map[hat_direction].type == TYPE_BUTTON) {
|
||||||
_button_event(p_device, map[hat_direction].index, p_val & hat_mask);
|
_button_event(p_device, (JoyButton)map[hat_direction].index, p_val & hat_mask);
|
||||||
}
|
}
|
||||||
if (map[hat_direction].type == TYPE_AXIS) {
|
if (map[hat_direction].type == TYPE_AXIS) {
|
||||||
_axis_event(p_device, map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
|
_axis_event(p_device, (JoyAxis)map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1029,7 @@ void Input::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 Input::_button_event(int p_device, int p_index, bool p_pressed) {
|
void Input::_button_event(int p_device, JoyButton p_index, bool p_pressed) {
|
||||||
Ref<InputEventJoypadButton> ievent;
|
Ref<InputEventJoypadButton> ievent;
|
||||||
ievent.instantiate();
|
ievent.instantiate();
|
||||||
ievent->set_device(p_device);
|
ievent->set_device(p_device);
|
||||||
|
@ -1039,7 +1039,7 @@ void Input::_button_event(int p_device, int p_index, bool p_pressed) {
|
||||||
parse_input_event(ievent);
|
parse_input_event(ievent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::_axis_event(int p_device, int p_axis, float p_value) {
|
void Input::_axis_event(int p_device, JoyAxis p_axis, float p_value) {
|
||||||
Ref<InputEventJoypadMotion> ievent;
|
Ref<InputEventJoypadMotion> ievent;
|
||||||
ievent.instantiate();
|
ievent.instantiate();
|
||||||
ievent->set_device(p_device);
|
ievent->set_device(p_device);
|
||||||
|
@ -1049,7 +1049,7 @@ void Input::_axis_event(int p_device, int p_axis, float p_value) {
|
||||||
parse_input_event(ievent);
|
parse_input_event(ievent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button) {
|
Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button) {
|
||||||
JoyEvent event;
|
JoyEvent event;
|
||||||
event.type = TYPE_MAX;
|
event.type = TYPE_MAX;
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value) {
|
Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value) {
|
||||||
JoyEvent event;
|
JoyEvent event;
|
||||||
event.type = TYPE_MAX;
|
event.type = TYPE_MAX;
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, i
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[]) {
|
void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[]) {
|
||||||
for (int i = 0; i < mapping.bindings.size(); i++) {
|
for (int i = 0; i < mapping.bindings.size(); i++) {
|
||||||
const JoyBinding binding = mapping.bindings[i];
|
const JoyBinding binding = mapping.bindings[i];
|
||||||
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
|
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
|
||||||
|
@ -1300,11 +1300,11 @@ void Input::parse_mapping(String p_mapping) {
|
||||||
switch (input[0]) {
|
switch (input[0]) {
|
||||||
case 'b':
|
case 'b':
|
||||||
binding.inputType = TYPE_BUTTON;
|
binding.inputType = TYPE_BUTTON;
|
||||||
binding.input.button = input.substr(1).to_int();
|
binding.input.button = (JoyButton)input.substr(1).to_int();
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
binding.inputType = TYPE_AXIS;
|
binding.inputType = TYPE_AXIS;
|
||||||
binding.input.axis.axis = input.substr(1).to_int();
|
binding.input.axis.axis = (JoyAxis)input.substr(1).to_int();
|
||||||
binding.input.axis.range = input_range;
|
binding.input.axis.range = input_range;
|
||||||
binding.input.axis.invert = invert_axis;
|
binding.input.axis.invert = invert_axis;
|
||||||
break;
|
break;
|
||||||
|
@ -1312,7 +1312,7 @@ void Input::parse_mapping(String p_mapping) {
|
||||||
ERR_CONTINUE_MSG(input.length() != 4 || input[2] != '.',
|
ERR_CONTINUE_MSG(input.length() != 4 || input[2] != '.',
|
||||||
String(entry[idx] + "\nInvalid hat input: " + input));
|
String(entry[idx] + "\nInvalid hat input: " + input));
|
||||||
binding.inputType = TYPE_HAT;
|
binding.inputType = TYPE_HAT;
|
||||||
binding.input.hat.hat = input.substr(1, 1).to_int();
|
binding.input.hat.hat = (HatDir)input.substr(1, 1).to_int();
|
||||||
binding.input.hat.hat_mask = static_cast<HatMask>(input.substr(3).to_int());
|
binding.input.hat.hat_mask = static_cast<HatMask>(input.substr(3).to_int());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -167,16 +167,16 @@ private:
|
||||||
struct JoyBinding {
|
struct JoyBinding {
|
||||||
JoyType inputType;
|
JoyType inputType;
|
||||||
union {
|
union {
|
||||||
int button;
|
JoyButton button;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int axis;
|
JoyAxis axis;
|
||||||
JoyAxisRange range;
|
JoyAxisRange range;
|
||||||
bool invert;
|
bool invert;
|
||||||
} axis;
|
} axis;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int hat;
|
HatDir hat;
|
||||||
HatMask hat_mask;
|
HatMask hat_mask;
|
||||||
} hat;
|
} hat;
|
||||||
|
|
||||||
|
@ -202,13 +202,13 @@ private:
|
||||||
|
|
||||||
Vector<JoyDeviceMapping> map_db;
|
Vector<JoyDeviceMapping> map_db;
|
||||||
|
|
||||||
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button);
|
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button);
|
||||||
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value);
|
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value);
|
||||||
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[HAT_MAX]);
|
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[HAT_MAX]);
|
||||||
JoyButton _get_output_button(String output);
|
JoyButton _get_output_button(String output);
|
||||||
JoyAxis _get_output_axis(String output);
|
JoyAxis _get_output_axis(String output);
|
||||||
void _button_event(int p_device, int p_index, bool p_pressed);
|
void _button_event(int p_device, JoyButton p_index, bool p_pressed);
|
||||||
void _axis_event(int p_device, int p_axis, float p_value);
|
void _axis_event(int p_device, JoyAxis p_axis, float p_value);
|
||||||
|
|
||||||
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
|
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
|
||||||
|
|
||||||
|
@ -245,8 +245,8 @@ public:
|
||||||
static Input *get_singleton();
|
static Input *get_singleton();
|
||||||
|
|
||||||
bool is_key_pressed(int p_keycode) const;
|
bool is_key_pressed(int p_keycode) const;
|
||||||
bool is_mouse_button_pressed(int p_button) const;
|
bool is_mouse_button_pressed(MouseButton p_button) const;
|
||||||
bool is_joy_button_pressed(int p_device, int p_button) const;
|
bool is_joy_button_pressed(int p_device, JoyButton p_button) const;
|
||||||
bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;
|
bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;
|
||||||
bool is_action_just_pressed(const StringName &p_action, bool p_exact = false) const;
|
bool is_action_just_pressed(const StringName &p_action, bool p_exact = false) const;
|
||||||
bool is_action_just_released(const StringName &p_action, bool p_exact = false) const;
|
bool is_action_just_released(const StringName &p_action, bool p_exact = false) const;
|
||||||
|
@ -256,7 +256,7 @@ public:
|
||||||
float get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const;
|
float get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const;
|
||||||
Vector2 get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone = -1.0f) const;
|
Vector2 get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone = -1.0f) const;
|
||||||
|
|
||||||
float get_joy_axis(int p_device, int p_axis) const;
|
float get_joy_axis(int p_device, JoyAxis p_axis) const;
|
||||||
String get_joy_name(int p_idx);
|
String get_joy_name(int p_idx);
|
||||||
Array get_connected_joypads();
|
Array get_connected_joypads();
|
||||||
Vector2 get_joy_vibration_strength(int p_device);
|
Vector2 get_joy_vibration_strength(int p_device);
|
||||||
|
@ -283,7 +283,7 @@ public:
|
||||||
void set_accelerometer(const Vector3 &p_accel);
|
void set_accelerometer(const Vector3 &p_accel);
|
||||||
void set_magnetometer(const Vector3 &p_magnetometer);
|
void set_magnetometer(const Vector3 &p_magnetometer);
|
||||||
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, JoyAxis p_axis, float p_value);
|
||||||
|
|
||||||
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);
|
||||||
void stop_joy_vibration(int p_device);
|
void stop_joy_vibration(int p_device);
|
||||||
|
@ -309,8 +309,8 @@ public:
|
||||||
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, JoyButton p_button, bool p_pressed);
|
||||||
void joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value);
|
void joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value);
|
||||||
void joy_hat(int p_device, int p_val);
|
void joy_hat(int p_device, int p_val);
|
||||||
|
|
||||||
void add_joy_mapping(String p_mapping, bool p_update_existing = false);
|
void add_joy_mapping(String p_mapping, bool p_update_existing = false);
|
||||||
|
|
|
@ -516,11 +516,11 @@ float InputEventMouseButton::get_factor() const {
|
||||||
return factor;
|
return factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventMouseButton::set_button_index(int p_index) {
|
void InputEventMouseButton::set_button_index(MouseButton p_index) {
|
||||||
button_index = p_index;
|
button_index = p_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputEventMouseButton::get_button_index() const {
|
MouseButton InputEventMouseButton::get_button_index() const {
|
||||||
return button_index;
|
return button_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,11 +845,11 @@ void InputEventMouseMotion::_bind_methods() {
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
void InputEventJoypadMotion::set_axis(int p_axis) {
|
void InputEventJoypadMotion::set_axis(JoyAxis p_axis) {
|
||||||
axis = p_axis;
|
axis = p_axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputEventJoypadMotion::get_axis() const {
|
JoyAxis InputEventJoypadMotion::get_axis() const {
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,11 +947,11 @@ void InputEventJoypadMotion::_bind_methods() {
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
void InputEventJoypadButton::set_button_index(int p_index) {
|
void InputEventJoypadButton::set_button_index(JoyButton p_index) {
|
||||||
button_index = p_index;
|
button_index = p_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputEventJoypadButton::get_button_index() const {
|
JoyButton InputEventJoypadButton::get_button_index() const {
|
||||||
return button_index;
|
return button_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1046,7 @@ String InputEventJoypadButton::to_string() {
|
||||||
return vformat("InputEventJoypadButton: button_index=%d, pressed=%s, pressure=%.2f", button_index, p, pressure);
|
return vformat("InputEventJoypadButton: button_index=%d, pressed=%s, pressure=%.2f", button_index, p, pressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<InputEventJoypadButton> InputEventJoypadButton::create_reference(int p_btn_index) {
|
Ref<InputEventJoypadButton> InputEventJoypadButton::create_reference(JoyButton p_btn_index) {
|
||||||
Ref<InputEventJoypadButton> ie;
|
Ref<InputEventJoypadButton> ie;
|
||||||
ie.instantiate();
|
ie.instantiate();
|
||||||
ie->set_button_index(p_btn_index);
|
ie->set_button_index(p_btn_index);
|
||||||
|
@ -1403,11 +1403,11 @@ int InputEventMIDI::get_channel() const {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventMIDI::set_message(const int p_message) {
|
void InputEventMIDI::set_message(const MIDIMessage p_message) {
|
||||||
message = p_message;
|
message = p_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputEventMIDI::get_message() const {
|
MIDIMessage InputEventMIDI::get_message() const {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ class InputEventMouseButton : public InputEventMouse {
|
||||||
GDCLASS(InputEventMouseButton, InputEventMouse);
|
GDCLASS(InputEventMouseButton, InputEventMouse);
|
||||||
|
|
||||||
float factor = 1;
|
float factor = 1;
|
||||||
int button_index = 0;
|
MouseButton button_index = MOUSE_BUTTON_NONE;
|
||||||
bool pressed = false; //otherwise released
|
bool pressed = false; //otherwise released
|
||||||
bool double_click = false; //last even less than double click time
|
bool double_click = false; //last even less than double click time
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ public:
|
||||||
void set_factor(float p_factor);
|
void set_factor(float p_factor);
|
||||||
float get_factor() const;
|
float get_factor() const;
|
||||||
|
|
||||||
void set_button_index(int p_index);
|
void set_button_index(MouseButton p_index);
|
||||||
int get_button_index() const;
|
MouseButton get_button_index() const;
|
||||||
|
|
||||||
void set_pressed(bool p_pressed);
|
void set_pressed(bool p_pressed);
|
||||||
virtual bool is_pressed() const override;
|
virtual bool is_pressed() const override;
|
||||||
|
@ -297,15 +297,15 @@ public:
|
||||||
|
|
||||||
class InputEventJoypadMotion : public InputEvent {
|
class InputEventJoypadMotion : public InputEvent {
|
||||||
GDCLASS(InputEventJoypadMotion, InputEvent);
|
GDCLASS(InputEventJoypadMotion, InputEvent);
|
||||||
int axis = 0; ///< Joypad axis
|
JoyAxis axis = (JoyAxis)0; ///< Joypad axis
|
||||||
float axis_value = 0; ///< -1 to 1
|
float axis_value = 0; ///< -1 to 1
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_axis(int p_axis);
|
void set_axis(JoyAxis p_axis);
|
||||||
int get_axis() const;
|
JoyAxis get_axis() const;
|
||||||
|
|
||||||
void set_axis_value(float p_value);
|
void set_axis_value(float p_value);
|
||||||
float get_axis_value() const;
|
float get_axis_value() const;
|
||||||
|
@ -325,15 +325,15 @@ public:
|
||||||
class InputEventJoypadButton : public InputEvent {
|
class InputEventJoypadButton : public InputEvent {
|
||||||
GDCLASS(InputEventJoypadButton, InputEvent);
|
GDCLASS(InputEventJoypadButton, InputEvent);
|
||||||
|
|
||||||
int button_index = 0;
|
JoyButton button_index = (JoyButton)0;
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
float pressure = 0; //0 to 1
|
float pressure = 0; //0 to 1
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_button_index(int p_index);
|
void set_button_index(JoyButton p_index);
|
||||||
int get_button_index() const;
|
JoyButton get_button_index() const;
|
||||||
|
|
||||||
void set_pressed(bool p_pressed);
|
void set_pressed(bool p_pressed);
|
||||||
virtual bool is_pressed() const override;
|
virtual bool is_pressed() const override;
|
||||||
|
@ -349,7 +349,7 @@ public:
|
||||||
virtual String as_text() const override;
|
virtual String as_text() const override;
|
||||||
virtual String to_string() override;
|
virtual String to_string() override;
|
||||||
|
|
||||||
static Ref<InputEventJoypadButton> create_reference(int p_btn_index);
|
static Ref<InputEventJoypadButton> create_reference(JoyButton p_btn_index);
|
||||||
|
|
||||||
InputEventJoypadButton() {}
|
InputEventJoypadButton() {}
|
||||||
};
|
};
|
||||||
|
@ -496,7 +496,7 @@ class InputEventMIDI : public InputEvent {
|
||||||
GDCLASS(InputEventMIDI, InputEvent);
|
GDCLASS(InputEventMIDI, InputEvent);
|
||||||
|
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
int message = 0;
|
MIDIMessage message = MIDI_MESSAGE_NONE;
|
||||||
int pitch = 0;
|
int pitch = 0;
|
||||||
int velocity = 0;
|
int velocity = 0;
|
||||||
int instrument = 0;
|
int instrument = 0;
|
||||||
|
@ -511,8 +511,8 @@ public:
|
||||||
void set_channel(const int p_channel);
|
void set_channel(const int p_channel);
|
||||||
int get_channel() const;
|
int get_channel() const;
|
||||||
|
|
||||||
void set_message(const int p_message);
|
void set_message(const MIDIMessage p_message);
|
||||||
int get_message() const;
|
MIDIMessage get_message() const;
|
||||||
|
|
||||||
void set_pitch(const int p_pitch);
|
void set_pitch(const int p_pitch);
|
||||||
int get_pitch() const;
|
int get_pitch() const;
|
||||||
|
|
|
@ -52,16 +52,16 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
|
||||||
if (data[0] >= 0xF0) {
|
if (data[0] >= 0xF0) {
|
||||||
// channel does not apply to system common messages
|
// channel does not apply to system common messages
|
||||||
event->set_channel(0);
|
event->set_channel(0);
|
||||||
event->set_message(data[0]);
|
event->set_message(MIDIMessage(data[0]));
|
||||||
last_received_message = data[0];
|
last_received_message = data[0];
|
||||||
} else if ((data[0] & 0x80) == 0x00) {
|
} else if ((data[0] & 0x80) == 0x00) {
|
||||||
// running status
|
// running status
|
||||||
event->set_channel(last_received_message & 0xF);
|
event->set_channel(last_received_message & 0xF);
|
||||||
event->set_message(last_received_message >> 4);
|
event->set_message(MIDIMessage(last_received_message >> 4));
|
||||||
param_position = 0;
|
param_position = 0;
|
||||||
} else {
|
} else {
|
||||||
event->set_channel(data[0] & 0xF);
|
event->set_channel(data[0] & 0xF);
|
||||||
event->set_message(data[0] >> 4);
|
event->set_message(MIDIMessage(data[0] >> 4));
|
||||||
param_position = 1;
|
param_position = 1;
|
||||||
last_received_message = data[0];
|
last_received_message = data[0];
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,8 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
|
||||||
event->set_pressure(data[param_position]);
|
event->set_pressure(data[param_position]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Input *id = Input::get_singleton();
|
Input *id = Input::get_singleton();
|
||||||
|
|
|
@ -436,7 +436,7 @@
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="mouse_get_button_state" qualifiers="const">
|
<method name="mouse_get_button_state" qualifiers="const">
|
||||||
<return type="int">
|
<return type="int" enum="MouseButton">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="device" type="int">
|
<argument index="0" name="device" type="int">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="axis" type="int">
|
<argument index="1" name="axis" type="int" enum="JoyAxis">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the current value of the joypad axis at given index (see [enum JoyAxis]).
|
Returns the current value of the joypad axis at given index (see [enum JoyAxis]).
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="device" type="int">
|
<argument index="0" name="device" type="int">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="button" type="int">
|
<argument index="1" name="button" type="int" enum="JoyButton">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButton]).
|
Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButton]).
|
||||||
|
@ -279,7 +279,7 @@
|
||||||
<method name="is_mouse_button_pressed" qualifiers="const">
|
<method name="is_mouse_button_pressed" qualifiers="const">
|
||||||
<return type="bool">
|
<return type="bool">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="button" type="int">
|
<argument index="0" name="button" type="int" enum="MouseButton">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton].
|
Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton].
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<methods>
|
<methods>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
|
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" enum="JoyButton" default="0">
|
||||||
Button identifier. One of the [enum JoyButton] button constants.
|
Button identifier. One of the [enum JoyButton] button constants.
|
||||||
</member>
|
</member>
|
||||||
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
|
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<methods>
|
<methods>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="axis" type="int" setter="set_axis" getter="get_axis" default="0">
|
<member name="axis" type="int" setter="set_axis" getter="get_axis" enum="JoyAxis" default="0">
|
||||||
Axis identifier. Use one of the [enum JoyAxis] axis constants.
|
Axis identifier. Use one of the [enum JoyAxis] axis constants.
|
||||||
</member>
|
</member>
|
||||||
<member name="axis_value" type="float" setter="set_axis_value" getter="get_axis_value" default="0.0">
|
<member name="axis_value" type="float" setter="set_axis_value" getter="get_axis_value" default="0.0">
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="instrument" type="int" setter="set_instrument" getter="get_instrument" default="0">
|
<member name="instrument" type="int" setter="set_instrument" getter="get_instrument" default="0">
|
||||||
</member>
|
</member>
|
||||||
<member name="message" type="int" setter="set_message" getter="get_message" default="0">
|
<member name="message" type="int" setter="set_message" getter="get_message" enum="MIDIMessage" default="0">
|
||||||
</member>
|
</member>
|
||||||
<member name="pitch" type="int" setter="set_pitch" getter="get_pitch" default="0">
|
<member name="pitch" type="int" setter="set_pitch" getter="get_pitch" default="0">
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<methods>
|
<methods>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
|
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" enum="MouseButton" default="0">
|
||||||
The mouse button identifier, one of the [enum MouseButton] button or button wheel constants.
|
The mouse button identifier, one of the [enum MouseButton] button or button wheel constants.
|
||||||
</member>
|
</member>
|
||||||
<member name="double_click" type="bool" setter="set_double_click" getter="is_double_click" default="false">
|
<member name="double_click" type="bool" setter="set_double_click" getter="is_double_click" default="false">
|
||||||
|
|
|
@ -334,7 +334,7 @@ void InputEventConfigurationDialog::_update_input_list() {
|
||||||
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
||||||
Ref<InputEventJoypadButton> joyb;
|
Ref<InputEventJoypadButton> joyb;
|
||||||
joyb.instantiate();
|
joyb.instantiate();
|
||||||
joyb->set_button_index(i);
|
joyb->set_button_index((JoyButton)i);
|
||||||
String desc = get_event_text(joyb);
|
String desc = get_event_text(joyb);
|
||||||
|
|
||||||
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
|
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
|
||||||
|
@ -359,7 +359,7 @@ void InputEventConfigurationDialog::_update_input_list() {
|
||||||
int direction = (i & 1) ? 1 : -1;
|
int direction = (i & 1) ? 1 : -1;
|
||||||
Ref<InputEventJoypadMotion> joym;
|
Ref<InputEventJoypadMotion> joym;
|
||||||
joym.instantiate();
|
joym.instantiate();
|
||||||
joym->set_axis(axis);
|
joym->set_axis((JoyAxis)axis);
|
||||||
joym->set_axis_value(direction);
|
joym->set_axis_value(direction);
|
||||||
String desc = get_event_text(joym);
|
String desc = get_event_text(joym);
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
|
||||||
int idx = selected->get_meta("__index");
|
int idx = selected->get_meta("__index");
|
||||||
Ref<InputEventMouseButton> mb;
|
Ref<InputEventMouseButton> mb;
|
||||||
mb.instantiate();
|
mb.instantiate();
|
||||||
mb->set_button_index(idx);
|
mb->set_button_index((MouseButton)idx);
|
||||||
// Maintain modifier state from checkboxes
|
// Maintain modifier state from checkboxes
|
||||||
mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
|
mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
|
||||||
mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
|
mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
|
||||||
|
@ -495,7 +495,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
|
||||||
} break;
|
} break;
|
||||||
case InputEventConfigurationDialog::INPUT_JOY_BUTTON: {
|
case InputEventConfigurationDialog::INPUT_JOY_BUTTON: {
|
||||||
int idx = selected->get_meta("__index");
|
int idx = selected->get_meta("__index");
|
||||||
Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx);
|
Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference((JoyButton)idx);
|
||||||
_set_event(jb);
|
_set_event(jb);
|
||||||
} break;
|
} break;
|
||||||
case InputEventConfigurationDialog::INPUT_JOY_MOTION: {
|
case InputEventConfigurationDialog::INPUT_JOY_MOTION: {
|
||||||
|
@ -504,7 +504,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
|
||||||
|
|
||||||
Ref<InputEventJoypadMotion> jm;
|
Ref<InputEventJoypadMotion> jm;
|
||||||
jm.instantiate();
|
jm.instantiate();
|
||||||
jm->set_axis(axis);
|
jm->set_axis((JoyAxis)axis);
|
||||||
jm->set_axis_value(value);
|
jm->set_axis_value(value);
|
||||||
_set_event(jm);
|
_set_event(jm);
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -127,6 +127,8 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
case MOUSE_BUTTON_LEFT:
|
case MOUSE_BUTTON_LEFT:
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1398,6 +1398,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1629,7 +1629,7 @@ void ScriptEditor::_help_overview_selected(int p_idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::_script_selected(int p_idx) {
|
void ScriptEditor::_script_selected(int p_idx) {
|
||||||
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
|
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(MOUSE_BUTTON_LEFT); //amazing hack, simply amazing
|
||||||
|
|
||||||
_go_to_tab(script_list->get_item_metadata(p_idx));
|
_go_to_tab(script_list->get_item_metadata(p_idx));
|
||||||
grab_focus_block = false;
|
grab_focus_block = false;
|
||||||
|
@ -2771,6 +2771,8 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
|
||||||
case MOUSE_BUTTON_RIGHT: {
|
case MOUSE_BUTTON_RIGHT: {
|
||||||
_make_script_list_context_menu();
|
_make_script_list_context_menu();
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,7 +412,7 @@ void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p
|
||||||
if (tracker.is_valid()) {
|
if (tracker.is_valid()) {
|
||||||
int joyid = tracker->get_joy_id();
|
int joyid = tracker->get_joy_id();
|
||||||
if (joyid != -1) {
|
if (joyid != -1) {
|
||||||
input->joy_button(joyid, p_button, p_is_pressed);
|
input->joy_button(joyid, (JoyButton)p_button, p_is_pressed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_a
|
||||||
Input::JoyAxisValue jx;
|
Input::JoyAxisValue 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, (JoyAxis)p_axis, jx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,8 +410,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
||||||
|
|
||||||
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
|
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
|
||||||
|
|
||||||
buttons_state = 0;
|
|
||||||
|
|
||||||
#if defined(OPENGL_ENABLED)
|
#if defined(OPENGL_ENABLED)
|
||||||
if (rendering_driver == "opengl") {
|
if (rendering_driver == "opengl") {
|
||||||
bool gl_initialization_error = false;
|
bool gl_initialization_error = false;
|
||||||
|
@ -484,16 +482,16 @@ DisplayServerAndroid::~DisplayServerAndroid() {
|
||||||
void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p_event) {
|
void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p_event) {
|
||||||
switch (p_event.type) {
|
switch (p_event.type) {
|
||||||
case JOY_EVENT_BUTTON:
|
case JOY_EVENT_BUTTON:
|
||||||
Input::get_singleton()->joy_button(p_event.device, p_event.index, p_event.pressed);
|
Input::get_singleton()->joy_button(p_event.device, (JoyButton)p_event.index, p_event.pressed);
|
||||||
break;
|
break;
|
||||||
case JOY_EVENT_AXIS:
|
case JOY_EVENT_AXIS:
|
||||||
Input::JoyAxisValue value;
|
Input::JoyAxisValue value;
|
||||||
value.min = -1;
|
value.min = -1;
|
||||||
value.value = p_event.value;
|
value.value = p_event.value;
|
||||||
Input::get_singleton()->joy_axis(p_event.device, p_event.index, value);
|
Input::get_singleton()->joy_axis(p_event.device, (JoyAxis)p_event.index, value);
|
||||||
break;
|
break;
|
||||||
case JOY_EVENT_HAT:
|
case JOY_EVENT_HAT:
|
||||||
Input::get_singleton()->joy_hat(p_event.device, p_event.hat);
|
Input::get_singleton()->joy_hat(p_event.device, (HatMask)p_event.hat);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -697,7 +695,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServerAndroid::process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
|
void DisplayServerAndroid::process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
|
||||||
int event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
|
MouseButton event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
|
||||||
switch (event_action) {
|
switch (event_action) {
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
|
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
|
||||||
|
@ -712,7 +710,7 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
|
||||||
ev->set_global_position(hover_prev_pos);
|
ev->set_global_position(hover_prev_pos);
|
||||||
}
|
}
|
||||||
ev->set_pressed(event_action == AMOTION_EVENT_ACTION_BUTTON_PRESS);
|
ev->set_pressed(event_action == AMOTION_EVENT_ACTION_BUTTON_PRESS);
|
||||||
int changed_button_mask = buttons_state ^ event_buttons_mask;
|
MouseButton changed_button_mask = MouseButton(buttons_state ^ event_buttons_mask);
|
||||||
|
|
||||||
buttons_state = event_buttons_mask;
|
buttons_state = event_buttons_mask;
|
||||||
|
|
||||||
|
@ -765,11 +763,11 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor) {
|
void DisplayServerAndroid::_wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor) {
|
||||||
Ref<InputEventMouseButton> evd = ev->duplicate();
|
Ref<InputEventMouseButton> evd = ev->duplicate();
|
||||||
_set_key_modifier_state(evd);
|
_set_key_modifier_state(evd);
|
||||||
evd->set_button_index(wheel_button);
|
evd->set_button_index(wheel_button);
|
||||||
evd->set_button_mask(event_buttons_mask ^ (1 << (wheel_button - 1)));
|
evd->set_button_mask(MouseButton(event_buttons_mask ^ (1 << (wheel_button - 1))));
|
||||||
evd->set_factor(factor);
|
evd->set_factor(factor);
|
||||||
Input::get_singleton()->accumulate_input_event(evd);
|
Input::get_singleton()->accumulate_input_event(evd);
|
||||||
Ref<InputEventMouseButton> evdd = evd->duplicate();
|
Ref<InputEventMouseButton> evdd = evd->duplicate();
|
||||||
|
@ -779,7 +777,7 @@ void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Point2 p_pos) {
|
void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Point2 p_pos) {
|
||||||
int event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
|
MouseButton event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
|
||||||
Ref<InputEventMouseButton> ev;
|
Ref<InputEventMouseButton> ev;
|
||||||
ev.instantiate();
|
ev.instantiate();
|
||||||
_set_key_modifier_state(ev);
|
_set_key_modifier_state(ev);
|
||||||
|
@ -792,7 +790,7 @@ void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Poi
|
||||||
Input::get_singleton()->accumulate_input_event(ev);
|
Input::get_singleton()->accumulate_input_event(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
|
MouseButton DisplayServerAndroid::_button_index_from_mask(MouseButton button_mask) {
|
||||||
switch (button_mask) {
|
switch (button_mask) {
|
||||||
case MOUSE_BUTTON_MASK_LEFT:
|
case MOUSE_BUTTON_MASK_LEFT:
|
||||||
return MOUSE_BUTTON_LEFT;
|
return MOUSE_BUTTON_LEFT;
|
||||||
|
@ -805,7 +803,7 @@ int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
|
||||||
case MOUSE_BUTTON_MASK_XBUTTON2:
|
case MOUSE_BUTTON_MASK_XBUTTON2:
|
||||||
return MOUSE_BUTTON_XBUTTON2;
|
return MOUSE_BUTTON_XBUTTON2;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return MOUSE_BUTTON_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,12 +861,12 @@ Point2i DisplayServerAndroid::mouse_get_position() const {
|
||||||
return hover_prev_pos;
|
return hover_prev_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerAndroid::mouse_get_button_state() const {
|
MouseButton DisplayServerAndroid::mouse_get_button_state() const {
|
||||||
return buttons_state;
|
return buttons_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
|
MouseButton DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
|
||||||
int godot_button_mask = 0;
|
MouseButton godot_button_mask = MOUSE_BUTTON_NONE;
|
||||||
if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) {
|
if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) {
|
||||||
godot_button_mask |= MOUSE_BUTTON_MASK_LEFT;
|
godot_button_mask |= MOUSE_BUTTON_MASK_LEFT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
bool control_mem = false;
|
bool control_mem = false;
|
||||||
bool meta_mem = false;
|
bool meta_mem = false;
|
||||||
|
|
||||||
int buttons_state;
|
MouseButton buttons_state = MOUSE_BUTTON_NONE;
|
||||||
|
|
||||||
// https://developer.android.com/reference/android/view/PointerIcon
|
// https://developer.android.com/reference/android/view/PointerIcon
|
||||||
// mapping between Godot's cursor shape to Android's'
|
// mapping between Godot's cursor shape to Android's'
|
||||||
|
@ -120,11 +120,11 @@ private:
|
||||||
|
|
||||||
void _set_key_modifier_state(Ref<InputEventWithModifiers> ev);
|
void _set_key_modifier_state(Ref<InputEventWithModifiers> ev);
|
||||||
|
|
||||||
static int _button_index_from_mask(int button_mask);
|
static MouseButton _button_index_from_mask(MouseButton button_mask);
|
||||||
|
|
||||||
static int _android_button_mask_to_godot_button_mask(int android_button_mask);
|
static MouseButton _android_button_mask_to_godot_button_mask(int android_button_mask);
|
||||||
|
|
||||||
void _wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor);
|
void _wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DisplayServerAndroid *get_singleton();
|
static DisplayServerAndroid *get_singleton();
|
||||||
|
@ -219,7 +219,7 @@ public:
|
||||||
void notify_surface_changed(int p_width, int p_height);
|
void notify_surface_changed(int p_width, int p_height);
|
||||||
|
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual MouseButton mouse_get_button_state() const;
|
||||||
|
|
||||||
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
~DisplayServerAndroid();
|
~DisplayServerAndroid();
|
||||||
|
|
|
@ -229,8 +229,8 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
|
||||||
}
|
}
|
||||||
|
|
||||||
Input *input = Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
int mask = input->get_mouse_button_mask();
|
MouseButton mask = input->get_mouse_button_mask();
|
||||||
int button_flag = 1 << (ev->get_button_index() - 1);
|
MouseButton button_flag = MouseButton(1 << (ev->get_button_index() - 1));
|
||||||
if (ev->is_pressed()) {
|
if (ev->is_pressed()) {
|
||||||
// Since the event is consumed, focus manually. The containing iframe,
|
// Since the event is consumed, focus manually. The containing iframe,
|
||||||
// if exists, may not have focus yet, so focus even if already focused.
|
// if exists, may not have focus yet, so focus even if already focused.
|
||||||
|
@ -478,11 +478,11 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
|
||||||
int button_flag = 1 << (ev->get_button_index() - 1);
|
int button_flag = 1 << (ev->get_button_index() - 1);
|
||||||
|
|
||||||
ev->set_pressed(true);
|
ev->set_pressed(true);
|
||||||
ev->set_button_mask(input->get_mouse_button_mask() | button_flag);
|
ev->set_button_mask(MouseButton(input->get_mouse_button_mask() | button_flag));
|
||||||
input->parse_input_event(ev);
|
input->parse_input_event(ev);
|
||||||
|
|
||||||
ev->set_pressed(false);
|
ev->set_pressed(false);
|
||||||
ev->set_button_mask(input->get_mouse_button_mask() & ~button_flag);
|
ev->set_button_mask(MouseButton(input->get_mouse_button_mask() & ~button_flag));
|
||||||
input->parse_input_event(ev);
|
input->parse_input_event(ev);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -450,7 +450,7 @@ Point2i DisplayServerX11::mouse_get_absolute_position() const {
|
||||||
return Vector2i();
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerX11::mouse_get_button_state() const {
|
MouseButton DisplayServerX11::mouse_get_button_state() const {
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2172,13 +2172,13 @@ void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<Inp
|
||||||
state->set_meta_pressed((p_x11_state & Mod4Mask));
|
state->set_meta_pressed((p_x11_state & Mod4Mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
|
MouseButton DisplayServerX11::_get_mouse_button_state(MouseButton p_x11_button, int p_x11_type) {
|
||||||
unsigned int mask = 1 << (p_x11_button - 1);
|
MouseButton mask = MouseButton(1 << (p_x11_button - 1));
|
||||||
|
|
||||||
if (p_x11_type == ButtonPress) {
|
if (p_x11_type == ButtonPress) {
|
||||||
last_button_state |= mask;
|
last_button_state |= mask;
|
||||||
} else {
|
} else {
|
||||||
last_button_state &= ~mask;
|
last_button_state &= MouseButton(~mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
|
@ -3130,11 +3130,11 @@ void DisplayServerX11::process_events() {
|
||||||
|
|
||||||
mb->set_window_id(window_id);
|
mb->set_window_id(window_id);
|
||||||
_get_key_modifier_state(event.xbutton.state, mb);
|
_get_key_modifier_state(event.xbutton.state, mb);
|
||||||
mb->set_button_index(event.xbutton.button);
|
mb->set_button_index((MouseButton)event.xbutton.button);
|
||||||
if (mb->get_button_index() == 2) {
|
if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
|
||||||
mb->set_button_index(3);
|
mb->set_button_index(MOUSE_BUTTON_MIDDLE);
|
||||||
} else if (mb->get_button_index() == 3) {
|
} else if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE) {
|
||||||
mb->set_button_index(2);
|
mb->set_button_index(MOUSE_BUTTON_RIGHT);
|
||||||
}
|
}
|
||||||
mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
|
mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
|
||||||
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
|
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
|
||||||
|
@ -3297,7 +3297,7 @@ void DisplayServerX11::process_events() {
|
||||||
if (xi.pressure_supported) {
|
if (xi.pressure_supported) {
|
||||||
mm->set_pressure(xi.pressure);
|
mm->set_pressure(xi.pressure);
|
||||||
} else {
|
} else {
|
||||||
mm->set_pressure((mouse_get_button_state() & (1 << (MOUSE_BUTTON_LEFT - 1))) ? 1.0f : 0.0f);
|
mm->set_pressure((mouse_get_button_state() & MOUSE_BUTTON_MASK_LEFT) ? 1.0f : 0.0f);
|
||||||
}
|
}
|
||||||
mm->set_tilt(xi.tilt);
|
mm->set_tilt(xi.tilt);
|
||||||
|
|
||||||
|
@ -3855,8 +3855,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||||
img[i] = nullptr;
|
img[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_button_state = 0;
|
|
||||||
|
|
||||||
xmbstring = nullptr;
|
xmbstring = nullptr;
|
||||||
|
|
||||||
last_click_ms = 0;
|
last_click_ms = 0;
|
||||||
|
|
|
@ -162,7 +162,7 @@ class DisplayServerX11 : public DisplayServer {
|
||||||
Point2i last_click_pos;
|
Point2i last_click_pos;
|
||||||
uint64_t last_click_ms;
|
uint64_t last_click_ms;
|
||||||
int last_click_button_index;
|
int last_click_button_index;
|
||||||
uint32_t last_button_state;
|
MouseButton last_button_state = MOUSE_BUTTON_NONE;
|
||||||
bool app_focused = false;
|
bool app_focused = false;
|
||||||
uint64_t time_since_no_focus = 0;
|
uint64_t time_since_no_focus = 0;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class DisplayServerX11 : public DisplayServer {
|
||||||
|
|
||||||
bool _refresh_device_info();
|
bool _refresh_device_info();
|
||||||
|
|
||||||
unsigned int _get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
|
MouseButton _get_mouse_button_state(MouseButton p_x11_button, int p_x11_type);
|
||||||
void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
|
void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
|
||||||
void _flush_mouse_motion();
|
void _flush_mouse_motion();
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ public:
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
virtual Point2i mouse_get_absolute_position() const;
|
virtual Point2i mouse_get_absolute_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual MouseButton mouse_get_button_state() const;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text);
|
virtual void clipboard_set(const String &p_text);
|
||||||
virtual String clipboard_get() const;
|
virtual String clipboard_get() const;
|
||||||
|
|
|
@ -475,7 +475,7 @@ void JoypadLinux::process_joypads() {
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case EV_KEY:
|
case EV_KEY:
|
||||||
input->joy_button(i, joy->key_map[ev.code], ev.value);
|
input->joy_button(i, (JoyButton)joy->key_map[ev.code], ev.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_ABS:
|
case EV_ABS:
|
||||||
|
@ -484,29 +484,29 @@ 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 = (joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT;
|
joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT);
|
||||||
} else {
|
} else {
|
||||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT;
|
joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT);
|
joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
input->joy_hat(i, joy->dpad);
|
input->joy_hat(i, (HatMask)joy->dpad);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ABS_HAT0Y:
|
case ABS_HAT0Y:
|
||||||
if (ev.value != 0) {
|
if (ev.value != 0) {
|
||||||
if (ev.value < 0) {
|
if (ev.value < 0) {
|
||||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN;
|
joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN);
|
||||||
} else {
|
} else {
|
||||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP;
|
joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN);
|
joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
input->joy_hat(i, joy->dpad);
|
input->joy_hat(i, (HatMask)joy->dpad);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -526,7 +526,7 @@ void JoypadLinux::process_joypads() {
|
||||||
for (int j = 0; j < MAX_ABS; j++) {
|
for (int j = 0; j < MAX_ABS; j++) {
|
||||||
int index = joy->abs_map[j];
|
int index = joy->abs_map[j];
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
input->joy_axis(i, index, joy->curr_axis[index]);
|
input->joy_axis(i, (JoyAxis)index, joy->curr_axis[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len == 0 || (len < 0 && errno != EAGAIN)) {
|
if (len == 0 || (len < 0 && errno != EAGAIN)) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ public:
|
||||||
|
|
||||||
MouseMode mouse_mode;
|
MouseMode mouse_mode;
|
||||||
Point2i last_mouse_pos;
|
Point2i last_mouse_pos;
|
||||||
uint32_t last_button_state;
|
MouseButton last_button_state = MOUSE_BUTTON_NONE;
|
||||||
|
|
||||||
bool window_focused;
|
bool window_focused;
|
||||||
bool drop_events;
|
bool drop_events;
|
||||||
|
@ -217,7 +217,7 @@ public:
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to) override;
|
virtual void mouse_warp_to_position(const Point2i &p_to) override;
|
||||||
virtual Point2i mouse_get_position() const override;
|
virtual Point2i mouse_get_position() const override;
|
||||||
virtual Point2i mouse_get_absolute_position() const override;
|
virtual Point2i mouse_get_absolute_position() const override;
|
||||||
virtual int mouse_get_button_state() const override;
|
virtual MouseButton mouse_get_button_state() const override;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text) override;
|
virtual void clipboard_set(const String &p_text) override;
|
||||||
virtual String clipboard_get() const override;
|
virtual String clipboard_get() const override;
|
||||||
|
|
|
@ -813,14 +813,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
DS_OSX->cursor_set_shape(p_shape);
|
DS_OSX->cursor_set_shape(p_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, int index, int mask, bool pressed) {
|
static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, MouseButton index, MouseButton mask, bool pressed) {
|
||||||
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
|
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
|
||||||
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
|
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
|
||||||
|
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
DS_OSX->last_button_state |= mask;
|
DS_OSX->last_button_state |= mask;
|
||||||
} else {
|
} else {
|
||||||
DS_OSX->last_button_state &= ~mask;
|
DS_OSX->last_button_state &= (MouseButton)~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<InputEventMouseButton> mb;
|
Ref<InputEventMouseButton> mb;
|
||||||
|
@ -1485,11 +1485,11 @@ static int remapKey(unsigned int key, unsigned int state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, double factor, int modifierFlags) {
|
inline void sendScrollEvent(DisplayServer::WindowID window_id, MouseButton button, double factor, int modifierFlags) {
|
||||||
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
|
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
|
||||||
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
|
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
|
||||||
|
|
||||||
unsigned int mask = 1 << (button - 1);
|
MouseButton mask = MouseButton(1 << (button - 1));
|
||||||
|
|
||||||
Ref<InputEventMouseButton> sc;
|
Ref<InputEventMouseButton> sc;
|
||||||
sc.instantiate();
|
sc.instantiate();
|
||||||
|
@ -1501,7 +1501,7 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, doubl
|
||||||
sc->set_pressed(true);
|
sc->set_pressed(true);
|
||||||
sc->set_position(wd.mouse_pos);
|
sc->set_position(wd.mouse_pos);
|
||||||
sc->set_global_position(wd.mouse_pos);
|
sc->set_global_position(wd.mouse_pos);
|
||||||
DS_OSX->last_button_state |= mask;
|
DS_OSX->last_button_state |= (MouseButton)mask;
|
||||||
sc->set_button_mask(DS_OSX->last_button_state);
|
sc->set_button_mask(DS_OSX->last_button_state);
|
||||||
|
|
||||||
Input::get_singleton()->accumulate_input_event(sc);
|
Input::get_singleton()->accumulate_input_event(sc);
|
||||||
|
@ -1513,7 +1513,7 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, doubl
|
||||||
sc->set_pressed(false);
|
sc->set_pressed(false);
|
||||||
sc->set_position(wd.mouse_pos);
|
sc->set_position(wd.mouse_pos);
|
||||||
sc->set_global_position(wd.mouse_pos);
|
sc->set_global_position(wd.mouse_pos);
|
||||||
DS_OSX->last_button_state &= ~mask;
|
DS_OSX->last_button_state &= (MouseButton)~mask;
|
||||||
sc->set_button_mask(DS_OSX->last_button_state);
|
sc->set_button_mask(DS_OSX->last_button_state);
|
||||||
|
|
||||||
Input::get_singleton()->accumulate_input_event(sc);
|
Input::get_singleton()->accumulate_input_event(sc);
|
||||||
|
@ -2173,7 +2173,7 @@ Point2i DisplayServerOSX::mouse_get_absolute_position() const {
|
||||||
return Vector2i();
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerOSX::mouse_get_button_state() const {
|
MouseButton DisplayServerOSX::mouse_get_button_state() const {
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3755,7 +3755,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
|
||||||
|
|
||||||
key_event_pos = 0;
|
key_event_pos = 0;
|
||||||
mouse_mode = MOUSE_MODE_VISIBLE;
|
mouse_mode = MOUSE_MODE_VISIBLE;
|
||||||
last_button_state = 0;
|
|
||||||
|
|
||||||
autoreleasePool = [[NSAutoreleasePool alloc] init];
|
autoreleasePool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
|
|
@ -458,17 +458,17 @@ void JoypadOSX::process_joypads() {
|
||||||
for (int j = 0; j < joy.axis_elements.size(); j++) {
|
for (int j = 0; j < joy.axis_elements.size(); j++) {
|
||||||
rec_element &elem = joy.axis_elements.write[j];
|
rec_element &elem = joy.axis_elements.write[j];
|
||||||
int value = joy.get_hid_element_state(&elem);
|
int value = joy.get_hid_element_state(&elem);
|
||||||
input->joy_axis(joy.id, j, axis_correct(value, elem.min, elem.max));
|
input->joy_axis(joy.id, (JoyAxis)j, axis_correct(value, elem.min, elem.max));
|
||||||
}
|
}
|
||||||
for (int j = 0; j < joy.button_elements.size(); j++) {
|
for (int j = 0; j < joy.button_elements.size(); j++) {
|
||||||
int value = joy.get_hid_element_state(&joy.button_elements.write[j]);
|
int value = joy.get_hid_element_state(&joy.button_elements.write[j]);
|
||||||
input->joy_button(joy.id, j, (value >= 1));
|
input->joy_button(joy.id, (JoyButton)j, (value >= 1));
|
||||||
}
|
}
|
||||||
for (int j = 0; j < joy.hat_elements.size(); j++) {
|
for (int j = 0; j < joy.hat_elements.size(); j++) {
|
||||||
rec_element &elem = joy.hat_elements.write[j];
|
rec_element &elem = joy.hat_elements.write[j];
|
||||||
int value = joy.get_hid_element_state(&elem);
|
int value = joy.get_hid_element_state(&elem);
|
||||||
int hat_value = process_hat_value(elem.min, elem.max, value);
|
int hat_value = process_hat_value(elem.min, elem.max, value);
|
||||||
input->joy_hat(joy.id, hat_value);
|
input->joy_hat(joy.id, (HatMask)hat_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joy.ffservice) {
|
if (joy.ffservice) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ void App::SetWindow(CoreWindow ^ p_window) {
|
||||||
Main::setup2();
|
Main::setup2();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
|
static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) {
|
||||||
using namespace Windows::UI::Input;
|
using namespace Windows::UI::Input;
|
||||||
|
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||||
|
@ -177,7 +177,7 @@ static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return MOUSE_BUTTON_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
|
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
|
||||||
|
@ -241,7 +241,7 @@ static int _get_finger(uint32_t p_touch_id) {
|
||||||
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
|
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
|
||||||
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
|
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
|
||||||
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
|
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
|
||||||
int but = _get_button(point);
|
MouseButton but = _get_button(point);
|
||||||
if (_is_touch(point)) {
|
if (_is_touch(point)) {
|
||||||
Ref<InputEventScreenTouch> screen_touch;
|
Ref<InputEventScreenTouch> screen_touch;
|
||||||
screen_touch.instantiate();
|
screen_touch.instantiate();
|
||||||
|
|
|
@ -126,8 +126,6 @@ void OS_UWP::set_keep_screen_on(bool p_enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_UWP::initialize_core() {
|
void OS_UWP::initialize_core() {
|
||||||
last_button_state = 0;
|
|
||||||
|
|
||||||
//RedirectIOToConsole();
|
//RedirectIOToConsole();
|
||||||
|
|
||||||
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
|
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
|
||||||
|
@ -423,7 +421,7 @@ Point2 OS_UWP::get_mouse_position() const {
|
||||||
return Point2(old_x, old_y);
|
return Point2(old_x, old_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OS_UWP::get_mouse_button_state() const {
|
MouseButton OS_UWP::get_mouse_button_state() const {
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ private:
|
||||||
bool control_mem;
|
bool control_mem;
|
||||||
bool meta_mem;
|
bool meta_mem;
|
||||||
bool force_quit;
|
bool force_quit;
|
||||||
uint32_t last_button_state;
|
MouseButton last_button_state = MOUSE_BUTTON_NONE;
|
||||||
|
|
||||||
CursorShape cursor_shape;
|
CursorShape cursor_shape;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public:
|
||||||
MouseMode get_mouse_mode() const;
|
MouseMode get_mouse_mode() const;
|
||||||
|
|
||||||
virtual Point2 get_mouse_position() const;
|
virtual Point2 get_mouse_position() const;
|
||||||
virtual int get_mouse_button_state() const;
|
virtual MouseButton get_mouse_button_state() const;
|
||||||
virtual void set_window_title(const String &p_title);
|
virtual void set_window_title(const String &p_title);
|
||||||
|
|
||||||
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
||||||
|
|
|
@ -161,7 +161,7 @@ Point2i DisplayServerWindows::mouse_get_position() const {
|
||||||
//return Point2(old_x, old_y);
|
//return Point2(old_x, old_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServerWindows::mouse_get_button_state() const {
|
MouseButton DisplayServerWindows::mouse_get_button_state() const {
|
||||||
return last_button_state;
|
return last_button_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2391,41 +2391,41 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_LBUTTONDOWN: {
|
case WM_LBUTTONDOWN: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(1);
|
mb->set_button_index(MOUSE_BUTTON_LEFT);
|
||||||
} break;
|
} break;
|
||||||
case WM_LBUTTONUP: {
|
case WM_LBUTTONUP: {
|
||||||
mb->set_pressed(false);
|
mb->set_pressed(false);
|
||||||
mb->set_button_index(1);
|
mb->set_button_index(MOUSE_BUTTON_LEFT);
|
||||||
} break;
|
} break;
|
||||||
case WM_MBUTTONDOWN: {
|
case WM_MBUTTONDOWN: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(3);
|
mb->set_button_index(MOUSE_BUTTON_MIDDLE);
|
||||||
} break;
|
} break;
|
||||||
case WM_MBUTTONUP: {
|
case WM_MBUTTONUP: {
|
||||||
mb->set_pressed(false);
|
mb->set_pressed(false);
|
||||||
mb->set_button_index(3);
|
mb->set_button_index(MOUSE_BUTTON_MIDDLE);
|
||||||
} break;
|
} break;
|
||||||
case WM_RBUTTONDOWN: {
|
case WM_RBUTTONDOWN: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(2);
|
mb->set_button_index(MOUSE_BUTTON_RIGHT);
|
||||||
} break;
|
} break;
|
||||||
case WM_RBUTTONUP: {
|
case WM_RBUTTONUP: {
|
||||||
mb->set_pressed(false);
|
mb->set_pressed(false);
|
||||||
mb->set_button_index(2);
|
mb->set_button_index(MOUSE_BUTTON_RIGHT);
|
||||||
} break;
|
} break;
|
||||||
case WM_LBUTTONDBLCLK: {
|
case WM_LBUTTONDBLCLK: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(1);
|
mb->set_button_index(MOUSE_BUTTON_LEFT);
|
||||||
mb->set_double_click(true);
|
mb->set_double_click(true);
|
||||||
} break;
|
} break;
|
||||||
case WM_RBUTTONDBLCLK: {
|
case WM_RBUTTONDBLCLK: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(2);
|
mb->set_button_index(MOUSE_BUTTON_RIGHT);
|
||||||
mb->set_double_click(true);
|
mb->set_double_click(true);
|
||||||
} break;
|
} break;
|
||||||
case WM_MBUTTONDBLCLK: {
|
case WM_MBUTTONDBLCLK: {
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
mb->set_button_index(3);
|
mb->set_button_index(MOUSE_BUTTON_MIDDLE);
|
||||||
mb->set_double_click(true);
|
mb->set_double_click(true);
|
||||||
} break;
|
} break;
|
||||||
case WM_MOUSEWHEEL: {
|
case WM_MOUSEWHEEL: {
|
||||||
|
@ -2492,9 +2492,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||||
mb->set_alt_pressed(alt_mem);
|
mb->set_alt_pressed(alt_mem);
|
||||||
//mb->is_alt_pressed()=(wParam&MK_MENU)!=0;
|
//mb->is_alt_pressed()=(wParam&MK_MENU)!=0;
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
last_button_state |= (1 << (mb->get_button_index() - 1));
|
last_button_state |= MouseButton(1 << (mb->get_button_index() - 1));
|
||||||
} else {
|
} else {
|
||||||
last_button_state &= ~(1 << (mb->get_button_index() - 1));
|
last_button_state &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
|
||||||
}
|
}
|
||||||
mb->set_button_mask(last_button_state);
|
mb->set_button_mask(last_button_state);
|
||||||
|
|
||||||
|
@ -2534,7 +2534,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||||
//send release for mouse wheel
|
//send release for mouse wheel
|
||||||
Ref<InputEventMouseButton> mbd = mb->duplicate();
|
Ref<InputEventMouseButton> mbd = mb->duplicate();
|
||||||
mbd->set_window_id(window_id);
|
mbd->set_window_id(window_id);
|
||||||
last_button_state &= ~(1 << (mbd->get_button_index() - 1));
|
last_button_state &= (MouseButton) ~(1 << (mbd->get_button_index() - 1));
|
||||||
mbd->set_button_mask(last_button_state);
|
mbd->set_button_mask(last_button_state);
|
||||||
mbd->set_pressed(false);
|
mbd->set_pressed(false);
|
||||||
Input::get_singleton()->accumulate_input_event(mbd);
|
Input::get_singleton()->accumulate_input_event(mbd);
|
||||||
|
|
|
@ -408,7 +408,7 @@ class DisplayServerWindows : public DisplayServer {
|
||||||
bool shift_mem = false;
|
bool shift_mem = false;
|
||||||
bool control_mem = false;
|
bool control_mem = false;
|
||||||
bool meta_mem = false;
|
bool meta_mem = false;
|
||||||
uint32_t last_button_state = 0;
|
MouseButton last_button_state = MOUSE_BUTTON_NONE;
|
||||||
bool use_raw_input = false;
|
bool use_raw_input = false;
|
||||||
bool drop_events = false;
|
bool drop_events = false;
|
||||||
bool in_dispatch_input_event = false;
|
bool in_dispatch_input_event = false;
|
||||||
|
@ -449,7 +449,7 @@ public:
|
||||||
|
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual MouseButton mouse_get_button_state() const;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text);
|
virtual void clipboard_set(const String &p_text);
|
||||||
virtual String clipboard_get() const;
|
virtual String clipboard_get() const;
|
||||||
|
|
|
@ -330,7 +330,7 @@ void JoypadWindows::process_joypads() {
|
||||||
if (joy.state.dwPacketNumber != joy.last_packet) {
|
if (joy.state.dwPacketNumber != joy.last_packet) {
|
||||||
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
|
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
|
||||||
for (int j = 0; j <= 16; j++) {
|
for (int j = 0; j <= 16; j++) {
|
||||||
input->joy_button(joy.id, j, joy.state.Gamepad.wButtons & button_mask);
|
input->joy_button(joy.id, (JoyButton)j, joy.state.Gamepad.wButtons & button_mask);
|
||||||
button_mask = button_mask * 2;
|
button_mask = button_mask * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,12 +381,12 @@ void JoypadWindows::process_joypads() {
|
||||||
for (int j = 0; j < 128; j++) {
|
for (int j = 0; j < 128; j++) {
|
||||||
if (js.rgbButtons[j] & 0x80) {
|
if (js.rgbButtons[j] & 0x80) {
|
||||||
if (!joy->last_buttons[j]) {
|
if (!joy->last_buttons[j]) {
|
||||||
input->joy_button(joy->id, j, true);
|
input->joy_button(joy->id, (JoyButton)j, true);
|
||||||
joy->last_buttons[j] = true;
|
joy->last_buttons[j] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (joy->last_buttons[j]) {
|
if (joy->last_buttons[j]) {
|
||||||
input->joy_button(joy->id, j, false);
|
input->joy_button(joy->id, (JoyButton)j, false);
|
||||||
joy->last_buttons[j] = false;
|
joy->last_buttons[j] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ void JoypadWindows::process_joypads() {
|
||||||
for (int j = 0; j < joy->joy_axis.size(); j++) {
|
for (int j = 0; j < joy->joy_axis.size(); j++) {
|
||||||
for (int k = 0; k < count; k++) {
|
for (int k = 0; k < count; k++) {
|
||||||
if (joy->joy_axis[j] == axes[k]) {
|
if (joy->joy_axis[j] == axes[k]) {
|
||||||
input->joy_axis(joy->id, j, axis_correct(values[k]));
|
input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k]));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -410,7 +410,7 @@ void JoypadWindows::process_joypads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
|
void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
|
||||||
int dpad_val = 0;
|
HatMask dpad_val = (HatMask)0;
|
||||||
|
|
||||||
// Should be -1 when centered, but according to docs:
|
// Should be -1 when centered, but according to docs:
|
||||||
// "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows:
|
// "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows:
|
||||||
|
|
|
@ -204,7 +204,7 @@ void XRController3D::_notification(int p_what) {
|
||||||
// check button states
|
// check button states
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
bool was_pressed = (button_states & mask) == mask;
|
bool was_pressed = (button_states & mask) == mask;
|
||||||
bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i);
|
bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, (JoyButton)i);
|
||||||
|
|
||||||
if (!was_pressed && is_pressed) {
|
if (!was_pressed && is_pressed) {
|
||||||
emit_signal("button_pressed", i);
|
emit_signal("button_pressed", i);
|
||||||
|
@ -304,7 +304,7 @@ bool XRController3D::is_button_pressed(int p_button) const {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Input::get_singleton()->is_joy_button_pressed(joy_id, p_button);
|
return Input::get_singleton()->is_joy_button_pressed(joy_id, (JoyButton)p_button);
|
||||||
};
|
};
|
||||||
|
|
||||||
float XRController3D::get_joystick_axis(int p_axis) const {
|
float XRController3D::get_joystick_axis(int p_axis) const {
|
||||||
|
@ -313,7 +313,7 @@ float XRController3D::get_joystick_axis(int p_axis) const {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
|
return Input::get_singleton()->get_joy_axis(joy_id, (JoyAxis)p_axis);
|
||||||
};
|
};
|
||||||
|
|
||||||
real_t XRController3D::get_rumble() const {
|
real_t XRController3D::get_rumble() const {
|
||||||
|
|
|
@ -248,6 +248,8 @@ void CodeEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,8 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
accept_event();
|
accept_event();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3161,6 +3161,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -644,9 +644,9 @@ void Viewport::_process_picking() {
|
||||||
physics_last_mouse_state.meta = mb->is_meta_pressed();
|
physics_last_mouse_state.meta = mb->is_meta_pressed();
|
||||||
|
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
physics_last_mouse_state.mouse_mask |= (1 << (mb->get_button_index() - 1));
|
physics_last_mouse_state.mouse_mask |= (MouseButton)(1 << (mb->get_button_index() - 1));
|
||||||
} else {
|
} else {
|
||||||
physics_last_mouse_state.mouse_mask &= ~(1 << (mb->get_button_index() - 1));
|
physics_last_mouse_state.mouse_mask &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
|
||||||
|
|
||||||
// If touch mouse raised, assume we don't know last mouse pos until new events come
|
// If touch mouse raised, assume we don't know last mouse pos until new events come
|
||||||
if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) {
|
if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) {
|
||||||
|
@ -2588,7 +2588,7 @@ void Viewport::_drop_mouse_focus() {
|
||||||
mb.instantiate();
|
mb.instantiate();
|
||||||
mb->set_position(c->get_local_mouse_position());
|
mb->set_position(c->get_local_mouse_position());
|
||||||
mb->set_global_position(c->get_local_mouse_position());
|
mb->set_global_position(c->get_local_mouse_position());
|
||||||
mb->set_button_index(i + 1);
|
mb->set_button_index(MouseButton(i + 1));
|
||||||
mb->set_pressed(false);
|
mb->set_pressed(false);
|
||||||
c->call(SceneStringNames::get_singleton()->_gui_input, mb);
|
c->call(SceneStringNames::get_singleton()->_gui_input, mb);
|
||||||
}
|
}
|
||||||
|
@ -2666,7 +2666,7 @@ void Viewport::_post_gui_grab_click_focus() {
|
||||||
//send unclick
|
//send unclick
|
||||||
|
|
||||||
mb->set_position(click);
|
mb->set_position(click);
|
||||||
mb->set_button_index(i + 1);
|
mb->set_button_index(MouseButton(i + 1));
|
||||||
mb->set_pressed(false);
|
mb->set_pressed(false);
|
||||||
gui.mouse_focus->call(SceneStringNames::get_singleton()->_gui_input, mb);
|
gui.mouse_focus->call(SceneStringNames::get_singleton()->_gui_input, mb);
|
||||||
}
|
}
|
||||||
|
@ -2684,7 +2684,7 @@ void Viewport::_post_gui_grab_click_focus() {
|
||||||
//send click
|
//send click
|
||||||
|
|
||||||
mb->set_position(click);
|
mb->set_position(click);
|
||||||
mb->set_button_index(i + 1);
|
mb->set_button_index(MouseButton(i + 1));
|
||||||
mb->set_pressed(true);
|
mb->set_pressed(true);
|
||||||
gui.mouse_focus->call_deferred(SceneStringNames::get_singleton()->_gui_input, mb);
|
gui.mouse_focus->call_deferred(SceneStringNames::get_singleton()->_gui_input, mb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,8 +148,8 @@ Point2i DisplayServer::mouse_get_position() const {
|
||||||
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
|
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int DisplayServer::mouse_get_button_state() const {
|
MouseButton DisplayServer::mouse_get_button_state() const {
|
||||||
ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
|
ERR_FAIL_V_MSG(MOUSE_BUTTON_NONE, "Mouse is not supported by this display server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServer::clipboard_set(const String &p_text) {
|
void DisplayServer::clipboard_set(const String &p_text) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||||
virtual Point2i mouse_get_position() const;
|
virtual Point2i mouse_get_position() const;
|
||||||
virtual Point2i mouse_get_absolute_position() const;
|
virtual Point2i mouse_get_absolute_position() const;
|
||||||
virtual int mouse_get_button_state() const;
|
virtual MouseButton mouse_get_button_state() const;
|
||||||
|
|
||||||
virtual void clipboard_set(const String &p_text);
|
virtual void clipboard_set(const String &p_text);
|
||||||
virtual String clipboard_get() const;
|
virtual String clipboard_get() const;
|
||||||
|
|
Loading…
Reference in New Issue