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