summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-08-16 15:46:49 +0200
committerSven Gothel <[email protected]>2012-08-16 15:46:49 +0200
commit0ca481381b51b4082ac2b3bbae80cfaf5b60c3b8 (patch)
treeab66219a22c671e0acd50ea0281b27111b8e0597 /src/newt/classes
parent3732d0162051ffe56af34ba345b59c15bfc6f552 (diff)
NEWT: Adding support for BCM VC IV (Broadcom VideoCodec 4) and Linux console mouse tracker
Rasperry PI uses the 'BCM VC IV' GPU via console as it's default configuration. This driver enables direct support for JOGL/NEWT. Due to the lack of detection (TODO) users have to specify the Java property: -Dnativewindow.ws.name=jogamp.newt.driver.bcm.vc.iv - Autodetection should be included in 'NativeWindowFactory._getNativeWindowingType()' while adding a new TYPE: 'TYPE_BCM_VC_IV'. - Autodetection may need to detect whether an X11 Display runs and the installed EGL library uses it (instead of the default console one) This work is authored in coop w/ Xerxes RĂ„nby <[email protected]>!
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java (renamed from src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java)2
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java (renamed from src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java)2
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java (renamed from src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java)2
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java78
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java73
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java149
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java221
7 files changed, 524 insertions, 3 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java
index e3f50b7e0..f08890da6 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java
@@ -32,7 +32,7 @@
*
*/
-package jogamp.newt.driver.broadcom.egl;
+package jogamp.newt.driver.bcm.egl;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeWindowException;
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java
index 0544bc06c..909444d24 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java
@@ -32,7 +32,7 @@
*
*/
-package jogamp.newt.driver.broadcom.egl;
+package jogamp.newt.driver.bcm.egl;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java
index 223ad6484..87170e4ab 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java
@@ -32,7 +32,7 @@
*
*/
-package jogamp.newt.driver.broadcom.egl;
+package jogamp.newt.driver.bcm.egl;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.GraphicsConfigurationFactory;
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java
new file mode 100644
index 000000000..62af02abb
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.newt.driver.bcm.vc.iv;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
+
+import jogamp.newt.DisplayImpl;
+import jogamp.newt.NEWTJNILibLoader;
+import jogamp.opengl.egl.EGL;
+import jogamp.opengl.egl.EGLDisplayUtil;
+
+public class Display extends DisplayImpl {
+ static {
+ NEWTJNILibLoader.loadNEWT();
+
+ if (!Display.initIDs()) {
+ throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs");
+ }
+ if (!Screen.initIDs()) {
+ throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs");
+ }
+ if (!Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public Display() {
+ }
+
+ protected void createNativeImpl() {
+ // FIXME: map name to EGL_*_DISPLAY
+ aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+ }
+
+ protected void closeNativeImpl() {
+ aDevice.close();
+ }
+
+ protected void dispatchMessagesNative() {
+ DispatchMessages();
+ }
+
+ protected static native boolean initIDs();
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java
new file mode 100644
index 000000000..484d4bf81
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.newt.driver.bcm.vc.iv;
+
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Point;
+
+import jogamp.newt.ScreenImpl;
+
+public class Screen extends ScreenImpl {
+ static {
+ Display.initSingleton();
+ }
+
+ public Screen() {
+ }
+
+ protected void createNativeImpl() {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx);
+ initNative();
+ }
+
+ protected void closeNativeImpl() { }
+
+ protected int validateScreenIndex(int idx) {
+ return 0; // only one screen available
+ }
+
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(cachedWidth);
+ virtualSize.setHeight(cachedHeight);
+ }
+
+ protected void setScreenSize(int width, int height) {
+ cachedWidth = width;
+ cachedHeight = height;
+ }
+
+ private static int cachedWidth = 0;
+ private static int cachedHeight = 0;
+
+ protected static native boolean initIDs();
+ protected native void initNative();
+}
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java
new file mode 100644
index 000000000..3d00949de
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.newt.driver.bcm.vc.iv;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.VisualIDHolder;
+import javax.media.nativewindow.util.Insets;
+import javax.media.nativewindow.util.Point;
+
+import jogamp.newt.WindowImpl;
+import jogamp.newt.driver.linux.LinuxMouseTracker;
+
+public class Window extends WindowImpl {
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+
+ static {
+ Display.initSingleton();
+ }
+
+ public Window() {
+ }
+
+ protected void createNativeImpl() {
+ if(0!=getParentWindowHandle()) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED);
+ if (null == cfg) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ setGraphicsConfiguration(cfg);
+
+ nativeWindowHandle = CreateWindow(getWidth(), getHeight());
+ if (nativeWindowHandle == 0) {
+ throw new NativeWindowException("Error creating egl window: "+cfg);
+ }
+ setVisible0(nativeWindowHandle, false);
+ setWindowHandle(nativeWindowHandle);
+ if (0 == getWindowHandle()) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = nativeWindowHandle;
+ addWindowListener(LinuxMouseTracker.getSingleton());
+ focusChanged(false, true);
+ }
+
+ protected void closeNativeImpl() {
+ removeWindowListener(LinuxMouseTracker.getSingleton());
+
+ if(0!=windowHandleClose) {
+ CloseWindow(windowHandleClose, windowUserData);
+ windowUserData=0;
+ }
+ }
+
+ protected void requestFocusImpl(boolean reparented) {
+ focusChanged(false, true);
+ }
+
+ protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
+ if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
+ setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags));
+ visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));
+ }
+
+ if(0!=nativeWindowHandle) {
+ if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) {
+ final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ;
+ setFullScreen0(nativeWindowHandle, fs);
+ if(fs) {
+ return true;
+ }
+ }
+ // int _x=(x>=0)?x:this.x;
+ // int _y=(x>=0)?y:this.y;
+ width=(width>0)?width:getWidth();
+ height=(height>0)?height:getHeight();
+ if(width>0 || height>0) {
+ setSize0(nativeWindowHandle, width, height);
+ }
+ if(x>=0 || y>=0) {
+ System.err.println("setPosition n/a in KD");
+ }
+ }
+
+ if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
+ visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));
+ }
+
+ return true;
+ }
+
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return new Point(x,y);
+ }
+
+ protected void updateInsetsImpl(Insets insets) {
+ // nop ..
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(int width, int height);
+ private native long RealizeWindow(long eglWindowHandle);
+ private native int CloseWindow(long eglWindowHandle, long userData);
+ private native void setVisible0(long eglWindowHandle, boolean visible);
+ private native void setSize0(long eglWindowHandle, int width, int height);
+ private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
+
+ private void windowCreated(long userData) {
+ windowUserData=userData;
+ }
+
+ private long nativeWindowHandle;
+ private long windowHandleClose;
+ private long windowUserData;
+}
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
new file mode 100644
index 000000000..885649d17
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
@@ -0,0 +1,221 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.newt.driver.linux;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import jogamp.newt.WindowImpl;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowListener;
+import com.jogamp.newt.event.WindowUpdateEvent;
+
+/**
+ * Experimental native mouse tracker thread for GNU/Linux
+ * just reading <code>/dev/input/mice</code>
+ * within it's own polling thread.
+ */
+public class LinuxMouseTracker implements WindowListener {
+
+ private static final LinuxMouseTracker lmt;
+
+ static {
+ lmt = new LinuxMouseTracker();
+ final Thread t = new Thread(lmt.mouseDevicePoller, "NEWT-LinuxMouseTracker");
+ t.setDaemon(true);
+ t.start();
+ }
+
+ public static LinuxMouseTracker getSingleton() {
+ return lmt;
+ }
+
+ private volatile boolean stop = false;
+ private int x = 0;
+ private int y = 0;
+ private int buttonDown = 0;
+ private int old_x = 0;
+ private int old_y = 0;
+ private int old_buttonDown = 0;
+ private WindowImpl focusedWindow = null;
+ private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller();
+
+ @Override
+ public void windowResized(WindowEvent e) { }
+
+ @Override
+ public void windowMoved(WindowEvent e) { }
+
+ @Override
+ public void windowDestroyNotify(WindowEvent e) {
+ Object s = e.getSource();
+ if(focusedWindow == s) {
+ focusedWindow = null;
+ }
+ }
+
+ @Override
+ public void windowDestroyed(WindowEvent e) { }
+
+ @Override
+ public void windowGainedFocus(WindowEvent e) {
+ Object s = e.getSource();
+ if(s instanceof WindowImpl) {
+ focusedWindow = (WindowImpl) s;
+ }
+ }
+
+ @Override
+ public void windowLostFocus(WindowEvent e) {
+ Object s = e.getSource();
+ if(focusedWindow == s) {
+ focusedWindow = null;
+ }
+ }
+
+ @Override
+ public void windowRepaint(WindowUpdateEvent e) { }
+
+ class MouseDevicePoller implements Runnable {
+ @Override
+ public void run() {
+ final byte[] b = new byte[3];
+ final File f = new File("/dev/input/mice");
+ f.setReadOnly();
+ InputStream fis;
+ try {
+ fis = new FileInputStream(f);
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return;
+ }
+ int xd=0,yd=0; //x/y movement delta
+ boolean xo=false,yo=false; // x/y overflow (out of range -255 to +255)
+ boolean lb=false,mb=false,rb=false,hs=false,vs=false; //left/middle/right mousebutton
+ while(!stop) {
+ int remaining=3;
+ while(remaining>0) {
+ int read = 0;
+ try {
+ read = fis.read(b, 0, remaining);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if(read<0) {
+ stop = true; // EOF of mouse !?
+ } else {
+ remaining -= read;
+ }
+ }
+ lb=(b[0]&1)>0;
+ rb=(b[0]&2)>0;
+ mb=(b[0]&4)>0;
+ hs=(b[0]&16)>0;
+ vs=(b[0]&32)>0;
+ xo=(b[0]&64)>0;
+ yo=(b[0]&128)>0;
+ xd=b[1];
+ yd=b[2];
+
+ x+=xd;
+ y+=yd;
+
+ if(x<0) {
+ x=0;
+ }
+ if(y<0) {
+ y=0;
+ }
+
+ if(lb) {
+ buttonDown = MouseEvent.BUTTON1;
+ }
+ if(mb) {
+ buttonDown = MouseEvent.BUTTON2;
+ }
+ if(rb) {
+ buttonDown = MouseEvent.BUTTON3;
+ }
+
+ if(null != focusedWindow) {
+ if( x >= focusedWindow.getScreen().getWidth() ) {
+ x = focusedWindow.getScreen().getWidth() - 1;
+ }
+ if( y >= focusedWindow.getScreen().getHeight() ) {
+ y = focusedWindow.getScreen().getHeight() - 1;
+ }
+ int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY();
+
+ if(old_x != x || old_y != y) {
+ // mouse moved
+ focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, 0, 0 );
+ }
+
+ if(old_buttonDown != buttonDown) {
+ // press/release
+ if( 0 != buttonDown ) {
+ focusedWindow.sendMouseEvent(
+ MouseEvent.EVENT_MOUSE_PRESSED,
+ 0, wx, wy, buttonDown, 0 );
+ } else {
+ focusedWindow.sendMouseEvent(
+ MouseEvent.EVENT_MOUSE_RELEASED,
+ 0, wx, wy, old_buttonDown, 0 );
+ }
+ }
+ } else {
+ if(Window.DEBUG_MOUSE_EVENT) {
+ System.out.println(x+"/"+y+", hs="+hs+",vs="+vs+",lb="+lb+",rb="+rb+",mb="+mb+",xo="+xo+",yo="+yo+"xd="+xd+",yd="+yd);
+ }
+ }
+
+ old_x = x;
+ old_y = y;
+ old_buttonDown = buttonDown;
+
+ }
+ if(null != fis) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}