/* * mouse.cpp : jni methods in nativemouse.dll * * For instructions on using javah and the C/C++ compiles see: * http://mindprod.com/jgloss/jni.html#COMPILING * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products */ // JNI prototypes generated by javah. #include "mouse.h" #include "windows.h" /** * x:y coordinates as pair of 32-bit ints * or as 64-bit xy, with y in high order, later bits. */ union compactPOINT { jlong xy; struct tagPOINT point; } compactpoint; /** * jni native code to find out where the mouse is on screen. * Class: com_mindprod_mouse_Mouse * Method: jniGetMousePosition * Signature: ()J * * @param env enviroment * @param theclass pointer to Mouse class * @return x:y packaged in a long, with y in high order bits. */ JNIEXPORT jlong JNICALL Java_com_mindprod_mouse_Mouse_jniGetMousePosition (JNIEnv* env, jclass theclass ) { if ( GetCursorPos( &compactpoint.point ) ) { // treat xy pair as a single long. return compactpoint.xy; } else { // failure return -1; } } /* * Class: com_mindprod_mouse_Mouse * Method: getVersion * Signature: ()I */ JNIEXPORT jint JNICALL Java_com_mindprod_mouse_Mouse_getVersion (JNIEnv *, jclass) { return 30; } // not class no so final }