1 /* 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 #ifndef ANDROIDINPUT_H 26 #define ANDROIDINPUT_H 27 28 #include <dlfcn.h> 29 #include <sys/types.h> 30 #include <android/native_window.h> 31 #include "input/LensInput.h" 32 #include <android/keycodes.h> 33 #include <linux/input.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define TRUE 1 40 #define FALSE 0 41 42 #define THROW_RUNTIME_EXCEPTION(ENV, MESSAGE, ...) \ 43 char error_msg[256]; \ 44 sprintf(error_msg, MESSAGE, __VA_ARGS__); \ 45 if (env) { \ 46 (*ENV)->ThrowNew(ENV, \ 47 (*ENV)->FindClass(ENV, "java/lang/RuntimeException"), error_msg); \ 48 } 49 50 #ifdef DEBUG 51 // This method is good for early debug, but is unneeded for general use 52 53 static void *get_check_symbol(JNIEnv *env, void *handle, const char *name) { 54 void *ret = dlsym(handle, name); 55 if (!ret) { 56 THROW_RUNTIME_EXCEPTION(env, "Failed to load symbol %s", name); 57 } 58 return ret; 59 } 60 #define GET_SYMBOL(env, handle,name) get_check_symbol(env, handle,name) 61 62 #else // #ifdef DEBUG 63 64 #define GET_SYMBOL(env, handle,name) dlsym(handle,name) 65 66 #endif 67 68 ANativeWindow *getAndroidNativeWindow(); 69 70 void android_shutdown(); 71 72 const char *android_getDataDir(); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* ANDROIDINPUT_H */