aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java25
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java2
-rw-r--r--src/newt/native/WindowsWindow.c14
-rw-r--r--src/newt/native/X11Display.c12
5 files changed, 26 insertions, 29 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 5f03189ac..b2e727355 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -558,7 +558,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private final PointerState1 pState1 = new PointerState1();
/** Pointer names -> pointer ID (consecutive index, starting w/ 0) */
- private final ArrayHashSet<Integer> pName2pID = new ArrayHashSet<Integer>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR);
+ private final ArrayHashSet<Short> pName2pID = new ArrayHashSet<Short>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR);
private boolean defaultGestureHandlerEnabled = true;
private DoubleTapScrollGesture gesture2PtrTouchScroll = null;
@@ -3464,36 +3464,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
*/
public final void doPointerEvent(final boolean enqueue, final boolean wait,
final PointerType[] pTypes, final short eventType, final int modifiers,
- final int actionIdx, final boolean normalPNames, final int[] pNames,
+ final int actionIdx, final boolean normalPNames, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure,
final float maxPressure, final float[] rotationXYZ, final float rotationScale) {
final int pCount = pNames.length;
- final short[] pIDs = new short[pCount];
- for(int i=0; i<pCount; i++) {
- if( !normalPNames ) {
+ final short[] pIDs = normalPNames ? pNames : new short[pCount];
+ if( !normalPNames ) {
+ for(int i=0; i<pCount; i++) {
// hash map int name -> short idx
final int sz0 = pName2pID.size();
- final Integer pNameI1 = pName2pID.getOrAdd(Integer.valueOf(pNames[i]));
- final short pID = (short)pName2pID.indexOf(pNameI1);
+ final Short pNameS1 = pName2pID.getOrAdd(Short.valueOf(pNames[i]));
+ final short pID = (short)pName2pID.indexOf(pNameS1);
pIDs[i] = pID;
if(DEBUG_MOUSE_EVENT) {
final int sz1 = pName2pID.size();
if( sz0 != sz1 ) {
- System.err.println("PointerName2ID[sz "+sz1+"]: Map "+pNameI1+" == "+pID);
+ System.err.println("PointerName2ID[sz "+sz1+"]: Map "+pNameS1+" == "+pID);
}
}
if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) {
- pName2pID.remove(pNameI1);
+ pName2pID.remove(pNameS1);
if(DEBUG_MOUSE_EVENT) {
- System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Unmap "+pNameI1+" == "+pID);
+ System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Unmap "+pNameS1+" == "+pID);
}
}
- } else {
- // simple type cast
- pIDs[i] = (short)pNames[i];
}
}
- final short button = 0 < pCount ? (short) ( pIDs[0] + 1 ) : (short)0;
+ final short button = 0 < pCount ? (short) ( pIDs[actionIdx] + 1 ) : (short)0;
doPointerEvent(enqueue, wait, pTypes, eventType, modifiers, actionIdx, pIDs, button,
pX, pY, pPressure, maxPressure, rotationXYZ, rotationScale);
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index af5dad3ac..020fe599b 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -334,7 +334,7 @@ public class WindowDriver extends WindowImpl {
* </p>
*/
public final void sendTouchScreenEvent(final short eventType, final int modifiers,
- final int pActionIdx, final int[] pNames,
+ final int pActionIdx, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure, final float maxPressure) {
final int pCount = pNames.length;
final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount];
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index afd10f54b..5adbba185 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -407,7 +407,7 @@ public class WindowDriver extends WindowImpl {
}
public final void sendTouchScreenEvent(final short eventType, final int modifiers,
- final int pActionIdx, final int[] pNames,
+ final int pActionIdx, final short[] pNames,
final int[] pX, final int[] pY, final float[] pPressure, final float maxPressure) {
final int pCount = pNames.length;
final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount];
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 59e054516..2571a3e63 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -906,12 +906,12 @@ static BOOL SafeShowCursor(BOOL show) {
static void sendTouchScreenEvent(JNIEnv *env, jobject window,
short eventType, int modifiers, int actionIdx,
- int count, jint* pointerNames, jint* x, jint* y, jfloat* pressure, float maxPressure) {
- jintArray jNames = (*env)->NewIntArray(env, count);
+ int count, jshort* pointerNames, jint* x, jint* y, jfloat* pressure, float maxPressure) {
+ jshortArray jNames = (*env)->NewShortArray(env, count);
if (jNames == NULL) {
- NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (names) of size %d", count);
+ NewtCommon_throwNewRuntimeException(env, "Could not allocate short array (names) of size %d", count);
}
- (*env)->SetIntArrayRegion(env, jNames, 0, count, pointerNames);
+ (*env)->SetShortArrayRegion(env, jNames, 0, count, pointerNames);
jintArray jX = (*env)->NewIntArray(env, count);
if (jX == NULL) {
@@ -1495,7 +1495,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
short eventType[cInputs];
jint modifiers = GetModifiers( 0 );
jint actionIdx = -1;
- jint pointerNames[cInputs];
+ jshort pointerNames[cInputs];
jint x[cInputs], y[cInputs];
jfloat pressure[cInputs];
jfloat maxPressure = 1.0F; // FIXME: n/a on windows ?
@@ -1525,7 +1525,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
}
#endif
- pointerNames[i] = (jint)pTi->dwID;
+ pointerNames[i] = (jshort)pTi->dwID;
eventPt.x = TOUCH_COORD_TO_PIXEL(pTi->x);
eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y);
ScreenToClient(wnd, &eventPt);
@@ -2132,7 +2132,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V");
- sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SII[I[I[I[FF)V");
+ sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SII[S[I[I[FF)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V");
requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 7c6741839..b16734e62 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -267,7 +267,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V");
sendMouseEventRequestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEventRequestFocus", "(SIIISF)V");
visibleChangedSendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "visibleChangedSendMouseEvent", "(ZISIIISF)V");
- sendTouchScreenEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendTouchScreenEvent", "(SII[I[I[I[FF)V");
+ sendTouchScreenEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendTouchScreenEvent", "(SII[S[I[I[FF)V");
sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSCLjava/lang/String;)V");
if (displayCompletedID == NULL ||
@@ -395,7 +395,7 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
int modifiers, // 0!
int actionId) // index of multiple-pointer arrays representing the pointer which triggered the event
{
- jint pointerNames[XI_TOUCHCOORD_COUNT];
+ jshort pointerNames[XI_TOUCHCOORD_COUNT];
jint x[XI_TOUCHCOORD_COUNT];
jint y[XI_TOUCHCOORD_COUNT];
jfloat pressure[] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
@@ -406,7 +406,7 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
if( -1 != jw->xiTouchCoords[i].id ) {
x[cnt] = jw->xiTouchCoords[i].x;
y[cnt] = jw->xiTouchCoords[i].y;
- pointerNames[cnt] = jw->xiTouchCoords[i].id;
+ pointerNames[cnt] = (jshort)jw->xiTouchCoords[i].id;
if (jw->xiTouchCoords[i].id == actionId) {
actionIdx = cnt;
}
@@ -420,11 +420,11 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
DBG_PRINT( "X11: XI event - sendTouchScreenEvent: Window %p, action-touchid[%d] %d of %d ptr: %d/%d\n",
(void*)jw->window, actionIdx, actionId, cnt, x[actionIdx], y[actionIdx]);
- jintArray jNames = (*env)->NewIntArray(env, cnt);
+ jshortArray jNames = (*env)->NewShortArray(env, cnt);
if (jNames == NULL) {
- NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (names) of size %d", cnt);
+ NewtCommon_throwNewRuntimeException(env, "Could not allocate short array (names) of size %d", cnt);
}
- (*env)->SetIntArrayRegion(env, jNames, 0, cnt, pointerNames);
+ (*env)->SetShortArrayRegion(env, jNames, 0, cnt, pointerNames);
jintArray jX = (*env)->NewIntArray(env, cnt);
if (jX == NULL) {