Mouse.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.event.*;
17: import java.awt.image.*;
18: import javax.swing.*;
19: import javax.swing.event.*;
20:
21: public class Mouse {
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73: public static final int[] MUS_DEACCELERATION_TABLE = new int[1025];
74:
75:
76: public static final String[][] MUS_CURSOR_PATTERN = {
77: {
78: },
79: {
80: "00.........",
81: "010........",
82: "0110.......",
83: "01110......",
84: "011110.....",
85: "0111110....",
86: "01111110...",
87: "011111110..",
88: "0111111110.",
89: "01111100000",
90: "0110110....",
91: "010.0110...",
92: "00..0110...",
93: ".....0110..",
94: ".....0110..",
95: "......00...",
96: },
97: };
98:
99:
100:
101:
102:
103:
104: public static boolean musSeamlessOn;
105: public static boolean musExclusiveStart;
106: public static boolean musEdgeAccelerationOn;
107: public static boolean musHostsPixelUnitsOn;
108:
109:
110: public static boolean musButtonLeft;
111: public static boolean musButtonRight;
112: public static int musData;
113: public static int musExtraData;
114: public static int musPanelX;
115: public static int musPanelY;
116: public static int musScreenX;
117: public static int musScreenY;
118: public static boolean musOnScreen;
119: public static boolean musOnKeyboard;
120:
121:
122: public static final int MUS_WHEEL_TRACE = 0;
123: public static final int MUS_WHEEL_CLICK = 1;
124: public static final int MUS_WHEEL_DO_NOTHING = 2;
125: public static int musWheelFunction;
126: public static int musWheelButton;
127: public static long musWheelReleaseTime;
128:
129:
130: public static boolean musCursorAvailable;
131: public static int musCursorNumber;
132: public static Cursor[] musCursorArray;
133:
134:
135: public static boolean musOutputButtonStatus;
136: public static int musNumberOfButtons;
137: public static int musLastModifiersEx;
138: public static boolean musCtrlRightOn;
139:
140: public static final int SHIFT_MASK = 0x00000001;
141: public static final int CTRL_MASK = 0x00000002;
142: public static final int META_MASK = 0x00000004;
143: public static final int BUTTON3_MASK = 0x00000004;
144: public static final int ALT_MASK = 0x00000008;
145: public static final int BUTTON2_MASK = 0x00000008;
146: public static final int BUTTON1_MASK = 0x00000010;
147: public static final int ALT_GRAPH_MASK = 0x00000020;
148:
149: public static final int SHIFT_DOWN_MASK = 0x00000040;
150: public static final int CTRL_DOWN_MASK = 0x00000080;
151: public static final int META_DOWN_MASK = 0x00000100;
152: public static final int ALT_DOWN_MASK = 0x00000200;
153: public static final int BUTTON1_DOWN_MASK = 0x00000400;
154: public static final int BUTTON2_DOWN_MASK = 0x00000800;
155: public static final int BUTTON3_DOWN_MASK = 0x00001000;
156: public static final int ALT_GRAPH_DOWN_MASK = 0x00002000;
157: public static final int BUTTON4_DOWN_MASK = 0x00004000;
158: public static final int BUTTON5_DOWN_MASK = 0x00008000;
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215: public static final int MUS_SPEED_SCALE_MIN = 0;
216: public static final int MUS_SPEED_SCALE_MAX = 40;
217: public static final int MUS_SPEED_SCALE_MID = (MUS_SPEED_SCALE_MAX - MUS_SPEED_SCALE_MIN) >> 1;
218: public static int musSpeedScaleIndex;
219: public static int musSpeedRatioX;
220: public static int musSpeedRatioY;
221: public static final String[] musSpeedTexts = new String[MUS_SPEED_SCALE_MAX - MUS_SPEED_SCALE_MIN + 1];
222: public static JLabel musSpeedLabel;
223: public static JSlider musSpeedSlider;
224:
225:
226: public static JCheckBoxMenuItem musSeamlessMouseCheckBox;
227: public static JMenu musWheelMenu;
228: public static JCheckBoxMenuItem musCtrlRightCheckBox;
229: public static JCheckBoxMenuItem musEdgeAccelerationCheckBox;
230: public static Box musMouseCursorSpeedBox;
231: public static JCheckBoxMenuItem musHostsPixelUnitsCheckBox;
232:
233:
234:
235: public static void musInit () {
236: musSeamlessOn = Settings.sgsGetOnOff ("seamless");
237: musCtrlRightOn = Settings.sgsGetOnOff ("ctrlright");
238: musEdgeAccelerationOn = Settings.sgsGetOnOff ("edgeaccel");
239: musHostsPixelUnitsOn = Settings.sgsGetOnOff ("hostspixelunits");
240: musSpeedScaleIndex = Math.max (MUS_SPEED_SCALE_MIN, Math.min (MUS_SPEED_SCALE_MAX, Settings.sgsGetInt ("mousespeed", MUS_SPEED_SCALE_MID)));
241: switch (Settings.sgsGetString ("mousewheel")) {
242: case "trace":
243: musWheelFunction = MUS_WHEEL_TRACE;
244: break;
245: case "click":
246: musWheelFunction = MUS_WHEEL_CLICK;
247: break;
248: default:
249: musWheelFunction = MUS_WHEEL_DO_NOTHING;
250: }
251:
252: musExclusiveStart = false;
253: musButtonLeft = false;
254: musButtonRight = false;
255: musData = 0;
256: musExtraData = 0;
257: musPanelX = 0;
258: musPanelY = 0;
259: musScreenX = 0;
260: musScreenY = 0;
261: musOnScreen = false;
262: musOnKeyboard = false;
263: musWheelButton = 0;
264: musWheelReleaseTime = 0L;
265:
266: {
267: int index = 0;
268: for (int delta = 0; delta <= 81; delta++) {
269: int next = delta + 1;
270: if (next >= 8) {
271: next *= next >> 3;
272: }
273: next += next >> 2;
274: while (index < next) {
275: MUS_DEACCELERATION_TABLE[index++] = delta;
276: }
277: }
278: }
279:
280: musCursorAvailable = false;
281: try {
282: Toolkit toolkit = Toolkit.getDefaultToolkit ();
283: Dimension bestCursorSize = toolkit.getBestCursorSize (16, 16);
284: int width = bestCursorSize.width;
285: int height = bestCursorSize.height;
286: if (width >= 16 && height >= 16) {
287: BufferedImage cursorImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB);
288: int[] cursorBitmap = ((DataBufferInt) cursorImage.getRaster ().getDataBuffer ()).getData ();
289: Point point = new Point (0, 0);
290: musCursorArray = new Cursor[MUS_CURSOR_PATTERN.length];
291: for (int i = 0; i < MUS_CURSOR_PATTERN.length; i++) {
292: String[] ss = MUS_CURSOR_PATTERN[i];
293: int h = ss.length;
294: for (int y = 0; y < height; y++) {
295: String s = y < h ? ss[y] : "";
296: int w = s.length ();
297: for (int x = 0; x < width; x++) {
298: char c = x < w ? s.charAt (x) : '.';
299: cursorBitmap[x + width * y] = 0xff000000 & ('.' - c) | -(c & 1);
300: }
301: }
302: musCursorArray[i] = toolkit.createCustomCursor (cursorImage, point, "XEiJ_" + i);
303: }
304: musCursorAvailable = true;
305: musCursorNumber = 1;
306: }
307: } catch (Exception e) {
308: }
309:
310: musOutputButtonStatus = false;
311: musNumberOfButtons = -1;
312: try {
313: musNumberOfButtons = MouseInfo.getNumberOfButtons ();
314: } catch (Exception e) {
315: }
316: musLastModifiersEx = 0;
317:
318:
319:
320:
321: for (int i = MUS_SPEED_SCALE_MIN; i <= MUS_SPEED_SCALE_MAX; i++) {
322: musSpeedTexts[i - MUS_SPEED_SCALE_MIN] = String.format ("%4.2f", Math.pow (4.0, (double) (i - MUS_SPEED_SCALE_MID) / (double) MUS_SPEED_SCALE_MID));
323: }
324: musSpeedLabel = ComponentFactory.createLabel (musSpeedTexts[MUS_SPEED_SCALE_MID]);
325:
326: musSpeedSlider = ComponentFactory.setEnabled (
327: ComponentFactory.setPreferredSize (
328: ComponentFactory.createHorizontalSlider (
329: MUS_SPEED_SCALE_MIN,
330: MUS_SPEED_SCALE_MAX,
331: musSpeedScaleIndex,
332: (MUS_SPEED_SCALE_MAX - MUS_SPEED_SCALE_MIN) / 4,
333: 1,
334: musSpeedTexts,
335: new ChangeListener () {
336: @Override public void stateChanged (ChangeEvent ce) {
337: musSetSpeedScaleIndex (((JSlider) ce.getSource ()).getValue ());
338: }
339: }),
340: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
341: XEiJ.rbtRobot != null);
342: musSetSpeedScaleIndex (musSpeedScaleIndex);
343:
344:
345: ActionListener listener = new ActionListener () {
346: @Override public void actionPerformed (ActionEvent ae) {
347: Object source = ae.getSource ();
348: String command = ae.getActionCommand ();
349: switch (command) {
350: case "Seamless mouse":
351: musSetSeamlessOn (((JCheckBoxMenuItem) source).isSelected ());
352: break;
353: case "Trace and step":
354: musWheelFunction = MUS_WHEEL_TRACE;
355: break;
356: case "Left and right click":
357: musWheelFunction = MUS_WHEEL_CLICK;
358: break;
359: case "Do nothing":
360: musWheelFunction = MUS_WHEEL_DO_NOTHING;
361: break;
362: case "Ctrl-key + left-button = right-button":
363: musCtrlRightOn = ((JCheckBoxMenuItem) source).isSelected ();
364: break;
365: case "Edge acceleration":
366: musSetEdgeAccelerationOn (((JCheckBoxMenuItem) source).isSelected ());
367: break;
368: case "Use host's pixel units":
369: musSetHostsPixelUnitsOn (((JCheckBoxMenuItem) source).isSelected ());
370: break;
371: default:
372: System.out.println ("unknown action command " + command);
373: }
374: }
375: };
376:
377: musSeamlessMouseCheckBox =
378: ComponentFactory.setEnabled (
379: Multilingual.mlnText (
380: ComponentFactory.createCheckBoxMenuItem (musSeamlessOn, "Seamless mouse", KeyEvent.VK_F12, listener),
381: "ja", "シームレスマウス"),
382: XEiJ.rbtRobot != null);
383: ButtonGroup wheelGroup = new ButtonGroup ();
384:
385: musWheelMenu =
386: Multilingual.mlnText (
387: ComponentFactory.createMenu (
388: "Mouse wheel",
389: Multilingual.mlnText (
390: ComponentFactory.createRadioButtonMenuItem (wheelGroup, musWheelFunction == MUS_WHEEL_TRACE, "Trace and step", listener),
391: "ja", "トレースとステップ"),
392: Multilingual.mlnText (
393: ComponentFactory.createRadioButtonMenuItem (wheelGroup, musWheelFunction == MUS_WHEEL_CLICK, "Left and right click", listener),
394: "ja", "左クリックと右クリック"),
395: Multilingual.mlnText (
396: ComponentFactory.createRadioButtonMenuItem (wheelGroup, musWheelFunction == MUS_WHEEL_DO_NOTHING, "Do nothing", listener),
397: "ja", "何もしない")
398: ),
399: "ja", "マウスホイール");
400: musCtrlRightCheckBox =
401: Multilingual.mlnText (
402: ComponentFactory.createCheckBoxMenuItem (
403: musCtrlRightOn,
404: "Ctrl-key + left-button = right-button",
405: listener),
406: "ja", "Ctrl キー+左ボタン=右ボタン");
407: musEdgeAccelerationCheckBox =
408: Multilingual.mlnText (
409: ComponentFactory.createCheckBoxMenuItem (musEdgeAccelerationOn, "Edge acceleration", listener),
410: "ja", "縁部加速");
411: musMouseCursorSpeedBox =
412: ComponentFactory.createHorizontalBox (
413: Box.createHorizontalGlue (),
414: Multilingual.mlnText (
415: ComponentFactory.createLabel ("Mouse cursor speed "),
416: "ja", "マウスカーソルの速度 "),
417: musSpeedLabel,
418: Box.createHorizontalGlue ()
419: );
420: musHostsPixelUnitsCheckBox =
421: ComponentFactory.setEnabled (
422: Multilingual.mlnText (
423: ComponentFactory.createCheckBoxMenuItem (musHostsPixelUnitsOn, "Use host's pixel units", listener),
424: "ja", "ホストの画素単位を使う"),
425: XEiJ.rbtRobot != null);
426:
427: }
428:
429:
430:
431: public static void musTini () {
432: Settings.sgsPutOnOff ("seamless", musSeamlessOn);
433: Settings.sgsPutOnOff ("ctrlright", musCtrlRightOn);
434: Settings.sgsPutOnOff ("edgeaccel", musEdgeAccelerationOn);
435: Settings.sgsPutOnOff ("hostspixelunits", musHostsPixelUnitsOn);
436: Settings.sgsPutInt ("mousespeed", musSpeedScaleIndex, MUS_SPEED_SCALE_MID);
437: Settings.sgsPutString ("mousewheel",
438: musWheelFunction == MUS_WHEEL_TRACE ? "trace" :
439: musWheelFunction == MUS_WHEEL_CLICK ? "click" :
440: "donothing");
441: }
442:
443: public static void musSetSpeedScaleIndex (int i) {
444: musSpeedScaleIndex = i;
445: musSpeedLabel.setText (musSpeedTexts[i]);
446: musUpdateSpeedRatio ();
447: }
448:
449: public static void musUpdateSpeedRatio () {
450: double scale = Math.pow (4.0, (double) (musSpeedScaleIndex - MUS_SPEED_SCALE_MID) / (double) MUS_SPEED_SCALE_MID);
451: if (musHostsPixelUnitsOn) {
452:
453:
454: musSpeedRatioX = (int) (65536.0 * scale * (double) XEiJ.pnlScreenWidth / (double) XEiJ.pnlZoomWidth);
455: musSpeedRatioY = (int) (65536.0 * scale * (double) XEiJ.pnlScreenHeight / (double) XEiJ.pnlZoomHeight);
456: } else {
457:
458:
459: musSpeedRatioX = (int) (65536.0 * scale);
460: musSpeedRatioY = (int) (65536.0 * scale);
461: }
462: }
463:
464:
465:
466: public static void musStart () {
467:
468: ComponentFactory.addListener (
469: XEiJ.pnlPanel,
470: new MouseAdapter () {
471: @Override public void mouseClicked (MouseEvent me) {
472: if (musOutputButtonStatus) {
473: int modifiersEx = me.getModifiersEx ();
474: if ((modifiersEx & BUTTON1_DOWN_MASK) != 0) {
475: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
476: 1, musNumberOfButtons, modifiersEx));
477: }
478: if ((modifiersEx & BUTTON2_DOWN_MASK) != 0) {
479: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
480: 2, musNumberOfButtons, modifiersEx));
481: }
482: if ((modifiersEx & BUTTON3_DOWN_MASK) != 0) {
483: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
484: 3, musNumberOfButtons, modifiersEx));
485: }
486: if ((modifiersEx & BUTTON4_DOWN_MASK) != 0) {
487: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
488: 4, musNumberOfButtons, modifiersEx));
489: }
490: if ((modifiersEx & BUTTON5_DOWN_MASK) != 0) {
491: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
492: 5, musNumberOfButtons, modifiersEx));
493: }
494: if ((modifiersEx & (BUTTON1_DOWN_MASK |
495: BUTTON2_DOWN_MASK |
496: BUTTON3_DOWN_MASK |
497: BUTTON4_DOWN_MASK |
498: BUTTON5_DOWN_MASK)) == 0) {
499: System.out.println (String.format ("mouse button ?/%d was clicked. (0x%08x)",
500: musNumberOfButtons, modifiersEx));
501: }
502: }
503: if (!XEiJ.pnlPanel.isFocusOwner ()) {
504: XEiJ.pnlPanel.requestFocusInWindow ();
505: }
506: }
507:
508:
509: @Override public void mouseExited (MouseEvent me) {
510: if (musOnScreen) {
511: musOnScreen = false;
512: }
513: if (musOnKeyboard) {
514: musOnKeyboard = false;
515: if (Keyboard.kbdPointedIndex >= 0) {
516: Keyboard.kbdHover (0, 0);
517: }
518: }
519: }
520: @Override public void mousePressed (MouseEvent me) {
521: musPressedOrReleased (me, true);
522: }
523: @Override public void mouseReleased (MouseEvent me) {
524: musPressedOrReleased (me, false);
525: }
526: @Override public void mouseDragged (MouseEvent me) {
527: musDraggedOrMoved (me);
528: }
529: @Override public void mouseMoved (MouseEvent me) {
530: musDraggedOrMoved (me);
531: }
532: @Override public void mouseWheelMoved (MouseWheelEvent mwe) {
533: if (musOutputButtonStatus) {
534: int modifiersEx = mwe.getModifiersEx ();
535: double preciseWheelRotation = mwe.getPreciseWheelRotation ();
536: int scrollAmount = mwe.getScrollAmount ();
537: int scrollType = mwe.getScrollType ();
538: int unitsToScroll = mwe.getUnitsToScroll ();
539: int wheelRotation = mwe.getWheelRotation ();
540: System.out.println (String.format ("mouse wheel moved (0x%08x)", modifiersEx));
541: System.out.println (String.format (" preciseWheelRotation = %f", preciseWheelRotation));
542: System.out.println (String.format (" scrollAmount = %d", scrollAmount));
543: System.out.println (String.format (" scrollType = %d", scrollType));
544: System.out.println (String.format (" unitsToScroll = %d", unitsToScroll));
545: System.out.println (String.format (" wheelRotation = %d", wheelRotation));
546: }
547: int wheelRotation = mwe.getWheelRotation ();
548: if (musWheelFunction == MUS_WHEEL_TRACE) {
549: if (0 < wheelRotation) {
550: XEiJ.mpuAdvance (mwe.isControlDown () ? 100 :
551: mwe.isShiftDown () ? 10 :
552: 1);
553: } else if (wheelRotation < 0) {
554: if (mwe.isAltDown ()) {
555: XEiJ.mpuStepUntilReturn ();
556: } else {
557: XEiJ.mpuStep (mwe.isControlDown () ? 100 :
558: mwe.isShiftDown () ? 10 :
559: 1);
560: }
561: }
562: } else if (musWheelFunction == MUS_WHEEL_CLICK) {
563: if (0 < wheelRotation) {
564: musWheelButton = 1;
565: musWheelReleaseTime = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * 100;
566: } else if (wheelRotation < 0) {
567: musWheelButton = 2;
568: musWheelReleaseTime = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * 100;
569: }
570: }
571:
572: mwe.consume ();
573: }
574: });
575:
576: }
577:
578:
579:
580: public static void musPressedOrReleased (MouseEvent me, boolean pressed) {
581:
582:
583: int modifiersEx = me.getModifiersEx ();
584: int pressedMask = ~musLastModifiersEx & modifiersEx;
585: int releasedMask = musLastModifiersEx & ~modifiersEx;
586: musLastModifiersEx = modifiersEx;
587: if (musOutputButtonStatus) {
588: if ((pressedMask & BUTTON1_DOWN_MASK) != 0) {
589: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
590: 1, musNumberOfButtons, modifiersEx));
591: } else if ((releasedMask & BUTTON1_DOWN_MASK) != 0) {
592: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
593: 1, musNumberOfButtons, modifiersEx));
594: }
595: if ((pressedMask & BUTTON2_DOWN_MASK) != 0) {
596: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
597: 2, musNumberOfButtons, modifiersEx));
598: } else if ((releasedMask & BUTTON2_DOWN_MASK) != 0) {
599: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
600: 2, musNumberOfButtons, modifiersEx));
601: }
602: if ((pressedMask & BUTTON3_DOWN_MASK) != 0) {
603: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
604: 3, musNumberOfButtons, modifiersEx));
605: } else if ((releasedMask & BUTTON3_DOWN_MASK) != 0) {
606: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
607: 3, musNumberOfButtons, modifiersEx));
608: }
609: if ((pressedMask & BUTTON4_DOWN_MASK) != 0) {
610: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
611: 4, musNumberOfButtons, modifiersEx));
612: } else if ((releasedMask & BUTTON4_DOWN_MASK) != 0) {
613: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
614: 4, musNumberOfButtons, modifiersEx));
615: }
616: if ((pressedMask & BUTTON5_DOWN_MASK) != 0) {
617: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
618: 5, musNumberOfButtons, modifiersEx));
619: } else if ((releasedMask & BUTTON5_DOWN_MASK) != 0) {
620: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
621: 5, musNumberOfButtons, modifiersEx));
622: }
623: if (((pressedMask | releasedMask) & (BUTTON1_DOWN_MASK |
624: BUTTON2_DOWN_MASK |
625: BUTTON3_DOWN_MASK |
626: BUTTON4_DOWN_MASK |
627: BUTTON5_DOWN_MASK)) == 0) {
628: System.out.println (String.format ("mouse button ?/%d was %s. (0x%08x)",
629: musNumberOfButtons, pressed ? "pressed" : "released", modifiersEx));
630: }
631: }
632: if (musCtrlRightOn &&
633: (modifiersEx & MouseEvent.CTRL_DOWN_MASK) != 0) {
634: if ((pressedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
635: pressedMask = ((pressedMask & ~MouseEvent.BUTTON1_DOWN_MASK) |
636: MouseEvent.BUTTON3_DOWN_MASK);
637: }
638: if ((releasedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
639: releasedMask = ((releasedMask & ~MouseEvent.BUTTON1_DOWN_MASK) |
640: MouseEvent.BUTTON3_DOWN_MASK);
641: }
642: }
643: if ((pressedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
644: musButtonLeft = true;
645:
646: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
647: musData |= 1;
648: musExtraData |= 1;
649: } else {
650: musData &= ~1;
651: }
652: } else if ((releasedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
653: musButtonLeft = false;
654: musData &= ~1;
655: }
656: if (musNumberOfButtons < 3) {
657: if ((pressedMask & (MouseEvent.BUTTON2_DOWN_MASK |
658: MouseEvent.BUTTON3_DOWN_MASK)) != 0) {
659: if ((modifiersEx & MouseEvent.ALT_DOWN_MASK) != 0) {
660: musSetSeamlessOn (!musSeamlessOn);
661: } else {
662: musButtonRight = true;
663:
664: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
665: musData |= 2;
666: musExtraData |= 2;
667: } else {
668: musData &= ~2;
669: }
670: }
671: } else if ((releasedMask & (MouseEvent.BUTTON2_DOWN_MASK |
672: MouseEvent.BUTTON3_DOWN_MASK)) != 0) {
673: musButtonRight = false;
674: musData &= ~2;
675: }
676: } else {
677: if ((pressedMask & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
678: musSetSeamlessOn (!musSeamlessOn);
679: }
680: if ((pressedMask & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
681: musButtonRight = true;
682:
683: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
684: musData |= 2;
685: musExtraData |= 2;
686: } else {
687: musData &= ~2;
688: }
689: } else if ((releasedMask & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
690: musButtonRight = false;
691: musData &= ~2;
692: }
693: if (5 <= musNumberOfButtons) {
694: if ((pressedMask & BUTTON4_DOWN_MASK) != 0) {
695: if (XEiJ.mpuTask == null) {
696: XEiJ.mpuStart ();
697: } else {
698: if (RootPointerList.RTL_ON) {
699: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
700: RootPointerList.rtlCurrentUserTaskIsStoppable) {
701: XEiJ.mpuStop (null);
702: }
703: } else {
704: XEiJ.mpuStop (null);
705: }
706: }
707: }
708:
709:
710:
711:
712:
713: }
714: }
715: musDraggedOrMoved (me);
716: }
717:
718:
719:
720: public static void musDraggedOrMoved (MouseEvent me) {
721: int x = musPanelX = me.getX ();
722: int y = musPanelY = me.getY ();
723: if (XEiJ.pnlScreenX1 <= x && x < XEiJ.pnlScreenX1 + XEiJ.pnlZoomWidth &&
724: XEiJ.pnlScreenY1 <= y && y < XEiJ.pnlScreenY1 + XEiJ.pnlZoomHeight) {
725: musOnScreen = true;
726: musScreenX = (x - XEiJ.pnlScreenX1) * XEiJ.pnlZoomRatioInX >> 16;
727: musScreenY = (y - XEiJ.pnlScreenY1) * XEiJ.pnlZoomRatioInY >> 16;
728: } else {
729: musOnScreen = false;
730: }
731: if (XEiJ.pnlKeyboardX <= x && x < XEiJ.pnlKeyboardX + Keyboard.kbdWidth &&
732: XEiJ.pnlKeyboardY <= y && y < XEiJ.pnlKeyboardY + Keyboard.kbdHeight) {
733: musOnKeyboard = true;
734: Keyboard.kbdHover (x - XEiJ.pnlKeyboardX, y - XEiJ.pnlKeyboardY);
735: } else {
736: if (musOnKeyboard) {
737: musOnKeyboard = false;
738: if (Keyboard.kbdPointedIndex >= 0) {
739: Keyboard.kbdHover (0, 0);
740: }
741: }
742: }
743: }
744:
745:
746:
747: public static void musSetSeamlessOn (boolean on) {
748: if (XEiJ.rbtRobot == null) {
749: return;
750: }
751: if (musSeamlessOn != on) {
752: musSeamlessOn = on;
753: if (on) {
754: musShow ();
755:
756: int x, y;
757: if (XEiJ.currentMPU < Model.MPU_MC68LC040) {
758: if (Z8530.SCC_FSX_MOUSE &&
759: Z8530.sccFSXMouseHook != 0 &&
760: MainMemory.mmrRls (0x0938) == Z8530.sccFSXMouseHook) {
761: int xy = MainMemory.mmrRls (Z8530.sccFSXMouseWork + 0x0a);
762: x = (xy >> 16) - CRTC.crtR10TxXPort;
763: y = (short) xy - CRTC.crtR11TxYPort;
764: } else {
765: int xy = MainMemory.mmrRls (0x0ace);
766: x = xy >> 16;
767: y = (short) xy;
768: }
769: } else {
770: if (Z8530.SCC_FSX_MOUSE &&
771: Z8530.sccFSXMouseHook != 0 &&
772: MC68060.mmuPeekLongData (0x0938, 1) == Z8530.sccFSXMouseHook) {
773: int xy = MC68060.mmuPeekLongData (Z8530.sccFSXMouseWork + 0x0a, 1);
774: x = (xy >> 16) - CRTC.crtR10TxXPort;
775: y = (short) xy - CRTC.crtR11TxYPort;
776: } else {
777: int xy = MC68060.mmuPeekLongData (0x0ace, 1);
778: x = xy >> 16;
779: y = (short) xy;
780: }
781: }
782: XEiJ.rbtRobot.mouseMove (x * XEiJ.pnlZoomWidth / XEiJ.pnlScreenWidth + XEiJ.pnlScreenX1 + XEiJ.pnlGlobalX,
783: y * XEiJ.pnlZoomHeight / XEiJ.pnlScreenHeight + XEiJ.pnlScreenY1 + XEiJ.pnlGlobalY);
784: } else {
785: musHide ();
786: Point point = XEiJ.pnlPanel.getLocationOnScreen ();
787: XEiJ.pnlGlobalX = point.x;
788: XEiJ.pnlGlobalY = point.y;
789: musExclusiveStart = true;
790: }
791: }
792: if (musSeamlessMouseCheckBox.isSelected () != on) {
793: musSeamlessMouseCheckBox.setSelected (on);
794: }
795: }
796:
797:
798:
799: public static void musHide () {
800: if (musCursorNumber != 0 && musCursorAvailable) {
801: musCursorNumber = 0;
802: XEiJ.pnlPanel.setCursor (musCursorArray[0]);
803: }
804: }
805:
806:
807:
808: public static void musShow () {
809: if (musCursorNumber != 1 && musCursorAvailable) {
810: musCursorNumber = 1;
811: XEiJ.pnlPanel.setCursor (musCursorArray[1]);
812: }
813: }
814:
815:
816:
817: public static void musSetEdgeAccelerationOn (boolean on) {
818: musEdgeAccelerationOn = on;
819: }
820:
821:
822:
823: public static void musSetHostsPixelUnitsOn (boolean on) {
824: musHostsPixelUnitsOn = on;
825: musUpdateSpeedRatio ();
826: }
827:
828: }