diff --git a/docs/todo.html b/docs/todo.html
index 5834061..823d07f 100644
--- a/docs/todo.html
+++ b/docs/todo.html
@@ -8,13 +8,13 @@
To-do list
Bugs
- - TabletEvent.isPopupTrigger() won't return the correct value
- Releasing mouse button outside of component doesn't send cursor released event
- Overlapping windows (or multiple applets) can receive simultaneous events
+ Overlapping windows (or multiple applets) can receive simultaneous events
- Listeners are not freed when a component is disposed/lost
- Max OS X
- - Clicking "maximize" button creates a mouse down event but no mouse up event... button state gets screwed up
+ Clicking "maximize" button creates a mouse down event but no mouse up event... button state gets screwed up
+ - Workaround: reset button state when a mouse moved event is received
Scroll gesture isn't smooth
@@ -22,6 +22,8 @@ Bugs
- Keyboard modifiers are not handled correctly
- Mouse buttons won't match the buttons if configured differently in the control panel
+ - Relatively positioned tablet inputs (e.g. mouse) report the wrong coordinates (maybe fallback on mouse
+ position?)
@@ -32,6 +34,7 @@ Desired/incomplete features
Standard mechanism for accessing "raw" tablet buttons independent of system settings
Ability to see extra tablet information (tablet name, vendor, etc)
Extension/installer/versioning support
+ TabletEvent.isPopupTrigger() won't return the correct value
Misc
diff --git a/src/cello/jtablet/event/TabletEvent.java b/src/cello/jtablet/event/TabletEvent.java
index 91e537b..6499626 100644
--- a/src/cello/jtablet/event/TabletEvent.java
+++ b/src/cello/jtablet/event/TabletEvent.java
@@ -103,7 +103,7 @@ public TabletEvent(Component source, Type type, long when, int modifiers,
this.scrollX = deltaX;
this.scrollY = deltaY;
this.zoomFactor = zoom;
- this.rawTabletButtonMask = 0;
+ this.rawTabletButtonMask = rawTabletButtonMask;
}
/**
* Wrap a {@link MouseEvent} as a TabletEvent.
@@ -137,6 +137,7 @@ public TabletEvent(MouseEvent e, Type type, TabletDevice device) {
* @param type
* @param when
* @param modifiers
+ * @param rawTabletButtonMask
* @param device
* @param x
* @param y
@@ -163,6 +164,7 @@ public TabletEvent(Component source, Type type, long when, int modifiers, int ra
* @param type
* @param when
* @param modifiers
+ * @param rawTabletButtonMask
* @param device
* @param x
* @param y
@@ -242,7 +244,18 @@ public String toString() {
sb.append(",zoom=").append(zoomFactor);
}
if (rawTabletButtonMask != 0) {
- sb.append(",rawTabletButtonMask=").append(Integer.toString(rawTabletButtonMask, 2));
+ sb.append(",rawTabletButtons=");
+ boolean first = true;
+ for (int i=0; i<31; i++) {
+ if ((rawTabletButtonMask&(1< PRESSED_THRESHOLD;
+
if (buttonJustReleased || buttonJustPressed) {
fireScreenTabletEvent(new TabletEvent(
SCREEN_COMPONENT,
diff --git a/src/cello/jtablet/impl/jpen/platform/NativeCocoaInterface.java b/src/cello/jtablet/impl/jpen/platform/NativeCocoaInterface.java
index 71594fb..e4e448d 100644
--- a/src/cello/jtablet/impl/jpen/platform/NativeCocoaInterface.java
+++ b/src/cello/jtablet/impl/jpen/platform/NativeCocoaInterface.java
@@ -67,12 +67,13 @@ protected void postScrollEvent(
double eventTimeSeconds,
int cocoaModifierFlags,
float screenX, float screenY,
+ boolean isDeviceDelta,
float deviceDeltaX, float deviceDeltaY
) {
long when = System.currentTimeMillis();
int keyModifiers = getMouseEventModifiers(cocoaModifierFlags);
- generateScrollEvent(when, keyModifiers, screenX, screenY,
- deviceDeltaX*DEVICE_DELTA_FACTOR, deviceDeltaY*DEVICE_DELTA_FACTOR);
+ float factor = isDeviceDelta ? DEVICE_DELTA_FACTOR : 1;
+ generateScrollEvent(when, keyModifiers, screenX, screenY, deviceDeltaX*factor, deviceDeltaY*factor);
}
@Override
protected void postMagnifyEvent(
@@ -181,6 +182,7 @@ protected TabletDevice makeDevice(final long uniqueId, int capabilityMask, int p
return new CocoaDevice(type,Long.toHexString(uniqueId),supportsButtons,supportsDeviceId,supportsPressure,supportsRotation,supportsSidePressure, supportsTiltXY);
}
+ private boolean leftButton, rightButton, otherButton;
@Override
protected void postEvent(int type,
@@ -197,45 +199,106 @@ protected void postEvent(int type,
boolean buttonJustPressed = false, buttonJustReleased = false;
int button = MouseEvent.NOBUTTON;
+
+ long when = System.currentTimeMillis();
+ int keyModifiers = getMouseEventModifiers(cocoaModifierFlags);
+
+ // tilt is in range of -1 ~ 1, where 1 is 64 degrees
+ tiltX *= TILT_TO_RADIANS;
+ // Avoid negative zero...
+ if (tiltY != 0) {
+ tiltY = -tiltY * TILT_TO_RADIANS;
+ }
+
switch (type) {
case NS_EVENT_TYPE_LeftMouseDown:
buttonJustPressed = true;
button = MouseEvent.BUTTON1;
+ leftButton = true;
break;
case NS_EVENT_TYPE_LeftMouseUp:
buttonJustReleased = true;
button = MouseEvent.BUTTON1;
+ leftButton = false;
break;
case NS_EVENT_TYPE_RightMouseDown:
buttonJustPressed = true;
button = MouseEvent.BUTTON3;
+ rightButton = true;
break;
case NS_EVENT_TYPE_RightMouseUp:
buttonJustReleased = true;
button = MouseEvent.BUTTON3;
+ rightButton = false;
break;
case NS_EVENT_TYPE_OtherMouseDown:
buttonJustPressed = true;
button = MouseEvent.BUTTON2;
+ otherButton = true;
break;
case NS_EVENT_TYPE_OtherMouseUp:
buttonJustReleased = true;
button = MouseEvent.BUTTON2;
+ otherButton = false;
+ break;
+ case NS_EVENT_TYPE_MouseMoved:
+ // For some reason when you click maximize on a window, you get a MouseDown event, but no MouseUp...
+ // To work around that issue, if I ever get a mousemoved event when I think a button is pressed, we
+ // can simply generate a fake button up event.
+ if (leftButton) {
+ generatePointEvents(
+ when,
+ keyModifiers,
+ x, y,
+ pressure,
+ tiltX, tiltY,
+ tangentialPressure,
+ rotation,
+ rawTabletButtonMask,
+ MouseEvent.BUTTON1,
+ false,
+ true
+ );
+ leftButton = false;
+ }
+ if (rightButton) {
+ generatePointEvents(
+ when,
+ keyModifiers,
+ x, y,
+ pressure,
+ tiltX, tiltY,
+ tangentialPressure,
+ rotation,
+ rawTabletButtonMask,
+ MouseEvent.BUTTON1,
+ false,
+ true
+ );
+ rightButton = false;
+ }
+ if (otherButton) {
+ generatePointEvents(
+ when,
+ keyModifiers,
+ x, y,
+ pressure,
+ tiltX, tiltY,
+ tangentialPressure,
+ rotation,
+ rawTabletButtonMask,
+ MouseEvent.BUTTON1,
+ false,
+ true
+ );
+ otherButton = false;
+ }
break;
}
- long when = System.currentTimeMillis();
- int modifiers = getMouseEventModifiers(cocoaModifierFlags);
-
- // tilt is in range of -1 ~ 1, where 1 is 64 degrees
- tiltX *= TILT_TO_RADIANS;
- // Avoid negative zero...
- if (tiltY != 0) {
- tiltY = -tiltY * TILT_TO_RADIANS;
- }
generatePointEvents(
when,
- modifiers,
+ keyModifiers,
x, y,
pressure,
tiltX, tiltY,