Fix build for 4.0.

This commit is contained in:
Relintai 2020-04-09 12:36:53 +02:00
parent 38acc650db
commit eb6be07648
2 changed files with 18 additions and 0 deletions

View File

@ -32,7 +32,14 @@ void BSInputEventKey::from_input_event_key(const Ref<InputEventKey> event) {
set_command(event->get_command()); set_command(event->get_command());
set_pressed(event->is_pressed()); set_pressed(event->is_pressed());
#if VERSION_MAJOR < 4
set_scancode(event->get_scancode()); set_scancode(event->get_scancode());
#else
set_keycode(event->get_keycode());
#endif
set_unicode(event->get_unicode()); set_unicode(event->get_unicode());
set_echo(event->is_echo()); set_echo(event->is_echo());
} }
@ -43,8 +50,13 @@ bool BSInputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_press
if (key.is_null()) if (key.is_null())
return false; return false;
#if VERSION_MAJOR < 4
uint32_t code = get_scancode_with_modifiers(); uint32_t code = get_scancode_with_modifiers();
uint32_t event_code = key->get_scancode_with_modifiers(); uint32_t event_code = key->get_scancode_with_modifiers();
#else
uint32_t code = get_keycode_with_modifiers();
uint32_t event_code = key->get_keycode_with_modifiers();
#endif
bool match = code == event_code; bool match = code == event_code;
if (match) { if (match) {

View File

@ -23,7 +23,13 @@ SOFTWARE.
#ifndef BS_INPUT_EVENT_KEY_H #ifndef BS_INPUT_EVENT_KEY_H
#define BS_INPUT_EVENT_KEY_H #define BS_INPUT_EVENT_KEY_H
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "core/os/input_event.h" #include "core/os/input_event.h"
#else
#include "core/input/input_event.h"
#endif
class BSInputEventKey : public InputEventKey { class BSInputEventKey : public InputEventKey {
GDCLASS(BSInputEventKey, InputEventKey); GDCLASS(BSInputEventKey, InputEventKey);