aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-02 07:54:41 +0100
committerSven Gothel <[email protected]>2011-12-02 07:54:41 +0100
commit30c959a4534bc0c6b4718ae65fd4f91d68d6eca6 (patch)
tree09d676201680f6a670385c8e5f78d23b4eea9955 /src/newt/native
parent4856f7800bac165c3770495b77de4a2eabcca46e (diff)
NEWT EVENT_MOUSE_WHEEL_MOVED: Fix Bug 413 - Generate proper mouse wheel events.
> 0: UP < 0: DOWN See MouseEvent.getWheelRotation() for details. OSX/Windows: Default to wheel 'button' 1 OSX: Properly report '<0' X11: Synthesize wheel events by mapping buttons 4/5 and 6/7 to wheel 1 and 2.
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/NewtMacWindow.m18
-rw-r--r--src/newt/native/WindowsWindow.c2
2 files changed, 7 insertions, 13 deletions
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 1018633b1..ce41673c4 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -44,15 +44,17 @@ jint GetDeltaY(NSEvent *event, jint javaMods) {
// mouse pad case
deltaY =
CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1);
+ // fprintf(stderr, "WHEEL/PAD: %lf\n", (double)deltaY);
} else {
// traditional mouse wheel case
deltaY = [event deltaY];
+ // fprintf(stderr, "WHEEL/TRAD: %lf\n", (double)deltaY);
if (deltaY == 0.0 && (javaMods & EVENT_SHIFT_MASK) != 0) {
// shift+vertical wheel scroll produces horizontal scroll
// we convert it to vertical
deltaY = [event deltaX];
}
- if (deltaY < 1.0 && deltaY > -1.0) {
+ if (-1.0 < deltaY && deltaY < 1.0) {
deltaY *= 10.0;
} else {
if (deltaY < 0.0) {
@@ -62,14 +64,8 @@ jint GetDeltaY(NSEvent *event, jint javaMods) {
}
}
}
-
- if (deltaY > 0) {
- return (NSInteger)deltaY;
- } else if (deltaY < 0) {
- return -(NSInteger)deltaY;
- }
-
- return 0;
+ // fprintf(stderr, "WHEEL/res: %d\n", (int)deltaY);
+ return (jint) deltaY;
}
static jmethodID enqueueMouseEventID = NULL;
@@ -581,6 +577,7 @@ static jint mods2JavaMods(NSUInteger mods)
switch ([event type]) {
case NSScrollWheel: {
scrollDeltaY = GetDeltaY(event, javaMods);
+ javaButtonNum = 1;
break;
}
case NSLeftMouseDown:
@@ -598,9 +595,6 @@ static jint mods2JavaMods(NSUInteger mods)
case NSOtherMouseDragged:
javaButtonNum = 2;
break;
- default:
- javaButtonNum = 0;
- break;
}
if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) {
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index b654fbe85..9b97895c6 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -953,7 +953,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
(jint) EVENT_MOUSE_WHEEL_MOVED,
GetModifiers(),
(jint) eventPt.x, (jint) eventPt.y,
- (jint) 0, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f));
+ (jint) 1, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f));
useDefWindowProc = 1;
break;
}