From 564039900d0ac1a0ee985dcf163bf9ac02a669ae Mon Sep 17 00:00:00 2001 From: HON95 Date: Mon, 22 Jun 2015 03:54:47 +0200 Subject: [PATCH] v1.0.0 Initial release --- .gitignore | 30 ++ JLAW back/JLAW back.sln | 28 ++ JLAW back/JLAW back/JLAW back.vcxproj | 178 ++++++++ JLAW back/JLAW back/JLAW back.vcxproj.filters | 63 +++ JLAW back/JLAW back/JlawArxControl.cpp | 145 +++++++ JLAW back/JLAW back/JlawArxControl.h | 144 +++++++ JLAW back/JLAW back/JlawGkey.cpp | 86 ++++ JLAW back/JLAW back/JlawGkey.h | 86 ++++ JLAW back/JLAW back/JlawLcd.cpp | 78 ++++ JLAW back/JLAW back/JlawLcd.h | 135 ++++++ JLAW back/JLAW back/JlawLed.cpp | 111 +++++ JLAW back/JLAW back/JlawLed.h | 162 +++++++ JLAW back/JLAW back/JlawUtil.cpp | 28 ++ JLAW back/JLAW back/JlawUtil.h | 11 + JLAW back/JLAW back/LogitechGArxControlLib.h | 84 ++++ JLAW back/JLAW back/LogitechGkeyLib.h | 60 +++ JLAW back/JLAW back/LogitechLCDLib.h | 47 ++ JLAW back/JLAW back/LogitechLEDLib.h | 159 +++++++ JLAW front/pom.xml | 45 ++ .../java/ninja/hon95/jlaw/JlawArxControl.java | 390 +++++++++++++++++ .../main/java/ninja/hon95/jlaw/JlawGkey.java | 126 ++++++ .../main/java/ninja/hon95/jlaw/JlawLcd.java | 305 +++++++++++++ .../main/java/ninja/hon95/jlaw/JlawLed.java | 403 ++++++++++++++++++ .../main/java/ninja/hon95/jlaw/JlawUtil.java | 97 +++++ JLAW front/src/main/resources/LICENSE.txt | 21 + JLAW test/pom.xml | 146 +++++++ .../java/ninja/hon95/jlawtest/LogMessage.java | 25 ++ .../main/java/ninja/hon95/jlawtest/Main.java | 85 ++++ .../java/ninja/hon95/jlawtest/Tester.java | 259 +++++++++++ .../ninja/hon95/jlawtest/WindowBuilder.java | 392 +++++++++++++++++ JLAW test/src/main/resources/LICENSE.txt | 21 + .../src/main/resources/icons/application.ico | Bin 0 -> 92147 bytes .../main/resources/icons/application_128.png | Bin 0 -> 1051 bytes .../main/resources/icons/application_16.png | Bin 0 -> 233 bytes .../main/resources/icons/application_256.png | Bin 0 -> 2509 bytes .../main/resources/icons/application_32.png | Bin 0 -> 298 bytes .../main/resources/icons/application_64.png | Bin 0 -> 557 bytes LICENSE.txt | 21 + README.md | 46 +- extract_dlls.bat | 3 + make_headers.bat | 5 + 41 files changed, 4024 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 JLAW back/JLAW back.sln create mode 100644 JLAW back/JLAW back/JLAW back.vcxproj create mode 100644 JLAW back/JLAW back/JLAW back.vcxproj.filters create mode 100644 JLAW back/JLAW back/JlawArxControl.cpp create mode 100644 JLAW back/JLAW back/JlawArxControl.h create mode 100644 JLAW back/JLAW back/JlawGkey.cpp create mode 100644 JLAW back/JLAW back/JlawGkey.h create mode 100644 JLAW back/JLAW back/JlawLcd.cpp create mode 100644 JLAW back/JLAW back/JlawLcd.h create mode 100644 JLAW back/JLAW back/JlawLed.cpp create mode 100644 JLAW back/JLAW back/JlawLed.h create mode 100644 JLAW back/JLAW back/JlawUtil.cpp create mode 100644 JLAW back/JLAW back/JlawUtil.h create mode 100644 JLAW back/JLAW back/LogitechGArxControlLib.h create mode 100644 JLAW back/JLAW back/LogitechGkeyLib.h create mode 100644 JLAW back/JLAW back/LogitechLCDLib.h create mode 100644 JLAW back/JLAW back/LogitechLEDLib.h create mode 100644 JLAW front/pom.xml create mode 100644 JLAW front/src/main/java/ninja/hon95/jlaw/JlawArxControl.java create mode 100644 JLAW front/src/main/java/ninja/hon95/jlaw/JlawGkey.java create mode 100644 JLAW front/src/main/java/ninja/hon95/jlaw/JlawLcd.java create mode 100644 JLAW front/src/main/java/ninja/hon95/jlaw/JlawLed.java create mode 100644 JLAW front/src/main/java/ninja/hon95/jlaw/JlawUtil.java create mode 100644 JLAW front/src/main/resources/LICENSE.txt create mode 100644 JLAW test/pom.xml create mode 100644 JLAW test/src/main/java/ninja/hon95/jlawtest/LogMessage.java create mode 100644 JLAW test/src/main/java/ninja/hon95/jlawtest/Main.java create mode 100644 JLAW test/src/main/java/ninja/hon95/jlawtest/Tester.java create mode 100644 JLAW test/src/main/java/ninja/hon95/jlawtest/WindowBuilder.java create mode 100644 JLAW test/src/main/resources/LICENSE.txt create mode 100644 JLAW test/src/main/resources/icons/application.ico create mode 100644 JLAW test/src/main/resources/icons/application_128.png create mode 100644 JLAW test/src/main/resources/icons/application_16.png create mode 100644 JLAW test/src/main/resources/icons/application_256.png create mode 100644 JLAW test/src/main/resources/icons/application_32.png create mode 100644 JLAW test/src/main/resources/icons/application_64.png create mode 100644 LICENSE.txt create mode 100644 extract_dlls.bat create mode 100644 make_headers.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bab4864 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Root folders +bin/ +lib/ + +## Visual Studio back +JLAW\ back/[Dd]ebug +JLAW\ back/[Rr]elease +JLAW\ back/x64 +JLAW\ back/JLAW\ back/[Dd]ebug +JLAW\ back/JLAW\ back/[Rr]elease +JLAW\ back/JLAW\ back/x64 + +*.suo +*.user +*.obj +*.opensdf +*.sdf + +## Eclipse front +JLAW\ front/target +JLAW\ front/.settings +JLAW\ front/.classpath +JLAW\ front/.project + +## Eclipse test +JLAW\ test/target +JLAW\ test/src/main/resources/natives/* +JLAW\ test/.settings +JLAW\ test/.classpath +JLAW\ test/.project diff --git a/JLAW back/JLAW back.sln b/JLAW back/JLAW back.sln new file mode 100644 index 0000000..8f21fbf --- /dev/null +++ b/JLAW back/JLAW back.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JLAW back", "JLAW back\JLAW back.vcxproj", "{AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Debug|Win32.ActiveCfg = Debug|Win32 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Debug|Win32.Build.0 = Debug|Win32 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Debug|x64.ActiveCfg = Debug|x64 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Debug|x64.Build.0 = Debug|x64 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Release|Win32.ActiveCfg = Release|Win32 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Release|Win32.Build.0 = Release|Win32 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Release|x64.ActiveCfg = Release|x64 + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/JLAW back/JLAW back/JLAW back.vcxproj b/JLAW back/JLAW back/JLAW back.vcxproj new file mode 100644 index 0000000..fcb530b --- /dev/null +++ b/JLAW back/JLAW back/JLAW back.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + {AB1FBDC8-F205-4D1C-A68B-A703270C3C4E} + Win32Proj + JLAWback + + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + F:\Workspace\workspace_mixed\JLAW\lib\Logitech LCD SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech Gkey SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech LED SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech ArxControl SDK\Lib\x86;$(LibraryPath) + F:\Workspace\workspace_mixed\JLAW\lib\JNI;$(IncludePath) + + + true + F:\Workspace\workspace_mixed\JLAW\lib\Logitech LCD SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech Gkey SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech LED SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech ArxControl SDK\Lib\x64;$(LibraryPath) + F:\Workspace\workspace_mixed\JLAW\lib\JNI;$(IncludePath) + + + false + F:\Workspace\workspace_mixed\JLAW\lib\Logitech LCD SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech Gkey SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech LED SDK\Lib\x86;F:\Workspace\workspace_mixed\JLAW\lib\Logitech ArxControl SDK\Lib\x86;$(LibraryPath) + F:\Workspace\workspace_mixed\JLAW\lib\JNI;$(IncludePath) + + + false + F:\Workspace\workspace_mixed\JLAW\lib\Logitech LCD SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech Gkey SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech LED SDK\Lib\x64;F:\Workspace\workspace_mixed\JLAW\lib\Logitech ArxControl SDK\Lib\x64;$(LibraryPath) + F:\Workspace\workspace_mixed\JLAW\lib\JNI;$(IncludePath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;JLAWBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + LogitechLCDLib.lib;LogitechGkeyLib.lib;LogitechLEDLib.lib;LogitechGArxControlLib.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;JLAWBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + LogitechLCDLib.lib;LogitechGkeyLib.lib;LogitechLEDLib.lib;LogitechGArxControlLib.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;JLAWBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + LogitechLCDLib.lib;LogitechGkeyLib.lib;LogitechLEDLib.lib;LogitechGArxControlLib.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;JLAWBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + LogitechLCDLib.lib;LogitechGkeyLib.lib;LogitechLEDLib.lib;LogitechGArxControlLib.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/JLAW back/JLAW back/JLAW back.vcxproj.filters b/JLAW back/JLAW back/JLAW back.vcxproj.filters new file mode 100644 index 0000000..1522bf6 --- /dev/null +++ b/JLAW back/JLAW back/JLAW back.vcxproj.filters @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/JLAW back/JLAW back/JlawArxControl.cpp b/JLAW back/JLAW back/JlawArxControl.cpp new file mode 100644 index 0000000..ef2a851 --- /dev/null +++ b/JLAW back/JLAW back/JlawArxControl.cpp @@ -0,0 +1,145 @@ +#pragma comment(lib, "LogitechLEDLib.lib") + +#include +#include +#include "JlawUtil.h" +#include "JlawArxControl.h" +#include "LogitechGArxControlLib.h" + +namespace jlaw_arx_control { + const char *callbackMethodName = "call"; + const char *callbackMethodSignature = "(IILjava/lang/String;)V"; + char *threadName = "logi-arx-callback-thread"; + JavaVM *storedJvm = NULL; + jmethodID callbackMethodID = NULL; + jobject currentCallback = NULL; + + void __cdecl Callback(unsigned __int32 eventType, unsigned __int32 eventValue, wchar_t *eventArg, void *context) { + JNIEnv *env; + JavaVMAttachArgs args; + args.version = JNI_VERSION_1_6; // JNI version + args.name = threadName; // Thread name + args.group = NULL; // Thread group + storedJvm->AttachCurrentThread((void**)&env, &args); + + jmethodID methodId = env->GetMethodID(env->GetObjectClass(currentCallback), callbackMethodName, callbackMethodSignature); + std::wstring wideEventArg = eventArg; + jstring javaEventArg = ToJavaStringFromWideString(wideEventArg, env); + env->CallVoidMethod(currentCallback, callbackMethodID, eventType, eventValue, javaEventArg); + storedJvm->DetachCurrentThread(); + } +} + +using namespace jlaw_arx_control; + +// logiArxInit // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxInit +(JNIEnv *env, jclass clazz, jstring identifier, jstring friendlyName, jobject callback){ + if (storedJvm == NULL) + env->GetJavaVM(&storedJvm); + if (callbackMethodID == NULL) + callbackMethodID = env->GetMethodID(env->GetObjectClass(callback), callbackMethodName, callbackMethodSignature); + if (currentCallback != NULL) + env->DeleteGlobalRef(currentCallback); + currentCallback = env->NewGlobalRef(callback); + + std::wstring wideIdentifier = ToWideStringFromJavaString(identifier, env); + std::wstring wideFriendlyName = ToWideStringFromJavaString(friendlyName, env); + logiArxCbContext context; + context.arxCallBack = (logiArxCb)Callback; + context.arxContext = NULL; + return LogiArxInit(&wideIdentifier[0], &wideFriendlyName[0], &context); +} + +// logiArxAddFileAs // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddFileAs +(JNIEnv *env, jclass clazz, jstring filePath, jstring fileName, jstring mimeType){ + std::wstring wideFilePath = ToWideStringFromJavaString(filePath, env); + std::wstring wideFileName = ToWideStringFromJavaString(fileName, env); + std::wstring wideMimeType = ToWideStringFromJavaString(mimeType, env); + return LogiArxAddFileAs(&wideFilePath[0], &wideFileName[0], &wideMimeType[0]); +} + +// logiArxAddContentAs // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddContentAs +(JNIEnv *env, jclass clazz, jbyteArray content, jstring fileName, jstring mimeType){ + std::wstring wideFileName = ToWideStringFromJavaString(fileName, env); + std::wstring wideMimeType = ToWideStringFromJavaString(mimeType, env); + jbyte *byteContent = env->GetByteArrayElements(content, NULL); + jsize size = env->GetArrayLength(content); + bool result = LogiArxAddContentAs(byteContent, size, &wideFileName[0], &wideMimeType[0]); + env->ReleaseByteArrayElements(content, byteContent, JNI_ABORT); + return result; +} + +// logiArxAddUTF8StringAs // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddUTF8StringAs +(JNIEnv *env, jclass clazz, jstring stringContent, jstring fileName, jstring mimeType){ + std::wstring wideStringContent = ToWideStringFromJavaString(stringContent, env); + std::wstring wideFileName = ToWideStringFromJavaString(fileName, env); + std::wstring wideMimeType = ToWideStringFromJavaString(mimeType, env); + return LogiArxAddUTF8StringAs(&wideStringContent[0], &wideFileName[0], &wideMimeType[0]); +} + +// logiArxAddImageFromBitmap // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddImageFromBitmap +(JNIEnv *env, jclass clazz, jbyteArray bitmap, jint width, jint height, jstring fileName){ + std::wstring wideFileName = ToWideStringFromJavaString(fileName, env); + jbyte *byteBitMap = env->GetByteArrayElements(bitmap, NULL); + bool result = LogiArxAddImageFromBitmap(reinterpret_cast(byteBitMap), width, height, &wideFileName[0]); + env->ReleaseByteArrayElements(bitmap, byteBitMap, JNI_ABORT); + return result; +} + +// logiArxSetIndex // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetIndex +(JNIEnv *env, jclass clazz, jstring fileName){ + std::wstring wideFileName = ToWideStringFromJavaString(fileName, env); + return LogiArxSetIndex(&wideFileName[0]); +} + +// logiArxSetTagPropertyById // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagPropertyById +(JNIEnv *env, jclass clazz, jstring tagId, jstring prop, jstring newValue){ + std::wstring wideTagId = ToWideStringFromJavaString(tagId, env); + std::wstring wideProp = ToWideStringFromJavaString(prop, env); + std::wstring wideNewValue = ToWideStringFromJavaString(newValue, env); + return LogiArxSetTagPropertyById(&wideTagId[0], &wideProp[0], &wideNewValue[0]); +} + +// logiArxSetTagsPropertyByClass // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagsPropertyByClass +(JNIEnv *env, jclass clazz, jstring tagsClass, jstring prop, jstring newValue){ + std::wstring wideTagsClass = ToWideStringFromJavaString(tagsClass, env); + std::wstring wideProp = ToWideStringFromJavaString(prop, env); + std::wstring wideNewValue = ToWideStringFromJavaString(newValue, env); + return LogiArxSetTagsPropertyByClass(&wideTagsClass[0], &wideProp[0], &wideNewValue[0]); +} + +// logiArxSetTagContentById // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagContentById +(JNIEnv *env, jclass clazz, jstring tagId, jstring newContent){ + std::wstring wideTagId = ToWideStringFromJavaString(tagId, env); + std::wstring wideNewContent = ToWideStringFromJavaString(newContent, env); + return LogiArxSetTagContentById(&wideTagId[0], &wideNewContent[0]); +} + +// logiArxSetTagsContentByClass // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagsContentByClass +(JNIEnv *env, jclass clazz, jstring tagsClass, jstring newContent){ + std::wstring wideTagsClass = ToWideStringFromJavaString(tagsClass, env); + std::wstring wideNewContent = ToWideStringFromJavaString(newContent, env); + return LogiArxSetTagsContentByClass(&wideTagsClass[0], &wideNewContent[0]); +} + +// logiArxGetLastError // +JNIEXPORT jint JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxGetLastError +(JNIEnv *env, jclass clazz){ + return LogiArxGetLastError(); +} + +// logiArxShutdown // +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxShutdown +(JNIEnv *env, jclass clazz){ + LogiArxShutdown(); +} diff --git a/JLAW back/JLAW back/JlawArxControl.h b/JLAW back/JLAW back/JlawArxControl.h new file mode 100644 index 0000000..7f65c1a --- /dev/null +++ b/JLAW back/JLAW back/JlawArxControl.h @@ -0,0 +1,144 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class ninja_hon95_jlaw_JlawArxControl */ + +#ifndef _Included_ninja_hon95_jlaw_JlawArxControl +#define _Included_ninja_hon95_jlaw_JlawArxControl +#ifdef __cplusplus +extern "C" { +#endif +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_FOCUS_ACTIVE +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_FOCUS_ACTIVE 1L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_FOCUS_INACTIVE +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_FOCUS_INACTIVE 2L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_TAP_ON_TAG +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_TAP_ON_TAG 4L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL 8L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL 16L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_IPHONE +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_IPHONE 1L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_IPAD +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_IPAD 2L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_SMALL +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_SMALL 3L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_NORMAL +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_NORMAL 4L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_LARGE +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_LARGE 5L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_XLARGE +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_XLARGE 6L +#undef ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_OTHER +#define ninja_hon95_jlaw_JlawArxControl_LOGI_ARX_DEVICETYPE_ANDROID_OTHER 7L +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxInit + * Signature: (Ljava/lang/String;Ljava/lang/String;Lninja/hon95/jlaw/JlawArxControl/JlawArxControlCallback;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxInit + (JNIEnv *, jclass, jstring, jstring, jobject); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxAddFileAs + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddFileAs + (JNIEnv *, jclass, jstring, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxAddContentAs + * Signature: ([BLjava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddContentAs + (JNIEnv *, jclass, jbyteArray, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxAddUTF8StringAs + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddUTF8StringAs + (JNIEnv *, jclass, jstring, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxAddImageFromBitmap + * Signature: ([BIILjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxAddImageFromBitmap + (JNIEnv *, jclass, jbyteArray, jint, jint, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxSetIndex + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetIndex + (JNIEnv *, jclass, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxSetTagPropertyById + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagPropertyById + (JNIEnv *, jclass, jstring, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxSetTagsPropertyByClass + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagsPropertyByClass + (JNIEnv *, jclass, jstring, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxSetTagContentById + * Signature: (Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagContentById + (JNIEnv *, jclass, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxSetTagsContentByClass + * Signature: (Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxSetTagsContentByClass + (JNIEnv *, jclass, jstring, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxGetLastError + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxGetLastError + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawArxControl + * Method: nLogiArxShutdown + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawArxControl_nLogiArxShutdown + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class ninja_hon95_jlaw_JlawArxControl_JlawArxControlCallback */ + +#ifndef _Included_ninja_hon95_jlaw_JlawArxControl_JlawArxControlCallback +#define _Included_ninja_hon95_jlaw_JlawArxControl_JlawArxControlCallback +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/JLAW back/JLAW back/JlawGkey.cpp b/JLAW back/JLAW back/JlawGkey.cpp new file mode 100644 index 0000000..ee92cc4 --- /dev/null +++ b/JLAW back/JLAW back/JlawGkey.cpp @@ -0,0 +1,86 @@ +#pragma comment(lib, "LogitechGkeyLib.lib") + +#include +#include +#include "JlawUtil.h" +#include "JlawGkey.h" +#include "LogitechGkeyLib.h" + +namespace jlaw_gkey { + const char *callbackMethodName = "call"; + const char *callbackMethodSignature = "(IZIZLjava/lang/String;)V"; + char *threadName = "logi-gkey-callback-thread"; + JavaVM *storedJvm = NULL; + jmethodID callbackMethodID = NULL; + jobject currentCallback = NULL; + + void __cdecl Callback(GkeyCode gkeyCode, wchar_t *gkeyOrButtonString, void *context) { + JNIEnv *env; + JavaVMAttachArgs args; + args.version = JNI_VERSION_1_6; // JNI version + args.name = threadName; // Thread name + args.group = NULL; // Thread group + storedJvm->AttachCurrentThread((void**)&env, &args); + + jmethodID methodId = env->GetMethodID(env->GetObjectClass(currentCallback), callbackMethodName, callbackMethodSignature); + std::wstring wideString = gkeyOrButtonString; + jstring javaString = ToJavaStringFromWideString(wideString, env); + env->CallVoidMethod(currentCallback, callbackMethodID, gkeyCode.keyIdx, gkeyCode.keyDown, gkeyCode.mState, gkeyCode.mouse, javaString); + storedJvm->DetachCurrentThread(); + } +} + +using namespace jlaw_gkey; + +// logiGkeyInit // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyInit +(JNIEnv *env, jclass clazz, jobject callback) { + if (storedJvm == NULL) + env->GetJavaVM(&storedJvm); + if (callbackMethodID == NULL) + callbackMethodID = env->GetMethodID(env->GetObjectClass(callback), callbackMethodName, callbackMethodSignature); + if (currentCallback != NULL) + env->DeleteGlobalRef(currentCallback); + currentCallback = env->NewGlobalRef(callback); + return LogiGkeyInitWithoutContext((logiGkeyCB)Callback); +} + +// logiGkeyInitWithoutCallback // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyInitWithoutCallback +(JNIEnv *env, jclass clazz) { + return LogiGkeyInitWithoutCallback(); +} + +// logiGkeyIsMouseButtonPressed // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyIsMouseButtonPressed +(JNIEnv *env, jclass clazz, jint buttonNumber) { + return LogiGkeyIsMouseButtonPressed(buttonNumber); +} + +// logiGkeyGetMouseButtonString // +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyGetMouseButtonString +(JNIEnv *env, jclass clazz, jint buttonNumber) { + std::wstring wideString = LogiGkeyGetMouseButtonString(buttonNumber); + jstring javaString = ToJavaStringFromWideString(wideString, env); + return javaString; +} + +// logiGkeyIsKeyboardGkeyPressed // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyIsKeyboardGkeyPressed +(JNIEnv *env, jclass clazz, jint gkeyNumber, jint modeNumber) { + return LogiGkeyIsKeyboardGkeyPressed(gkeyNumber, modeNumber); +} + +// logiGkeyGetKeyboardGkeyString // +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyGetKeyboardGkeyString +(JNIEnv *env, jclass clazz, jint gkeyNumber, jint modeNumber) { + std::wstring wideString = LogiGkeyGetKeyboardGkeyString(gkeyNumber, modeNumber); + jstring javaString = ToJavaStringFromWideString(wideString, env); + return javaString; +} + +// logiGkeyShutdown // +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyShutdown +(JNIEnv *env, jclass clazz) { + LogiGkeyShutdown(); +} diff --git a/JLAW back/JLAW back/JlawGkey.h b/JLAW back/JLAW back/JlawGkey.h new file mode 100644 index 0000000..69cb11c --- /dev/null +++ b/JLAW back/JLAW back/JlawGkey.h @@ -0,0 +1,86 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class ninja_hon95_jlaw_JlawGkey */ + +#ifndef _Included_ninja_hon95_jlaw_JlawGkey +#define _Included_ninja_hon95_jlaw_JlawGkey +#ifdef __cplusplus +extern "C" { +#endif +#undef ninja_hon95_jlaw_JlawGkey_LOGI_MAX_MOUSE_BUTTONS +#define ninja_hon95_jlaw_JlawGkey_LOGI_MAX_MOUSE_BUTTONS 20L +#undef ninja_hon95_jlaw_JlawGkey_LOGI_MAX_GKEYS +#define ninja_hon95_jlaw_JlawGkey_LOGI_MAX_GKEYS 29L +#undef ninja_hon95_jlaw_JlawGkey_LOGI_MAX_M_STATES +#define ninja_hon95_jlaw_JlawGkey_LOGI_MAX_M_STATES 3L +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyInit + * Signature: (Lninja/hon95/jlaw/JlawGkey/JlawGkeyCallback;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyInit + (JNIEnv *, jclass, jobject); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyInitWithoutCallback + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyInitWithoutCallback + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyIsMouseButtonPressed + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyIsMouseButtonPressed + (JNIEnv *, jclass, jint); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyGetMouseButtonString + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyGetMouseButtonString + (JNIEnv *, jclass, jint); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyIsKeyboardGkeyPressed + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyIsKeyboardGkeyPressed + (JNIEnv *, jclass, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyGetKeyboardGkeyString + * Signature: (II)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyGetKeyboardGkeyString + (JNIEnv *, jclass, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawGkey + * Method: nLogiGkeyShutdown + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawGkey_nLogiGkeyShutdown + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class ninja_hon95_jlaw_JlawGkey_JlawGkeyCallback */ + +#ifndef _Included_ninja_hon95_jlaw_JlawGkey_JlawGkeyCallback +#define _Included_ninja_hon95_jlaw_JlawGkey_JlawGkeyCallback +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/JLAW back/JLAW back/JlawLcd.cpp b/JLAW back/JLAW back/JlawLcd.cpp new file mode 100644 index 0000000..033f4b7 --- /dev/null +++ b/JLAW back/JLAW back/JlawLcd.cpp @@ -0,0 +1,78 @@ +#pragma comment(lib, "LogitechLCDLib.lib") + +#include +#include +#include "JlawUtil.h" +#include "JlawLcd.h" +#include "LogitechLCDLib.h" + + +// logiLcdInit // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdInit +(JNIEnv *env, jclass clazz, jstring friendlyName, jint lcdType) { + std::wstring wideString = ToWideStringFromJavaString(friendlyName, env); + return LogiLcdInit(&wideString[0], lcdType); +} + +// logiLcdIsConnected // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdIsConnected +(JNIEnv *env, jclass clazz, jint lcdType) { + return LogiLcdIsConnected(lcdType); +} + +// logiLcdIsButtonPressed // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdIsButtonPressed +(JNIEnv *env, jclass clazz, jint button) { + return LogiLcdIsButtonPressed(button); +} + +// logiLcdUpdate // +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdUpdate +(JNIEnv *env, jclass clazz) { + LogiLcdUpdate(); +} + +// logiLcdShutdown // +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdShutdown +(JNIEnv *env, jclass clazz) { + LogiLcdShutdown(); +} + +// logiLcdMonoSetBackground // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdMonoSetBackground +(JNIEnv *env, jclass clazz, jbyteArray monoBitmap) { + jbyte *byteMonoBitmap = env->GetByteArrayElements(monoBitmap, NULL); + bool result = LogiLcdMonoSetBackground(reinterpret_cast(byteMonoBitmap)); + env->ReleaseByteArrayElements(monoBitmap, byteMonoBitmap, JNI_ABORT); + return result; +} + +// logiLcdMonoSetText // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdMonoSetText +(JNIEnv *env, jclass clazz, jint lineNumber, jstring text) { + std::wstring wideString = ToWideStringFromJavaString(text, env); + return LogiLcdMonoSetText(lineNumber, &wideString[0]); +} + +// logiLcdColorSetBackground // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetBackground +(JNIEnv *env, jclass clazz, jbyteArray colorBitmap) { + jbyte *byteColorBitmap = env->GetByteArrayElements(colorBitmap, NULL); + bool result = LogiLcdColorSetBackground(reinterpret_cast(byteColorBitmap)); + env->ReleaseByteArrayElements(colorBitmap, byteColorBitmap, JNI_ABORT); + return result; +} + +// logiLcdColorSetTitle // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetTitle +(JNIEnv *env, jclass clazz, jstring text, jint red, jint green, jint blue) { + std::wstring wideString = ToWideStringFromJavaString(text, env); + return LogiLcdColorSetTitle(&wideString[0], red, green, blue); +} + +// logiLcdColorSetText // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetText +(JNIEnv *env, jclass clazz, jint lineNumber, jstring text, jint red, jint green, jint blue) { + std::wstring wideString = ToWideStringFromJavaString(text, env); + return LogiLcdColorSetText(lineNumber, &wideString[0], red, green, blue); +} diff --git a/JLAW back/JLAW back/JlawLcd.h b/JLAW back/JLAW back/JlawLcd.h new file mode 100644 index 0000000..7b5a995 --- /dev/null +++ b/JLAW back/JLAW back/JlawLcd.h @@ -0,0 +1,135 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class ninja_hon95_jlaw_JlawLcd */ + +#ifndef _Included_ninja_hon95_jlaw_JlawLcd +#define _Included_ninja_hon95_jlaw_JlawLcd +#ifdef __cplusplus +extern "C" { +#endif +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_MONO +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_MONO 1L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_COLOR +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_COLOR 2L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_BOTH +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_TYPE_BOTH 3L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_0 +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_0 1L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_1 +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_1 2L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_2 +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_2 4L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_3 +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BUTTON_3 8L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_LEFT +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_LEFT 256L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_RIGHT +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_RIGHT 512L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_OK +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_OK 1024L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_CANCEL +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_CANCEL 2048L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_UP +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_UP 4096L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_DOWN +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_DOWN 8192L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_MENU +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BUTTON_MENU 16384L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_WIDTH +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_WIDTH 160L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_HEIGHT +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_HEIGHT 43L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_WIDTH +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_WIDTH 320L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_HEIGHT +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_HEIGHT 240L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BITMAP_SIZE +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_MONO_BITMAP_SIZE 6880L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BITMAP_BYTES_PER_PIXEL +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BITMAP_BYTES_PER_PIXEL 4L +#undef ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BITMAP_SIZE +#define ninja_hon95_jlaw_JlawLcd_LOGI_LCD_COLOR_BITMAP_SIZE 307200L +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdInit + * Signature: (Ljava/lang/String;I)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdInit + (JNIEnv *, jclass, jstring, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdIsConnected + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdIsConnected + (JNIEnv *, jclass, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdIsButtonPressed + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdIsButtonPressed + (JNIEnv *, jclass, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdUpdate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdUpdate + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdShutdown + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdShutdown + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdMonoSetBackground + * Signature: ([B)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdMonoSetBackground + (JNIEnv *, jclass, jbyteArray); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdMonoSetText + * Signature: (ILjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdMonoSetText + (JNIEnv *, jclass, jint, jstring); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdColorSetBackground + * Signature: ([B)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetBackground + (JNIEnv *, jclass, jbyteArray); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdColorSetTitle + * Signature: (Ljava/lang/String;III)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetTitle + (JNIEnv *, jclass, jstring, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLcd + * Method: nLogiLcdColorSetText + * Signature: (ILjava/lang/String;III)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLcd_nLogiLcdColorSetText + (JNIEnv *, jclass, jint, jstring, jint, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/JLAW back/JLAW back/JlawLed.cpp b/JLAW back/JLAW back/JlawLed.cpp new file mode 100644 index 0000000..176d4d9 --- /dev/null +++ b/JLAW back/JLAW back/JlawLed.cpp @@ -0,0 +1,111 @@ +#pragma comment(lib, "LogitechLEDLib.lib") + +#include +#include +#include "JlawUtil.h" +#include "JlawLed.h" +#include "LogitechLEDLib.h" + +// logiLedInit // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedInit +(JNIEnv *env, jclass clazz){ + return LogiLedInit(); +} + +// logiLedGetSdkVersion // +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedGetSdkVersion +(JNIEnv *env, jclass clazz){ + int major, minor, build; + if (LogiLedGetSdkVersion(&major, &minor, &build)) { + std::wstring wideString; + wideString += std::to_wstring(major); + wideString += L"."; + wideString += std::to_wstring(minor); + wideString += L"."; + wideString += std::to_wstring(build); + jstring javaString = ToJavaStringFromWideString(wideString, env); + return javaString; + } + return NULL; +} + +// logiLedSetTargetDevice // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetTargetDevice +(JNIEnv *env, jclass clazz, jint targetDevice){ + return LogiLedSetTargetDevice(targetDevice); +} + +// logiLedSaveCurrentLighting // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSaveCurrentLighting +(JNIEnv *env, jclass clazz){ + return LogiLedSaveCurrentLighting(); +} + +// logiLedSetLighting // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLighting +(JNIEnv *env, jclass clazz, jint redPercentage, jint greenPercentage, jint bluePercentage){ + return LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage); +} + +// logiLedRestoreLighting +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedRestoreLighting +(JNIEnv *env, jclass clazz){ + return LogiLedRestoreLighting(); +} + +// logiLedFlashLighting // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedFlashLighting +(JNIEnv *env, jclass clazz, jint redPercentage, jint greenPercentage, jint bluePercentage, jint milliSecondsDuration, jint milliSecondsInterval){ + return LogiLedFlashLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval); +} + +// logiLedPulseLighting // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedPulseLighting +(JNIEnv *env, jclass clazz, jint redPercentage, jint greenPercentage, jint bluePercentage, jint milliSecondsDuration, jint milliSecondsInterval){ + return LogiLedPulseLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval); +} + +// logiLedStopEffects // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedStopEffects +(JNIEnv *env, jclass clazz){ + return LogiLedStopEffects(); +} + +// logiLedSetLightingFromBitmap // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingFromBitmap +(JNIEnv *env, jclass clazz, jbyteArray bitmap){ + jbyte *byteBitmap = env->GetByteArrayElements(bitmap, NULL); + bool result = LogiLedSetLightingFromBitmap(reinterpret_cast(byteBitmap)); + env->ReleaseByteArrayElements(bitmap, byteBitmap, JNI_ABORT); + return result; +} + +// logiLedSetLightingForKeyWithScanCode // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithScanCode +(JNIEnv *env, jclass clazz, jint keyCode, jint redPercentage, jint greenPercentage, jint bluePercentage){ + return LogiLedSetLightingForKeyWithScanCode(keyCode, redPercentage, greenPercentage, bluePercentage); +} + +// logiLedSetLightingForKeyWithHidCode // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithHidCode +(JNIEnv *env, jclass clazz, jint keyCode, jint redPercentage, jint greenPercentage, jint bluePercentage){ + return LogiLedSetLightingForKeyWithHidCode(keyCode, redPercentage, greenPercentage, bluePercentage); +} + +// logiLedSetLightingForKeyWithQuartzCode // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithQuartzCode +(JNIEnv *env, jclass clazz, jint keyCode, jint redPercentage, jint greenPercentage, jint bluePercentage){ + return LogiLedSetLightingForKeyWithQuartzCode(keyCode, redPercentage, greenPercentage, bluePercentage); +} + +// logiLedSetLightingForKeyWithKeyName // +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithKeyName +(JNIEnv *env, jclass clazz, jint keyName, jint redPercentage, jint greenPercentage, jint bluePercentage){ + return LogiLedSetLightingForKeyWithKeyName(static_cast(keyName), redPercentage, greenPercentage, bluePercentage); +} + +// logiLedShutdown // +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedShutdown +(JNIEnv *env, jclass clazz){ + LogiLedShutdown(); +} diff --git a/JLAW back/JLAW back/JlawLed.h b/JLAW back/JLAW back/JlawLed.h new file mode 100644 index 0000000..cbfdb8e --- /dev/null +++ b/JLAW back/JLAW back/JlawLed.h @@ -0,0 +1,162 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class ninja_hon95_jlaw_JlawLed */ + +#ifndef _Included_ninja_hon95_jlaw_JlawLed +#define _Included_ninja_hon95_jlaw_JlawLed +#ifdef __cplusplus +extern "C" { +#endif +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_WIDTH +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_WIDTH 21L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_HEIGHT +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_HEIGHT 6L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_BYTES_PER_KEY +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_BYTES_PER_KEY 6L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_SIZE +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_BITMAP_SIZE 756L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_MONOCHROME +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_MONOCHROME 1L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_RGB +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_RGB 2L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_PERKEY_RGB +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_PERKEY_RGB 4L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_ALL +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_DEVICETYPE_ALL 7L +#undef ninja_hon95_jlaw_JlawLed_LOGI_LED_DURATION_INFINATE +#define ninja_hon95_jlaw_JlawLed_LOGI_LED_DURATION_INFINATE 0L +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedInit + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedInit + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedGetSdkVersion + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedGetSdkVersion + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetTargetDevice + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetTargetDevice + (JNIEnv *, jclass, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSaveCurrentLighting + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSaveCurrentLighting + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLighting + * Signature: (III)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLighting + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedRestoreLighting + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedRestoreLighting + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedFlashLighting + * Signature: (IIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedFlashLighting + (JNIEnv *, jclass, jint, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedPulseLighting + * Signature: (IIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedPulseLighting + (JNIEnv *, jclass, jint, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedStopEffects + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedStopEffects + (JNIEnv *, jclass); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLightingFromBitmap + * Signature: ([B)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingFromBitmap + (JNIEnv *, jclass, jbyteArray); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLightingForKeyWithScanCode + * Signature: (IIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithScanCode + (JNIEnv *, jclass, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLightingForKeyWithHidCode + * Signature: (IIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithHidCode + (JNIEnv *, jclass, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLightingForKeyWithQuartzCode + * Signature: (IIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithQuartzCode + (JNIEnv *, jclass, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedSetLightingForKeyWithKeyName + * Signature: (IIII)Z + */ +JNIEXPORT jboolean JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedSetLightingForKeyWithKeyName + (JNIEnv *, jclass, jint, jint, jint, jint); + +/* + * Class: ninja_hon95_jlaw_JlawLed + * Method: nLogiLedShutdown + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_ninja_hon95_jlaw_JlawLed_nLogiLedShutdown + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class ninja_hon95_jlaw_JlawLed_KeyName */ + +#ifndef _Included_ninja_hon95_jlaw_JlawLed_KeyName +#define _Included_ninja_hon95_jlaw_JlawLed_KeyName +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/JLAW back/JLAW back/JlawUtil.cpp b/JLAW back/JLAW back/JlawUtil.cpp new file mode 100644 index 0000000..f682552 --- /dev/null +++ b/JLAW back/JLAW back/JlawUtil.cpp @@ -0,0 +1,28 @@ +#include +#include +#include "JlawUtil.h" + +jstring ToJavaStringFromWideString(std::wstring &wideString, JNIEnv *env) { + jstring javaString; + size_t length = wideString.length(); + jchar *javaChars = new jchar[length]; + for (size_t i = 0; i < length; i++) + javaChars[i] = (wideString)[i]; + javaString = env->NewString(javaChars, static_cast(length)); + delete javaChars; + return javaString; +} + +std::wstring ToWideStringFromJavaString(jstring &javaString, JNIEnv *env) { + std::wstring wideString; + const jchar *javaChars = env->GetStringChars(javaString, NULL); + jsize length = env->GetStringLength(javaString); + wchar_t *tmpWideString = new wchar_t[length + 1]; + for (int i = 0; i < length; i++) + tmpWideString[i] = javaChars[i]; + tmpWideString[length] = '\0'; + wideString = tmpWideString; + env->ReleaseStringChars(javaString, javaChars); + delete tmpWideString; + return wideString; +} diff --git a/JLAW back/JLAW back/JlawUtil.h b/JLAW back/JLAW back/JlawUtil.h new file mode 100644 index 0000000..4ac18d8 --- /dev/null +++ b/JLAW back/JLAW back/JlawUtil.h @@ -0,0 +1,11 @@ +#ifndef _JLAW_BACK_UTIL_H +#define _JLAW_BACK_UTIL_H + +#include +#include + +jstring ToJavaStringFromWideString(std::wstring &wideString, JNIEnv *env); + +std::wstring ToWideStringFromJavaString(jstring &javaString, JNIEnv *env); + +#endif // _JLAW_BACK_UTIL_H diff --git a/JLAW back/JLAW back/LogitechGArxControlLib.h b/JLAW back/JLAW back/LogitechGArxControlLib.h new file mode 100644 index 0000000..1950946 --- /dev/null +++ b/JLAW back/JLAW back/LogitechGArxControlLib.h @@ -0,0 +1,84 @@ +// LogitechGArxControlLib.h : Defines the exported functions for the API +// +// Logitech Gaming Arx Control SDK +// +// Copyright (C) 2011-2014 Logitech. All rights reserved. +// Author: Tiziano Pigliucci +// Email: devtechsupport@logitech.com + +#pragma once +#include + +#pragma pack(push, 1) + +#define LOGI_ARX_ORIENTATION_PORTRAIT 0x01 +#define LOGI_ARX_ORIENTATION_LANDSCAPE 0x10 + +#define LOGI_ARX_EVENT_FOCUS_ACTIVE 0x01 +#define LOGI_ARX_EVENT_FOCUS_INACTIVE 0x02 +#define LOGI_ARX_EVENT_TAP_ON_TAG 0x04 +#define LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL 0x08 +#define LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL 0x10 + +#define LOGI_ARX_DEVICETYPE_IPHONE 0x01 +#define LOGI_ARX_DEVICETYPE_IPAD 0x02 +#define LOGI_ARX_DEVICETYPE_ANDROID_SMALL 0x03 +#define LOGI_ARX_DEVICETYPE_ANDROID_NORMAL 0x04 +#define LOGI_ARX_DEVICETYPE_ANDROID_LARGE 0x05 +#define LOGI_ARX_DEVICETYPE_ANDROID_XLARGE 0x06 +#define LOGI_ARX_DEVICETYPE_ANDROID_OTHER 0x07 + + + +typedef void (__cdecl *logiArxCb)(unsigned __int32 eventType, unsigned __int32 eventValue, wchar_t *eventArg, void * context); + +typedef struct +{ + logiArxCb arxCallBack; + void* arxContext; +}logiArxCbContext; + + + +//Initializes the applet on the app with the given friendlyName +bool LogiArxInit(wchar_t * identifier, wchar_t * friendlyName, logiArxCbContext *callbackContest); + +//CONTENT TRANSFER + +//Sends a file to the device/s from local filePath and assigns fileName to it. mimeType if assigned, specifies the MIME type of the file +bool LogiArxAddFileAs(wchar_t * filePath, wchar_t * fileName, wchar_t *mimeType = L""); + +//Sends content to the device/s saving it to a virtual file called fileName. mimeType if assigned, specifies the MIME type of the file +bool LogiArxAddContentAs(const void* content, int size, wchar_t * fileName, wchar_t *mimeType = L""); + +//Sends UTF8 string to the device/s saving it to a virtual file called fileName. mimeType if assigned, specifies the MIME type of the file +bool LogiArxAddUTF8StringAs(wchar_t* stringContent, wchar_t * fileName, wchar_t *mimeType = L""); + +//Compresses the image specified by the RGBA byte array bitmap (interpreting the array using width and height) into a png file with name specified by fileName, then sends it over to the device +bool LogiArxAddImageFromBitmap(BYTE bitmap[], int width, int height, wchar_t * fileName); + +//Sets which of the sent file is the index (first one to be displayed in the applet) +bool LogiArxSetIndex(wchar_t * fileName); + +//DATA UPDATE + +//Change at runtime a property on the tag with id tagId from the old value to the newValue +bool LogiArxSetTagPropertyById(wchar_t * tagId, wchar_t * prop, wchar_t *newValue); + +//Change at runtime a property on the tags with class tagClass from the old value to the newValue +bool LogiArxSetTagsPropertyByClass(wchar_t * tagsClass, wchar_t * prop, wchar_t *newValue); + +//Change at runtime the content of a tag with id tagId from the old to the newContent +bool LogiArxSetTagContentById(wchar_t * tagId, const wchar_t *newContent); + +//Change at runtime the content on the tags with class tagClass from the old to the newContent +bool LogiArxSetTagsContentByClass(wchar_t * tagsClass, const wchar_t *newContent); + +//Each function returns a bool, to get detailed info on the last error code call this function +int LogiArxGetLastError(); + +//Shuts down the applet on the app +void LogiArxShutdown(); + + +#pragma pack(pop) \ No newline at end of file diff --git a/JLAW back/JLAW back/LogitechGkeyLib.h b/JLAW back/JLAW back/LogitechGkeyLib.h new file mode 100644 index 0000000..9de12f2 --- /dev/null +++ b/JLAW back/JLAW back/LogitechGkeyLib.h @@ -0,0 +1,60 @@ +// +// Logitech Gaming G-Key SDK +// +// Copyright (C) 2011-2014 Logitech. All rights reserved. +// Author: Tiziano Pigliucci +// Email: tpigliucci@logitech.com + +#pragma once +#include + +#define LOGITECH_MAX_MOUSE_BUTTONS 20 +#define LOGITECH_MAX_GKEYS 29 +#define LOGITECH_MAX_M_STATES 3 + +#pragma pack(push, 1) + +typedef struct +{ + unsigned int keyIdx : 8; // index of the G key or mouse button, for example, 6 for G6 or Button 6 + unsigned int keyDown : 1; // key up or down, 1 is down, 0 is up + unsigned int mState : 2; // mState (1, 2 or 3 for M1, M2 and M3) + unsigned int mouse : 1; // indicate if the Event comes from a mouse, 1 is yes, 0 is no. + unsigned int reserved1 : 4; // reserved1 + unsigned int reserved2 : 16; // reserved2 +} GkeyCode; + +// Callback used to allow client to react to the Gkey events. It is called in the context of another thread. +typedef void (__cdecl *logiGkeyCB)(GkeyCode gkeyCode, const wchar_t* gkeyOrButtonString, void* context); + +typedef struct +{ + logiGkeyCB gkeyCallBack; + void* gkeyContext; +} logiGkeyCBContext; + +// Enable the Gkey SDK by calling this function +BOOL LogiGkeyInit(logiGkeyCBContext* gkeyCBContext); + +// Enable the Gkey SDK by calling this function if not using callback. Use this initialization if using Unreal Engine +BOOL LogiGkeyInitWithoutCallback(); + +//Enable the Gkey SDK be calling this function if not using context. Use this initialization if working with Unity Engine +BOOL LogiGkeyInitWithoutContext(logiGkeyCB gkeyCallBack); + +// Check if a mouse button is currently pressed +BOOL LogiGkeyIsMouseButtonPressed(const int buttonNumber); + +// Get friendly name for mouse button +wchar_t* LogiGkeyGetMouseButtonString(const int buttonNumber); + +// Check if a keyboard G-key is currently pressed +BOOL LogiGkeyIsKeyboardGkeyPressed(const int gkeyNumber,const int modeNumber); + +// Get friendly name for G-key +wchar_t* LogiGkeyGetKeyboardGkeyString(const int gkeyNumber,const int modeNumber); + +// Disable the Gkey SDK, free up all the resources. +void LogiGkeyShutdown(); + +#pragma pack(pop) \ No newline at end of file diff --git a/JLAW back/JLAW back/LogitechLCDLib.h b/JLAW back/JLAW back/LogitechLCDLib.h new file mode 100644 index 0000000..a68bc3a --- /dev/null +++ b/JLAW back/JLAW back/LogitechLCDLib.h @@ -0,0 +1,47 @@ +// +// Logitech Gaming LCD SDK +// +// Copyright (C) 2011-2014 Logitech. All rights reserved. +// Author: Tiziano Pigliucci +// Email: tpigliucci@logitech.com + +#pragma once +#include + +#define LOGI_LCD_TYPE_MONO (0x00000001) +#define LOGI_LCD_TYPE_COLOR (0x00000002) + + +#define LOGI_LCD_MONO_BUTTON_0 (0x00000001) +#define LOGI_LCD_MONO_BUTTON_1 (0x00000002) +#define LOGI_LCD_MONO_BUTTON_2 (0x00000004) +#define LOGI_LCD_MONO_BUTTON_3 (0x00000008) + +#define LOGI_LCD_COLOR_BUTTON_LEFT (0x00000100) +#define LOGI_LCD_COLOR_BUTTON_RIGHT (0x00000200) +#define LOGI_LCD_COLOR_BUTTON_OK (0x00000400) +#define LOGI_LCD_COLOR_BUTTON_CANCEL (0x00000800) +#define LOGI_LCD_COLOR_BUTTON_UP (0x00001000) +#define LOGI_LCD_COLOR_BUTTON_DOWN (0x00002000) +#define LOGI_LCD_COLOR_BUTTON_MENU (0x00004000) + +const int LOGI_LCD_MONO_WIDTH = 160; +const int LOGI_LCD_MONO_HEIGHT = 43; + +const int LOGI_LCD_COLOR_WIDTH = 320; +const int LOGI_LCD_COLOR_HEIGHT = 240; + +bool LogiLcdInit(wchar_t* friendlyName, int lcdType); +bool LogiLcdIsConnected(int lcdType); +bool LogiLcdIsButtonPressed(int button); +void LogiLcdUpdate(); +void LogiLcdShutdown(); + +// Monochrome LCD functions +bool LogiLcdMonoSetBackground(BYTE monoBitmap[]); +bool LogiLcdMonoSetText(int lineNumber, wchar_t* text); + +// Color LCD functions +bool LogiLcdColorSetBackground(BYTE colorBitmap[]); +bool LogiLcdColorSetTitle(wchar_t* text, int red = 255, int green = 255, int blue = 255); +bool LogiLcdColorSetText(int lineNumber, wchar_t* text, int red = 255, int green = 255, int blue = 255); diff --git a/JLAW back/JLAW back/LogitechLEDLib.h b/JLAW back/JLAW back/LogitechLEDLib.h new file mode 100644 index 0000000..91c65bc --- /dev/null +++ b/JLAW back/JLAW back/LogitechLEDLib.h @@ -0,0 +1,159 @@ +// +// Logitech Gaming LED SDK +// +// Copyright (C) 2011-2014 Logitech. All rights reserved. +// Author: Tiziano Pigliucci +// Email: devtechsupport@logitech.com + +#pragma once +#include + +#define LOGI_LED_BITMAP_WIDTH 21 +#define LOGI_LED_BITMAP_HEIGHT 6 +#define LOGI_LED_BITMAP_BYTES_PER_KEY 4 + +#define LOGI_LED_BITMAP_SIZE (LOGI_LED_BITMAP_WIDTH*LOGI_LED_BITMAP_HEIGHT*LOGI_LED_BITMAP_BYTES_PER_KEY) + +#define LOGI_LED_DURATION_INFINITE 0 + +#define LOGI_DEVICETYPE_MONOCHROME_ORD 0 +#define LOGI_DEVICETYPE_RGB_ORD 1 +#define LOGI_DEVICETYPE_PERKEY_RGB_ORD 2 + +#define LOGI_DEVICETYPE_MONOCHROME (1 << LOGI_DEVICETYPE_MONOCHROME_ORD) +#define LOGI_DEVICETYPE_RGB (1 << LOGI_DEVICETYPE_RGB_ORD) +#define LOGI_DEVICETYPE_PERKEY_RGB (1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD) + +#define LOGI_DEVICETYPE_ALL (LOGI_DEVICETYPE_MONOCHROME | LOGI_DEVICETYPE_RGB | LOGI_DEVICETYPE_PERKEY_RGB) + + +namespace LogiLed +{ + typedef enum + { + ESC = 0x01, + F1 = 0x3b, + F2 = 0x3c, + F3 = 0x3d, + F4 = 0x3e, + F5 = 0x3f, + F6 = 0x40, + F7 = 0x41, + F8 = 0x42, + F9 = 0x43, + F10 = 0x44, + F11 = 0x57, + F12 = 0x58, + PRINT_SCREEN = 0x137, + SCROLL_LOCK = 0x46, + PAUSE_BREAK = 0x145, + TILDE = 0x29, + ONE = 0x02, + TWO = 0x03, + THREE = 0x04, + FOUR = 0x05, + FIVE = 0x06, + SIX = 0x07, + SEVEN = 0x08, + EIGHT = 0x09, + NINE = 0x0A, + ZERO = 0x0B, + MINUS = 0x0C, + EQUALS = 0x0D, + BACKSPACE = 0x0E, + INSERT = 0x152, + HOME = 0x147, + PAGE_UP = 0x149, + NUM_LOCK = 0x45, + NUM_SLASH = 0x135, + NUM_ASTERISK = 0x37, + NUM_MINUS = 0x4A, + TAB = 0x0F, + Q = 0x10, + W = 0x11, + E = 0x12, + R = 0x13, + T = 0x14, + Y = 0x15, + U = 0x16, + I = 0x17, + O = 0x18, + P = 0x19, + OPEN_BRACKET = 0x1A, + CLOSE_BRACKET = 0x1B, + BACKSLASH = 0x2B, + KEYBOARD_DELETE = 0x153, + END = 0x14F, + PAGE_DOWN = 0x151, + NUM_SEVEN = 0x47, + NUM_EIGHT = 0x48, + NUM_NINE = 0x49, + NUM_PLUS = 0x4E, + CAPS_LOCK = 0x3A, + A = 0x1E, + S = 0x1F, + D = 0x20, + F = 0x21, + G = 0x22, + H = 0x23, + J = 0x24, + K = 0x25, + L = 0x26, + SEMICOLON = 0x27, + APOSTROPHE = 0x28, + ENTER = 0x1C, + NUM_FOUR = 0x4B, + NUM_FIVE = 0x4C, + NUM_SIX = 0x4D, + LEFT_SHIFT = 0x2A, + Z = 0x2C, + X = 0x2D, + C = 0x2E, + V = 0x2F, + B = 0x30, + N = 0x31, + M = 0x32, + COMMA = 0x33, + PERIOD = 0x34, + FORWARD_SLASH = 0x35, + RIGHT_SHIFT = 0x36, + ARROW_UP = 0x148, + NUM_ONE = 0x4F, + NUM_TWO = 0x50, + NUM_THREE = 0x51, + NUM_ENTER = 0x11C, + LEFT_CONTROL = 0x1D, + LEFT_WINDOWS = 0x15B, + LEFT_ALT = 0x38, + SPACE = 0x39, + RIGHT_ALT = 0x138, + RIGHT_WINDOWS = 0x15C, + APPLICATION_SELECT = 0x15D, + RIGHT_CONTROL = 0x11D, + ARROW_LEFT = 0x14B, + ARROW_DOWN = 0x150, + ARROW_RIGHT = 0x14D, + NUM_ZERO = 0x52, + NUM_PERIOD = 0x53, + + }KeyName; +} + +bool LogiLedInit(); +bool LogiLedGetSdkVersion(int *majorNum, int *minorNum, int *buildNum); +bool LogiLedSetTargetDevice(int targetDevice); +bool LogiLedSaveCurrentLighting(); +bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage); +bool LogiLedRestoreLighting(); +bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval); +bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval); +bool LogiLedStopEffects(); +bool LogiLedSetLightingFromBitmap(BYTE bitmap[]); +bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); +bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); +bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); +bool LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage); +void LogiLedShutdown(); + + + diff --git a/JLAW front/pom.xml b/JLAW front/pom.xml new file mode 100644 index 0000000..b16bebc --- /dev/null +++ b/JLAW front/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + ninja.hon95.jlaw + jlaw + jar + 1.0.0 + JLAW + Java Logitech API Wrapper + https://github.com/HON95/JLAW + + + + UTF-8 + HON95 + 2015 + + + + + ${project.artifactId} + clean install + src/main/java + + + . + true + ${basedir}/src/main/resources/ + + LICENSE.txt + + + + + + maven-compiler-plugin + 3.3 + + 1.6 + 1.6 + + + + + \ No newline at end of file diff --git a/JLAW front/src/main/java/ninja/hon95/jlaw/JlawArxControl.java b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawArxControl.java new file mode 100644 index 0000000..d3a5f9e --- /dev/null +++ b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawArxControl.java @@ -0,0 +1,390 @@ +package ninja.hon95.jlaw; + +import ninja.hon95.jlaw.JlawUtil; + +/** + * JLAW Arx Control API + */ +public final class JlawArxControl { + + // Events // + public static final int LOGI_ARX_EVENT_FOCUS_ACTIVE = 0x01; + public static final int LOGI_ARX_EVENT_FOCUS_INACTIVE = 0x02; + public static final int LOGI_ARX_EVENT_TAP_ON_TAG = 0x04; + public static final int LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL = 0x08; + public static final int LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL = 0x10; + + // Device Types // + public static final int LOGI_ARX_DEVICETYPE_IPHONE = 0x01; + public static final int LOGI_ARX_DEVICETYPE_IPAD = 0x02; + public static final int LOGI_ARX_DEVICETYPE_ANDROID_SMALL = 0x03; + public static final int LOGI_ARX_DEVICETYPE_ANDROID_NORMAL = 0x04; + public static final int LOGI_ARX_DEVICETYPE_ANDROID_LARGE = 0x05; + public static final int LOGI_ARX_DEVICETYPE_ANDROID_XLARGE = 0x06; + public static final int LOGI_ARX_DEVICETYPE_ANDROID_OTHER = 0x07; + + // Error Text Descriptions // + private static final String[] ERROR_TEXT = { + "Success", + "Wrong parameter format", + "Null parameter not supported", + "Wrong file path", + "SDK not initialized", + "SDK already initialized", + "Connection with Logitech Gaming Software broken", + "Error creating thread", + "Error copying memory" + }; + + /** + * Initializes the Arx Control system. + * + * @param identifier + * A unique identifier for your applet. Capped to 128 characters. + * @param friendlyName + * A friendly name for your applet. + * @param callback + * Callback for events from the applet. + * @return If the initialization was successful. + */ + public static boolean logiArxInit(String identifier, String friendlyName, JlawArxControlCallback callback) { + if (identifier == null || friendlyName == null) + throw new NullPointerException(); + return nLogiArxInit(identifier, friendlyName, callback); + } + + private static native boolean nLogiArxInit(String identifier, String friendlyName, JlawArxControlCallback callback); + + /** + * Sends a file to Arx Control. + * + * @param filePath + * Path to file on local file system. + * @param fileName + * ID to reference from the applet. + * @return If it was successful. + */ + public static boolean logiArxAddFileAs(String filePath, String fileName) { + if (filePath == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddFileAs(filePath, fileName, ""); + } + + /** + * Sends a file to Arx Control. + * + * @param filePath + * Path to file on local file system. + * @param fileName + * ID to reference from the applet. Capped to 256 characters. + * @param mimeType + * MIME type of the file content. + * @return If it was successful. + */ + public static boolean logiArxAddFileAs(String filePath, String fileName, String mimeType) { + if (filePath == null || fileName == null || mimeType == null) + throw new NullPointerException(); + return nLogiArxAddFileAs(filePath, fileName, mimeType); + } + + private static native boolean nLogiArxAddFileAs(String filePath, String fileName, String mimeType); + + /** + * Sends a block of bytes to Arx Control. + * + * @param intContent + * Array of data to send, in the form of ints. Each int should only hold only one byte of data. + * @param fileName + * ID to reference from the applet. Capped to 256 characters. + * @return If it was successful. + * @see #logiArxAddFileAs(byte[], String) + */ + public static boolean logiArxAddContentAs(int[] intContent, String fileName) { + if (intContent == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddContentAs(JlawUtil.toUBytesFromInts(intContent), fileName, ""); + } + + /** + * Sends a block of bytes to Arx Control.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param content + * Array of data to send, in the form of "unsigned" bytes. + * @param fileName + * ID to reference from the applet. Capped to 256 characters. + * @return If it was successful. + * @see #logiArxAddFileAs(int[], String) + */ + public static boolean logiArxAddContentAs(byte[] content, String fileName) { + if (content == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddContentAs(content, fileName, ""); + } + + /** + * Sends a block of bytes to Arx Control. + * + * @param intContent + * Array of data to send, in the form of ints. Each int should only hold one byte of data. + * @param fileName + * ID to reference from the applet. Capped to 256 characters. + * @param mimeType + * MIME type of content. + * @return If it was successful. + * @see #logiArxAddFileAs(byte[], String, String) + */ + public static boolean logiArxAddContentAs(int[] intContent, String fileName, String mimeType) { + if (intContent == null || fileName == null || mimeType == null) + throw new NullPointerException(); + return nLogiArxAddContentAs(JlawUtil.toUBytesFromInts(intContent), fileName, mimeType); + } + + /** + * Sends a block of bytes to Arx Control.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param content + * Array of data to send, in the form of "unsigned" bytes. + * @param fileName + * ID to reference from the applet. Capped to 256 characters. + * @param mimeType + * MIME type of content. + * @return If it was successful. + * @see #logiArxAddFileAs(int[], String, String) + */ + public static boolean logiArxAddContentAs(byte[] content, String fileName, String mimeType) { + if (content == null || fileName == null || mimeType == null) + throw new NullPointerException(); + return nLogiArxAddContentAs(content, fileName, mimeType); + } + + private static native boolean nLogiArxAddContentAs(byte[] content, String fileName, String mimeType); + + /** + * Saves a UTF-8 encoded string in a file and sends it to Arx Control. + * + * @param stringContent + * UTF-8 encoded string. + * @param fileName + * ID to reference from applet. + * @return If it was successful. + */ + public static boolean logiArxAddUTF8StringAs(String stringContent, String fileName) { + if (stringContent == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddUTF8StringAs(stringContent, fileName, ""); + } + + /** + * Saves a UTF-8 encoded string in a file and sends it to Arx Control. + * + * @param stringContent + * UTF-8 encoded string. + * @param fileName + * ID to reference from applet. + * @param mimeType + * MIME type of content + * @return If it was successful. + */ + public static boolean logiArxAddUTF8StringAs(String stringContent, String fileName, String mimeType) { + if (stringContent == null || fileName == null || mimeType == null) + throw new NullPointerException(); + return nLogiArxAddUTF8StringAs(stringContent, fileName, mimeType); + } + + private static native boolean nLogiArxAddUTF8StringAs(String stringContent, String fileName, String mimeType); + + /** + * Compresses and saves an image to a PNG file and sends it to Arx Control. + * + * @param intBitmap + * A byte array containing the image. Each int should contain only one byte. BGRA-encoded. + * @param width + * Width of image. + * @param height + * Height of image. + * @param fileName + * ID to reference from the applet. + * @return If it was successful. + * @see #logiArxAddImageFromBitmap(byte[], int, int, String) + */ + public static boolean logiArxAddImageFromBitmap(int[] intBitmap, int width, int height, String fileName) { + if (intBitmap == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddImageFromBitmap(JlawUtil.toUBytesFromInts(intBitmap), width, height, fileName); + } + + /** + * Compresses and saves an image to a PNG file and sends it to Arx Control.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param bitmap + * A byte array containing the image. BGRA-encoded. + * @param width + * Width of image. + * @param height + * Height of image. + * @param fileName + * ID to reference from the applet. + * @return If it was successful. + * @see #logiArxAddImageFromBitmap(byte[], int, int, String) + */ + public static boolean logiArxAddImageFromBitmap(byte[] bitmap, int width, int height, String fileName) { + if (bitmap == null || fileName == null) + throw new NullPointerException(); + return nLogiArxAddImageFromBitmap(bitmap, width, height, fileName); + } + + private static native boolean nLogiArxAddImageFromBitmap(byte[] bitmap, int width, int height, String fileName); + + /** + * Sets which page is to be displayed on Arx Control. + * + * @param fileName + * Reference to file to display. + * @return If it was successful. + */ + public static boolean logiArxSetIndex(String fileName) { + if (fileName == null) + throw new NullPointerException(); + return nLogiArxSetIndex(fileName); + } + + private static native boolean nLogiArxSetIndex(String fileName); + + /** + * Updates a tag property in the applet HTML pages. + * + * @param tagId + * Tag. Capped to 128 characters. + * @param prop + * Tag property. Capped to 128 characters. + * @param newValue + * New value for property on tag. Capped to 128 characters. + * @return If it was successful. + */ + public static boolean logiArxSetTagPropertyById(String tagId, String prop, String newValue) { + if (tagId == null || prop == null || newValue == null) + throw new NullPointerException(); + return nLogiArxSetTagPropertyById(tagId, prop, newValue); + } + + private static native boolean nLogiArxSetTagPropertyById(String tagId, String prop, String newValue); + + /** + * Updates properties on a class of tags in the applet HTML pages. + * + * @param tagsClass + * Tag class. Capped to 128 characters. + * @param prop + * Tag property. Capped to 128 characters. + * @param newValue + * New value for tag properties in class. Capped to 128 characters. + * @return If it was successful. + */ + public static boolean logiArxSetTagsPropertyByClass(String tagsClass, String prop, String newValue) { + if (tagsClass == null || prop == null || newValue == null) + throw new NullPointerException(); + return nLogiArxSetTagsPropertyByClass(tagsClass, prop, newValue); + } + + private static native boolean nLogiArxSetTagsPropertyByClass(String tagsClass, String prop, String newValue); + + /** + * Updates the content of a tag in the applet HTML pages. + * + * @param tagId + * Tag. Capped to 128 characters. + * @param newContent + * New tag content. Capped to 128 characters. + * @return If it was successful. + */ + public static boolean logiArxSetTagContentById(String tagId, String newContent) { + if (tagId == null || newContent == null) + throw new NullPointerException(); + return nLogiArxSetTagContentById(tagId, newContent); + } + + private static native boolean nLogiArxSetTagContentById(String tagId, String newContent); + + /** + * Updates the content of a class of tags in the applet HTML pages. + * + * @param tagsClass + * Tag class. Capped to 128 characters. + * @param newContent + * New content of tags in class. Capped to 128 characters. + * @return + */ + public static boolean logiArxSetTagsContentByClass(String tagsClass, String newContent) { + if (tagsClass == null || newContent == null) + throw new NullPointerException(); + return nLogiArxSetTagsContentByClass(tagsClass, newContent); + } + + private static native boolean nLogiArxSetTagsContentByClass(String tagsClass, String newContent); + + /** + * Returns the last error from SDK function calls. + * + * @return Error code. + * @see #logiArxGetErrorText + */ + public static int logiArxGetLastError() { + return nLogiArxGetLastError(); + } + + private static native int nLogiArxGetLastError(); + + /** + * Shut down the Arx Control system. + */ + public static void logiArxShutdown() { + nLogiArxShutdown(); + } + + private static native void nLogiArxShutdown(); + + /** + * Returns text for the common error codes. + * + * @param errorCode + * Error code to get text for. + * @return Text of error. + * @see logiArxGetLastError + */ + public static String logiArxGetErrorText(int errorCode) { + if (errorCode >= 0 && errorCode < ERROR_TEXT.length) + return ERROR_TEXT[errorCode]; + return null; + } + + private JlawArxControl() {} + + /** + * Callback for Arx events. Needs to be thread safe. + */ + public interface JlawArxControlCallback { + + /** + * Called when Arx events happen. + * + * @param eventType + * Type of event.
+ * Possible values: + *
    + *
  • LOGI_ARX_EVENT_FOCUS_ACTIVE
  • + *
  • LOGI_ARX_EVENT_FOCUS_INACTIVE
  • + *
  • LOGI_ARX_EVENT_TAP_ON_TAG
  • + *
  • LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL
  • + *
  • LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL
  • + *
