summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/audio_driver_jandroid.h2
-rw-r--r--platform/android/dir_access_jandroid.h2
-rw-r--r--platform/android/file_access_jandroid.h2
-rw-r--r--platform/android/godot_android.cpp24
-rw-r--r--platform/android/java_glue.h4
-rw-r--r--platform/uwp/export/export.cpp4
-rw-r--r--platform/windows/joypad.cpp8
-rw-r--r--platform/windows/os_windows.cpp134
-rw-r--r--platform/windows/os_windows.h10
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp2
-rw-r--r--platform/windows/packet_peer_udp_winsock.h2
-rw-r--r--platform/windows/tcp_server_winsock.cpp2
-rw-r--r--platform/windows/tcp_server_winsock.h2
-rw-r--r--platform/x11/joypad_linux.h10
14 files changed, 128 insertions, 80 deletions
diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h
index e2bb5ede86..3697ca6f21 100644
--- a/platform/android/audio_driver_jandroid.h
+++ b/platform/android/audio_driver_jandroid.h
@@ -71,7 +71,7 @@ public:
virtual void set_pause(bool p_pause);
- static void setup(jobject act);
+ static void setup(jobject p_io);
static void thread_func(JNIEnv *env);
AudioDriverAndroid();
diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h
index 0175595543..21d1f697b7 100644
--- a/platform/android/dir_access_jandroid.h
+++ b/platform/android/dir_access_jandroid.h
@@ -79,7 +79,7 @@ public:
//virtual FileType get_file_type() const;
size_t get_space_left();
- static void setup(jobject io);
+ static void setup(jobject p_io);
DirAccessJAndroid();
~DirAccessJAndroid();
diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h
index 9bb471246a..a04f28d0d7 100644
--- a/platform/android/file_access_jandroid.h
+++ b/platform/android/file_access_jandroid.h
@@ -71,7 +71,7 @@ public:
virtual bool file_exists(const String &p_path); ///< return true if a file exists
- static void setup(jobject io);
+ static void setup(jobject p_io);
virtual uint64_t _get_modified_time(const String &p_file) { return 0; }
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 71db03049a..6fbd42d7b3 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -739,21 +739,21 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) {
}
}
-void android_main(struct android_app *state) {
+void android_main(struct android_app *app) {
struct engine engine;
// Make sure glue isn't stripped.
app_dummy();
memset(&engine, 0, sizeof(engine));
- state->userData = &engine;
- state->onAppCmd = engine_handle_cmd;
- state->onInputEvent = engine_handle_input;
- engine.app = state;
+ app->userData = &engine;
+ app->onAppCmd = engine_handle_cmd;
+ app->onInputEvent = engine_handle_input;
+ engine.app = app;
engine.requested_quit = false;
engine.os = NULL;
engine.display_active = false;
- FileAccessAndroid::asset_manager = state->activity->assetManager;
+ FileAccessAndroid::asset_manager = app->activity->assetManager;
// Prepare to monitor sensors
engine.sensorManager = ASensorManager_getInstance();
@@ -764,11 +764,11 @@ void android_main(struct android_app *state) {
engine.gyroscopeSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
ASENSOR_TYPE_GYROSCOPE);
engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
- state->looper, LOOPER_ID_USER, NULL, NULL);
+ app->looper, LOOPER_ID_USER, NULL, NULL);
- ANativeActivity_setWindowFlags(state->activity, AWINDOW_FLAG_FULLSCREEN | AWINDOW_FLAG_KEEP_SCREEN_ON, 0);
+ ANativeActivity_setWindowFlags(app->activity, AWINDOW_FLAG_FULLSCREEN | AWINDOW_FLAG_KEEP_SCREEN_ON, 0);
- state->activity->vm->AttachCurrentThread(&engine.jni, NULL);
+ app->activity->vm->AttachCurrentThread(&engine.jni, NULL);
// loop waiting for stuff to do.
@@ -790,7 +790,7 @@ void android_main(struct android_app *state) {
if (source != NULL) {
// LOGI("process\n");
- source->process(state, source);
+ source->process(app, source);
} else {
nullmax--;
if (nullmax < 0)
@@ -824,11 +824,11 @@ void android_main(struct android_app *state) {
}
// Check if we are exiting.
- if (state->destroyRequested != 0) {
+ if (app->destroyRequested != 0) {
if (engine.os) {
engine.os->main_loop_request_quit();
}
- state->destroyRequested = 0;
+ app->destroyRequested = 0;
}
if (engine.requested_quit) {
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index f400f41e28..bcb3304c3e 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -56,8 +56,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env,
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv *env, jobject obj, jstring name, jobject p_object);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args);
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jobject obj, jstring path);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jobject obj, jint ID, jstring method, jobjectArray params);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jobject obj, jint ID, jstring method, jobjectArray params);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params);
}
#endif
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index a1aa58a5e7..39717196aa 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -171,7 +171,7 @@ class AppxPackager {
}
Vector<uint8_t> make_file_header(FileMeta p_file_meta);
- void store_central_dir_header(const FileMeta p_file, bool p_do_hash = true);
+ void store_central_dir_header(const FileMeta &p_file, bool p_do_hash = true);
Vector<uint8_t> make_end_of_central_record();
String content_type(String p_extension);
@@ -329,7 +329,7 @@ Vector<uint8_t> AppxPackager::make_file_header(FileMeta p_file_meta) {
return buf;
}
-void AppxPackager::store_central_dir_header(const FileMeta p_file, bool p_do_hash) {
+void AppxPackager::store_central_dir_header(const FileMeta &p_file, bool p_do_hash) {
Vector<uint8_t> &buf = central_dir_data;
int offs = buf.size();
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index 7263e89c1a..e8a5084daf 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -235,13 +235,13 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
}
}
-BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE *instance, void *pContext) {
+BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE *p_instance, void *p_context) {
- JoypadWindows *self = (JoypadWindows *)pContext;
- if (self->is_xinput_device(&instance->guidProduct)) {
+ JoypadWindows *self = (JoypadWindows *)p_context;
+ if (self->is_xinput_device(&p_instance->guidProduct)) {
return DIENUM_CONTINUE;
}
- self->setup_dinput_joypad(instance);
+ self->setup_dinput_joypad(p_instance);
return DIENUM_CONTINUE;
}
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index f72e5ef595..779f909a15 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -889,23 +889,6 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
return (dpiX + dpiY) / 2;
}
-BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
- OS_Windows *self = (OS_Windows *)OS::get_singleton();
- MonitorInfo minfo;
- minfo.hMonitor = hMonitor;
- minfo.hdcMonitor = hdcMonitor;
- minfo.rect.position.x = lprcMonitor->left;
- minfo.rect.position.y = lprcMonitor->top;
- minfo.rect.size.x = lprcMonitor->right - lprcMonitor->left;
- minfo.rect.size.y = lprcMonitor->bottom - lprcMonitor->top;
-
- minfo.dpi = QueryDpiForMonitor(hMonitor);
-
- self->monitor_info.push_back(minfo);
-
- return TRUE;
-}
-
void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
main_loop = NULL;
@@ -941,9 +924,6 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
return; // Return
}
- EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
-
- print_line("DETECTED MONITORS: " + itos(monitor_info.size()));
pre_fs_valid = true;
if (video_mode.fullscreen) {
@@ -1217,8 +1197,6 @@ void OS_Windows::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
-
- monitor_info.clear();
}
void OS_Windows::finalize_core() {
@@ -1344,51 +1322,131 @@ OS::VideoMode OS_Windows::get_video_mode(int p_screen) const {
void OS_Windows::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
+static BOOL CALLBACK _MonitorEnumProcCount(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ int *data = (int *)dwData;
+ (*data)++;
+ return TRUE;
+}
+
int OS_Windows::get_screen_count() const {
- return monitor_info.size();
+ int data = 0;
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcCount, (LPARAM)&data);
+ return data;
}
-int OS_Windows::get_current_screen() const {
- HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- for (int i = 0; i < monitor_info.size(); i++) {
- if (monitor_info[i].hMonitor == monitor)
- return i;
+typedef struct {
+ int count;
+ int screen;
+ HMONITOR monitor;
+} EnumScreenData;
+
+static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumScreenData *data = (EnumScreenData *)dwData;
+ if (data->monitor == hMonitor) {
+ data->screen = data->count;
}
- return 0;
+ data->count++;
+ return TRUE;
}
-void OS_Windows::set_current_screen(int p_screen) {
- ERR_FAIL_INDEX(p_screen, monitor_info.size());
+int OS_Windows::get_current_screen() const {
+
+ EnumScreenData data = { 0, 0, MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data);
+ return data.screen;
+}
+
+void OS_Windows::set_current_screen(int p_screen) {
Vector2 ofs = get_window_position() - get_screen_position(get_current_screen());
set_window_position(ofs + get_screen_position(p_screen));
}
+typedef struct {
+ int count;
+ int screen;
+ Point2 pos;
+} EnumPosData;
+
+static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumPosData *data = (EnumPosData *)dwData;
+ if (data->count == data->screen) {
+ data->pos.x = lprcMonitor->left;
+ data->pos.y = lprcMonitor->top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
Point2 OS_Windows::get_screen_position(int p_screen) const {
- ERR_FAIL_INDEX_V(p_screen, monitor_info.size(), Point2());
- return Vector2(monitor_info[p_screen].rect.position);
+ EnumPosData data = { 0, p_screen, Point2() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data);
+ return data.pos;
}
+
+typedef struct {
+ int count;
+ int screen;
+ Size2 size;
+} EnumSizeData;
+
+static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumSizeData *data = (EnumSizeData *)dwData;
+ if (data->count == data->screen) {
+ data->size.x = lprcMonitor->right - lprcMonitor->left;
+ data->size.y = lprcMonitor->bottom - lprcMonitor->top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
Size2 OS_Windows::get_screen_size(int p_screen) const {
- ERR_FAIL_INDEX_V(p_screen, monitor_info.size(), Point2());
- return Vector2(monitor_info[p_screen].rect.size);
+ EnumSizeData data = { 0, p_screen, Size2() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
+ return data.size;
+}
+
+typedef struct {
+ int count;
+ int screen;
+ int dpi;
+} EnumDpiData;
+
+static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumDpiData *data = (EnumDpiData *)dwData;
+ if (data->count == data->screen) {
+ data->dpi = QueryDpiForMonitor(hMonitor);
+ }
+
+ data->count++;
+ return TRUE;
}
int OS_Windows::get_screen_dpi(int p_screen) const {
- ERR_FAIL_INDEX_V(p_screen, monitor_info.size(), 72);
- UINT dpix, dpiy;
- return monitor_info[p_screen].dpi;
+ EnumDpiData data = { 0, p_screen, 72 };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data);
+ return data.dpi;
}
+
Point2 OS_Windows::get_window_position() const {
RECT r;
GetWindowRect(hWnd, &r);
return Point2(r.left, r.top);
}
+
void OS_Windows::set_window_position(const Point2 &p_position) {
if (video_mode.fullscreen) return;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index beaf5d5e35..e9af14f11c 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -164,22 +164,12 @@ protected:
};
Map<ProcessID, ProcessInfo> *process_map;
- struct MonitorInfo {
- HMONITOR hMonitor;
- HDC hdcMonitor;
- Rect2 rect;
- int dpi;
- };
-
bool pre_fs_valid;
RECT pre_fs_rect;
- Vector<MonitorInfo> monitor_info;
bool maximized;
bool minimized;
bool borderless;
- static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
-
public:
LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
index f3b91c1b56..3991a90423 100644
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ b/platform/windows/packet_peer_udp_winsock.cpp
@@ -118,7 +118,7 @@ void PacketPeerUDPWinsock::_set_sock_blocking(bool p_blocking) {
};
}
-Error PacketPeerUDPWinsock::listen(int p_port, IP_Address p_bind_address, int p_recv_buffer_size) {
+Error PacketPeerUDPWinsock::listen(int p_port, const IP_Address &p_bind_address, int p_recv_buffer_size) {
ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h
index ceb6df71aa..01f2e5113f 100644
--- a/platform/windows/packet_peer_udp_winsock.h
+++ b/platform/windows/packet_peer_udp_winsock.h
@@ -67,7 +67,7 @@ public:
virtual int get_max_packet_size() const;
- virtual Error listen(int p_port, IP_Address p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536);
+ virtual Error listen(int p_port, const IP_Address &p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536);
virtual void close();
virtual Error wait();
virtual bool is_listening() const;
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index 3292813d4e..cc17c8a631 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -63,7 +63,7 @@ void TCPServerWinsock::cleanup() {
};
};
-Error TCPServerWinsock::listen(uint16_t p_port, const IP_Address p_bind_address) {
+Error TCPServerWinsock::listen(uint16_t p_port, const IP_Address &p_bind_address) {
ERR_FAIL_COND_V(listen_sockfd != -1, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h
index 7e5d1e750e..077acb94d7 100644
--- a/platform/windows/tcp_server_winsock.h
+++ b/platform/windows/tcp_server_winsock.h
@@ -40,7 +40,7 @@ class TCPServerWinsock : public TCP_Server {
static TCP_Server *_create();
public:
- virtual Error listen(uint16_t p_port, const IP_Address p_bind_address = IP_Address("*"));
+ virtual Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*"));
virtual bool is_connection_available() const;
virtual Ref<StreamPeerTCP> take_connection();
diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h
index a0ac559b1c..55383885a0 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -80,22 +80,22 @@ private:
static void joy_thread_func(void *p_user);
- int get_joy_from_path(String path) const;
+ int get_joy_from_path(String p_path) const;
void setup_joypad_properties(int p_id);
void close_joypad(int p_id = -1);
#ifdef UDEV_ENABLED
- void enumerate_joypads(struct udev *_udev);
- void monitor_joypads(struct udev *_udev);
+ void enumerate_joypads(struct udev *p_udev);
+ void monitor_joypads(struct udev *p_udev);
#endif
void monitor_joypads();
void run_joypad_thread();
- void open_joypad(const char *path);
+ void open_joypad(const char *p_path);
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;
+ InputDefault::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const;
};
#endif