summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/SCsub2
-rw-r--r--platform/x11/detect.py18
-rw-r--r--platform/x11/joypad_linux.cpp (renamed from platform/x11/joystick_linux.cpp)107
-rw-r--r--platform/x11/joypad_linux.h (renamed from platform/x11/joystick_linux.h)45
-rw-r--r--platform/x11/os_x11.cpp8
-rw-r--r--platform/x11/os_x11.h4
-rw-r--r--platform/x11/platform_config.h4
7 files changed, 97 insertions, 91 deletions
diff --git a/platform/x11/SCsub b/platform/x11/SCsub
index 0defd4f025..4ae8ac07f7 100644
--- a/platform/x11/SCsub
+++ b/platform/x11/SCsub
@@ -7,7 +7,7 @@ common_x11 = [\
"context_gl_x11.cpp",\
"os_x11.cpp",\
"key_mapping_x11.cpp",\
- "joystick_linux.cpp",\
+ "joypad_linux.cpp",\
]
env.Program('#bin/godot', ['godot_x11.cpp'] + common_x11)
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 19884feaa8..b5f6359d21 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -139,6 +139,13 @@ def configure(env):
if (env['builtin_libwebp'] == 'no'):
env.ParseConfig('pkg-config libwebp --cflags --libs')
+ # freetype depends on libpng and zlib, so bundling one of them while keeping others
+ # as shared libraries leads to weird issues
+ if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'):
+ env['builtin_freetype'] = 'yes'
+ env['builtin_libpng'] = 'yes'
+ env['builtin_zlib'] = 'yes'
+
if (env['builtin_freetype'] == 'no'):
env.ParseConfig('pkg-config freetype2 --cflags --libs')
@@ -175,9 +182,6 @@ def configure(env):
env.Append(CPPFLAGS=['-DOPENGL_ENABLED'])
- if (env['builtin_glew'] == 'no'):
- env.ParseConfig('pkg-config glew --cflags --libs')
-
if os.system("pkg-config --exists alsa") == 0:
print("Enabling ALSA")
env.Append(CPPFLAGS=["-DALSA_ENABLED"])
@@ -206,10 +210,14 @@ def configure(env):
else:
print("PulseAudio development libraries not found, disabling driver")
+ if (env['builtin_zlib'] == 'no'):
+ env.ParseConfig('pkg-config zlib --cflags --libs')
+
env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
- env.Append(LIBS=['GL', 'pthread', 'z'])
+ env.Append(LIBS=['GL', 'pthread'])
+
if (platform.system() == "Linux"):
- env.Append(LIBS='dl')
+ env.Append(LIBS=['dl'])
# env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
# host compiler is default..
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joypad_linux.cpp
index d101a725ad..362999661e 100644
--- a/platform/x11/joystick_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* joystick_linux.cpp */
+/* joypad_linux.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-//author: Andreas Haas <hondres, liugam3@gmail.com>
#ifdef JOYDEV_ENABLED
-#include "joystick_linux.h"
+#include "joypad_linux.h"
#include <linux/input.h>
#include <unistd.h>
@@ -49,7 +48,7 @@
static const char* ignore_str = "/dev/input/js";
#endif
-joystick_linux::Joystick::Joystick() {
+JoypadLinux::Joypad::Joypad() {
fd = -1;
dpad = 0;
devpath = "";
@@ -58,7 +57,7 @@ joystick_linux::Joystick::Joystick() {
}
}
-joystick_linux::Joystick::~Joystick() {
+JoypadLinux::Joypad::~Joypad() {
for (int i = 0; i < MAX_ABS; i++) {
if (abs_info[i]) {
@@ -67,7 +66,7 @@ joystick_linux::Joystick::~Joystick() {
}
}
-void joystick_linux::Joystick::reset() {
+void JoypadLinux::Joypad::reset() {
dpad = 0;
fd = -1;
@@ -80,7 +79,7 @@ void joystick_linux::Joystick::reset() {
}
}
-joystick_linux::joystick_linux(InputDefault *in)
+JoypadLinux::JoypadLinux(InputDefault *in)
{
exit_udev = false;
input = in;
@@ -88,37 +87,37 @@ joystick_linux::joystick_linux(InputDefault *in)
joy_thread = Thread::create(joy_thread_func, this);
}
-joystick_linux::~joystick_linux() {
+JoypadLinux::~JoypadLinux() {
exit_udev = true;
Thread::wait_to_finish(joy_thread);
memdelete(joy_thread);
memdelete(joy_mutex);
- close_joystick();
+ close_joypad();
}
-void joystick_linux::joy_thread_func(void *p_user) {
+void JoypadLinux::joy_thread_func(void *p_user) {
if (p_user) {
- joystick_linux* joy = (joystick_linux*) p_user;
- joy->run_joystick_thread();
+ JoypadLinux* joy = (JoypadLinux*) p_user;
+ joy->run_joypad_thread();
}
return;
}
-void joystick_linux::run_joystick_thread() {
+void JoypadLinux::run_joypad_thread() {
#ifdef UDEV_ENABLED
udev *_udev = udev_new();
ERR_FAIL_COND(!_udev);
- enumerate_joysticks(_udev);
- monitor_joysticks(_udev);
+ enumerate_joypads(_udev);
+ monitor_joypads(_udev);
udev_unref(_udev);
#else
- monitor_joysticks();
+ monitor_joypads();
#endif
}
#ifdef UDEV_ENABLED
-void joystick_linux::enumerate_joysticks(udev *p_udev) {
+void JoypadLinux::enumerate_joypads(udev *p_udev) {
udev_enumerate *enumerate;
udev_list_entry *devices, *dev_list_entry;
@@ -126,7 +125,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
enumerate = udev_enumerate_new(p_udev);
udev_enumerate_add_match_subsystem(enumerate,"input");
- udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1");
+ udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYPAD", "1");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
@@ -141,7 +140,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
joy_mutex->lock();
- open_joystick(devnode);
+ open_joypad(devnode);
joy_mutex->unlock();
}
}
@@ -150,7 +149,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
udev_enumerate_unref(enumerate);
}
-void joystick_linux::monitor_joysticks(udev *p_udev) {
+void JoypadLinux::monitor_joypads(udev *p_udev) {
udev_device *dev = NULL;
udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev");
@@ -188,9 +187,9 @@ void joystick_linux::monitor_joysticks(udev *p_udev) {
if (devnode_str.find(ignore_str) == -1) {
if (action == "add")
- open_joystick(devnode);
+ open_joypad(devnode);
else if (String(action) == "remove")
- close_joystick(get_joy_from_path(devnode));
+ close_joypad(get_joy_from_path(devnode));
}
}
@@ -204,7 +203,7 @@ void joystick_linux::monitor_joysticks(udev *p_udev) {
}
#endif
-void joystick_linux::monitor_joysticks() {
+void JoypadLinux::monitor_joypads() {
while (!exit_udev) {
joy_mutex->lock();
@@ -212,7 +211,7 @@ void joystick_linux::monitor_joysticks() {
char fname[64];
sprintf(fname, "/dev/input/event%d", i);
if (attached_devices.find(fname) == -1) {
- open_joystick(fname);
+ open_joypad(fname);
}
}
joy_mutex->unlock();
@@ -220,37 +219,37 @@ void joystick_linux::monitor_joysticks() {
}
}
-int joystick_linux::get_free_joy_slot() const {
+int JoypadLinux::get_free_joy_slot() const {
- for (int i = 0; i < JOYSTICKS_MAX; i++) {
+ for (int i = 0; i < JOYPADS_MAX; i++) {
- if (joysticks[i].fd == -1) return i;
+ if (joypads[i].fd == -1) return i;
}
return -1;
}
-int joystick_linux::get_joy_from_path(String p_path) const {
+int JoypadLinux::get_joy_from_path(String p_path) const {
- for (int i = 0; i < JOYSTICKS_MAX; i++) {
+ for (int i = 0; i < JOYPADS_MAX; i++) {
- if (joysticks[i].devpath == p_path) {
+ if (joypads[i].devpath == p_path) {
return i;
}
}
return -2;
}
-void joystick_linux::close_joystick(int p_id) {
+void JoypadLinux::close_joypad(int p_id) {
if (p_id == -1) {
- for (int i=0; i<JOYSTICKS_MAX; i++) {
+ for (int i=0; i<JOYPADS_MAX; i++) {
- close_joystick(i);
+ close_joypad(i);
};
return;
}
else if (p_id < 0) return;
- Joystick &joy = joysticks[p_id];
+ Joypad &joy = joypads[p_id];
if (joy.fd != -1) {
@@ -273,9 +272,9 @@ static String _hex_str(uint8_t p_byte) {
return ret;
}
-void joystick_linux::setup_joystick_properties(int p_id) {
+void JoypadLinux::setup_joypad_properties(int p_id) {
- Joystick* joy = &joysticks[p_id];
+ Joypad* joy = &joypads[p_id];
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
@@ -328,7 +327,7 @@ void joystick_linux::setup_joystick_properties(int p_id) {
}
}
-void joystick_linux::open_joystick(const char *p_path) {
+void JoypadLinux::open_joypad(const char *p_path) {
int joy_num = get_free_joy_slot();
int fd = open(p_path, O_RDWR | O_NONBLOCK);
@@ -349,7 +348,7 @@ void joystick_linux::open_joystick(const char *p_path) {
}
//check if the device supports basic gamepad events, prevents certain keyboards from
- //being detected as joysticks
+ //being detected as joypads
if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
(test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit) ||
test_bit(ABS_GAS, absbit) || test_bit(ABS_RUDDER, absbit)) &&
@@ -372,12 +371,12 @@ void joystick_linux::open_joystick(const char *p_path) {
return;
}
- joysticks[joy_num].reset();
+ joypads[joy_num].reset();
- Joystick &joy = joysticks[joy_num];
+ Joypad &joy = joypads[joy_num];
joy.fd = fd;
joy.devpath = String(p_path);
- setup_joystick_properties(joy_num);
+ setup_joypad_properties(joy_num);
sprintf(uid, "%04x%04x", __bswap_16(inpid.bustype), 0);
if (inpid.vendor && inpid.product && inpid.version) {
@@ -401,14 +400,14 @@ void joystick_linux::open_joystick(const char *p_path) {
}
}
-void joystick_linux::joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp)
+void JoypadLinux::joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp)
{
- Joystick& joy = joysticks[p_id];
+ Joypad& joy = joypads[p_id];
if (!joy.force_feedback || joy.fd == -1 || p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
return;
}
if (joy.ff_effect_id != -1) {
- joystick_vibration_stop(p_id, p_timestamp);
+ joypad_vibration_stop(p_id, p_timestamp);
}
struct ff_effect effect;
@@ -433,9 +432,9 @@ void joystick_linux::joystick_vibration_start(int p_id, float p_weak_magnitude,
joy.ff_effect_timestamp = p_timestamp;
}
-void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp)
+void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp)
{
- Joystick& joy = joysticks[p_id];
+ Joypad& joy = joypads[p_id];
if (!joy.force_feedback || joy.fd == -1 || joy.ff_effect_id == -1) {
return;
}
@@ -448,7 +447,7 @@ void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp)
joy.ff_effect_timestamp = p_timestamp;
}
-InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const {
+InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
int min = p_abs->minimum;
int max = p_abs->maximum;
@@ -468,17 +467,17 @@ InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, i
return jx;
}
-uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
+uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
if (joy_mutex->try_lock() != OK) {
return p_event_id;
}
- for (int i=0; i<JOYSTICKS_MAX; i++) {
+ for (int i=0; i<JOYPADS_MAX; i++) {
- if (joysticks[i].fd == -1) continue;
+ if (joypads[i].fd == -1) continue;
input_event events[32];
- Joystick* joy = &joysticks[i];
+ Joypad* joy = &joypads[i];
int len;
@@ -539,7 +538,7 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
}
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
- close_joystick(i);
+ close_joypad(i);
};
if (joy->force_feedback) {
@@ -548,9 +547,9 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
Vector2 strength = input->get_joy_vibration_strength(i);
float duration = input->get_joy_vibration_duration(i);
if (strength.x == 0 && strength.y == 0) {
- joystick_vibration_stop(i, timestamp);
+ joypad_vibration_stop(i, timestamp);
} else {
- joystick_vibration_start(i, strength.x, strength.y, duration, timestamp);
+ joypad_vibration_start(i, strength.x, strength.y, duration, timestamp);
}
}
}
diff --git a/platform/x11/joystick_linux.h b/platform/x11/joypad_linux.h
index 34e7001ca9..18ad199f6b 100644
--- a/platform/x11/joystick_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* joystick_linux.h */
+/* joypad_linux.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,9 @@
/*************************************************************************/
//author: Andreas Haas <hondres, liugam3@gmail.com>
-#ifndef JOYSTICK_LINUX_H
-#define JOYSTICK_LINUX_H
+#ifndef JOYPAD_LINUX_H
+#define JOYPAD_LINUX_H
+
#ifdef JOYDEV_ENABLED
#include "main/input_default.h"
#include "os/thread.h"
@@ -37,21 +38,21 @@
struct input_absinfo;
-class joystick_linux
+class JoypadLinux
{
public:
- joystick_linux(InputDefault *in);
- ~joystick_linux();
- uint32_t process_joysticks(uint32_t p_event_id);
+ JoypadLinux(InputDefault *in);
+ ~JoypadLinux();
+ uint32_t process_joypads(uint32_t p_event_id);
private:
enum {
- JOYSTICKS_MAX = 16,
+ JOYPADS_MAX = 16,
MAX_ABS = 63,
MAX_KEY = 767, // Hack because <linux/input.h> can't be included here
};
- struct Joystick {
+ struct Joypad {
InputDefault::JoyAxis curr_axis[MAX_ABS];
int key_map[MAX_KEY];
int abs_map[MAX_ABS];
@@ -65,8 +66,8 @@ private:
int ff_effect_id;
uint64_t ff_effect_timestamp;
- Joystick();
- ~Joystick();
+ Joypad();
+ ~Joypad();
void reset();
};
@@ -74,7 +75,7 @@ private:
Mutex *joy_mutex;
Thread *joy_thread;
InputDefault *input;
- Joystick joysticks[JOYSTICKS_MAX];
+ Joypad joypads[JOYPADS_MAX];
Vector<String> attached_devices;
static void joy_thread_func(void *p_user);
@@ -82,21 +83,21 @@ private:
int get_joy_from_path(String path) const;
int get_free_joy_slot() const;
- void setup_joystick_properties(int p_id);
- void close_joystick(int p_id = -1);
+ void setup_joypad_properties(int p_id);
+ void close_joypad(int p_id = -1);
#ifdef UDEV_ENABLED
- void enumerate_joysticks(struct udev *_udev);
- void monitor_joysticks(struct udev *_udev);
+ void enumerate_joypads(struct udev *_udev);
+ void monitor_joypads(struct udev *_udev);
#endif
- void monitor_joysticks();
- void run_joystick_thread();
- void open_joystick(const char* path);
+ void monitor_joypads();
+ void run_joypad_thread();
+ void open_joypad(const char* path);
- void joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
- void joystick_vibration_stop(int p_id, 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);
InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const;
};
#endif
-#endif // JOYSTICK_LINUX_H
+#endif // JOYPAD_LINUX_H
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 74482a57e7..9a4b19f2db 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -458,7 +458,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
input = memnew( InputDefault );
#ifdef JOYDEV_ENABLED
- joystick = memnew( joystick_linux(input));
+ joypad = memnew( JoypadLinux(input));
#endif
_ensure_data_dir();
}
@@ -479,7 +479,7 @@ void OS_X11::finalize() {
//}
#ifdef JOYDEV_ENABLED
- memdelete(joystick);
+ memdelete(joypad);
#endif
memdelete(input);
@@ -1894,7 +1894,7 @@ void OS_X11::set_icon(const Image& p_icon) {
pd[0]=w;
pd[1]=h;
- DVector<uint8_t>::Read r = img.get_data().read();
+ PoolVector<uint8_t>::Read r = img.get_data().read();
long * wr = &pd[2];
uint8_t const * pr = r.ptr();
@@ -1932,7 +1932,7 @@ void OS_X11::run() {
process_xevents(); // get rid of pending events
#ifdef JOYDEV_ENABLED
- event_id = joystick->process_joysticks(event_id);
+ event_id = joypad->process_joypads(event_id);
#endif
if (Main::iteration()==true)
break;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index b89921fb3e..bf676b5edf 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -48,7 +48,7 @@
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "main/input_default.h"
-#include "joystick_linux.h"
+#include "joypad_linux.h"
#include <X11/keysym.h>
#include <X11/Xlib.h>
@@ -155,7 +155,7 @@ class OS_X11 : public OS_Unix {
InputDefault *input;
#ifdef JOYDEV_ENABLED
- joystick_linux *joystick;
+ JoypadLinux *joypad;
#endif
#ifdef RTAUDIO_ENABLED
diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h
index 74d507f5a2..342270b74a 100644
--- a/platform/x11/platform_config.h
+++ b/platform/x11/platform_config.h
@@ -34,6 +34,4 @@
#define PTHREAD_BSD_SET_NAME
#endif
-#define GLES2_INCLUDE_H "GL/glew.h"
-//#define GLES3_INCLUDE_H "GL/glew.h"
-#define GLES3_INCLUDE_H "gl_context/glad/glad.h"
+#define GLES3_INCLUDE_H "glad/glad.h"