aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/sys/JOGLKBD.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2/sys/JOGLKBD.java')
-rw-r--r--src/jake2/sys/JOGLKBD.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/jake2/sys/JOGLKBD.java b/src/jake2/sys/JOGLKBD.java
index 409d290..194500f 100644
--- a/src/jake2/sys/JOGLKBD.java
+++ b/src/jake2/sys/JOGLKBD.java
@@ -38,7 +38,7 @@ final public class JOGLKBD extends KBD
private void HandleEvents()
{
- int b;
+ int key;
Jake2InputEvent event;
while ( (event=InputListener.nextEvent()) != null ) {
@@ -61,15 +61,15 @@ final public class JOGLKBD extends KBD
my = 0;
}
break;
-
+ // see java.awt.MouseEvent
case Jake2InputEvent.ButtonPress:
- b=((MouseEvent)event.ev).getButton()-1;
- Do_Key_Event(Key.K_MOUSE1 + b, true);
+ key = mouseEventToKey((MouseEvent)event.ev);
+ Do_Key_Event(key, true);
break;
case Jake2InputEvent.ButtonRelease:
- b=((MouseEvent)event.ev).getButton()-1;
- Do_Key_Event(Key.K_MOUSE1 + b, false);
+ key = mouseEventToKey((MouseEvent)event.ev);
+ Do_Key_Event(key, false);
break;
case Jake2InputEvent.WheelMoved:
@@ -110,6 +110,20 @@ final public class JOGLKBD extends KBD
}
}
+ // strange button numbering in java.awt.MouseEvent
+ // BUTTON1(left) BUTTON2(center) BUTTON3(right)
+ // K_MOUSE1 K_MOUSE3 K_MOUSE2
+ private final int mouseEventToKey(MouseEvent ev) {
+ switch (ev.getButton()) {
+ case MouseEvent.BUTTON3:
+ return Key.K_MOUSE2;
+ case MouseEvent.BUTTON2:
+ return Key.K_MOUSE3;
+ default:
+ return Key.K_MOUSE1;
+ }
+ }
+
private static int XLateKey(KeyEvent ev) {
int key = 0;