CRobot.m revision 4639
4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. Oracle designates this 4632N/A * particular file as subject to the "Classpath" exception as provided 4632N/A * by Oracle in the LICENSE file that accompanied this code. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4632N/A * or visit www.oracle.com if you need additional information or have any 4632N/A#
import "sun_lwawt_macosx_CRobot.h" 4632N/A// Theoretically, Quarts works with up to 32 buttons. 4639N/A// In OS X, left and right mouse button share the same click count. 4639N/A// That is, if one starts clicking the left button rapidly and then 4639N/A// switches to the right button, then the click count will continue 4639N/A// increasing, without dropping to 1 in between. The middle button, 4639N/A// however, has its own click count. 4639N/A// For robot, we aren't going to emulate all that complexity. All our 4639N/A// synhtetic clicks share the same click count. 4632N/A // Throw a java exception indicating what is wrong. 4632N/A * Class: sun_lwawt_macosx_CRobot 4632N/A // Set things up to let our app act like a synthetic keyboard and mouse. 4632N/A // Always set all states, in case Apple ever changes default behaviors. 4632N/A // Don't block local events after posting ours 4632N/A // Let our event's modifier key state blend with local hardware events 4632N/A // Don't let our events block local hardware events 4632N/A * Class: sun_lwawt_macosx_CRobot 4632N/A // This is the native method called when Robot mouse events occur. 4632N/A // The CRobot tracks the mouse position, and which button was 4632N/A // pressed. If the mouse position is unknown it is obtained from 4632N/A // CGEvents. The peer also tracks the mouse button desired state, 4632N/A // the appropriate key modifier state, and whether the mouse action 4632N/A // is simply a mouse move with no mouse button state changes. 4632N/A // Set unknown mouse location, if needed. 4632N/A // Normalize the coords within this display device, as 4632N/A // volatile, otherwise it warns that it might be clobbered by 'longjmp' 4632N/A // Translate the device relative point into a valid global CGPoint. 4632N/A // When moving, the buttons aren't changed from their current state. 4632N/A // Some of the buttons are changing state. 4632N/A // could be mouse moved or mouse dragged 4632N/A * Class: sun_lwawt_macosx_CRobot 4632N/A * Class: sun_lwawt_macosx_CRobot 4639N/A * a better solution, however, it gives me all kinds of trouble and I have 4639N/A * no idea how to solve them without inserting delays between simulated 4639N/A * events. So, I've ended up disabling it and opted for another approach 4639N/A * that uses Accessibility API instead. 4632N/A * Class: sun_lwawt_macosx_CRobot 4632N/A * Method: nativeGetScreenPixels 4632N/A // get a pointer to the Java int array 4632N/A // create a graphics context around the Java int array 4632N/A // flip, scale, and color correct the screen image into the Java pixels 4632N/A // release the Java int array back up to the JVM 4632N/A/**************************************************** 4632N/A ****************************************************/ 4632N/A// NOTE: Don't modify this table directly. It is machine generated. See below. 4632N/A 127,
// 0 0 VK_UNDEFINED No_Equivalent 4632N/A 127,
// 3 0x3 VK_CANCEL No_Equivalent 4632N/A 57,
// 20 0x14 VK_CAPS_LOCK 4632N/A 127,
// 21 0x15 VK_KANA No_Equivalent 4632N/A 127,
// 24 0x18 VK_FINAL No_Equivalent 4632N/A 127,
// 25 0x19 VK_KANJI No_Equivalent 4632N/A 127,
// 28 0x1c VK_CONVERT No_Equivalent 4632N/A 127,
// 29 0x1d VK_NONCONVERT No_Equivalent 4632N/A 127,
// 30 0x1e VK_ACCEPT No_Equivalent 4632N/A 127,
// 31 0x1f VK_MODECHANGE No_Equivalent 4632N/A 121,
// 34 0x22 VK_PAGE_DOWN 4632N/A 41,
// 59 0x3b VK_SEMICOLON 4632N/A 33,
// 91 0x5b VK_OPEN_BRACKET 4632N/A 42,
// 92 0x5c VK_BACK_SLASH 4632N/A 30,
// 93 0x5d VK_CLOSE_BRACKET 4632N/A 67,
// 106 0x6a VK_MULTIPLY 4632N/A 127,
// 108 0x6c VK_SEPARATER No_Equivalent 4632N/A 78,
// 109 0x6d VK_SUBTRACT 4632N/A 127,
// 128 0x80 VK_DEAD_GRAVE No_Equivalent 4632N/A 127,
// 129 0x81 VK_DEAD_ACUTE No_Equivalent 4632N/A 127,
// 130 0x82 VK_DEAD_CIRCUMFLEX No_Equivalent 4632N/A 127,
// 131 0x83 VK_DEAD_TILDE No_Equivalent 4632N/A 127,
// 132 0x84 VK_DEAD_MACRON No_Equivalent 4632N/A 127,
// 133 0x85 VK_DEAD_BREVE No_Equivalent 4632N/A 127,
// 134 0x86 VK_DEAD_ABOVEDOT No_Equivalent 4632N/A 127,
// 135 0x87 VK_DEAD_DIAERESIS No_Equivalent 4632N/A 127,
// 136 0x88 VK_DEAD_ABOVERING No_Equivalent 4632N/A 127,
// 137 0x89 VK_DEAD_DOUBLEACUTE No_Equivalent 4632N/A 127,
// 138 0x8a VK_DEAD_CARON No_Equivalent 4632N/A 127,
// 139 0x8b VK_DEAD_CEDILLA No_Equivalent 4632N/A 127,
// 140 0x8c VK_DEAD_OGONEK No_Equivalent 4632N/A 127,
// 141 0x8d VK_DEAD_IOTA No_Equivalent 4632N/A 127,
// 142 0x8e VK_DEAD_VOICED_SOUND No_Equivalent 4632N/A 127,
// 143 0x8f VK_DEAD_SEMIVOICED_SOUND No_Equivalent 4632N/A 127,
// 144 0x90 VK_NUM_LOCK No_Equivalent 4632N/A 107,
// 145 0x91 VK_SCROLL_LOCK 4632N/A 127,
// 150 0x96 VK_AMPERSAND No_Equivalent 4632N/A 127,
// 151 0x97 VK_ASTERISK No_Equivalent 4632N/A 127,
// 152 0x98 VK_QUOTEDBL No_Equivalent 4632N/A 127,
// 153 0x99 VK_LESS No_Equivalent 4632N/A 105,
// 154 0x9a VK_PRINTSCREEN 4632N/A 127,
// 155 0x9b VK_INSERT No_Equivalent 4632N/A 127,
// 160 0xa0 VK_GREATER No_Equivalent 4632N/A 127,
// 161 0xa1 VK_BRACELEFT No_Equivalent 4632N/A 127,
// 162 0xa2 VK_BRACERIGHT No_Equivalent 4632N/A 50,
// 192 0xc0 VK_BACK_QUOTE 4632N/A// NOTE: All values above 222 don't have an equivalent on MacOSX. 4639N/A // In OS X, a mouse up has the click count of the last mouse down 4639N/A // if an interval between up and down is within the double click 4639N/A // threshold, and 0 otherwise.