int deviceX = (int) (normalizedX * deviceSize.width); int deviceY = (int) (normalizedY * deviceSize.height); Touch newTS = new Touch(identity, source, state, primary, deviceX, deviceY); return newTS;
void sendTouchEvent (TOUCHINPUT touchInput []) { Event event = new Event (); POINT pt = new POINT (); OS.GetCursorPos (pt); OS.ScreenToClient (handle, pt); event.setLocationInPixels(pt.x, pt.y); Touch [] touches = new Touch [touchInput.length]; Monitor monitor = getMonitor (); for (int i = 0; i < touchInput.length; i++) { TOUCHINPUT ti = touchInput [i]; TouchSource inputSource = display.findTouchSource (ti.hSource, monitor); int state = 0; if ((ti.dwFlags & OS.TOUCHEVENTF_DOWN) != 0) state = SWT.TOUCHSTATE_DOWN; if ((ti.dwFlags & OS.TOUCHEVENTF_UP) != 0) state = SWT.TOUCHSTATE_UP; if ((ti.dwFlags & OS.TOUCHEVENTF_MOVE) != 0) state = SWT.TOUCHSTATE_MOVE; boolean primary = (ti.dwFlags & OS.TOUCHEVENTF_PRIMARY) != 0; int x = (int)OS.TOUCH_COORD_TO_PIXEL (ti.x); int y = (int)OS.TOUCH_COORD_TO_PIXEL (ti.y); touches [i] = new Touch (ti.dwID, inputSource, state, primary, x, y); } event.touches = touches; setInputState (event, SWT.Touch); postEvent (SWT.Touch, event); }