aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorDmitri Trembovetski <[email protected]>2009-05-25 00:10:13 +0000
committerDmitri Trembovetski <[email protected]>2009-05-25 00:10:13 +0000
commitbeaa6d5d02d747c2eda1a3a81ba5e4030c9c5587 (patch)
tree2e3551c56d2850af07ab6b4890f0a596506d3c55 /src/newt/native
parent1d428d4fce17329e7d3cc212ae45729836c07a25 (diff)
Newt fixes: implemented mouse wheel support - currently only hooked up on Windows platform, others will follow
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1913 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/newt/native')
-rwxr-xr-xsrc/newt/native/KDWindow.c6
-rw-r--r--src/newt/native/MouseEvent.h2
-rw-r--r--src/newt/native/NewtMacWindow.m4
-rwxr-xr-xsrc/newt/native/WindowsWindow.c80
4 files changed, 70 insertions, 22 deletions
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index 8e4764c49..e5fb41a76 100755
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -97,7 +97,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_kd_KDWindow_initIDs
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIII)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
if (sizeChangedID == NULL ||
windowDestroyNotifyID == NULL ||
@@ -289,12 +289,12 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_DispatchMessages
(*env)->CallVoidMethod(env, obj, sendMouseEventID,
(ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED,
(jint) 0,
- (jint) ptr->x, (jint) ptr->y, 1);
+ (jint) ptr->x, (jint) ptr->y, 1, 0);
} else {
DBG_PRINT( "event mouse: src: %d, s:%d, i:0x%X (%d,%d)\n", owner, ptr->select, ptr->index, ptr->x, ptr->y);
(*env)->CallVoidMethod(env, obj, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
0,
- (jint) ptr->x, (jint) ptr->y, 0);
+ (jint) ptr->x, (jint) ptr->y, 0, 0);
}
}
break;
diff --git a/src/newt/native/MouseEvent.h b/src/newt/native/MouseEvent.h
index 37157808b..e9c0476ef 100644
--- a/src/newt/native/MouseEvent.h
+++ b/src/newt/native/MouseEvent.h
@@ -8,6 +8,8 @@
#define EVENT_MOUSE_PRESSED 203
#define EVENT_MOUSE_RELEASED 204
#define EVENT_MOUSE_MOVED 205
+// can't find how to regenerate this file, adding manually
+#define EVENT_MOUSE_WHEEL_MOVED 207
// Generated by Java: EVENT_MOUSE_DRAGGED = 206;
#endif
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 43f9b271e..e97d8b9ca 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -50,7 +50,7 @@ static JNIEnv* env = NULL;
+ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz
{
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIII)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
@@ -170,7 +170,7 @@ static jint mods2JavaMods(NSUInteger mods)
evType, javaMods,
(jint) location.x,
(jint) (contentRect.size.height - location.y),
- (jint) (1 + [event buttonNumber]));
+ (jint) (1 + [event buttonNumber]), 0);
}
- (void) mouseEntered: (NSEvent*) theEvent
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 9d802b213..8a6617645 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -31,7 +31,7 @@
*
*/
-#include <windows.h>
+#include <Windows.h>
#include <tchar.h>
#include <stdlib.h>
// NOTE: it looks like SHFullScreen and/or aygshell.dll is not available on the APX 2500 any more
@@ -49,6 +49,22 @@ typedef int intptr_t;
#endif
#endif
+#ifndef WM_MOUSEWHEEL
+#define WM_MOUSEWHEEL 0x020A
+#endif //WM_MOUSEWHEEL
+
+#ifndef WHEEL_DELTA
+#define WHEEL_DELTA 120
+#endif //WHEEL_DELTA
+
+#ifndef WHEEL_PAGESCROLL
+#define WHEEL_PAGESCROLL (UINT_MAX)
+#endif //WHEEL_PAGESCROLL
+
+#ifndef GET_WHEEL_DELTA_WPARAM // defined for (_WIN32_WINNT >= 0x0500)
+#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
+#endif
+
#include "com_sun_javafx_newt_windows_WindowsWindow.h"
#include "EventListener.h"
@@ -124,7 +140,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
// Shouldn't happen
return DefWindowProc(wnd, message, wParam, lParam);
}
-
+
switch (message) {
case WM_CLOSE:
(*env)->CallVoidMethod(env, window, windowDestroyNotifyID);
@@ -172,44 +188,74 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_LBUTTONDOWN:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 1);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_PRESSED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 1, (jint) 0);
useDefWindowProc = 1;
break;
case WM_LBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 1);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_RELEASED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 1, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MBUTTONDOWN:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 2);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_PRESSED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 2, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 2);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_RELEASED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 2, (jint) 0);
useDefWindowProc = 1;
break;
case WM_RBUTTONDOWN:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 3);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_PRESSED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 3, (jint) 0);
useDefWindowProc = 1;
break;
case WM_RBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 3);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_RELEASED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 3, (jint) 0);
useDefWindowProc = 1;
break;
case WM_MOUSEMOVE:
- (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
- ConvertModifiers(wParam), (jint) LOWORD(lParam), (jint) HIWORD(lParam), (jint) 0);
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_MOVED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 0, (jint) 0);
+ useDefWindowProc = 1;
+ break;
+
+ case WM_MOUSEWHEEL:
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (jint) EVENT_MOUSE_WHEEL_MOVED,
+ ConvertModifiers(wParam),
+ (jint) LOWORD(lParam), (jint) HIWORD(lParam),
+ (jint) 0, (jint) GET_WHEEL_DELTA_WPARAM(wParam));
useDefWindowProc = 1;
break;
@@ -247,7 +293,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_initID
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIII)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
if (sizeChangedID == NULL ||
positionChangedID == NULL ||