+ * @param eventValue + * Value of event. + * @param eventArg + * Additional argument of event. + */ + public void call(int eventType, int eventValue, String eventArg); + } +} diff --git a/JLAW front/src/main/java/ninja/hon95/jlaw/JlawGkey.java b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawGkey.java new file mode 100644 index 0000000..1cb03b5 --- /dev/null +++ b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawGkey.java @@ -0,0 +1,126 @@ +package ninja.hon95.jlaw; + +/** + * JLAW G-key API + */ +public final class JlawGkey { + + public static final int LOGI_MAX_MOUSE_BUTTONS = 20; + public static final int LOGI_MAX_GKEYS = 29; + public static final int LOGI_MAX_M_STATES = 3; + + /** + * Initialized the G-key system. + * + * @param callback + * Callback for G-key events. + * @return If the initialization was successful. + */ + public static boolean logiGkeyInit(JlawGkeyCallback callback) { + if (callback == null) + throw new NullPointerException(); + return nLogiGkeyInit(callback); + } + + private static native boolean nLogiGkeyInit(JlawGkeyCallback callback); + + /** + * Initialize the G-key system without a callback for G-key events. + * + * @return If the initialization was successful. + */ + public static boolean logiGkeyInitWithoutCallback() { + return nLogiGkeyInitWithoutCallback(); + } + + private static native boolean nLogiGkeyInitWithoutCallback(); + + /** + * Check if a mouse button is pressed. + * + * @param buttonNumber + * Mouse button number. + * @return If the button is pressed. + */ + public static boolean logiGkeyIsMouseButtonPressed(int buttonNumber) { + return nLogiGkeyIsMouseButtonPressed(buttonNumber); + } + + private static native boolean nLogiGkeyIsMouseButtonPressed(int buttonNumber); + + /** + * Returns a friendly name for the mouse button. + * + * @param buttonNumber + * Mouse button number. + * @return Friendly name for mouse button. + */ + public static String logiGkeyGetMouseButtonString(int buttonNumber) { + return nLogiGkeyGetMouseButtonString(buttonNumber); + } + + private static native String nLogiGkeyGetMouseButtonString(int buttonNumber); + + /** + * Check if keyboard G-key is pressed and if specified mode is active. + * + * @param gkeyNumber + * G-key number. + * @param modeNumber + * Mode number. + * @return If the G-key is pressed and specified mode is active. + */ + public static boolean logiGkeyIsKeyboardGkeyPressed(int gkeyNumber, int modeNumber) { + return nLogiGkeyIsKeyboardGkeyPressed(gkeyNumber, modeNumber); + } + + private static native boolean nLogiGkeyIsKeyboardGkeyPressed(int gkeyNumber, int modeNumber); + + /** + * Returns a friendly name for the G-key for specified mode. + * + * @param gkeyNumber + * G-key number. + * @param modeNumber + * Mode number. + * @return Friendly name for G-key in mode. + */ + public static String logiGkeyGetKeyboardGkeyString(int gkeyNumber, int modeNumber) { + return nLogiGkeyGetKeyboardGkeyString(gkeyNumber, modeNumber); + } + + private static native String nLogiGkeyGetKeyboardGkeyString(int gkeyNumber, int modeNumber); + + /** + * Shutdown the G-key system. + */ + public static void logiGkeyShutdown() { + nLogiGkeyShutdown(); + } + + private static native void nLogiGkeyShutdown(); + + private JlawGkey() {} + + /** + * Callback for JLAW G-key API. Needs to be thread safe. + */ + public interface JlawGkeyCallback { + + /** + * Called when G-key events happen. + * + * @param keyIndex + * Index of the G-key or mouse button + * @param keyDown + * If the button is pressed + * @param mState + * M state + * @param fromMouse + * If the event comes from a mouse + * @param gkeyName + * Name of G-key or button + */ + public void call(int keyIndex, boolean keyDown, int mState, boolean fromMouse, String gkeyName); + } +} diff --git a/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLcd.java b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLcd.java new file mode 100644 index 0000000..8d48d01 --- /dev/null +++ b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLcd.java @@ -0,0 +1,305 @@ +package ninja.hon95.jlaw; + +import ninja.hon95.jlaw.JlawUtil; + +/** + * JLAW LCD API + */ +public final class JlawLcd { + + // LCD types // + public static final int LOGI_LCD_TYPE_MONO = 0x01; + public static final int LOGI_LCD_TYPE_COLOR = 0x02; + public static final int LOGI_LCD_TYPE_BOTH = LOGI_LCD_TYPE_MONO | LOGI_LCD_TYPE_COLOR; + + // Monochrome buttons // + public static final int LOGI_LCD_MONO_BUTTON_0 = 0x01; + public static final int LOGI_LCD_MONO_BUTTON_1 = 0x02; + public static final int LOGI_LCD_MONO_BUTTON_2 = 0x04; + public static final int LOGI_LCD_MONO_BUTTON_3 = 0x08; + + // Color buttons // + public static final int LOGI_LCD_COLOR_BUTTON_LEFT = 0x0100; + public static final int LOGI_LCD_COLOR_BUTTON_RIGHT = 0x0200; + public static final int LOGI_LCD_COLOR_BUTTON_OK = 0x0400; + public static final int LOGI_LCD_COLOR_BUTTON_CANCEL = 0x0800; + public static final int LOGI_LCD_COLOR_BUTTON_UP = 0x1000; + public static final int LOGI_LCD_COLOR_BUTTON_DOWN = 0x2000; + public static final int LOGI_LCD_COLOR_BUTTON_MENU = 0x4000; + + // Screen sizes // + public static final int LOGI_LCD_MONO_WIDTH = 160; + public static final int LOGI_LCD_MONO_HEIGHT = 43; + public static final int LOGI_LCD_COLOR_WIDTH = 320; + public static final int LOGI_LCD_COLOR_HEIGHT = 240; + + // Bitmaps // + public static final int LOGI_LCD_MONO_BITMAP_SIZE = LOGI_LCD_MONO_WIDTH * LOGI_LCD_MONO_HEIGHT; + public static final int LOGI_LCD_COLOR_BITMAP_BYTES_PER_PIXEL = 4; + public static final int LOGI_LCD_COLOR_BITMAP_SIZE = LOGI_LCD_COLOR_WIDTH * LOGI_LCD_COLOR_HEIGHT * LOGI_LCD_COLOR_BITMAP_BYTES_PER_PIXEL; + + /** + * Initializes your applet. + * + * @param friendlyName + * Name of applet. + * @param lcdType + * LCD type.
+ * Possible values: + *
    + *
  • LOGI_LCD_TYPE_MONO
  • + *
  • LOGI_LCD_TYPE_COLOR
  • + *
  • LOGI_LCD_TYPE_MONO | LOGI_LCD_TYPE_COLOR
  • + *
+ * @return If the initialization was successful. + */ + public static boolean logiLcdInit(String friendlyName, int lcdType) { + if (friendlyName == null) + throw new NullPointerException(); + return nLogiLcdInit(friendlyName, lcdType); + } + + private static native boolean nLogiLcdInit(String friendlyName, int lcdType); + + /** + * Check if LCD device is connected.
+ * Note: Applet must be initialized first. + * + * @param lcdType + * LCD type.
+ * Possible values: + *
    + *
  • LOGI_LCD_TYPE_MONO
  • + *
  • LOGI_LCD_TYPE_COLOR
  • + *
  • LOGI_LCD_TYPE_MONO | LOGI_LCD_TYPE_COLOR
  • + *
+ * @return If the LCD device is connected. + */ + public static boolean logiLcdIsConnected(int lcdType) { + return nLogiLcdIsConnected(lcdType); + } + + private static native boolean nLogiLcdIsConnected(int lcdType); + + /** + * Checks if a specified button on the LCD device is pressed.
+ * Note: The button will be considered pressed only if your applet is the one currently in the foreground. + * + * @param button + * Button ID.
+ * Possible values: + *
    + *
  • LOGI_LCD_MONO_BUTTON_0
  • + *
  • LOGI_LCD_MONO_BUTTON_1
  • + *
  • LOGI_LCD_MONO_BUTTON_2
  • + *
  • LOGI_LCD_MONO_BUTTON_3
  • + *
  • LOGI_LCD_COLOR_BUTTON_LEFT
  • + *
  • LOGI_LCD_COLOR_BUTTON_RIGHT
  • + *
  • LOGI_LCD_COLOR_BUTTON_OK
  • + *
  • LOGI_LCD_COLOR_BUTTON_CANCEL
  • + *
  • LOGI_LCD_COLOR_BUTTON_UP
  • + *
  • LOGI_LCD_COLOR_BUTTON_DOWN
  • + *
  • LOGI_LCD_COLOR_BUTTON_MENU
  • + *
+ * @return If the button is pressed. + */ + public static boolean logiLcdIsButtonPressed(int button) { + return nLogiLcdIsButtonPressed(button); + } + + private static native boolean nLogiLcdIsButtonPressed(int button); + + /** + * Updates the display.
+ * Should be called every frame of your main loop. + */ + public static void logiLcdUpdate() { + nLogiLcdUpdate(); + } + + private static native void nLogiLcdUpdate(); + + /** + * Shuts down your applet. + */ + public static void logiLcdShutdown() { + nLogiLcdShutdown(); + } + + private static native void nLogiLcdShutdown(); + + /** + * Sets the specified monochrome image as the background.
+ * Note: Since bytes in Java are signed, this method takes an array of ints instead. + * + * @param intMonoBitmap + * The image as a monochrome bitmap. Every pixel consists of 8 bits (0-255) and stored in one array element. + * Ordered in rows from top left to bottom right. The width and height of the monochrome display is 160 x 43, so the array must consist of 6880 + * elements. + * @return If it was successful. + * @see #logiLcdMonoSetBackground(byte[]) + */ + public static boolean logiLcdMonoSetBackground(int[] intMonoBitmap) { + if (intMonoBitmap == null) + throw new NullPointerException(); + if (intMonoBitmap.length != LOGI_LCD_MONO_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLcdMonoSetBackground(JlawUtil.toUBytesFromInts(intMonoBitmap)); + } + + /** + * Sets the specified monochrome image as the background.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param monoBitmap + * The image as a monochrome bitmap. Every pixel consists of 8 bits (0-255) and stored in one array element. + * Ordered in rows from top left to bottom right. The width and height of the monochrome display is 160 x 43, so the array must consist of 6880 + * elements. + * @return If it was successful. + * @see #logiLcdMonoSetBackground(int[]) + */ + public static boolean logiLcdMonoSetBackground(byte[] monoBitmap) { + if (monoBitmap == null) + throw new NullPointerException(); + if (monoBitmap.length != LOGI_LCD_MONO_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLcdMonoSetBackground(monoBitmap); + } + + private static native boolean nLogiLcdMonoSetBackground(byte[] monoBitmap); + + /** + * Sets the text for a specified line number. + * + * @param lineNumber + * The line number. Monochrome displays can have 4 lines, so this value must range from 0 to 3. + * @param text + * The text to be displayed. + * @return If it was successful. + */ + public static boolean logiLcdMonoSetText(int lineNumber, String text) { + if (text == null) + throw new NullPointerException(); + return nLogiLcdMonoSetText(lineNumber, text); + } + + private static native boolean nLogiLcdMonoSetText(int lineNumber, String text); + + /** + * Sets the specified color image as the background.
+ * Note: Since bytes in Java are signed, this method takes an array of shorts instead. + * + * @param shortColorBitmap + * The image as a color bitmap. Every pixel consists of 32 bits stored as BGRA with 8 bits each (0-255), and each byte stored in one array + * element. + * Ordered in rows from top left to bottom right. The width and height of the color display is 320 x 240 and each pixel has 4 components, + * so the array must consist of 307200 elements. + * @return If it was successful. + * @see #logiLcdColorSetBackground(byte) + */ + public static boolean logiLcdColorSetBackground(int[] intColorBitmap) { + if (intColorBitmap == null) + throw new NullPointerException(); + if (intColorBitmap.length != LOGI_LCD_COLOR_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLcdColorSetBackground(JlawUtil.toUBytesFromInts(intColorBitmap)); + } + + /** + * Sets the specified color image as the background.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param colorBitmap + * The image as a color bitmap. Every pixel consists of 32 bits stored as BGRA with 8 bits each (0-255), and each byte stored in one array + * element. + * Ordered in rows from top left to bottom right. The width and height of the color display is 320 x 240 and each pixel has 4 components, + * so the array must consist of 307200 elements. + * @return If it was successful. + * @see #logiLcdColorSetBackground(int[]) + */ + public static boolean logiLcdColorSetBackground(byte[] colorBitmap) { + if (colorBitmap == null) + throw new NullPointerException(); + if (colorBitmap.length != LOGI_LCD_COLOR_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLcdColorSetBackground(colorBitmap); + } + + private static native boolean nLogiLcdColorSetBackground(byte[] colorBitmap); + + /** + * Sets the title at the top of the display as white text. + * + * @param title + * The title. + * @return If it was successful. + * @see #logiLcdColorSetTitle(String, int, int, int) + */ + public static boolean logiLcdColorSetTitle(String title) { + if (title == null) + throw new NullPointerException(); + return logiLcdColorSetTitle(title, 255, 255, 255); + } + + /** + * Sets the title at the top of the display. + * + * @param title + * The title. + * @param red + * Red color component. + * @param green + * Green color component. + * @param blue + * Blue color component. + * @return If it was successful. + */ + public static boolean logiLcdColorSetTitle(String title, int red, int green, int blue) { + if (title == null) + throw new NullPointerException(); + return nLogiLcdColorSetTitle(title, red, green, blue); + } + + private static native boolean nLogiLcdColorSetTitle(String title, int red, int green, int blue); + + /** + * Sets the text for the specified line as white text. + * + * @param lineNumber + * The line number. Color displays have 8 lines, so this value must range from 0 to 7. Characters are fixed-width and one line can hold 29 of + * them. + * @param text + * The text. + * @return If it was successful. + * @see #logiLcdColorSetText(int, String, int, int, int) + */ + public static boolean logiLcdColorSetText(int lineNumber, String text) { + if (text == null) + throw new NullPointerException(); + return logiLcdColorSetText(lineNumber, text, 255, 255, 255); + } + + /** + * Sets the text for the specified line. + * + * @param lineNumber + * The line number. Color displays have 8 lines, so this value must range from 0 to 7. Characters are fixed-width and one line can hold 29 of + * them. + * @param text + * The text. + * @param red + * Red color component. + * @param green + * Green color component. + * @param blue + * Blue color component. + * @return If it was successful. + */ + public static boolean logiLcdColorSetText(int lineNumber, String text, int red, int green, int blue) { + return nLogiLcdColorSetText(lineNumber, text, red, green, blue); + } + + private static native boolean nLogiLcdColorSetText(int lineNumber, String text, int red, int green, int blue); + + private JlawLcd() {} +} diff --git a/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLed.java b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLed.java new file mode 100644 index 0000000..d58c7a9 --- /dev/null +++ b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawLed.java @@ -0,0 +1,403 @@ +package ninja.hon95.jlaw; + +import ninja.hon95.jlaw.JlawUtil; + +/** + * JLAW LED API + */ +public final class JlawLed { + + // Key bitmap // + public static final int LOGI_LED_BITMAP_WIDTH = 21; + public static final int LOGI_LED_BITMAP_HEIGHT = 6; + public static final int LOGI_LED_BITMAP_BYTES_PER_KEY = 6; + public static final int LOGI_LED_BITMAP_SIZE = LOGI_LED_BITMAP_WIDTH * LOGI_LED_BITMAP_HEIGHT * LOGI_LED_BITMAP_BYTES_PER_KEY; + + // Device types // + public static final int LOGI_LED_DEVICETYPE_MONOCHROME = 0x01; + public static final int LOGI_LED_DEVICETYPE_RGB = 0x02; + public static final int LOGI_LED_DEVICETYPE_PERKEY_RGB = 0x04; + public static final int LOGI_LED_DEVICETYPE_ALL = LOGI_LED_DEVICETYPE_MONOCHROME | LOGI_LED_DEVICETYPE_RGB | LOGI_LED_DEVICETYPE_PERKEY_RGB; + + // Other // + public static final int LOGI_LED_DURATION_INFINATE = 0; + + /** + * Initialize the LED system. + * + * @return If it was successful. + */ + public static boolean logiLedInit() { + return nLogiLedInit(); + } + + private static native boolean nLogiLedInit(); + + /** + * Returns the SDK version installed. + * + * @return SDK version. Contains major, minor and build numbers separated by a period ("."). + */ + public static String logiLedGetSdkVersion() { + return nLogiLedGetSdkVersion(); + } + + private static native String nLogiLedGetSdkVersion(); + + /** + * Sets the target device. By default, all devices are accepted. + * + * @param targetDevice + * Target device(s). Multiple values can be bitwisely OR-ed together.
+ * Possible values: + *
    + *
  • LOGI_LED_DEVICETYPE_MONOCHROME
  • + *
  • LOGI_LED_DEVICETYPE_RGB
  • + *
  • LOGI_LED_DEVICETYPE_PERKEY_RGB
  • + *
  • LOGI_LED_DEVICETYPE_ALL
  • + *
+ * + */ + public static boolean logiLedSetTargetDevice(int targetDevice) { + return nLogiLedSetTargetDevice(targetDevice); + } + + private static native boolean nLogiLedSetTargetDevice(int targetDevice); + + /** + * Saves the lighting. + * + * @return If it was successful. + * @see #logiLedRestoreLighting + */ + public static boolean logiLedSaveCurrentLighting() { + return nLogiLedSaveCurrentLighting(); + } + + private static native boolean nLogiLedSaveCurrentLighting(); + + /** + * Sets the lighting. For devices that only support a single color, the highest percentage of the three will define the intensity. + * + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @return If it was successful. + */ + public static boolean logiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage) { + return nLogiLedSetLighting(redPercentage, greenPercentage, bluePercentage); + } + + private static native boolean nLogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage); + + /** + * Restores the last saved lighting. + * + * @return If it was successful. + * @see #logiLedSaveCurrentLighting + */ + public static boolean logiLedRestoreLighting() { + return nLogiLedRestoreLighting(); + } + + private static native boolean nLogiLedRestoreLighting(); + + /** + * Plays a flashing effect and then restores the lighting. + * + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @param milliSecondsDuration + * Duration of effect in milliseconds. Can be set to LOGI_LED_DURATION_INFINATE to last indefinitely. + * @param milliSecondsInterval + * Duration of flashing intervals in milliseconds. + * @return If it was successful. + * @see #logiLedStopEffects + */ + public static boolean logiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval) { + return nLogiLedFlashLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval); + } + + private static native boolean nLogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval); + + /** + * Plays a pulsing effect and then restores the lighting. + * + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @param milliSecondsDuration + * Duration of effect in milliseconds. Can be set to LOGI_LED_DURATION_INFINATE to last indefinitely. + * @param milliSecondsInterval + * Duration of pulsing intervals in milliseconds. + * @return If it was successful. + * @see #logiLedStopEffects + */ + public static boolean logiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval) { + return nLogiLedPulseLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval); + } + + private static native boolean nLogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval); + + /** + * Stops active effects. + * + * @return If it was successful. + */ + public static boolean logiLedStopEffects() { + return nLogiLedStopEffects(); + } + + private static native boolean nLogiLedStopEffects(); + + /** + * Sets the lighting from a bitmap. + * + * @param intBitmap + * Bitmap of key colors. Each int should only hold only one byte of data. RGBA encoded. Must be the same size as LOGI_LED_BITMAP_SIZE. + * @return If it was successful. + */ + public static boolean logiLedSetLightingFromBitmap(int[] intBitmap) { + if (intBitmap == null) + throw new NullPointerException(); + if (intBitmap.length != LOGI_LED_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLedSetLightingFromBitmap(JlawUtil.toUBytesFromInts(intBitmap)); + } + + /** + * Sets the lighting from a bitmap.
+ * Note: Since bytes in Java are signed, values between 128 and 255 are written from -128 to -1. + * + * @param bitmap + * Bitmap of key colors. RGBA encoded. Must be the same size as LOGI_LED_BITMAP_SIZE. + * @return If it was successful. + */ + public static boolean logiLedSetLightingFromBitmap(byte[] bitmap) { + if (bitmap == null) + throw new NullPointerException(); + if (bitmap.length != LOGI_LED_BITMAP_SIZE) + throw new IllegalArgumentException("Wrong bitmap size"); + return nLogiLedSetLightingFromBitmap(bitmap); + } + + private static native boolean nLogiLedSetLightingFromBitmap(byte[] bitmap); + + /** + * Sets the color of a key using its scan code. + * + * @param keyCode + * Scan code for the key. + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @return If it was successful. + */ + public static boolean logiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) { + return nLogiLedSetLightingForKeyWithScanCode(keyCode, redPercentage, greenPercentage, bluePercentage); + } + + private static native boolean nLogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); + + /** + * Sets the color of a key using its HID code. + * + * @param keyCode + * HID code for the key. + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @return If it was successful. + */ + public static boolean logiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) { + return nLogiLedSetLightingForKeyWithHidCode(keyCode, redPercentage, greenPercentage, bluePercentage); + } + + private static native boolean nLogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); + + /** + * Sets the color of a key using its quartz code. + * + * @param keyCode + * Quartz code for the key. + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @return If it was successful. + */ + public static boolean logiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) { + return nLogiLedSetLightingForKeyWithQuartzCode(keyCode, redPercentage, greenPercentage, bluePercentage); + } + + private static native boolean nLogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage); + + /** + * Sets the color of a key using its key name. + * + * @param keyCode + * Key name. + * @param redPercentage + * Red percentage. + * @param greenPercentage + * Green percentage. + * @param bluePercentage + * Blue percentage. + * @return If it was successful. + */ + public static boolean logiLedSetLightingForKeyWithKeyName(KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage) { + return nLogiLedSetLightingForKeyWithKeyName(keyName.getCode(), redPercentage, greenPercentage, bluePercentage); + } + + private static native boolean nLogiLedSetLightingForKeyWithKeyName(int keyName, int redPercentage, int greenPercentage, int bluePercentage); + + /** + * Shuts down the LED system. + */ + public static void logiLedShutdown() { + nLogiLedShutdown(); + } + + private static native void nLogiLedShutdown(); + + private JlawLed() {} + + /** + * KeyNames for JLAW LED API + */ + public enum KeyName { + + ESC(0x01), + F1(0x3b), + F2(0x3c), + F3(0x3d), + F4(0x3e), + F5(0x3f), + F6(0x40), + F7(0x41), + F8(0x42), + F9(0x43), + F10(0x44), + F11(0x57), + F12(0x58), + PRINT_SCREEN(0x137), + SCROLL_LOCK(0x46), + PAUSE_BREAK(0x145), + TILDE(0x29), + ONE(0x02), + TWO(0x03), + THREE(0x04), + FOUR(0x05), + FIVE(0x06), + SIX(0x07), + SEVEN(0x08), + EIGHT(0x09), + NINE(0x0A), + ZERO(0x0B), + MINUS(0x0C), + EQUALS(0x0D), + BACKSPACE(0x0E), + INSERT(0x152), + HOME(0x147), + PAGE_UP(0x149), + NUM_LOCK(0x45), + NUM_SLASH(0x135), + NUM_ASTERISK(0x37), + NUM_MINUS(0x4A), + TAB(0x0F), + Q(0x10), + W(0x11), + E(0x12), + R(0x13), + T(0x14), + Y(0x15), + U(0x16), + I(0x17), + O(0x18), + P(0x19), + OPEN_BRACKET(0x1A), + CLOSE_BRACKET(0x1B), + BACKSLASH(0x2B), + KEYBOARD_DELETE(0x153), + END(0x14F), + PAGE_DOWN(0x151), + NUM_SEVEN(0x47), + NUM_EIGHT(0x48), + NUM_NINE(0x49), + NUM_PLUS(0x4E), + CAPS_LOCK(0x3A), + A(0x1E), + S(0x1F), + D(0x20), + F(0x21), + G(0x22), + H(0x23), + J(0x24), + K(0x25), + L(0x26), + SEMICOLON(0x27), + APOSTROPHE(0x28), + ENTER(0x1C), + NUM_FOUR(0x4B), + NUM_FIVE(0x4C), + NUM_SIX(0x4D), + LEFT_SHIFT(0x2A), + Z(0x2C), + X(0x2D), + C(0x2E), + V(0x2F), + B(0x30), + N(0x31), + M(0x32), + COMMA(0x33), + PERIOD(0x34), + FORWARD_SLASH(0x35), + RIGHT_SHIFT(0x36), + ARROW_UP(0x148), + NUM_ONE(0x4F), + NUM_TWO(0x50), + NUM_THREE(0x51), + NUM_ENTER(0x11C), + LEFT_CONTROL(0x1D), + LEFT_WINDOWS(0x15B), + LEFT_ALT(0x38), + SPACE(0x39), + RIGHT_ALT(0x138), + RIGHT_WINDOWS(0x15C), + APPLICATION_SELECT(0x15D), + RIGHT_CONTROL(0x11D), + ARROW_LEFT(0x14B), + ARROW_DOWN(0x150), + ARROW_RIGHT(0x14D), + NUM_ZERO(0x52), + NUM_PERIOD(0x53); + + private final int gCode; + + private KeyName(int code) { + gCode = code; + } + + public int getCode() { + return gCode; + } + } +} diff --git a/JLAW front/src/main/java/ninja/hon95/jlaw/JlawUtil.java b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawUtil.java new file mode 100644 index 0000000..ccd5f24 --- /dev/null +++ b/JLAW front/src/main/java/ninja/hon95/jlaw/JlawUtil.java @@ -0,0 +1,97 @@ +package ninja.hon95.jlaw; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public final class JlawUtil { + + /** + * Extracts and loads the appropriate version of the native JLAW dll file from the current folder. + * The folder can be either inside or outside the Java file system/environment. + * You are free to load the library yourself, this is only for convenience. + * + * @param folderPath + * The folder containing 'jlaw.dll' for 32-bit and jlaw64.dll for 64-bit systems. + * For example "/natives/". Cannot be null. + * @param referenceClass + * A class inside the Java file system/environment. If this is null, this method will look in the normal file system instead. + * @return If the loading was successful. + * @throws UnsatisfiedLinkError + * if the library cannot be loaded. + * @throws IOException + * if there was a problem while extracting the library file from the jar file. + * @throws FileNotFoundException + * if the file was not found either inside or outside the Java file system/environment. + */ + public static void loadNatives(String folderPath, Class referenceClass) throws UnsatisfiedLinkError, IOException, FileNotFoundException { + if (folderPath == null) + throw new NullPointerException(); + + String fileName = (System.getProperty("sun.arch.data.model").equals("64") ? "jlaw64.dll" : "jlaw.dll"); + String filePath = (folderPath.endsWith("/") || folderPath.endsWith("\\") ? folderPath + fileName : folderPath + '/' + fileName); + File tempFile = File.createTempFile(fileName.split("\\.", 2)[0], ".dll"); + tempFile.deleteOnExit(); + + InputStream inStream = null; + OutputStream outStream = null; + try { + // Look in Java FS/Env first, in file system secondly + if (referenceClass != null) + inStream = referenceClass.getResourceAsStream(filePath); + if (inStream == null) + inStream = new FileInputStream(filePath); + outStream = new FileOutputStream(tempFile); + + byte[] buffer = new byte[1024]; + int length; + while ((length = inStream.read(buffer)) > 0) + outStream.write(buffer, 0, length); + } finally { + if (inStream != null) + inStream.close(); + if (outStream != null) + outStream.close(); + } + + System.load(tempFile.getAbsolutePath()); + } + + /** + * Convert an array of ints to an array of "unsigned" bytes, where values from 128 to 255 will be mapped from -128 to -1. + * + * @param intArray + * Array of ints to be converted. + * @return Array of "unsigned" bytes. + */ + public static byte[] toUBytesFromInts(int[] intArray) { + if (intArray == null) + throw new NullPointerException(); + byte[] byteArray = new byte[intArray.length]; + for (int i = 0; i < intArray.length; i++) + byteArray[i] = (byte) (intArray[i] & 0xFF); + return byteArray; + } + + /** + * Convert an array of "unsigned" bytes to an array of ints, where values from 128 to 255 are mapped from -128 to -1. + * + * @param byteArray + * Array of "unsigned" bytes to be converted. + * @return Array of ints. + */ + public static int[] toIntsFromUBytes(byte[] byteArray) { + if (byteArray == null) + throw new NullPointerException(); + int[] intArray = new int[byteArray.length]; + for (int i = 0; i < byteArray.length; i++) + intArray[i] = byteArray[i] & 0xFF; + return intArray; + } + + private JlawUtil() {} +} diff --git a/JLAW front/src/main/resources/LICENSE.txt b/JLAW front/src/main/resources/LICENSE.txt new file mode 100644 index 0000000..0ea617c --- /dev/null +++ b/JLAW front/src/main/resources/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) ${year} ${author} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/JLAW test/pom.xml b/JLAW test/pom.xml new file mode 100644 index 0000000..7d67c63 --- /dev/null +++ b/JLAW test/pom.xml @@ -0,0 +1,146 @@ + + 4.0.0 + ninja.hon95.jlaw + jlaw-test + jar + 1.0.0 + JLAW Test + A JLAW sample + https://github.com/HON95/JLAW + + + + UTF-8 + HON95 + 2015 + ninja.hon95.jlawtest + ${mainPackage}.Main + + + + + ${project.artifactId} + clean package + src/main/java + + + . + false + ${basedir}/src/main/resources/ + + LICENSE.txt + + + + . + true + ${basedir}/src/main/resources/ + + LICENSE.txt + + + + + + maven-compiler-plugin + 3.3 + + 1.6 + 1.6 + + + + maven-shade-plugin + 2.3 + + false + + + + ninja.hon95.jlaw:jlaw + net.java.dev.designgridlayout:designgridlayout + + + + + net.java.dev.designgridlayout + ${mainPackage}.lib.designgridlayout + + + + + ${mainClass} + + + + + + package + + shade + + + + + + com.akathist.maven.plugins.launch4j + launch4j-maven-plugin + 1.7.7 + + + l4j-clui + package + + launch4j + + + + gui + true + ${project.build.directory}/${project.artifactId}.jar + ${project.build.directory}/${project.artifactId}.exe + JLAW Test + + ${mainClass} + anything + + src/main/resources/icons/application.ico + + 1.6.0 + preferJre + + + 0.0.0.0 + ${project.version} + ${project.artifactId} + ${year} ${author} + 0.0.0.0 + ${project.version} + ${project.artifactId} + ${author} + ${project.artifactId} + ${project.artifactId}.exe + + + + + + + + + + + + ninja.hon95.jlaw + jlaw + 1.0.0 + + + net.java.dev.designgridlayout + designgridlayout + 1.11 + + + \ No newline at end of file diff --git a/JLAW test/src/main/java/ninja/hon95/jlawtest/LogMessage.java b/JLAW test/src/main/java/ninja/hon95/jlawtest/LogMessage.java new file mode 100644 index 0000000..b5cce89 --- /dev/null +++ b/JLAW test/src/main/java/ninja/hon95/jlawtest/LogMessage.java @@ -0,0 +1,25 @@ +package ninja.hon95.jlawtest; + +public class LogMessage { + + private final String message; + private final boolean error; + + public LogMessage(String message, boolean error) { + this.message = message; + this.error = error; + } + + public String getMessage() { + return message; + } + + public boolean isError() { + return error; + } + + @Override + public String toString() { + return (isError() ? "ERROR: " + getMessage() : getMessage()); + } +} diff --git a/JLAW test/src/main/java/ninja/hon95/jlawtest/Main.java b/JLAW test/src/main/java/ninja/hon95/jlawtest/Main.java new file mode 100644 index 0000000..73d878c --- /dev/null +++ b/JLAW test/src/main/java/ninja/hon95/jlawtest/Main.java @@ -0,0 +1,85 @@ +package ninja.hon95.jlawtest; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import ninja.hon95.jlaw.JlawUtil; + +/* + * TODO Place 'jlaw.dll' and 'jlaw64.dll' in 'src/main/resources/natives/' before building + */ + +public final class Main { + + /* + * ERRORS + * Wont package + * Runs wrongly as exe + */ + + public static final String NATIVE_FOLDER_PATH = "/natives/"; + public static final String WINDOW_ICON_PATHS[] = { + "/icons/application_16.png", "/icons/application_32.png", + "/icons/application_64.png", "/icons/application_128.png", + "/icons/application_256.png" + }; + public static final int WINDOW_WIDTH = 800; + public static final int WINDOW_HEIGHT = 600; + + private static volatile boolean running = true; + private static BlockingQueue logQueue = new LinkedBlockingQueue(); + + public static void main(String[] args) { + start(); + } + + public static synchronized void start() { + log("[CORE] Building frame..."); + WindowBuilder.buildWindow(); + log("[CORE] Loading natives..."); + loadNative(); + log("[CORE] Done."); + } + + public static synchronized void stop() { + if (!running) + return; + running = false; + log("[CORE] Stopping..."); + Tester.stopAll(); + WindowBuilder.destroyWindow(); + } + + private static void loadNative() { + try { + JlawUtil.loadNatives(NATIVE_FOLDER_PATH, Main.class); + WindowBuilder.setNativeLibStatus(true); + } catch (Throwable tr) { + StringBuilder builder = new StringBuilder("UnsatisfiedLinkError: ").append(tr.getLocalizedMessage()); + for (StackTraceElement e : tr.getStackTrace()) + builder.append('\n').append(e); + logError(builder.toString()); + WindowBuilder.setNativeLibStatus(false); + } + } + + public static void log(String message) { + logQueue.offer(new LogMessage(message, false)); + } + + public static void logf(String messageFormat, Object... args) { + logQueue.offer(new LogMessage(String.format(messageFormat, args), false)); + } + + public static void logError(String message) { + logQueue.offer(new LogMessage(message, true)); + } + + public static void logErrorf(String messageFormat, Object... args) { + logQueue.offer(new LogMessage(String.format(messageFormat, args), true)); + } + + public static BlockingQueue getLogQueue() { + return logQueue; + } +} diff --git a/JLAW test/src/main/java/ninja/hon95/jlawtest/Tester.java b/JLAW test/src/main/java/ninja/hon95/jlawtest/Tester.java new file mode 100644 index 0000000..e24fa2e --- /dev/null +++ b/JLAW test/src/main/java/ninja/hon95/jlawtest/Tester.java @@ -0,0 +1,259 @@ +package ninja.hon95.jlawtest; + +import static ninja.hon95.jlaw.JlawArxControl.*; +import static ninja.hon95.jlaw.JlawGkey.*; +import static ninja.hon95.jlaw.JlawLcd.*; +import static ninja.hon95.jlaw.JlawLed.*; +import ninja.hon95.jlaw.JlawArxControl.JlawArxControlCallback; +import ninja.hon95.jlaw.JlawGkey.JlawGkeyCallback; + +public final class Tester { + + private static Object arxLock = new Object(); + private static Object gkeyLock = new Object(); + private static Object lcdLock = new Object(); + private static Object ledLock = new Object(); + private static volatile boolean arxActive = false; + private static volatile boolean gkeyActive = false; + private static volatile boolean lcdActive = false; + private static volatile boolean ledActive = false; + private static volatile boolean arxStop; + private static volatile boolean gkeyStop; + private static volatile boolean lcdStop; + private static volatile boolean ledStop; + + private static volatile String arxStatus = "Not initialized"; + private static volatile String gkeyStatus = "Not initialized"; + private static volatile String lcdStatus = "Not initialized"; + private static volatile String ledStatus = "Not initialized"; + + public static void testArx() { + synchronized (arxLock) { + arxActive = true; + arxStop = false; + Main.log("[ARX] START"); + logiArxInit("ninja.hon95.jlawtest", "JLAW Test", new JlawArxControlCallback() { + + @Override + public void call(int eventType, int eventValue, String eventArg) { + String eventTypeString; + switch (eventType) { + case LOGI_ARX_EVENT_FOCUS_ACTIVE: + eventTypeString = "LOGI_ARX_EVENT_FOCUS_ACTIVE"; + break; + case LOGI_ARX_EVENT_FOCUS_INACTIVE: + eventTypeString = "LOGI_ARX_EVENT_FOCUS_INACTIVE"; + break; + case LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL: + eventTypeString = "LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL"; + break; + case LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL: + eventTypeString = "LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL"; + break; + case LOGI_ARX_EVENT_TAP_ON_TAG: + eventTypeString = "LOGI_ARX_EVENT_TAP_ON_TAG"; + break; + default: + eventTypeString = "UNKNOWN"; + break; + } + Main.logf("[ARX] Event: type=%s value=%d arg='%s' ", eventTypeString, eventValue, eventArg); + } + }); + + arxStatus = "Initialized"; + + int errorCode = logiArxGetLastError(); + if (errorCode != 0) + Main.logError("[ARX] Error: " + logiArxGetErrorText(errorCode)); + else + Main.log("[ARX] No errors"); + + while (!arxStop) + sleep(10); + + Main.log("[ARX] STOP"); + logiArxShutdown(); + arxStatus = "Shut down"; + arxActive = false; + } + } + + public static void testGkey() { + synchronized (gkeyLock) { + gkeyActive = true; + gkeyStop = false; + Main.log("[GKEY] START"); + logiGkeyInit(new JlawGkeyCallback() { + @Override + public void call(int keyIndex, boolean keyDown, int mState, boolean fromMouse, String gkeyName) { + Main.logf("[GKEY] Event: index=%d down=%b m_state=%d mouse=%b name=%s", keyIndex, keyDown, mState, fromMouse, gkeyName); + } + }); + + gkeyStatus = "Initialized"; + + while (!gkeyStop) + sleep(10); + + Main.log("[GKEY] STOP"); + logiGkeyShutdown(); + gkeyStatus = "Shut down"; + gkeyActive = false; + } + } + + public static void testLcd() { + synchronized (lcdLock) { + lcdActive = true; + lcdStop = false; + boolean color = false; + boolean mono = false; + Main.log("[LCD] START"); + logiLcdInit("JLAW Test", LOGI_LCD_TYPE_COLOR | LOGI_LCD_TYPE_MONO); + + if (logiLcdIsConnected(LOGI_LCD_TYPE_COLOR)) { + Main.log("[LCD] Connected to color LCD"); + color = true; + int[] colorBitmap = new int[4 * LOGI_LCD_COLOR_WIDTH * LOGI_LCD_COLOR_HEIGHT]; + for (int i = 0; i + 3 < colorBitmap.length; i += 4) { + colorBitmap[i] = (255 - (i % 256)); + colorBitmap[i + 1] = (i % 256); + colorBitmap[i + 2] = ((i / LOGI_LCD_COLOR_WIDTH) % 256); + colorBitmap[i + 3] = 255; + } + logiLcdColorSetTitle("JLAW", 255, 255, 255); + logiLcdColorSetText(0, "Line 0 abc", 100, 100, 100); + logiLcdColorSetText(2, "<--------- 29 wide --------->"); + logiLcdColorSetBackground(colorBitmap); + } + + if (logiLcdIsConnected(LOGI_LCD_TYPE_MONO)) { + Main.log("[LCD] Connected to mono LCD"); + mono = true; + int[] monoBitmap = new int[LOGI_LCD_MONO_WIDTH * LOGI_LCD_MONO_HEIGHT]; + for (int i = 0; i < monoBitmap.length; i++) { + monoBitmap[i] = (i % 256); + } + logiLcdMonoSetText(0, "Line 0"); + logiLcdMonoSetBackground(monoBitmap); + } + + if (color && !mono) + lcdStatus = "Initialized with color"; + else if (!color && mono) + lcdStatus = "Initialized with mono"; + else if (color && !mono) + lcdStatus = "Initialized with color and mono"; + else + lcdStatus = "Initialized with neither color or mono"; + + while (!lcdStop) { + logiLcdUpdate(); + sleep(33); + } + + Main.log("[LCD] STOP"); + logiLcdShutdown(); + lcdStatus = "Shut down"; + lcdActive = false; + } + } + + public static void testLed() { + synchronized (ledLock) { + ledActive = true; + ledStop = false; + Main.log("[LED] START"); + logiLedInit(); + logiLedSaveCurrentLighting(); + logiLedFlashLighting(100, 0, 0, LOGI_LED_DURATION_INFINATE, 500); + + ledStatus = "Initialized"; + + while (!ledStop) + sleep(10); + + Main.log("[LED] STOP"); + logiLedStopEffects(); + logiLedRestoreLighting(); + logiLedShutdown(); + ledStatus = "Shut down"; + ledActive = false; + } + } + + public static void stopAll() { + if (arxActive) + arxStop = true; + if (gkeyActive) + gkeyStop = true; + if (lcdActive) + lcdStop = true; + if (ledActive) + ledStop = true; + synchronized (arxLock) { + } + synchronized (gkeyLock) { + } + synchronized (lcdLock) { + } + synchronized (ledLock) { + } + } + + public static boolean isArxActive() { + return arxActive; + } + + public static boolean isGkeyActive() { + return gkeyActive; + } + + public static boolean isLcdActive() { + return lcdActive; + } + + public static boolean isLedActive() { + return ledActive; + } + + public static void stopArx() { + arxStop = true; + } + + public static void stopGkey() { + gkeyStop = true; + } + + public static void stopLcd() { + lcdStop = true; + } + + public static void stopLed() { + ledStop = true; + } + + public static String getArxStatus() { + return arxStatus; + } + + public static String getGkeyStatus() { + return gkeyStatus; + } + + public static String getLcdStatus() { + return lcdStatus; + } + + public static String getLedStatus() { + return ledStatus; + } + + private static void sleep(int millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException ex) { + } + } +} diff --git a/JLAW test/src/main/java/ninja/hon95/jlawtest/WindowBuilder.java b/JLAW test/src/main/java/ninja/hon95/jlawtest/WindowBuilder.java new file mode 100644 index 0000000..6fb43f4 --- /dev/null +++ b/JLAW test/src/main/java/ninja/hon95/jlawtest/WindowBuilder.java @@ -0,0 +1,392 @@ +package ninja.hon95.jlawtest; + +import java.awt.Color; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.net.URL; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.BlockingQueue; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import net.java.dev.designgridlayout.DesignGridLayout; + +public final class WindowBuilder { + + private static final String ABOUT = "JLAW Test by HON95"; + private static final SimpleAttributeSet FONT_RED = new SimpleAttributeSet(); + { + StyleConstants.setForeground(FONT_RED, Color.RED); + } + + private static final String AC_ARX_TEST = "arx_test"; + private static final String AC_GKEY_TEST = "gkey_test"; + private static final String AC_LCD_TEST = "lcd_test"; + private static final String AC_LED_TEST = "led_test"; + private static final String AC_ARX_STOP = "arx_stop"; + private static final String AC_GKEY_STOP = "gkey_stop"; + private static final String AC_LCD_STOP = "lcd_stop"; + private static final String AC_LED_STOP = "led_stop"; + + private static JFrame frame = null; + private static JTextPane logPane; + private static StatusWorker statusWorker; + private static LogMessageWorker logWorker; + + private static JLabel nativeLibStatus; + private static JLabel arxStatus; + private static JLabel gkeyStatus; + private static JLabel lcdStatus; + private static JLabel ledStatus; + private static JButton arxTest; + private static JButton gkeyTest; + private static JButton lcdTest; + private static JButton ledTest; + private static JButton arxStop; + private static JButton gkeyStop; + private static JButton lcdStop; + private static JButton ledStop; + + public static void buildWindow() { + if (frame != null) + return; + frame = new JFrame("JLAW Test"); + frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + frame.setSize(Main.WINDOW_WIDTH, Main.WINDOW_HEIGHT); + frame.setLocationRelativeTo(null); + frame.setIconImages(loadIcons(Main.WINDOW_ICON_PATHS)); + frame.addWindowListener(buildWindowListener()); + + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + frame.getContentPane().add(splitPane); + splitPane.setDividerLocation(Main.WINDOW_WIDTH / 2); + + JTabbedPane tabPane = new JTabbedPane(); + splitPane.add(tabPane); + ActionListener actionListener = new TestActionListener(); + + buildGeneralTab(tabPane); + buildArxTab(tabPane, actionListener); + buildGkeyTab(tabPane, actionListener); + buildLcdTab(tabPane, actionListener); + buildLedTab(tabPane, actionListener); + + logPane = new JTextPane(); + logPane.setEditable(false); + splitPane.add(new JScrollPane(logPane)); + + frame.setVisible(true); + statusWorker = new StatusWorker(); + statusWorker.execute(); + logWorker = new LogMessageWorker(Main.getLogQueue()); + logWorker.execute(); + } + + private static List loadIcons(String[] paths) { + LinkedList icons = new LinkedList(); + for (String path : paths) { + URL url = Main.class.getResource(path); + if (url != null) + icons.add(new ImageIcon(url).getImage()); + else + Main.logError("[WINDOW] Icon image not found: " + path); + } + return icons; + } + + private static WindowListener buildWindowListener() { + return new WindowListener() { + + public void windowOpened(WindowEvent ev) {} + + public void windowIconified(WindowEvent ev) {} + + public void windowDeiconified(WindowEvent ev) {} + + public void windowDeactivated(WindowEvent ev) {} + + public void windowClosing(WindowEvent ev) { + Main.stop(); + } + + public void windowClosed(WindowEvent ev) {} + + public void windowActivated(WindowEvent ev) {} + }; + } + + private static void buildGeneralTab(JTabbedPane tabPane) { + DesignGridLayout tabGeneral = newTab(tabPane, "General"); + tabGeneral.row().grid(new JLabel("About")).add(new JLabel(ABOUT)); + nativeLibStatus = new JLabel("Loading..."); + tabGeneral.row().grid(new JLabel("Native")).add(nativeLibStatus); + } + + private static void buildArxTab(JTabbedPane tabPane, ActionListener actionListener) { + DesignGridLayout tabArx = newTab(tabPane, "Arx Control"); + tabArx.row().grid(new JLabel("About")).add(new JLabel("Prints Arx Control events.")); + tabArx.row().grid(new JLabel("Note")).add(new JLabel("This sample does not create a Arx Control applet.")); + arxStatus = new JLabel(Tester.getArxStatus()); + tabArx.row().grid(new JLabel("Status")).add(arxStatus); + arxTest = new JButton("Test"); + arxTest.addActionListener(actionListener); + arxTest.setActionCommand(AC_ARX_TEST); + arxTest.setEnabled(false); + tabArx.row().grid().add(arxTest); + arxStop = new JButton("Stop"); + arxStop.addActionListener(actionListener); + arxStop.setActionCommand(AC_ARX_STOP); + arxStop.setEnabled(false); + tabArx.row().grid().add(arxStop); + } + + private static void buildGkeyTab(JTabbedPane tabPane, ActionListener actionListener) { + DesignGridLayout tabGkey = newTab(tabPane, "G-Key"); + tabGkey.row().grid(new JLabel("About")).add(new JLabel("Prints G-key events.")); + tabGkey.row().grid(new JLabel("Note")).add(new JLabel("The test profile will be activated
every time this receives focus.")); + tabGkey.row().grid().add(new JLabel("You have to manually remove the profile from LGS.")); + gkeyStatus = new JLabel(Tester.getGkeyStatus()); + tabGkey.row().grid(new JLabel("Status")).add(gkeyStatus); + gkeyTest = new JButton("Test"); + gkeyTest.addActionListener(actionListener); + gkeyTest.setActionCommand(AC_GKEY_TEST); + gkeyTest.setEnabled(false); + tabGkey.row().grid().add(gkeyTest); + gkeyStop = new JButton("Stop"); + gkeyStop.addActionListener(actionListener); + gkeyStop.setActionCommand(AC_GKEY_STOP); + gkeyStop.setEnabled(false); + tabGkey.row().grid().add(gkeyStop); + } + + private static void buildLcdTab(JTabbedPane tabPane, ActionListener actionListener) { + DesignGridLayout tabLcd = newTab(tabPane, "LCD"); + tabLcd.row().grid(new JLabel("About")).add(new JLabel("Displays an image on connected displays.")); + tabLcd.row().grid(new JLabel("Note")).add(new JLabel("This sample was only tested with G19.")); + lcdStatus = new JLabel(Tester.getLcdStatus()); + tabLcd.row().grid(new JLabel("Status")).add(lcdStatus); + lcdTest = new JButton("Test"); + lcdTest.addActionListener(actionListener); + lcdTest.setActionCommand(AC_LCD_TEST); + lcdTest.setEnabled(false); + tabLcd.row().grid().add(lcdTest); + lcdStop = new JButton("Stop"); + lcdStop.addActionListener(actionListener); + lcdStop.setActionCommand(AC_LCD_STOP); + lcdStop.setEnabled(false); + tabLcd.row().grid().add(lcdStop); + } + + private static void buildLedTab(JTabbedPane tabPane, ActionListener actionListener) { + DesignGridLayout tabLed = newTab(tabPane, "LED"); + tabLed.row().grid(new JLabel("About")).add(new JLabel("Flashes your keyboard. Didn't work for me, though.")); + tabLed.row().grid(new JLabel("Note")).add(new JLabel("Lighting for this sample was only tested with G710+.
It might contain bugs.")); + ledStatus = new JLabel(Tester.getLedStatus()); + tabLed.row().grid(new JLabel("Status")).add(ledStatus); + ledTest = new JButton("Test"); + ledTest.addActionListener(actionListener); + ledTest.setActionCommand(AC_LED_TEST); + ledTest.setEnabled(false); + tabLed.row().grid().add(ledTest); + ledStop = new JButton("Stop"); + ledStop.addActionListener(actionListener); + ledStop.setActionCommand(AC_LED_STOP); + ledStop.setEnabled(false); + tabLed.row().grid().add(ledStop); + } + + private static DesignGridLayout newTab(JTabbedPane tabbedPane, String tabName) { + JPanel tab = new JPanel(); + DesignGridLayout grid = new DesignGridLayout(tab); + tabbedPane.addTab(tabName, new JScrollPane(tab)); + return grid; + } + + public static void destroyWindow() { + statusWorker.cancel(true); + logWorker.cancel(true); + frame.setVisible(false); + frame.dispose(); + frame = null; + } + + public static void setNativeLibStatus(final boolean linked) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (linked) { + nativeLibStatus.setText("Linked"); + arxTest.setEnabled(true); + gkeyTest.setEnabled(true); + lcdTest.setEnabled(true); + ledTest.setEnabled(true); + } else { + nativeLibStatus.setText("ERROR"); + } + } + }); + } + + private static class TestActionListener implements ActionListener { + + @Override + public void actionPerformed(ActionEvent ev) { + String ac = ev.getActionCommand(); + Runnable runnable = null; + if (ac.equals(AC_ARX_TEST)) { + arxTest.setEnabled(false); + arxStop.setEnabled(true); + runnable = new Runnable() { + public void run() { + if (!Tester.isArxActive()) + Tester.testArx(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + arxTest.setEnabled(true); + arxStop.setEnabled(false); + } + }); + } + }; + } else if (ac.equals(AC_GKEY_TEST)) { + gkeyTest.setEnabled(false); + gkeyStop.setEnabled(true); + runnable = new Runnable() { + public void run() { + if (!Tester.isGkeyActive()) + Tester.testGkey(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + gkeyTest.setEnabled(true); + gkeyStop.setEnabled(false); + } + }); + } + }; + } else if (ac.equals(AC_LCD_TEST)) { + lcdTest.setEnabled(false); + lcdStop.setEnabled(true); + runnable = new Runnable() { + public void run() { + if (!Tester.isLcdActive()) + Tester.testLcd(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + lcdTest.setEnabled(true); + lcdStop.setEnabled(false); + } + }); + } + }; + } else if (ac.equals(AC_LED_TEST)) { + ledTest.setEnabled(false); + ledStop.setEnabled(true); + runnable = new Runnable() { + public void run() { + if (!Tester.isLedActive()) + Tester.testLed(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ledTest.setEnabled(true); + ledStop.setEnabled(false); + } + }); + } + }; + } else if (ac.equals(AC_ARX_STOP)) { + Tester.stopArx(); + } else if (ac.equals(AC_GKEY_STOP)) { + Tester.stopGkey(); + } else if (ac.equals(AC_LCD_STOP)) { + Tester.stopLcd(); + } else if (ac.equals(AC_LED_STOP)) { + Tester.stopLed(); + } else { + Main.log("[WINDOW] Unknown action command: " + ac); + } + + if (runnable != null) { + Thread thread = new Thread(runnable); + thread.setDaemon(false); + thread.start(); + } + } + } + + private static class StatusWorker extends SwingWorker { + + @Override + protected Void doInBackground() throws Exception { + while (true) { + Thread.sleep(50); + publish((Void) null); + } + } + + @Override + protected void process(List chunks) { + if (!arxStatus.getText().equals(Tester.getArxStatus())) + arxStatus.setText(Tester.getArxStatus()); + if (!gkeyStatus.getText().equals(Tester.getGkeyStatus())) + gkeyStatus.setText(Tester.getGkeyStatus()); + if (!lcdStatus.getText().equals(Tester.getLcdStatus())) + lcdStatus.setText(Tester.getLcdStatus()); + if (!ledStatus.getText().equals(Tester.getLedStatus())) + ledStatus.setText(Tester.getLedStatus()); + } + } + + private static class LogMessageWorker extends SwingWorker { + + private final BlockingQueue logQueue; + + private LogMessageWorker(BlockingQueue logQueue) { + this.logQueue = logQueue; + } + + @Override + protected Void doInBackground() throws Exception { + while (true) { + LogMessage message = logQueue.take(); + (message.isError() ? System.err : System.out).println(message.getMessage()); + publish(message); + } + } + + @Override + protected void process(List messages) { + for (LogMessage message : messages) { + if (message == null) + continue; + + if (frame == null) + break; + Document document = logPane.getDocument(); + String text = (document.getLength() == 0 ? message.getMessage() : '\n' + message.getMessage()); + MutableAttributeSet font = (message.isError() ? FONT_RED : null); + try { + document.insertString(document.getLength(), text, font); + } catch (BadLocationException ex) { + } + } + } + } +} diff --git a/JLAW test/src/main/resources/LICENSE.txt b/JLAW test/src/main/resources/LICENSE.txt new file mode 100644 index 0000000..0ea617c --- /dev/null +++ b/JLAW test/src/main/resources/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) ${year} ${author} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/JLAW test/src/main/resources/icons/application.ico b/JLAW test/src/main/resources/icons/application.ico new file mode 100644 index 0000000000000000000000000000000000000000..07ed980cce514f554c223272d9acdeacfcbf820d GIT binary patch literal 92147 zcmeHQe~ev46`mE40>L&>V^XEof0`mBh-pe7Kz~@fU6PVo5rs$W5rk!Lu2p{ zN!lh-8?=9bt|YYyH3%g}2@=$xQo*fJQjInmFlaGusEL9bo-^<5;k|zQ=AAot?%cU^ z=WKHKyff$L_kFYbns!-~8dGPeMT?ZSOV!rXmAY0bwRCCEKcLSa*JrC&_x$B+m7093 zQag9f`3uI>?hoq%{bA~_SfJFS9~)E4wXaL{N$*@6rF6{YqqA3a%;QosnCntcxkc^Z z9P_$p9p%~T2hWG)4m%s1UuFGZFM5sh$wy21WHHY9R7cj9k8$#Cmil0P*m==2)2nFi zu)M)~igVVsKUYU_tRLpP9I7L(QeW{Yk@LQ6AahS^e+pRprqf>PME&(Ndf&#>uBRSvt2_$|GA> z9?hY-Wa%6&#mQove2SB$bDO0+vbMaU=hTNRS4VkdxqL28eaK=yofoxOkABfUW%F@m{PW`<8_Y}s7{6W0hY~=NVkGJ8b^WY0a z9zZy4Hu8GG$J=nzdGG}y48awTz2^aPJfJ?QT1U9^(o@Avd(Q*pctCwpwT^J- zrKgIU_MQjG@qqf+tYf>^e{Q9z{Sc3BPddkZ&Zjz?qF<5@9I+@n{8V^#ACxv z=a|p=RA;kXJ;rT)=p6H1ed=SgZR>}4Y`Ezh^EsdDY?iCXxUCPJW4^0TeQdUE{Sc20 zH=ScX=Tn`{a`hOu^`UdjclD`{&ARrhI^VVzo%_zCJ~r#y-?!ej7o9h~f7ACP9&Ofl zf8ToBUUbg&r@T;>o6p5V?NwJ_4j&hp zUk)D^uWQdxb2xllJk(xw_2uw!@z8tv&gbew$2op{=ZEg!^!)_?sXq^heE90;TaWvo z-?aX?ANsEQVm}45HI?e&-qx7K39)%tVbX7U486_e%tyX9>j}2=5s#QqtDf29P81? zd{-a)rRKZh#r)Lp;=YK-)yICR`L1{|KQ+9#FXD0av0rMwD_+b`4KMDCcwBw#mzwX2 z7xPoYi~Ay;*go!ue(e21&quuIhn^q1KjK9{_I{z~BVP1F&yU?7@uDAlztHm$FZ!Y9 z$L^1K(T}}f==q2j{m}EVf2Y%#S*Smiw!Ma(xnG)E!kYQ|-&j;>t5@&V54C!|5<7K4 zb?Z#)QT;vkp2OXrRccpH{mk!)*lAW68~8mD>J8>3s}KA-boH|$tA$`)^~U@bQj!%U z)YH|^imVobb=4d5TS!S(kWf!oKP$3Y2-a0^%x@tjSwTWQUHz=cY9Uxxy)nOqlw<`7 z^>p>KBCCa9UG>KN7E+QGB-GQ@&x))Tf_2p!^IJ$sR*+CnS3fJVS_sxvZ_IBYC0Rj2 zJzf2*$Z8>2SG_U6g_KkZ3HcIV|6s}7|8KYsTd9~On$>|(X4vmk3CSug5pC?+)WJ=q zVwPxD2S%A;zhfmNtF%P4v1?NYHR4QhPW_4hc8TLC?Lb6Ire6^``nIX+& zzagYlcqIJ#k=b?dFd|C;D>?jgB{+ztP+4U&7`2vyNPU-?;4O z%i!pG;deAYT(s%@rM`dD`EB}sqCdxgUtIL}(*Z{p0c< zd%EZ!TY9s z-~QhQrLJv}{Y8J#Kjs}Maz`a6+#QXny_qfAhSRnPx1xVs{)=c7GDq|m{bSyNkat^p z^LIO@_GY$d#A_6iBhf!D{~@(4(p&Tw{bSyNB6n1B!rjrB+MC&;Z8&X^FUX*^g7u zFE0GHn?DYn=+7}UI^J~tMsF{F{^R)J;-WvtkYBv%{5E|*j{T97o;&}s@rTxz>mM6` z?(;c)LdSFGKQ{i*`f~ka(~|MVHi z8-aZNi~c@$AaC~4NAIJ(y#I^-=`)Zw0{QwE{eA90-t481-bec!-v2wj5B(qVpYoBB zKX}It2l@G3(DX^;r%SZq5R%$>viwnynK9OJrutM`}Z$-hW9_m zd)NQEGdFMUOTYUvFaK+st{y-4?8RqmKF*!kux_(bWBTQoTJT0~KKl6slg8V=d3>!p z^vpZ{uAS3AwPxcQr5@UI&g_k6X#cFwZMbf`Qg8aHdB&c)?Z8b+oq2R(-I{B@wB?__ zz4-3;ty%Q5O~+UL`G0p@bpMh2zkU7{oBsNX8)jd5{)a#L*MGK6Ecwp(wtdgP>yEvX zO@BFi*Odnke&cV`%Rh9%uctn6@Y-*UPhIoiiaqPUcm1{{yEY#_diml9KK;Os6<7W4 zs*_vy#!Gz5!zW%`)_r!Yxck`cU%03HT)z0{FJ1PdUz+EZCA&WH#q<7jlX+I|S%2}5 zcYpT1=Gi|!b?*)1mweMa8sL#bQ~SG*Mm+i4^v3RUa;vl-NzN@(w>@bH-goQ2H{NSl z{K2lr&w5xZaowZSm)vORetPAr%Z?aMkF7s`*DiA!JoU`SFOm60!*Xx~qo{S8{bH+=oR r-;Cd!#=Bnkt@+ZIPQG&H@xwDmuiW^L4f-u#O}zi=b%)k|{44(l;u)^X literal 0 HcmV?d00001 diff --git a/JLAW test/src/main/resources/icons/application_128.png b/JLAW test/src/main/resources/icons/application_128.png new file mode 100644 index 0000000000000000000000000000000000000000..272f3b5707a02318635d897eec993aee87736859 GIT binary patch literal 1051 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEa{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXWa8_dH@3h^Gr_{ z$B>G+w-+6|QalBiFYfwZ_3m~tWAiZ$kwd>vKgcbbs8{#r&*#72pPyg9=JCbFQm-q% ztT<*RXS-@+pL>56SwjDWYPVD_m+PHX{_5fi$`~5TvUg1`UG!Zn*J}i%K)hEM2czKQ z*B8wVflecfu9N-yQuS@dWz`>#=|t`C`*-C>)feBMDw9*>(jM;Sy(J}=SGX_k0a73y z(6GTLn00TZ`{HMFt4t_je4YMcu_P7p1}Ibgx%~IfAAb9gKUzT(mR$j6WCl-HKbLh* G2~7ZP>J`-h literal 0 HcmV?d00001 diff --git a/JLAW test/src/main/resources/icons/application_16.png b/JLAW test/src/main/resources/icons/application_16.png new file mode 100644 index 0000000000000000000000000000000000000000..fe193b756c3a4d05162ba332155a87ed65242d5e GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ>#Bd(*uBNqC8z3LoEE~_89Up7;+r`@xSK(TTT_L2@aQ|J_+gMJc-t>dG^Zj*eZr@ zHO8`l?GC*+#kRCFl~{&ouPJ=_A}r!@UP4BOHB{z_qiDj#B}YQfSlAi-W>o8t{}4G% RR32yxgQu&X%Q~loCIA|MO$Gn} literal 0 HcmV?d00001 diff --git a/JLAW test/src/main/resources/icons/application_256.png b/JLAW test/src/main/resources/icons/application_256.png new file mode 100644 index 0000000000000000000000000000000000000000..f0d3f11ac8e69f7032763af01d5e1da4659e784b GIT binary patch literal 2509 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5Fo{p?&#~tz_78O`%fY(0|PTd zfKP}kP@G}Pe-JqeMnhoag}|YdtaG4@QWE4B{C{KvhT!k)s=yS$S>O>_%)r2R2!t6$ zHM|;tf)XXJ5hcO-X(i=}MX3x0iJ5sNdU>fO3MP66dd5A^rUx)Euo`>1IEGZjy}e+_ zr)tjQ;`sYt`#oQ++6@K`KNM$7HOMS%`+I(V;{Si_8x5lyERW6g%sC^L&{vo)B)yq+ zM)IARM~>w%K9eX{qnUKtr}*YcKmb-;Kj$OS4Jljo^|@fOw@C+De@o!Jb=(?HIge59{(8W>*^ zOHiwxbi?pG7)OBo;xA3`gWpw6*>Y(5F<(BG2# zCmw-%;rx$Y6{zRxj^(Rtgn0X#ah-A}G(hHml=g%M)!&}`9!Z(p6Ludfx7++|mhOQ) z$7JV67M~SMh4RFd{om7IU;mG(eaefZA3~3HKsB$YtDnm{r-UW|-v6Oc literal 0 HcmV?d00001 diff --git a/JLAW test/src/main/resources/icons/application_32.png b/JLAW test/src/main/resources/icons/application_32.png new file mode 100644 index 0000000000000000000000000000000000000000..85287e887f41a580229cef921965181a2e05d198 GIT binary patch literal 298 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7i zo^j8!=>b4BvproLLn7SY_8IaWHsCq(=l{hjj_W$e3<4|FDjr>mdKI;Vst0Gh^Z=l}o! literal 0 HcmV?d00001 diff --git a/JLAW test/src/main/resources/icons/application_64.png b/JLAW test/src/main/resources/icons/application_64.png new file mode 100644 index 0000000000000000000000000000000000000000..87eb6a69a2d71611b6501ce893424688ff870202 GIT binary patch literal 557 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ>#Bd(*uBp&hvC}45^5_d)}~%*-?Py;NShV|EJzDnI!CLD)m*RW%GukUp{~R7q`AX zcD}6d^>p{kUvFM4sVy@>;(jT=r0*^{=Z41BJZq+L)@;Q&Hwqaq zOTMYC+8k&#cW>vboGE_k`HQTimtMX(`$h7%%S+5|&sid`zV+ramA@7%&zh;fJnosh z&C=7}FKhEz&tHW>vvd6}^-sQ)Q#`3|&Xu&;lkL*%FTQ-^8P?Ng=kB?b znt3hXY#unbH)vLF01#2k$O}qeJp0Pc7iy(uyFBOiB6ClkPwijwdh_C!zusi*va_DG k?tI@eB<{XjpZ73+uKv$(HiK&+Fg6)HUHx3vIVCg!073HoT>t<8 literal 0 HcmV?d00001 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..bc6a3e8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 HON95 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 981dea2..88f0140 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ # JLAW -JLAW +Java Logitech API Wrapper + +JLAW is a wrapper for the four Logitech SDKs (Logitech ArxControl SDK, Logitech Gkey SDK, Logitech LCD SDK and Logitech LED SDK) for Java. It provides four classes plus one utility class which provides as direct as possible access to the SDKs, with some adjustments. JLAW uses Logitech Gaming Software (LGS). + +## Usage +### Getting JLAW +The library consists of a Java front-end and a JNI/C++ back-end. Both of the components can be build from source or downloaded as pre-built binaries, in any of the four combinations. If you're using Maven for your project, you should download and install the front-end source and use it as a Maven dependency. The back-end binaries are easiest to just download pre-built. + +#### Building JLAW Front-End from Source +Open the "JLAW front" directory and run Maven there (no arguments needed). This will build and install the project to you local repository. If you wish, you can open the directory as an Eclipse Java M2E project by creating a new Eclipse Maven project in that directory. + +#### Building JLAW Back-End from Source +Open the "JLAW back" directory and open the Visual Studio project (click the .sln file) (VS 2013 or other compatible). Change the project include and library paths so that they point to the JNI headers and Logitech SDK libraries and headers (Right click project -> Properties -> Configuration Properties -> VC++ Directories -> Include Directories and Library Directories). Remember to set up for both Win32 and x64 (top of property window). Build the project with CTRL + SHIFT + B. x64 DLL will be placed in x64/Release and Win32 DLL will be placed in Release. + +#### Building the JLAW Test from Source +Open the "JLAW test" directory. Copy the JLAW back-end DLLs to "src/main/resources/natives" as "jlaw.dll" and "jlaw64.dll". Run Maven (no arguments needed). This will build the project and create an EXE program. + +### Using JLAW +First you need to add the front-end as a dependency and load the native back-end. I suggest packaging both ends in your JAR or EXE. The front-end can be packaged using the Maven shader plugin and the back-end natives can be added as resources. The JlawUtil class contains the static method "loadNatives" for a convenient way to load the natives. The four classes JlawArxControl, JlawGkey, JlawLed and JlawLcd contains static methods which resembles the ones from the SDKs. All four SDKs require to be initialized before use and shutdown after. For inspiration, see the "JLAW test" sample project. The JLAW JavaDoc contains documentation about all the functions and callbacks. See the Logitech SDK documentation (included in the SDKs) for more detailed information. + +## Contents of Repository +- JLAW back: The C++ JNI back-end (Visual Studio 2013 project) +- JLAW front: The Java front-end (Eclipse Juno, Maven, targeted at Java 1.6) +- JLAW test: A sample project using JLAW (Eclipse Juno, Maven, Java 1.6) +- lib: Where to place the Logitech SDKs and JNI headers (jni.h and jni_md.h inside folder JNI) (optional) +- bin: Where extract_dlls.bat copies the built JLAW DLLs to +- LICENSE.txt: License for the project (MIT License) +- make_headers.bat: A simple batch file to build the JLAW headers and place them directly in the back-end project +- extract_dlls.bat: A simple batch file to move the JLAW DLLs to the bin folder and rename them + +## FAQ +Why does LGS use the Java icon for my applet or profile? +> I don't know. Maybe invoking the Java VM from another program (C++ and JNI, for example) will do the trick. + +How do I remove all the messy LCD applets in LGSs applet list? +> You have to edit the LGS settings file. Close LGS first. Open the JSON file "~\AppData\Local\Logitech\Logitech Gaming Software\settings.json" and remove the applets you want gone from the lcd/applets section. Try not to break the syntax, obviously. Make a backup to be sure you don't need to reconfigure LGS if you mess up. + +Questions related to the Logitech SDKs and usage of them: +> Read through the Logitech SDK documents found in the downloaded SDKs. Ask Logitech if you're still confused. + +## Legal +JLAW is licensed under the [MIT License](http://choosealicense.com/licenses/mit/). +JLAW is not is not affiliated with Logitech or Java. +Logitech is a registered trademark of Logitech. +Java is a registered trademark of Oracle. diff --git a/extract_dlls.bat b/extract_dlls.bat new file mode 100644 index 0000000..d879c96 --- /dev/null +++ b/extract_dlls.bat @@ -0,0 +1,3 @@ +copy /Y "JLAW back\Release\JLAW back.dll" "bin\jlaw.dll" +copy /Y "JLAW back\x64\Release\JLAW back.dll" "bin\jlaw64.dll" +pause \ No newline at end of file diff --git a/make_headers.bat b/make_headers.bat new file mode 100644 index 0000000..e74e874 --- /dev/null +++ b/make_headers.bat @@ -0,0 +1,5 @@ +javah -cp "JLAW front/src/main/java" -o "JLAW back/JLAW back/JlawArxControl.h" ninja.hon95.jlaw.JlawArxControl +javah -cp "JLAW front/src/main/java" -o "JLAW back/JLAW back/JlawGkey.h" ninja.hon95.jlaw.JlawGkey +javah -cp "JLAW front/src/main/java" -o "JLAW back/JLAW back/JlawLcd.h" ninja.hon95.jlaw.JlawLcd +javah -cp "JLAW front/src/main/java" -o "JLAW back/JLAW back/JlawLed.h" ninja.hon95.jlaw.JlawLed +pause \ No newline at end of file