aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorhurikhan2015-02-15 17:49:34 +0800
committerhurikhan2015-02-15 17:49:34 +0800
commitee81d4b359ec5dbeaed5725739ba53b7734372cd (patch)
tree50bff1e6e336fe66d0f58c00841403ce091d3f1c /platform
parenta13e180052d2e17275498a2fa78185cc299ace11 (diff)
parent2185c018f6593e6d64b2beb62202d2291e2e008e (diff)
downloadgodot-ee81d4b359ec5dbeaed5725739ba53b7734372cd.tar.gz
godot-ee81d4b359ec5dbeaed5725739ba53b7734372cd.tar.zst
godot-ee81d4b359ec5dbeaed5725739ba53b7734372cd.zip
Merge remote-tracking branch 'upstream/master' into x11-window-management
Diffstat (limited to 'platform')
-rw-r--r--platform/osx/os_osx.mm13
-rw-r--r--platform/windows/os_windows.cpp60
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/os_x11.cpp6
4 files changed, 75 insertions, 5 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 5bc47a74c..af2552496 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1093,8 +1093,19 @@ void OS_OSX::warp_mouse_pos(const Point2& p_to) {
mouse_y = p_to.y;
}
else{ //set OS position
- CGPoint lMouseWarpPos = {p_to.x, p_to.y};
+ /* this code has not been tested, please be a kind soul and fix it if it fails! */
+
+ //local point in window coords
+ NSPoint localPoint = { p_to.x, p_to.y };
+
+ NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil];
+ NSPoint pointOnScreen = [[window_view window] convertRectToScreen:(CGRect){.origin=pointInWindow}];
+
+ //point in scren coords
+ CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y};
+
+ //do the warping
CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
CGAssociateMouseAndMouseCursorPosition(false);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 915e1a609..13f2c32e7 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -54,6 +54,8 @@
#include "io/marshalls.h"
#include "shlobj.h"
+#include <regstr.h>
+
static const WORD MAX_CONSOLE_LINES = 1500;
extern "C" {
@@ -685,6 +687,48 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
+
+String OS_Windows::get_joystick_name(int id, JOYCAPS jcaps)
+{
+ char buffer [256];
+ char OEM [256];
+ HKEY hKey;
+ DWORD sz;
+ int res;
+
+ _snprintf(buffer, sizeof(buffer), "%s\\%s\\%s",
+ REGSTR_PATH_JOYCONFIG, jcaps.szRegKey,
+ REGSTR_KEY_JOYCURR );
+ res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ {
+ res = RegOpenKeyEx(HKEY_CURRENT_USER, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+ }
+
+ sz = sizeof(OEM);
+ _snprintf( buffer, sizeof(buffer), "Joystick%d%s", id + 1, REGSTR_VAL_JOYOEMNAME);
+ res = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEM, &sz);
+ RegCloseKey ( hKey );
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ _snprintf( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEM);
+ res = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ sz = sizeof(buffer);
+ res = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buffer,
+ &sz);
+ RegCloseKey(hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ return String(buffer);
+}
+
void OS_Windows::probe_joysticks() {
static uint32_t last_attached = 0;
@@ -726,7 +770,13 @@ void OS_Windows::probe_joysticks() {
JOYCAPS jcaps;
MMRESULT res = joyGetDevCaps(JOYSTICKID1 + i, &jcaps, sizeof(jcaps));
if (res == JOYERR_NOERROR) {
- joy.name = jcaps.szPname;
+ String name = get_joystick_name(JOYSTICKID1 + i, jcaps);
+ if ( name == "")
+ joy.name = jcaps.szPname;
+ else
+ joy.name = name;
+
+
};
};
@@ -1382,9 +1432,13 @@ void OS_Windows::warp_mouse_pos(const Point2& p_to) {
old_y=p_to.y;
} else {
- SetCursorPos(p_to.x, p_to.y);
- }
+ POINT p;
+ p.x=p_to.x;
+ p.y=p_to.y;
+ ClientToScreen(hWnd,&p);
+ SetCursorPos(p.x,p.y);
+ }
}
Point2 OS_Windows::get_mouse_pos() const {
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 20993c641..210e25d2d 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -187,6 +187,7 @@ protected:
void probe_joysticks();
void process_joysticks();
void process_key_events();
+ String get_joystick_name( int id, JOYCAPS jcaps);
struct ProcessInfo {
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 9fb2a4c64..4c86f5a82 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -508,8 +508,12 @@ void OS_X11::warp_mouse_pos(const Point2& p_to) {
last_mouse_pos=p_to;
} else {
+ /*XWindowAttributes xwa;
+ XGetWindowAttributes(x11_display, x11_window, &xwa);
+ printf("%d %d\n", xwa.x, xwa.y); needed? */
+
XWarpPointer(x11_display, None, x11_window,
- 0,0,0,0, (int)p_to.x, (int)p_to.y);
+ 0,0,0,0, (int)p_to.x , (int)p_to.y);
}
}