diff --git a/src/java/org/jnativehook/GlobalScreen.java b/src/java/org/jnativehook/GlobalScreen.java
index ce2f3b93..139c1827 100644
--- a/src/java/org/jnativehook/GlobalScreen.java
+++ b/src/java/org/jnativehook/GlobalScreen.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -445,6 +445,24 @@ public final void setEventDispatcher(ExecutorService dispatcher) {
* include unpacking and loading the library into the Java Virtual Machine.
*/
private static void loadNativeLibrary() {
+ System.out.println(
+ "JNativeHook: Global keyboard and mouse hooking for Java.\n" +
+ "Copyright (C) 2006-2014 Alexander Barker. All Rights Received.\n" +
+ "https://github.com/kwhat/libuiohook/\n" +
+ "\n" +
+ "JNativeHook is free software: you can redistribute it and/or modify\n" +
+ "it under the terms of the GNU Lesser General Public License as published\n" +
+ "by the Free Software Foundation, either version 3 of the License, or\n" +
+ "(at your option) any later version.\n" +
+ "\n" +
+ "JNativeHook is distributed in the hope that it will be useful,\n" +
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +
+ "GNU General Public License for more details.\n" +
+ "\n" +
+ "You should have received a copy of the GNU Lesser General Public License\n" +
+ "along with this program. If not, see .\n");
+
String libName = "JNativeHook";
try {
diff --git a/src/java/org/jnativehook/NativeHookException.java b/src/java/org/jnativehook/NativeHookException.java
index 6dfb61e5..3c66c5bf 100644
--- a/src/java/org/jnativehook/NativeHookException.java
+++ b/src/java/org/jnativehook/NativeHookException.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/NativeInputEvent.java b/src/java/org/jnativehook/NativeInputEvent.java
index 2d85ec12..90c56352 100644
--- a/src/java/org/jnativehook/NativeInputEvent.java
+++ b/src/java/org/jnativehook/NativeInputEvent.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/NativeSystem.java b/src/java/org/jnativehook/NativeSystem.java
index b4b9323d..882bb3ba 100644
--- a/src/java/org/jnativehook/NativeSystem.java
+++ b/src/java/org/jnativehook/NativeSystem.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/example/NativeHookDemo.java b/src/java/org/jnativehook/example/NativeHookDemo.java
index e1b708e0..b19d26fa 100644
--- a/src/java/org/jnativehook/example/NativeHookDemo.java
+++ b/src/java/org/jnativehook/example/NativeHookDemo.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/keyboard/NativeKeyEvent.java b/src/java/org/jnativehook/keyboard/NativeKeyEvent.java
index c590517e..58a3311e 100644
--- a/src/java/org/jnativehook/keyboard/NativeKeyEvent.java
+++ b/src/java/org/jnativehook/keyboard/NativeKeyEvent.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/keyboard/NativeKeyListener.java b/src/java/org/jnativehook/keyboard/NativeKeyListener.java
index e7c87ab9..23e1adf5 100644
--- a/src/java/org/jnativehook/keyboard/NativeKeyListener.java
+++ b/src/java/org/jnativehook/keyboard/NativeKeyListener.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -18,9 +18,10 @@
package org.jnativehook.keyboard;
//Imports
-import java.util.EventListener;
import org.jnativehook.GlobalScreen;
+import java.util.EventListener;
+
/**
* The listener interface for receiving global NativeKeyEvents
.
*
diff --git a/src/java/org/jnativehook/mouse/NativeMouseEvent.java b/src/java/org/jnativehook/mouse/NativeMouseEvent.java
index a0966711..1bd076e8 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseEvent.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseEvent.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -18,10 +18,11 @@
package org.jnativehook.mouse;
//Imports
-import java.awt.Point;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeInputEvent;
+import java.awt.*;
+
/**
* An event which indicates that a mouse action occurred on the system.
* This event is not limited to a particular component's scope or visibility.
diff --git a/src/java/org/jnativehook/mouse/NativeMouseInputListener.java b/src/java/org/jnativehook/mouse/NativeMouseInputListener.java
index 9c3bfa2a..c655bfbb 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseInputListener.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseInputListener.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/mouse/NativeMouseListener.java b/src/java/org/jnativehook/mouse/NativeMouseListener.java
index 8e9d8f3f..7fa54fb2 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseListener.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseListener.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -18,9 +18,10 @@
package org.jnativehook.mouse;
//Imports
-import java.util.EventListener;
import org.jnativehook.GlobalScreen;
+import java.util.EventListener;
+
/**
* The listener interface for receiving systemwide NativeMouseEvents
.
* (To track native mouse moves, use the NativeMouseMotionListener
.)
diff --git a/src/java/org/jnativehook/mouse/NativeMouseMotionListener.java b/src/java/org/jnativehook/mouse/NativeMouseMotionListener.java
index 5198e143..058b0964 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseMotionListener.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseMotionListener.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -18,9 +18,10 @@
package org.jnativehook.mouse;
//Imports
-import java.util.EventListener;
import org.jnativehook.GlobalScreen;
+import java.util.EventListener;
+
/**
* The listener interface for receiving native mouse motion events.
* (For clicks and other mouse events, use the NativeMouseListener
.)
diff --git a/src/java/org/jnativehook/mouse/NativeMouseWheelEvent.java b/src/java/org/jnativehook/mouse/NativeMouseWheelEvent.java
index 2d2952ef..284f9a2c 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseWheelEvent.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseWheelEvent.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/java/org/jnativehook/mouse/NativeMouseWheelListener.java b/src/java/org/jnativehook/mouse/NativeMouseWheelListener.java
index c40d0914..1ea2acce 100644
--- a/src/java/org/jnativehook/mouse/NativeMouseWheelListener.java
+++ b/src/java/org/jnativehook/mouse/NativeMouseWheelListener.java
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -18,9 +18,10 @@
package org.jnativehook.mouse;
//Imports
-import java.util.EventListener;
import org.jnativehook.GlobalScreen;
+import java.util.EventListener;
+
/**
* The listener interface for receiving native mouse wheel events.
* (For clicks and other mouse events, use the NativeMouseListener
.)
diff --git a/src/jni/include/org_jnativehook_NativeInputEvent.h b/src/jni/include/org_jnativehook_NativeInputEvent.h
index 3c388d5a..1590cb03 100644
--- a/src/jni/include/org_jnativehook_NativeInputEvent.h
+++ b/src/jni/include/org_jnativehook_NativeInputEvent.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/include/org_jnativehook_keyboard_NativeKeyEvent.h b/src/jni/include/org_jnativehook_keyboard_NativeKeyEvent.h
index a858d260..b7317e84 100644
--- a/src/jni/include/org_jnativehook_keyboard_NativeKeyEvent.h
+++ b/src/jni/include/org_jnativehook_keyboard_NativeKeyEvent.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/include/org_jnativehook_mouse_NativeMouseEvent.h b/src/jni/include/org_jnativehook_mouse_NativeMouseEvent.h
index 21ad8a4e..20245743 100644
--- a/src/jni/include/org_jnativehook_mouse_NativeMouseEvent.h
+++ b/src/jni/include/org_jnativehook_mouse_NativeMouseEvent.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/include/org_jnativehook_mouse_NativeMouseWheelEvent.h b/src/jni/include/org_jnativehook_mouse_NativeMouseWheelEvent.h
index b283b84c..47ee923f 100644
--- a/src/jni/include/org_jnativehook_mouse_NativeMouseWheelEvent.h
+++ b/src/jni/include/org_jnativehook_mouse_NativeMouseWheelEvent.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Converter.c b/src/jni/jni_Converter.c
index 258cba59..ce12e91c 100644
--- a/src/jni/jni_Converter.c
+++ b/src/jni/jni_Converter.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Converter.h b/src/jni/jni_Converter.h
index 5a8cbc15..82cdd6a2 100644
--- a/src/jni/jni_Converter.h
+++ b/src/jni/jni_Converter.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Errors.c b/src/jni/jni_Errors.c
index 28d2b9de..63c2943c 100644
--- a/src/jni/jni_Errors.c
+++ b/src/jni/jni_Errors.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Errors.h b/src/jni/jni_Errors.h
index 5d33be34..78e9cf11 100644
--- a/src/jni/jni_Errors.h
+++ b/src/jni/jni_Errors.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_EventDispatcher.c b/src/jni/jni_EventDispatcher.c
index 31677206..5f49e37a 100644
--- a/src/jni/jni_EventDispatcher.c
+++ b/src/jni/jni_EventDispatcher.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include "jni_Converter.h"
#include "jni_Globals.h"
+#include "jni_Logger.h"
#include "org_jnativehook_NativeInputEvent.h"
#include "org_jnativehook_keyboard_NativeKeyEvent.h"
#include "org_jnativehook_mouse_NativeMouseEvent.h"
@@ -197,16 +198,14 @@ void jni_EventDispatcher(virtual_event * const event) {
else {
// FIXME an exception should be thrown!
- #ifdef DEBUG
- fprintf(stderr, "jni_EventDispatcher(): Failed to acquire GlobalScreen singleton!\n");
- #endif
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire GlobalScreen singleton!\n",
+ __FUNCTION__, __LINE__);
}
}
else {
// FIXME an exception should be thrown!
- #ifdef DEBUG
- fprintf(stderr, "jni_EventDispatcher(): AttachCurrentThread() failed!\n");
- #endif
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: AttachCurrentThread() failed!\n",
+ __FUNCTION__, __LINE__);
}
}
diff --git a/src/jni/jni_EventDispathcer.h b/src/jni/jni_EventDispathcer.h
index 9ebaf379..631c038e 100644
--- a/src/jni/jni_EventDispathcer.h
+++ b/src/jni/jni_EventDispathcer.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Globals.c b/src/jni/jni_Globals.c
index a769be61..e338945a 100644
--- a/src/jni/jni_Globals.c
+++ b/src/jni/jni_Globals.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -16,15 +16,12 @@
* along with this program. If not, see .
*/
-#ifdef DEBUG
-#include
-#endif
-
#include
#include
#include "jni_Errors.h"
#include "jni_Globals.h"
+#include "jni_Logger.h"
GlobalScreen *org_jnativehook_GlobalScreen = NULL;
NativeInputEvent *org_jnativehook_NativeInputEvent = NULL;
@@ -67,12 +64,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"getInstance",
"()Lorg/jnativehook/GlobalScreen;");
- #ifdef DEBUG
if (org_jnativehook_GlobalScreen->getInstance == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for GlobalScreen.getInstance()Lorg/jnativehook/GlobalScreen;!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for GlobalScreen.getInstance()Lorg/jnativehook/GlobalScreen;!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for GlobalScreen.dispatchEvent().
@@ -82,19 +77,15 @@ int jni_CreateGlobals(JNIEnv *env) {
"dispatchEvent",
"(Lorg/jnativehook/NativeInputEvent;)V");
- #ifdef DEBUG
if (org_jnativehook_GlobalScreen->dispatchEvent == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for GlobalScreen.dispatchEvent(Lorg/jnativehook/NativeInputEvent;)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for GlobalScreen.dispatchEvent(Lorg/jnativehook/NativeInputEvent;)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the GlobalScreen class!\n",
- __FUNCTION__, __LINE__);
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the GlobalScreen class!\n",
+ __FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the NativeInputEvent Object.
@@ -109,12 +100,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"reserved",
"S");
- #ifdef DEBUG
if (org_jnativehook_NativeInputEvent->reserved == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the field ID for NativeInputEvent.reserved S!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the field ID for NativeInputEvent.reserved S!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for NativeInputEvent constructor.
@@ -124,12 +113,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"",
"(Lorg/jnativehook/GlobalScreen;IJI)V");
- #ifdef DEBUG
if (org_jnativehook_NativeInputEvent->init == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.(Lorg.jnativehook.GlobalScreen;IJI)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.(Lorg.jnativehook.GlobalScreen;IJI)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for NativeInputEvent.getID().
@@ -139,12 +126,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"getID",
"()I");
- #ifdef DEBUG
if (org_jnativehook_NativeInputEvent->getID == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.getID()I!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.getID()I!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for NativeInputEvent.getModifiers().
@@ -154,19 +139,15 @@ int jni_CreateGlobals(JNIEnv *env) {
"getModifiers",
"()I");
- #ifdef DEBUG
if (org_jnativehook_NativeInputEvent->getModifiers == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.getModifiers()I!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeInputEvent.getModifiers()I!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the NativeInputEvent class!\n",
- __FUNCTION__, __LINE__);
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the NativeInputEvent class!\n",
+ __FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the NativeKeyEvent Object.
@@ -184,13 +165,11 @@ int jni_CreateGlobals(JNIEnv *env) {
"",
"(IJIIICI)V");
- #ifdef DEBUG
if (org_jnativehook_keyboard_NativeKeyEvent->init == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.(IJIIICI)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.(IJIIICI)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
-
+
// Get the method ID for NativeKeyEvent.getKeyCode().
org_jnativehook_keyboard_NativeKeyEvent->getKeyCode = (*env)->GetMethodID(
@@ -199,12 +178,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"getKeyCode",
"()I");
- #ifdef DEBUG
if (org_jnativehook_keyboard_NativeKeyEvent->getKeyCode == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyCode()!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyCode()!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for NativeKeyEvent.getKeyLocation().
@@ -214,12 +191,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"getKeyLocation",
"()I");
- #ifdef DEBUG
if (org_jnativehook_keyboard_NativeKeyEvent->getKeyLocation == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyLocation()!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyLocation()!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for NativeKeyEvent.getKeyChar().
@@ -229,19 +204,15 @@ int jni_CreateGlobals(JNIEnv *env) {
"getKeyChar",
"()C");
- #ifdef DEBUG
if (org_jnativehook_keyboard_NativeKeyEvent->getKeyChar == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyChar()!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyChar()!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the NativeKeyEvent class!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the NativeKeyEvent class!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the NativeMouseEvent Object.
@@ -259,19 +230,28 @@ int jni_CreateGlobals(JNIEnv *env) {
"",
"(IJIIIII)V");
- #ifdef DEBUG
if (org_jnativehook_mouse_NativeMouseEvent->init == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeMouseEvent.(IJIIIII)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeMouseEvent.(IJIIIII)V!\n",
+ __FUNCTION__, __LINE__);
+ }
+
+
+ // Get the method ID for NativeKeyEvent.getKeyCode().
+ org_jnativehook_mouse_NativeMouseEvent->getButton = (*env)->GetMethodID(
+ env,
+ org_jnativehook_mouse_NativeMouseEvent->cls,
+ "getButton",
+ "()I");
+
+ if (org_jnativehook_keyboard_NativeKeyEvent->getKeyCode == NULL) {
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeKeyEvent.getKeyCode()!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the NativeMouseEvent class!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the NativeMouseEvent class!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the NativeMouseWheelEvent Object.
@@ -289,19 +269,15 @@ int jni_CreateGlobals(JNIEnv *env) {
"",
"(IJIIIIIII)V");
- #ifdef DEBUG
if (org_jnativehook_mouse_NativeMouseWheelEvent->init == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for NativeMouseEvent.(IJIIIIIII)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for NativeMouseEvent.(IJIIIIIII)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the NativeMouseWheelEvent class!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the NativeMouseWheelEvent class!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the Logger Object.
@@ -316,12 +292,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
- #ifdef DEBUG
if (java_lang_System->setProperty == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for System.setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for System.setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Get the method ID for System.setProperty().
@@ -331,19 +305,15 @@ int jni_CreateGlobals(JNIEnv *env) {
"clearProperty",
"(Ljava/lang/String;)Ljava/lang/String;");
- #ifdef DEBUG
if (java_lang_System->clearProperty == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for System.clearProperty(Ljava/lang/String;)Ljava/lang/String;!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for System.clearProperty(Ljava/lang/String;)Ljava/lang/String;!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the System class!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the System class!\n",
__FUNCTION__, __LINE__);
}
- #endif
// Class and Constructor for the Logger Object.
@@ -358,13 +328,11 @@ int jni_CreateGlobals(JNIEnv *env) {
"getLogger",
"(Ljava/lang/String;)Ljava/util/logging/Logger;");
- #ifdef DEBUG
if (java_util_logging_Logger->getLogger == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for Logger.getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for Logger.getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;!\n",
__FUNCTION__, __LINE__);
}
- #endif
-
+
java_util_logging_Logger->fine = (*env)->GetMethodID(
env,
@@ -372,12 +340,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"fine",
"(Ljava/lang/String;)V");
- #ifdef DEBUG
if (java_util_logging_Logger->fine == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for Logger.fine(Ljava/lang/String;)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for Logger.fine(Ljava/lang/String;)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
java_util_logging_Logger->info = (*env)->GetMethodID(
env,
@@ -385,12 +351,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"info",
"(Ljava/lang/String;)V");
- #ifdef DEBUG
if (java_util_logging_Logger->info == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for Logger.info(Ljava/lang/String;)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for Logger.info(Ljava/lang/String;)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
java_util_logging_Logger->warning = (*env)->GetMethodID(
env,
@@ -398,12 +362,10 @@ int jni_CreateGlobals(JNIEnv *env) {
"warning",
"(Ljava/lang/String;)V");
- #ifdef DEBUG
if (java_util_logging_Logger->warning == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for Logger.warning(Ljava/lang/String;)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for Logger.warning(Ljava/lang/String;)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
java_util_logging_Logger->severe = (*env)->GetMethodID(
env,
@@ -411,29 +373,23 @@ int jni_CreateGlobals(JNIEnv *env) {
"severe",
"(Ljava/lang/String;)V");
- #ifdef DEBUG
if (java_util_logging_Logger->severe == NULL) {
- fprintf(stderr, "%s [%u]: Failed to acquire the method ID for Logger.severe(Ljava/lang/String;)V!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to acquire the method ID for Logger.severe(Ljava/lang/String;)V!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to locate the Logger class!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to locate the Logger class!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
else {
status = JNI_ENOMEM;
- #ifdef DEBUG
- fprintf(stderr, "%s [%u]: Failed to allocate memory for JNI structures!\n",
+ jni_Logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to allocate memory for JNI structures!\n",
__FUNCTION__, __LINE__);
- #endif
- // FIXME Throw java.lang.OutOfMemoryError ?
+ // FIXME Throw java.lang.OutOfMemoryError
}
// Check and make sure everything is correct.
diff --git a/src/jni/jni_Globals.h b/src/jni/jni_Globals.h
index 6b904ce2..6ef775d5 100644
--- a/src/jni/jni_Globals.h
+++ b/src/jni/jni_Globals.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -60,6 +60,7 @@ typedef struct _org_jnativehook_mouse_NativeMouseEvent {
jclass cls;
jmethodID init;
NativeInputEvent *parent;
+ jmethodID getButton;
} NativeMouseEvent;
typedef struct _org_jnativehook_mouse_NativeMouseWheelEvent {
diff --git a/src/jni/jni_Load.c b/src/jni/jni_Load.c
index 9cc0f995..e15f9566 100644
--- a/src/jni/jni_Load.c
+++ b/src/jni/jni_Load.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -25,54 +25,23 @@
#include "jni_Logger.h"
#include "jni_Properties.h"
-#ifdef USE_QUIET
-#define COPYRIGHT() (void) 0;
-#else
-#include
-#define COPYRIGHT() fprintf(stdout, \
- "JNativeHook: Global keyboard and mouse hooking for Java.\n" \
- "Copyright (C) 2006-2014 Alexander Barker. All Rights Received.\n" \
- "https://github.com/kwhat/libuiohook/\n" \
- "\n" \
- "JNativeHook is free software: you can redistribute it and/or modify\n" \
- "it under the terms of the GNU Lesser General Public License as published\n" \
- "by the Free Software Foundation, either version 3 of the License, or\n" \
- "(at your option) any later version.\n" \
- "\n" \
- "JNativeHook is distributed in the hope that it will be useful,\n" \
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
- "GNU General Public License for more details.\n" \
- "\n" \
- "You should have received a copy of the GNU Lesser General Public License\n" \
- "along with this program. If not, see .\n\n");
-#endif
-
// JNI Related global references.
JavaVM *jvm;
jint jni_version = JNI_VERSION_1_4;
// JNI entry point, This is executed when the Java virtual machine attaches to the native library.
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
- // Display the copyright on library load.
- COPYRIGHT();
-
/* Grab the currently running virtual machine so we can attach to it in
* functions that are not called from java.
*/
jvm = vm;
JNIEnv *env = NULL;
if ((*jvm)->GetEnv(jvm, (void **)(&env), jni_version) == JNI_OK) {
- #ifdef DEBUG
- fprintf(stdout, "%s [%u]: GetEnv() successful.\n",
- __FUNCTION__, __LINE__);
- #endif
-
// Create all the global class references onload to prevent class loader
// issues with JNLP and some IDE's.
// FIXME Change to take jvm, not env!
if (jni_CreateGlobals(env) != JNI_OK) {
- #ifdef DEBUG
+ #ifndef QUIET
fprintf(stderr, "%s [%u]: CreateJNIGlobals() failed!\n",
__FUNCTION__, __LINE__);
#endif
@@ -80,28 +49,26 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
ThrowFatalError("Failed to locate one or more required classes.");
}
- // Set java properties from native sources.
- jni_SetProperties(env);
-
// Set Java logger for native code messages.
hook_set_logger_proc(&jni_Logger);
+ // Set java properties from native sources.
+ jni_SetProperties(env);
+
// Set the hook callback function to dispatch events.
hook_set_dispatch_proc(&jni_EventDispatcher);
}
else {
- #ifdef DEBUG
- fprintf(stderr, "%s [%u]: GetEnv() failed!\n",
+ #ifndef USE_QUIET
+ fprintf(stderr, "%s [%u]: GetEnv() failed!\n",
__FUNCTION__, __LINE__);
#endif
- ThrowFatalError("Failed to aquire JNI interface pointer");
+ ThrowFatalError("Failed to acquire JNI interface pointer");
}
- #ifdef DEBUG
- fprintf(stdout, "%s [%u]: JNI Loaded.\n",
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: JNI Loaded.\n",
__FUNCTION__, __LINE__);
- #endif
return jni_version;
}
@@ -116,18 +83,18 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
// FIXME Change to take jvm, not env!
jni_ClearProperties(env);
}
- #ifdef DEBUG
else {
// It is not critical that these values are cleared so no exception
// will be thrown.
- fprintf(stdout, "%s [%u]: GetEnv() failed!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to call jni_ClearProperties()!\n",
__FUNCTION__, __LINE__);
}
- #endif
- jni_DestroyGlobals(env);
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: JNI Unloaded.\n",
+ __FUNCTION__, __LINE__);
- #ifdef DEBUG
- fprintf(stdout, "JNI_OnUnload(): JNI Unloaded.\n");
- #endif
+ // FIXME Change to take jvm, not env!
+ if (env != NULL) {
+ jni_DestroyGlobals(env);
+ }
}
diff --git a/src/jni/jni_Logger.c b/src/jni/jni_Logger.c
index 9caa761b..a9076c3c 100644
--- a/src/jni/jni_Logger.c
+++ b/src/jni/jni_Logger.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/jni_Logger.h b/src/jni/jni_Logger.h
index 5073bbb9..02eae8ce 100644
--- a/src/jni/jni_Logger.h
+++ b/src/jni/jni_Logger.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -19,6 +19,9 @@
#ifndef _Included_jni_Logger_h
#define _Included_jni_Logger_h
+#include
+#include
+
extern bool jni_Logger(unsigned int level, const char *format, ...);
#endif
diff --git a/src/jni/jni_Properties.c b/src/jni/jni_Properties.c
index a69a541b..d9258914 100644
--- a/src/jni/jni_Properties.c
+++ b/src/jni/jni_Properties.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -20,6 +20,7 @@
#include
#include "jni_Globals.h"
+#include "jni_Logger.h"
void jni_SetProperties(JNIEnv *env) {
// Create a buffer for converting numbers to strings.
@@ -28,6 +29,9 @@ void jni_SetProperties(JNIEnv *env) {
// Set the native keyboard auto repeat rate.
long rate = hook_get_auto_repeat_rate();
if (rate >= 0) {
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_auto_repeat_rate(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, rate);
+
if (snprintf(buffer, sizeof(buffer), "%li", rate) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.autoRepeatRate");
jstring value = (*env)->NewStringUTF(env, buffer);
@@ -42,23 +46,22 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert auto repeat rate to string!\n",
- __FUNCTION__, __LINE__);
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert auto repeat rate to string!\n",
+ __FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_auto_repeat_rate()!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_auto_repeat_rate()!\n",
__FUNCTION__, __LINE__);
}
- #endif
long delay = hook_get_auto_repeat_delay();
if (delay >= 0) {
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_auto_repeat_delay(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, delay);
+
if (snprintf(buffer, sizeof(buffer), "%li", delay) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.autoRepeatDelay");
jstring value = (*env)->NewStringUTF(env, buffer);
@@ -73,24 +76,23 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert auto repeat delay to string!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert auto repeat delay to string!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_auto_repeat_delay()!\n",
- __FUNCTION__, __LINE__);
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_auto_repeat_delay()!\n",
+ __FUNCTION__, __LINE__);
}
- #endif
// 0-Threshold X, 1-Threshold Y and 2-Speed.
long multiplier = hook_get_pointer_acceleration_multiplier();
if (multiplier >= 0) {
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_pointer_acceleration_multiplier(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, multiplier);
+
if (snprintf(buffer, sizeof(buffer), "%li", multiplier) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.pointerAccelerationMultiplier");
jstring value = (*env)->NewStringUTF(env, buffer);
@@ -105,24 +107,23 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert pointer acceleration multiplier to string!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert pointer acceleration multiplier to string!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_pointer_acceleration_multiplier()!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_pointer_acceleration_multiplier()!\n",
__FUNCTION__, __LINE__);
}
- #endif
// 0-Threshold X, 1-Threshold Y and 2-Speed.
long threshold = hook_get_pointer_acceleration_threshold();
if (threshold >= 0) {
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_pointer_acceleration_threshold(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, threshold);
+
if (snprintf(buffer, sizeof(buffer), "%li", threshold) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.pointerAccelerationThreshold");
jstring value = (*env)->NewStringUTF(env, buffer);
@@ -137,23 +138,22 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert pointer acceleration threshold to string!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert pointer acceleration threshold to string!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_pointer_acceleration_threshold()!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_pointer_acceleration_threshold()!\n",
__FUNCTION__, __LINE__);
}
- #endif
long sensitivity = hook_get_pointer_sensitivity();
if (sensitivity >= 0) {
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_pointer_sensitivity(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, sensitivity);
+
if (snprintf(buffer, sizeof(buffer), "%li", sensitivity) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.pointerSensitivity");
jstring value = (*env)->NewStringUTF(env, buffer);
@@ -168,26 +168,21 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert pointer sensitivity to string!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert pointer sensitivity to string!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_pointer_sensitivity()!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_pointer_sensitivity()!\n",
__FUNCTION__, __LINE__);
}
- #endif
long clicktime = hook_get_multi_click_time();
if (clicktime >= 0) {
- #ifdef DEBUG
- fprintf(stdout, "GetMultiClickTime(): successful. (time: %li)\n", clicktime);
- #endif
+ jni_Logger(LOG_LEVEL_DEBUG, "%s [%u]: hook_get_multi_click_time(): successful. (%li)\n",
+ __FUNCTION__, __LINE__, clicktime);
if (snprintf(buffer, sizeof(buffer), "%li", clicktime) >= 0) {
jstring name = (*env)->NewStringUTF(env, "jnativehook.multiClickInterval");
@@ -203,19 +198,15 @@ void jni_SetProperties(JNIEnv *env) {
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, value);
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Failed to convert multi click time to string!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Failed to convert multi click time to string!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
- #ifdef DEBUG
else {
- fprintf(stderr, "%s [%u]: Invalid result returned from hook_get_multi_click_time()!\n",
+ jni_Logger(LOG_LEVEL_WARN, "%s [%u]: Invalid result returned from hook_get_multi_click_time()!\n",
__FUNCTION__, __LINE__);
}
- #endif
}
diff --git a/src/jni/jni_Properties.h b/src/jni/jni_Properties.h
index 304d71d5..3d8e62a2 100644
--- a/src/jni/jni_Properties.h
+++ b/src/jni/jni_Properties.h
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
diff --git a/src/jni/org_jnativehook_GlobalScreen.c b/src/jni/org_jnativehook_GlobalScreen.c
index a727e3df..7933877c 100644
--- a/src/jni/org_jnativehook_GlobalScreen.c
+++ b/src/jni/org_jnativehook_GlobalScreen.c
@@ -1,5 +1,5 @@
/* JNativeHook: Global keyboard and mouse hooking for Java.
- * Copyright (C) 2006-2013 Alexander Barker. All Rights Received.
+ * Copyright (C) 2006-2014 Alexander Barker. All Rights Received.
* http://code.google.com/p/jnativehook/
*
* JNativeHook is free software: you can redistribute it and/or modify
@@ -58,7 +58,6 @@ JNIEXPORT jboolean JNICALL Java_org_jnativehook_GlobalScreen_isNativeHookRegiste
JNIEXPORT void JNICALL Java_org_jnativehook_GlobalScreen_postNativeEvent(JNIEnv *env, jclass cls, jobject event) {
// Convert the event type.
- unsigned int nativeType;
jint javaType = (*env)->CallIntMethod(env, event, org_jnativehook_NativeInputEvent->getID);
// Allocate memory for the virtual event and set the type.
@@ -80,14 +79,16 @@ JNIEXPORT void JNICALL Java_org_jnativehook_GlobalScreen_postNativeEvent(JNIEnv
(*env)->CallIntMethod(env, event, org_jnativehook_keyboard_NativeKeyEvent->getKeyCode);
break;
- // FIXME Implement!
case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_CLICKED:
case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_PRESSED:
case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_RELEASED:
- case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_MOVED:
+ virtualEvent->data.mouse.button =
+ (*env)->CallIntMethod(env, event, org_jnativehook_mouse_NativeMouseEvent->getButton);
+ break;
+ // FIXME Implement!
+ case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_MOVED:
case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_DRAGGED:
-
case org_jnativehook_mouse_NativeMouseEvent_NATIVE_MOUSE_WHEEL:
default: