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 musFollowScrollOn;
106: public static boolean musExclusiveStart;
107: public static boolean musEdgeAccelerationOn;
108: public static boolean musHostsPixelUnitsOn;
109:
110:
111: public static boolean musButtonLeft;
112: public static boolean musButtonRight;
113: public static int musData;
114: public static int musExtraData;
115: public static int musPanelX;
116: public static int musPanelY;
117: public static int musScreenX;
118: public static int musScreenY;
119: public static boolean musOnScreen;
120: public static boolean musOnKeyboard;
121:
122:
123: public static final int MUS_WHEEL_TRACE = 0;
124: public static final int MUS_WHEEL_CLICK = 1;
125: public static final int MUS_WHEEL_DO_NOTHING = 2;
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 JCheckBoxMenuItem musFollowScrollCheckBox;
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: musFollowScrollOn = Settings.sgsGetOnOff ("followscroll");
238: musCtrlRightOn = Settings.sgsGetOnOff ("ctrlright");
239: musEdgeAccelerationOn = Settings.sgsGetOnOff ("edgeaccel");
240: musHostsPixelUnitsOn = Settings.sgsGetOnOff ("hostspixelunits");
241: musSpeedScaleIndex = Math.max (MUS_SPEED_SCALE_MIN, Math.min (MUS_SPEED_SCALE_MAX, Settings.sgsGetInt ("mousespeed", MUS_SPEED_SCALE_MID)));
242:
243: musExclusiveStart = false;
244: musButtonLeft = false;
245: musButtonRight = false;
246: musData = 0;
247: musExtraData = 0;
248: musPanelX = 0;
249: musPanelY = 0;
250: musScreenX = 0;
251: musScreenY = 0;
252: musOnScreen = false;
253: musOnKeyboard = false;
254: musWheelButton = 0;
255: musWheelReleaseTime = 0L;
256:
257: {
258: int index = 0;
259: for (int delta = 0; delta <= 81; delta++) {
260: int next = delta + 1;
261: if (next >= 8) {
262: next *= next >> 3;
263: }
264: next += next >> 2;
265: while (index < next) {
266: MUS_DEACCELERATION_TABLE[index++] = delta;
267: }
268: }
269: }
270:
271: musCursorAvailable = false;
272: try {
273: Toolkit toolkit = Toolkit.getDefaultToolkit ();
274: Dimension bestCursorSize = toolkit.getBestCursorSize (16, 16);
275: int width = bestCursorSize.width;
276: int height = bestCursorSize.height;
277: if (width >= 16 && height >= 16) {
278: BufferedImage cursorImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB);
279: int[] cursorBitmap = ((DataBufferInt) cursorImage.getRaster ().getDataBuffer ()).getData ();
280: Point point = new Point (0, 0);
281: musCursorArray = new Cursor[MUS_CURSOR_PATTERN.length];
282: for (int i = 0; i < MUS_CURSOR_PATTERN.length; i++) {
283: String[] ss = MUS_CURSOR_PATTERN[i];
284: int h = ss.length;
285: for (int y = 0; y < height; y++) {
286: String s = y < h ? ss[y] : "";
287: int w = s.length ();
288: for (int x = 0; x < width; x++) {
289: char c = x < w ? s.charAt (x) : '.';
290: cursorBitmap[x + width * y] = 0xff000000 & ('.' - c) | -(c & 1);
291: }
292: }
293: musCursorArray[i] = toolkit.createCustomCursor (cursorImage, point, "XEiJ_" + i);
294: }
295: musCursorAvailable = true;
296: musCursorNumber = 1;
297: }
298: } catch (Exception e) {
299: }
300:
301: musOutputButtonStatus = false;
302: musNumberOfButtons = -1;
303: try {
304: musNumberOfButtons = MouseInfo.getNumberOfButtons ();
305: } catch (Exception e) {
306: }
307: musLastModifiersEx = 0;
308:
309:
310:
311:
312: for (int i = MUS_SPEED_SCALE_MIN; i <= MUS_SPEED_SCALE_MAX; i++) {
313: 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));
314: }
315: musSpeedLabel = ComponentFactory.createLabel (musSpeedTexts[MUS_SPEED_SCALE_MID]);
316:
317: musSpeedSlider = ComponentFactory.setEnabled (
318: ComponentFactory.setPreferredSize (
319: ComponentFactory.createHorizontalSlider (
320: MUS_SPEED_SCALE_MIN,
321: MUS_SPEED_SCALE_MAX,
322: musSpeedScaleIndex,
323: (MUS_SPEED_SCALE_MAX - MUS_SPEED_SCALE_MIN) / 4,
324: 1,
325: musSpeedTexts,
326: new ChangeListener () {
327: @Override public void stateChanged (ChangeEvent ce) {
328: musSetSpeedScaleIndex (((JSlider) ce.getSource ()).getValue ());
329: }
330: }),
331: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
332: XEiJ.rbtRobot != null);
333: musSetSpeedScaleIndex (musSpeedScaleIndex);
334:
335:
336: ActionListener listener = new ActionListener () {
337: @Override public void actionPerformed (ActionEvent ae) {
338: Object source = ae.getSource ();
339: String command = ae.getActionCommand ();
340: switch (command) {
341: case "Seamless mouse":
342: musSetSeamlessOn (((JCheckBoxMenuItem) source).isSelected ());
343: break;
344: case "Follow scroll":
345: musFollowScrollOn = ((JCheckBoxMenuItem) source).isSelected ();
346: break;
347: case "Ctrl-key + left-button = right-button":
348: musCtrlRightOn = ((JCheckBoxMenuItem) source).isSelected ();
349: break;
350: case "Edge acceleration":
351: musSetEdgeAccelerationOn (((JCheckBoxMenuItem) source).isSelected ());
352: break;
353: case "Use host's pixel units":
354: musSetHostsPixelUnitsOn (((JCheckBoxMenuItem) source).isSelected ());
355: break;
356: default:
357: System.out.println ("unknown action command " + command);
358: }
359: }
360: };
361:
362: musSeamlessMouseCheckBox =
363: ComponentFactory.setEnabled (
364: Multilingual.mlnText (
365: ComponentFactory.createCheckBoxMenuItem (musSeamlessOn, "Seamless mouse", listener),
366: "ja", "シームレスマウス"),
367: XEiJ.rbtRobot != null);
368: musFollowScrollCheckBox =
369: ComponentFactory.setEnabled (
370: Multilingual.mlnText (
371: ComponentFactory.createCheckBoxMenuItem (musFollowScrollOn, "Follow scroll", listener),
372: "ja", "スクロールに追従する"),
373: XEiJ.rbtRobot != null);
374:
375: musCtrlRightCheckBox =
376: Multilingual.mlnText (
377: ComponentFactory.createCheckBoxMenuItem (
378: musCtrlRightOn,
379: "Ctrl-key + left-button = right-button",
380: listener),
381: "ja", "Ctrl キー+左ボタン=右ボタン");
382: musEdgeAccelerationCheckBox =
383: Multilingual.mlnText (
384: ComponentFactory.createCheckBoxMenuItem (musEdgeAccelerationOn, "Edge acceleration", listener),
385: "ja", "縁部加速");
386: musMouseCursorSpeedBox =
387: ComponentFactory.createHorizontalBox (
388: Box.createHorizontalGlue (),
389: Multilingual.mlnText (
390: ComponentFactory.createLabel ("Mouse cursor speed "),
391: "ja", "マウスカーソルの速度 "),
392: musSpeedLabel,
393: Box.createHorizontalGlue ()
394: );
395: musHostsPixelUnitsCheckBox =
396: ComponentFactory.setEnabled (
397: Multilingual.mlnText (
398: ComponentFactory.createCheckBoxMenuItem (musHostsPixelUnitsOn, "Use host's pixel units", listener),
399: "ja", "ホストの画素単位を使う"),
400: XEiJ.rbtRobot != null);
401:
402: }
403:
404:
405:
406: public static void musTini () {
407: Settings.sgsPutOnOff ("seamless", musSeamlessOn);
408: Settings.sgsPutOnOff ("followscroll", musFollowScrollOn);
409: Settings.sgsPutOnOff ("ctrlright", musCtrlRightOn);
410: Settings.sgsPutOnOff ("edgeaccel", musEdgeAccelerationOn);
411: Settings.sgsPutOnOff ("hostspixelunits", musHostsPixelUnitsOn);
412: Settings.sgsPutInt ("mousespeed", musSpeedScaleIndex, MUS_SPEED_SCALE_MID);
413: }
414:
415: public static void musSetSpeedScaleIndex (int i) {
416: musSpeedScaleIndex = i;
417: musSpeedLabel.setText (musSpeedTexts[i]);
418: musUpdateSpeedRatio ();
419: }
420:
421: public static void musUpdateSpeedRatio () {
422: double scale = Math.pow (4.0, (double) (musSpeedScaleIndex - MUS_SPEED_SCALE_MID) / (double) MUS_SPEED_SCALE_MID);
423: if (musHostsPixelUnitsOn) {
424:
425:
426: musSpeedRatioX = (int) (65536.0 * scale * (double) XEiJ.pnlScreenWidth / (double) XEiJ.pnlZoomWidth);
427: musSpeedRatioY = (int) (65536.0 * scale * (double) XEiJ.pnlScreenHeight / (double) XEiJ.pnlZoomHeight);
428: } else {
429:
430:
431: musSpeedRatioX = (int) (65536.0 * scale);
432: musSpeedRatioY = (int) (65536.0 * scale);
433: }
434: }
435:
436:
437:
438: public static void musStart () {
439:
440: ComponentFactory.addListener (
441: XEiJ.pnlCanvasOrPanel,
442: new MouseAdapter () {
443: @Override public void mouseClicked (MouseEvent me) {
444: if (musOutputButtonStatus) {
445: int modifiersEx = me.getModifiersEx ();
446: if ((modifiersEx & BUTTON1_DOWN_MASK) != 0) {
447: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
448: 1, musNumberOfButtons, modifiersEx));
449: }
450: if ((modifiersEx & BUTTON2_DOWN_MASK) != 0) {
451: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
452: 2, musNumberOfButtons, modifiersEx));
453: }
454: if ((modifiersEx & BUTTON3_DOWN_MASK) != 0) {
455: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
456: 3, musNumberOfButtons, modifiersEx));
457: }
458: if ((modifiersEx & BUTTON4_DOWN_MASK) != 0) {
459: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
460: 4, musNumberOfButtons, modifiersEx));
461: }
462: if ((modifiersEx & BUTTON5_DOWN_MASK) != 0) {
463: System.out.println (String.format ("mouse button %d/%d was clicked. (0x%08x)",
464: 5, musNumberOfButtons, modifiersEx));
465: }
466: if ((modifiersEx & (BUTTON1_DOWN_MASK |
467: BUTTON2_DOWN_MASK |
468: BUTTON3_DOWN_MASK |
469: BUTTON4_DOWN_MASK |
470: BUTTON5_DOWN_MASK)) == 0) {
471: System.out.println (String.format ("mouse button ?/%d was clicked. (0x%08x)",
472: musNumberOfButtons, modifiersEx));
473: }
474: }
475: if (!XEiJ.pnlCanvasOrPanel.isFocusOwner ()) {
476: XEiJ.pnlCanvasOrPanel.requestFocusInWindow ();
477: }
478: }
479:
480:
481: @Override public void mouseExited (MouseEvent me) {
482: if (musOnScreen) {
483: musOnScreen = false;
484: }
485: if (musOnKeyboard) {
486: musOnKeyboard = false;
487: if (Keyboard.kbdPointedIndex >= 0) {
488: Keyboard.kbdHover (0, 0);
489: }
490: }
491: }
492: @Override public void mousePressed (MouseEvent me) {
493: musPressedOrReleased (me, true);
494: }
495: @Override public void mouseReleased (MouseEvent me) {
496: musPressedOrReleased (me, false);
497: }
498: @Override public void mouseDragged (MouseEvent me) {
499: musDraggedOrMoved (me);
500: }
501: @Override public void mouseMoved (MouseEvent me) {
502: musDraggedOrMoved (me);
503: }
504: @Override public void mouseWheelMoved (MouseWheelEvent mwe) {
505: int modifiersEx = mwe.getModifiersEx ();
506: if (musOutputButtonStatus) {
507: double preciseWheelRotation = mwe.getPreciseWheelRotation ();
508: int scrollAmount = mwe.getScrollAmount ();
509: int scrollType = mwe.getScrollType ();
510: int unitsToScroll = mwe.getUnitsToScroll ();
511: int wheelRotation = mwe.getWheelRotation ();
512: System.out.println (String.format ("mouse wheel moved (0x%08x)", modifiersEx));
513: System.out.println (String.format (" preciseWheelRotation = %f", preciseWheelRotation));
514: System.out.println (String.format (" scrollAmount = %d", scrollAmount));
515: System.out.println (String.format (" scrollType = %d", scrollType));
516: System.out.println (String.format (" unitsToScroll = %d", unitsToScroll));
517: System.out.println (String.format (" wheelRotation = %d", wheelRotation));
518: }
519: int wheelRotation = mwe.getWheelRotation ();
520: if (0 < wheelRotation) {
521: ButtonFunction.bfnExecute (ButtonFunction.Button.WHEELUP, modifiersEx, true, null);
522: } else if (wheelRotation < 0) {
523: ButtonFunction.bfnExecute (ButtonFunction.Button.WHEELDOWN, modifiersEx, true, null);
524: }
525:
526: mwe.consume ();
527: }
528: });
529:
530: }
531:
532:
533:
534: public static void musPressedOrReleased (MouseEvent me, boolean pressed) {
535:
536:
537: int modifiersEx = me.getModifiersEx ();
538: int pressedMask = ~musLastModifiersEx & modifiersEx;
539: int releasedMask = musLastModifiersEx & ~modifiersEx;
540: musLastModifiersEx = modifiersEx;
541: if (musOutputButtonStatus) {
542: if ((pressedMask & BUTTON1_DOWN_MASK) != 0) {
543: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
544: 1, musNumberOfButtons, modifiersEx));
545: } else if ((releasedMask & BUTTON1_DOWN_MASK) != 0) {
546: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
547: 1, musNumberOfButtons, modifiersEx));
548: }
549: if ((pressedMask & BUTTON2_DOWN_MASK) != 0) {
550: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
551: 2, musNumberOfButtons, modifiersEx));
552: } else if ((releasedMask & BUTTON2_DOWN_MASK) != 0) {
553: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
554: 2, musNumberOfButtons, modifiersEx));
555: }
556: if ((pressedMask & BUTTON3_DOWN_MASK) != 0) {
557: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
558: 3, musNumberOfButtons, modifiersEx));
559: } else if ((releasedMask & BUTTON3_DOWN_MASK) != 0) {
560: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
561: 3, musNumberOfButtons, modifiersEx));
562: }
563: if ((pressedMask & BUTTON4_DOWN_MASK) != 0) {
564: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
565: 4, musNumberOfButtons, modifiersEx));
566: } else if ((releasedMask & BUTTON4_DOWN_MASK) != 0) {
567: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
568: 4, musNumberOfButtons, modifiersEx));
569: }
570: if ((pressedMask & BUTTON5_DOWN_MASK) != 0) {
571: System.out.println (String.format ("mouse button %d/%d was pressed. (0x%08x)",
572: 5, musNumberOfButtons, modifiersEx));
573: } else if ((releasedMask & BUTTON5_DOWN_MASK) != 0) {
574: System.out.println (String.format ("mouse button %d/%d was released. (0x%08x)",
575: 5, musNumberOfButtons, modifiersEx));
576: }
577: if (((pressedMask | releasedMask) & (BUTTON1_DOWN_MASK |
578: BUTTON2_DOWN_MASK |
579: BUTTON3_DOWN_MASK |
580: BUTTON4_DOWN_MASK |
581: BUTTON5_DOWN_MASK)) == 0) {
582: System.out.println (String.format ("mouse button ?/%d was %s. (0x%08x)",
583: musNumberOfButtons, pressed ? "pressed" : "released", modifiersEx));
584: }
585: }
586: if (musCtrlRightOn &&
587: (modifiersEx & MouseEvent.CTRL_DOWN_MASK) != 0) {
588: if ((pressedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
589: pressedMask = ((pressedMask & ~MouseEvent.BUTTON1_DOWN_MASK) |
590: MouseEvent.BUTTON3_DOWN_MASK);
591: }
592: if ((releasedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
593: releasedMask = ((releasedMask & ~MouseEvent.BUTTON1_DOWN_MASK) |
594: MouseEvent.BUTTON3_DOWN_MASK);
595: }
596: }
597: if ((pressedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
598: musButtonLeft = true;
599:
600: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
601: musData |= 1;
602: musExtraData |= 1;
603: } else {
604: musData &= ~1;
605: }
606: } else if ((releasedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
607: musButtonLeft = false;
608: musData &= ~1;
609: }
610: if (musNumberOfButtons < 3) {
611: if ((pressedMask & (MouseEvent.BUTTON2_DOWN_MASK |
612: MouseEvent.BUTTON3_DOWN_MASK)) != 0) {
613: if ((modifiersEx & MouseEvent.ALT_DOWN_MASK) != 0) {
614: musSetSeamlessOn (!musSeamlessOn);
615: } else {
616: musButtonRight = true;
617:
618: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
619: musData |= 2;
620: musExtraData |= 2;
621: } else {
622: musData &= ~2;
623: }
624: }
625: } else if ((releasedMask & (MouseEvent.BUTTON2_DOWN_MASK |
626: MouseEvent.BUTTON3_DOWN_MASK)) != 0) {
627: musButtonRight = false;
628: musData &= ~2;
629: }
630: } else {
631: if ((pressedMask & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
632: ButtonFunction.bfnExecute (ButtonFunction.Button.WHEEL, modifiersEx, true, null);
633: } else if ((releasedMask & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
634: ButtonFunction.bfnExecute (ButtonFunction.Button.WHEEL, modifiersEx, false, null);
635: }
636: if ((pressedMask & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
637: musButtonRight = true;
638:
639: if (musOnScreen && (musSeamlessOn || XEiJ.frmIsActive)) {
640: musData |= 2;
641: musExtraData |= 2;
642: } else {
643: musData &= ~2;
644: }
645: } else if ((releasedMask & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
646: musButtonRight = false;
647: musData &= ~2;
648: }
649: if (4 <= musNumberOfButtons) {
650: if ((pressedMask & BUTTON4_DOWN_MASK) != 0) {
651: ButtonFunction.bfnExecute (ButtonFunction.Button.BUTTON4, modifiersEx, true, null);
652: } else if ((releasedMask & BUTTON4_DOWN_MASK) != 0) {
653: ButtonFunction.bfnExecute (ButtonFunction.Button.BUTTON4, modifiersEx, false, null);
654: }
655: if (5 <= musNumberOfButtons) {
656: if ((pressedMask & BUTTON5_DOWN_MASK) != 0) {
657: ButtonFunction.bfnExecute (ButtonFunction.Button.BUTTON5, modifiersEx, true, null);
658: } else if ((releasedMask & BUTTON5_DOWN_MASK) != 0) {
659: ButtonFunction.bfnExecute (ButtonFunction.Button.BUTTON5, modifiersEx, false, null);
660: }
661: }
662: }
663: }
664: musDraggedOrMovedSub (me);
665: if (TextCopy.txcEncloseEachTime && musOnScreen) {
666: if ((pressedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
667: TextCopy.txcMousePressed (musScreenX, musScreenY);
668: } else if ((releasedMask & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
669: TextCopy.txcMouseReleased (musScreenX, musScreenY);
670: }
671: }
672: }
673:
674:
675:
676: public static void musDraggedOrMoved (MouseEvent me) {
677: musDraggedOrMovedSub (me);
678: if (TextCopy.txcEncloseEachTime && musOnScreen) {
679: TextCopy.txcMouseMoved (musScreenX, musScreenY);
680: }
681: }
682: public static void musDraggedOrMovedSub (MouseEvent me) {
683: int x = musPanelX = me.getX ();
684: int y = musPanelY = me.getY ();
685: if (XEiJ.PNL_ROTATION_ON) {
686: if (XEiJ.pnlScreenX1 <= x && x < XEiJ.pnlScreenX2 &&
687: XEiJ.pnlScreenY1 <= y && y < XEiJ.pnlScreenY2) {
688: musOnScreen = true;
689: musScreenX = (int) Math.round (XEiJ.pnlInverseL00 * (double) x + XEiJ.pnlInverseL01 * (double) y + XEiJ.pnlInverseL02);
690: musScreenY = (int) Math.round (XEiJ.pnlInverseL10 * (double) x + XEiJ.pnlInverseL11 * (double) y + XEiJ.pnlInverseL12);
691: } else if (XEiJ.pnlScreenX3 <= x && x < XEiJ.pnlScreenX4 &&
692: XEiJ.pnlScreenY3 <= y && y < XEiJ.pnlScreenY4) {
693: musOnScreen = true;
694: musScreenX = (int) Math.round (XEiJ.pnlInverseR00 * (double) x + XEiJ.pnlInverseR01 * (double) y + XEiJ.pnlInverseR02);
695: musScreenY = (int) Math.round (XEiJ.pnlInverseR10 * (double) x + XEiJ.pnlInverseR11 * (double) y + XEiJ.pnlInverseR12);
696: } else {
697: musOnScreen = false;
698: }
699: } else {
700: if (XEiJ.pnlScreenX1 <= x && x < XEiJ.pnlScreenX1 + XEiJ.pnlZoomWidth &&
701: XEiJ.pnlScreenY1 <= y && y < XEiJ.pnlScreenY1 + XEiJ.pnlZoomHeight) {
702: musOnScreen = true;
703: musScreenX = (x - XEiJ.pnlScreenX1) * XEiJ.pnlZoomRatioInX >> 16;
704: musScreenY = (y - XEiJ.pnlScreenY1) * XEiJ.pnlZoomRatioInY >> 16;
705: if (CRTC.crtDuplication) {
706: musScreenY >>= 1;
707: }
708: } else {
709: musOnScreen = false;
710: }
711: }
712: if (XEiJ.pnlKeyboardX <= x && x < XEiJ.pnlKeyboardX + Keyboard.kbdWidth &&
713: XEiJ.pnlKeyboardY <= y && y < XEiJ.pnlKeyboardY + Keyboard.kbdHeight) {
714: musOnKeyboard = true;
715: Keyboard.kbdHover (x - XEiJ.pnlKeyboardX, y - XEiJ.pnlKeyboardY);
716: } else {
717: if (musOnKeyboard) {
718: musOnKeyboard = false;
719: if (Keyboard.kbdPointedIndex >= 0) {
720: Keyboard.kbdHover (0, 0);
721: }
722: }
723: }
724: }
725:
726:
727:
728: public static void musSetSeamlessOn (boolean on) {
729: if (XEiJ.rbtRobot == null) {
730: return;
731: }
732: if (musSeamlessOn != on) {
733: musSeamlessOn = on;
734: if (on) {
735: musShow ();
736:
737: int x, y;
738: if (XEiJ.currentMPU < Model.MPU_MC68LC040) {
739: if (Z8530.SCC_FSX_MOUSE &&
740: Z8530.sccFSXMouseHook != 0 &&
741: MainMemory.mmrRls (0x0938) == Z8530.sccFSXMouseHook) {
742: int xy = MainMemory.mmrRls (Z8530.sccFSXMouseWork + 0x0a);
743: x = (xy >> 16) - CRTC.crtR10TxXPort;
744: y = (short) xy - CRTC.crtR11TxYPort;
745: } else {
746: int xy = MainMemory.mmrRls (0x0ace);
747: x = xy >> 16;
748: y = (short) xy;
749: if (musFollowScrollOn) {
750: x -= CRTC.crtR10TxXPort;
751: y -= CRTC.crtR11TxYPort;
752: }
753: }
754: } else {
755: if (Z8530.SCC_FSX_MOUSE &&
756: Z8530.sccFSXMouseHook != 0 &&
757: MC68060.mmuPeekLongData (0x0938, 1) == Z8530.sccFSXMouseHook) {
758: int xy = MC68060.mmuPeekLongData (Z8530.sccFSXMouseWork + 0x0a, 1);
759: x = (xy >> 16) - CRTC.crtR10TxXPort;
760: y = (short) xy - CRTC.crtR11TxYPort;
761: } else {
762: int xy = MC68060.mmuPeekLongData (0x0ace, 1);
763: x = xy >> 16;
764: y = (short) xy;
765: if (musFollowScrollOn) {
766: x -= CRTC.crtR10TxXPort;
767: y -= CRTC.crtR11TxYPort;
768: }
769: }
770: }
771: if (XEiJ.PNL_ROTATION_ON) {
772: XEiJ.rbtRobot.mouseMove (XEiJ.pnlGlobalX + (int) Math.round (XEiJ.pnlMatrixL00 * (double) x + XEiJ.pnlMatrixL01 * (double) y + XEiJ.pnlMatrixL02),
773: XEiJ.pnlGlobalY + (int) Math.round (XEiJ.pnlMatrixL10 * (double) x + XEiJ.pnlMatrixL11 * (double) y + XEiJ.pnlMatrixL12));
774: } else {
775: XEiJ.rbtRobot.mouseMove (x * XEiJ.pnlZoomWidth / XEiJ.pnlScreenWidth + XEiJ.pnlScreenX1 + XEiJ.pnlGlobalX,
776: y * XEiJ.pnlZoomHeight / XEiJ.pnlScreenHeight + XEiJ.pnlScreenY1 + XEiJ.pnlGlobalY);
777: }
778: } else {
779: musHide ();
780: Point point = XEiJ.pnlCanvasOrPanel.getLocationOnScreen ();
781: XEiJ.pnlGlobalX = point.x;
782: XEiJ.pnlGlobalY = point.y;
783: musExclusiveStart = true;
784: }
785: }
786: if (musSeamlessMouseCheckBox.isSelected () != on) {
787: musSeamlessMouseCheckBox.setSelected (on);
788: }
789: }
790:
791:
792:
793: public static void musHide () {
794: if (musCursorNumber != 0 && musCursorAvailable) {
795: musCursorNumber = 0;
796: XEiJ.pnlPanel.setCursor (musCursorArray[0]);
797: }
798: }
799:
800:
801:
802: public static void musShow () {
803: if (musCursorNumber != 1 && musCursorAvailable) {
804: musCursorNumber = 1;
805: XEiJ.pnlPanel.setCursor (musCursorArray[1]);
806: }
807: }
808:
809:
810:
811: public static void musSetEdgeAccelerationOn (boolean on) {
812: musEdgeAccelerationOn = on;
813: }
814:
815:
816:
817: public static void musSetHostsPixelUnitsOn (boolean on) {
818: musHostsPixelUnitsOn = on;
819: musUpdateSpeedRatio ();
820: }
821:
822: }