*** empty log message ***
This commit is contained in:
parent
50326a73f7
commit
561f3cff10
|
@ -36,6 +36,7 @@ import java.util.StringTokenizer;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.Display;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
@ -75,86 +76,91 @@ public abstract class BaseAL {
|
|||
*
|
||||
* @throws Exception if a failiure occured in the AL creation process
|
||||
*/
|
||||
public static void create() throws OpenALException {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
public static void create() throws OpenALException {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
// need to pass path of possible locations of OAL to native side
|
||||
String libpath = System.getProperty("java.library.path");
|
||||
String seperator = System.getProperty("path.separator");
|
||||
String libname;
|
||||
// need to pass path of possible locations of OAL to native side
|
||||
String libpath = System.getProperty("java.library.path");
|
||||
String seperator = System.getProperty("path.separator");
|
||||
String libname;
|
||||
String jwsLibname;
|
||||
|
||||
// libname is hardcoded atm - this will change in a near future...
|
||||
libname =
|
||||
(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
|
||||
? "libopenal.so"
|
||||
: "lwjglaudio.dll";
|
||||
// libname is hardcoded atm - this will change in a near future...
|
||||
switch (Display.getPlatform()) {
|
||||
case Display.PLATFORM_WGL:
|
||||
libname = "lwjglaudio.dll";
|
||||
jwsLibname = "lwjglaudio";
|
||||
break;
|
||||
case Display.PLATFORM_GLX:
|
||||
libname = "libopenal.so";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
case Display.PLATFORM_AGL:
|
||||
libname = "openal.dylib";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
default:
|
||||
throw new OpenALException("Unknown platform");
|
||||
}
|
||||
|
||||
String jwsPath = getPathFromJWS(jwsLibname);
|
||||
if (jwsPath != null) {
|
||||
libpath += seperator
|
||||
+ jwsPath.substring(0, jwsPath.lastIndexOf(File.separator));
|
||||
}
|
||||
|
||||
// try to get path from JWS (if possible)
|
||||
String jwsLibname =
|
||||
(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
|
||||
? "openal"
|
||||
: "lwjglaudio";
|
||||
|
||||
String jwsPath = getPathFromJWS(jwsLibname);
|
||||
if (jwsPath != null) {
|
||||
libpath += seperator
|
||||
+ jwsPath.substring(0, jwsPath.lastIndexOf(File.separator));
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
||||
|
||||
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
||||
//create needed string array
|
||||
String[] oalPaths = new String[st.countTokens() + 1];
|
||||
|
||||
//create needed string array
|
||||
String[] oalPaths = new String[st.countTokens() + 1];
|
||||
//build paths
|
||||
for (int i = 0; i < oalPaths.length - 1; i++) {
|
||||
oalPaths[i] = st.nextToken() + File.separator + libname;
|
||||
}
|
||||
|
||||
//build paths
|
||||
for (int i = 0; i < oalPaths.length - 1; i++) {
|
||||
oalPaths[i] = st.nextToken() + File.separator + libname;
|
||||
}
|
||||
//add cwd path
|
||||
oalPaths[oalPaths.length - 1] = libname;
|
||||
nCreate(oalPaths);
|
||||
|
||||
//add cwd path
|
||||
oalPaths[oalPaths.length - 1] = libname;
|
||||
if (!nCreate(oalPaths)) {
|
||||
throw new OpenALException("AL instance could not be created.");
|
||||
}
|
||||
init();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate OpenAL from the JWS Library path
|
||||
* This method exists because OpenAL is loaded from native code, and as such
|
||||
* is exempt from JWS library loading rutines. OpenAL therefore always fails.
|
||||
* We therefore invoke the protected method of the JWS classloader to see if it can
|
||||
* locate it.
|
||||
*
|
||||
* @param libname Name of library to search for
|
||||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
|
||||
init();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate OpenAL from the JWS Library path
|
||||
* This method exists because OpenAL is loaded from native code, and as such
|
||||
* is exempt from JWS library loading rutines. OpenAL therefore always fails.
|
||||
* We therefore invoke the protected method of the JWS classloader to see if it can
|
||||
* locate it.
|
||||
*
|
||||
* @param libname Name of library to search for
|
||||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
if(Sys.DEBUG) {
|
||||
System.out.println("JWS Classloader looking for: " + libname);
|
||||
}
|
||||
|
||||
Object o = BaseAL.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
Method findLibrary =
|
||||
c.getMethod("findLibrary", new Class[] { String.class });
|
||||
Object[] arguments = new Object[] { libname };
|
||||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
if(Sys.DEBUG) {
|
||||
System.out.println("JWS Classloader looking for: " + libname);
|
||||
}
|
||||
|
||||
Object o = BaseAL.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
Method findLibrary =
|
||||
c.getMethod("findLibrary", new Class[] { String.class });
|
||||
Object[] arguments = new Object[] { libname };
|
||||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
} catch (Exception e) {
|
||||
if(Sys.DEBUG) {
|
||||
System.out.println("Failure locating OpenAL using classloader:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(Sys.DEBUG) {
|
||||
System.out.println("Failure locating OpenAL using classloader:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create AL instance
|
||||
|
@ -162,7 +168,7 @@ public abstract class BaseAL {
|
|||
* @param oalPaths Array of strings containing paths to search for OpenAL library
|
||||
* @return true if the AL creation process succeeded
|
||||
*/
|
||||
protected static native boolean nCreate(String[] oalPaths);
|
||||
protected static native void nCreate(String[] oalPaths) throws OpenALException;
|
||||
|
||||
/**
|
||||
* Calls whatever destruction rutines that are needed
|
||||
|
|
|
@ -180,4 +180,4 @@ public class WaveData {
|
|||
|
||||
return wavedata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,16 @@ int getEventBufferSize(event_queue_t *event_queue) {
|
|||
return EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
void throwException(JNIEnv * env, const char * err) {
|
||||
jclass cls = env->FindClass("java/lang/Exception");
|
||||
static void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) {
|
||||
jclass cls = env->FindClass(exception_name);
|
||||
env->ThrowNew(cls, err);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
void throwOpenALException(JNIEnv * env, const char * err) {
|
||||
throwGeneralException(env, "org/lwjgl/openal/OpenALException", err);
|
||||
}
|
||||
|
||||
void throwException(JNIEnv * env, const char * err) {
|
||||
throwGeneralException(env, "java/lang/Exception", err);
|
||||
}
|
||||
|
|
|
@ -58,5 +58,6 @@ extern void putEventElement(event_queue_t *queue, unsigned char byte);
|
|||
extern unsigned char *getOutputList(event_queue_t *queue);
|
||||
extern int getEventBufferSize(event_queue_t *event_queue);
|
||||
extern void throwException(JNIEnv *env, const char *msg);
|
||||
extern void throwOpenALException(JNIEnv * env, const char * err);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "extal.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
#ifdef _X11
|
||||
#include <dlfcn.h>
|
||||
|
@ -117,8 +118,8 @@ alcGetProcAddressPROC alcGetProcAddress = NULL;
|
|||
alcGetEnumValuePROC alcGetEnumValue = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
EAXSet eaxSet; // EAXSet function, ret$
|
||||
EAXGet eaxGet; // EAXGet function, ret$
|
||||
EAXSet eaxSet; // EAXSet function, ret$
|
||||
EAXGet eaxGet; // EAXGet function, ret$
|
||||
|
||||
/* Handle to OpenAL Library */
|
||||
HMODULE handleOAL;
|
||||
|
@ -127,30 +128,50 @@ HMODULE handleOAL;
|
|||
void* handleOAL;
|
||||
#endif
|
||||
#ifdef _AGL
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
OSStatus oalInitEntryPoints (void);
|
||||
void oalDellocEntryPoints (void);
|
||||
CFBundleRef handleOAL = NULL;
|
||||
#include <mach-o/dyld.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
const struct mach_header* handleOAL;
|
||||
#endif
|
||||
|
||||
/* Loads OpenAL */
|
||||
void LoadOpenAL();
|
||||
static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths);
|
||||
|
||||
/* Unloads OpenAL */
|
||||
void UnLoadOpenAL();
|
||||
static void UnLoadOpenAL(void);
|
||||
|
||||
/* Gets a pointer to the named function */
|
||||
void* GetFunctionPointer(const char* function);
|
||||
static void* GetFunctionPointer(const char* function);
|
||||
|
||||
/* Loads OpenAL basic functions */
|
||||
int LoadAL();
|
||||
static bool LoadAL(void);
|
||||
|
||||
/* Loads OpenAL ALC functions */
|
||||
int LoadALC();
|
||||
static bool LoadALC(void);
|
||||
|
||||
/* Loads any extensions to OpenAL */
|
||||
int LoadALExtensions();
|
||||
static bool LoadALExtensions(void);
|
||||
|
||||
static void *NativeGetFunctionPointer(const char *function) {
|
||||
#ifdef _WIN32
|
||||
return GetProcAddress(handleOAL, function);
|
||||
#endif
|
||||
#ifdef _X11
|
||||
return dlsym(handleOAL, function);
|
||||
#endif
|
||||
#ifdef _AGL
|
||||
char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
|
||||
if (mac_symbol_name == NULL)
|
||||
return NULL;
|
||||
mac_symbol_name[0] = '_';
|
||||
strcpy(&(mac_symbol_name[1]), function);
|
||||
NSSymbol symbol = NSLookupSymbolInImage(handleOAL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
free(mac_symbol_name);
|
||||
if (symbol == NULL)
|
||||
return NULL;
|
||||
return NSAddressOfSymbol(symbol);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a pointer to the named function
|
||||
|
@ -158,108 +179,105 @@ int LoadALExtensions();
|
|||
* @param function Name of function
|
||||
* @return pointer to named function, or NULL if not found
|
||||
*/
|
||||
void* GetFunctionPointer(const char* function) {
|
||||
#ifdef _WIN32
|
||||
return GetProcAddress(handleOAL, function);
|
||||
static void* GetFunctionPointer(const char* function) {
|
||||
void *p = NativeGetFunctionPointer(function);
|
||||
if (p == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not locate symbol %s\n", function);
|
||||
#endif
|
||||
#ifdef _X11
|
||||
return dlsym(handleOAL, function);
|
||||
#endif
|
||||
#ifdef _AGL
|
||||
return CFBundleGetFunctionPointerForName (handleOAL,CFStringCreateWithCStringNoCopy (NULL, function, CFStringGetSystemEncoding (), NULL));
|
||||
#endif
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the OpenAL Library
|
||||
*/
|
||||
void LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
|
||||
jsize pathcount = env->GetArrayLength(oalPaths);
|
||||
#ifdef _DEBUG
|
||||
printf("Found %d OpenAL paths\n", pathcount);
|
||||
#endif
|
||||
for(int i=0;i<pathcount;i++) {
|
||||
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
||||
const char *path_str = env->GetStringUTFChars(path, NULL);
|
||||
printf("Found %d OpenAL paths\n", pathcount);
|
||||
#endif
|
||||
for(int i=0;i<pathcount;i++) {
|
||||
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
||||
const char *path_str = env->GetStringUTFChars(path, NULL);
|
||||
#ifdef _DEBUG
|
||||
printf("Testing '%s'\n", path_str);
|
||||
#endif
|
||||
printf("Testing '%s'\n", path_str);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
handleOAL = LoadLibrary(path_str);
|
||||
handleOAL = LoadLibrary(path_str);
|
||||
#endif
|
||||
#ifdef _X11
|
||||
handleOAL = dlopen(path_str, RTLD_LAZY);
|
||||
handleOAL = dlopen(path_str, RTLD_LAZY);
|
||||
#endif
|
||||
#ifdef _AGL
|
||||
// NOTE: This totally ignores the input array! - SWP
|
||||
oalInitEntryPoints();
|
||||
handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
#endif
|
||||
if (handleOAL != NULL) {
|
||||
if (handleOAL != NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Found OpenAL at '%s'\n", path_str);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
env->ReleaseStringUTFChars(path, path_str);
|
||||
}
|
||||
printf("Found OpenAL at '%s'\n", path_str);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
env->ReleaseStringUTFChars(path, path_str);
|
||||
}
|
||||
throwOpenALException(env, "Could not load openal library.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the OpenAL Library
|
||||
*/
|
||||
void UnLoadOpenAL() {
|
||||
static void UnLoadOpenAL() {
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(handleOAL);
|
||||
FreeLibrary(handleOAL);
|
||||
#endif
|
||||
#ifdef _X11
|
||||
dlclose(handleOAL);
|
||||
dlclose(handleOAL);
|
||||
#endif
|
||||
#ifdef _AGL
|
||||
oalDellocEntryPoints();
|
||||
// Cannot remove the image
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes OpenAL by loading the library
|
||||
*/
|
||||
int InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
if(handleOAL != 0) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
void InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
if(handleOAL != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//load our library
|
||||
LoadOpenAL(env, oalPaths);
|
||||
//load our library
|
||||
if (!LoadOpenAL(env, oalPaths)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if we couldn't load the library, get out
|
||||
if(handleOAL == 0) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
//load basic OpenAL functions
|
||||
if(!LoadAL()) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
//load basic OpenAL functions
|
||||
if(!LoadAL()) {
|
||||
throwOpenALException(env, "Could not load OpenAL function pointers.");
|
||||
return;
|
||||
}
|
||||
|
||||
//load OpenAL context functions
|
||||
if(!LoadALC()) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
//load OpenAL context functions
|
||||
if(!LoadALC()) {
|
||||
throwOpenALException(env, "Could not load ALC function pointers.");
|
||||
return;
|
||||
}
|
||||
|
||||
//load OpenAL extensions
|
||||
if(!LoadALExtensions()) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
return JNI_TRUE;
|
||||
//load OpenAL extensions
|
||||
if(!LoadALExtensions()) {
|
||||
throwOpenALException(env, "Could not load AL extension function pointers.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to deinitialize OpenAL
|
||||
*/
|
||||
void DeInitializeOpenAL() {
|
||||
UnLoadOpenAL();
|
||||
handleOAL = 0;
|
||||
UnLoadOpenAL();
|
||||
handleOAL = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,119 +285,119 @@ void DeInitializeOpenAL() {
|
|||
*
|
||||
* @return true if all methods were loaded, false if one of the methods could not be loaded
|
||||
*/
|
||||
int LoadAL() {
|
||||
alEnable = (alEnablePROC) GetFunctionPointer("alEnable");
|
||||
alDisable = (alDisablePROC) GetFunctionPointer("alDisable");
|
||||
alIsEnabled = (alIsEnabledPROC) GetFunctionPointer("alIsEnabled");
|
||||
//alHint = (alHintPROC) GetFunctionPointer("alHint");
|
||||
alGetBoolean = (alGetBooleanPROC) GetFunctionPointer("alGetBoolean");
|
||||
alGetInteger = (alGetIntegerPROC) GetFunctionPointer("alGetInteger");
|
||||
alGetFloat = (alGetFloatPROC) GetFunctionPointer("alGetFloat");
|
||||
alGetDouble = (alGetDoublePROC) GetFunctionPointer("alGetDouble");
|
||||
alGetBooleanv = (alGetBooleanvPROC) GetFunctionPointer("alGetBooleanv");
|
||||
alGetIntegerv = (alGetIntegervPROC) GetFunctionPointer("alGetIntegerv");
|
||||
alGetFloatv = (alGetFloatvPROC) GetFunctionPointer("alGetFloatv");
|
||||
alGetDoublev = (alGetDoublevPROC) GetFunctionPointer("alGetDoublev");
|
||||
alGetString = (alGetStringPROC) GetFunctionPointer("alGetString");
|
||||
alGetError = (alGetErrorPROC) GetFunctionPointer("alGetError");
|
||||
alIsExtensionPresent = (alIsExtensionPresentPROC) GetFunctionPointer("alIsExtensionPresent");
|
||||
alGetProcAddress = (alGetProcAddressPROC) GetFunctionPointer("alGetProcAddress");
|
||||
alGetEnumValue = (alGetEnumValuePROC) GetFunctionPointer("alGetEnumValue");
|
||||
alListeneri = (alListeneriPROC) GetFunctionPointer("alListeneri");
|
||||
alListenerf = (alListenerfPROC) GetFunctionPointer("alListenerf");
|
||||
alListener3f = (alListener3fPROC) GetFunctionPointer("alListener3f");
|
||||
alListenerfv = (alListenerfvPROC) GetFunctionPointer("alListenerfv");
|
||||
alGetListeneri = (alGetListeneriPROC) GetFunctionPointer("alGetListeneri");
|
||||
alGetListenerf = (alGetListenerfPROC) GetFunctionPointer("alGetListenerf");
|
||||
alGetListener3f = (alGetListener3fPROC) GetFunctionPointer("alGetListener3f");
|
||||
alGetListenerfv = (alGetListenerfvPROC) GetFunctionPointer("alGetListenerfv");
|
||||
alGenSources = (alGenSourcesPROC) GetFunctionPointer("alGenSources");
|
||||
alDeleteSources = (alDeleteSourcesPROC) GetFunctionPointer("alDeleteSources");
|
||||
alIsSource = (alIsSourcePROC) GetFunctionPointer("alIsSource");
|
||||
alSourcei = (alSourceiPROC) GetFunctionPointer("alSourcei");
|
||||
alSourcef = (alSourcefPROC) GetFunctionPointer("alSourcef");
|
||||
alSource3f = (alSource3fPROC) GetFunctionPointer("alSource3f");
|
||||
alSourcefv = (alSourcefvPROC) GetFunctionPointer("alSourcefv");
|
||||
alGetSourcei = (alGetSourceiPROC) GetFunctionPointer("alGetSourcei");
|
||||
alGetSourcef = (alGetSourcefPROC) GetFunctionPointer("alGetSourcef");
|
||||
alGetSource3f = (alGetSource3fPROC) GetFunctionPointer("alGetSource3f");
|
||||
alGetSourcefv = (alGetSourcefvPROC) GetFunctionPointer("alGetSourcefv");
|
||||
alSourcePlayv = (alSourcePlayvPROC) GetFunctionPointer("alSourcePlayv");
|
||||
alSourcePausev = (alSourcePausevPROC) GetFunctionPointer("alSourcePausev");
|
||||
alSourceStopv = (alSourceStopvPROC) GetFunctionPointer("alSourceStopv");
|
||||
alSourceRewindv = (alSourceRewindvPROC) GetFunctionPointer("alSourceRewindv");
|
||||
alSourcePlay = (alSourcePlayPROC) GetFunctionPointer("alSourcePlay");
|
||||
alSourcePause = (alSourcePausePROC) GetFunctionPointer("alSourcePause");
|
||||
alSourceStop = (alSourceStopPROC) GetFunctionPointer("alSourceStop");
|
||||
alSourceRewind = (alSourceRewindPROC) GetFunctionPointer("alSourceRewind");
|
||||
alGenBuffers = (alGenBuffersPROC) GetFunctionPointer("alGenBuffers");
|
||||
alDeleteBuffers = (alDeleteBuffersPROC) GetFunctionPointer("alDeleteBuffers");
|
||||
alIsBuffer = (alIsBufferPROC) GetFunctionPointer("alIsBuffer");
|
||||
alBufferData = (alBufferDataPROC) GetFunctionPointer("alBufferData");
|
||||
alGetBufferi = (alGetBufferiPROC) GetFunctionPointer("alGetBufferi");
|
||||
alGetBufferf = (alGetBufferfPROC) GetFunctionPointer("alGetBufferf");
|
||||
alSourceQueueBuffers = (alSourceQueueBuffersPROC) GetFunctionPointer("alSourceQueueBuffers");
|
||||
alSourceUnqueueBuffers = (alSourceUnqueueBuffersPROC) GetFunctionPointer("alSourceUnqueueBuffers");
|
||||
alDistanceModel = (alDistanceModelPROC) GetFunctionPointer("alDistanceModel");
|
||||
alDopplerFactor = (alDopplerFactorPROC) GetFunctionPointer("alDopplerFactor");
|
||||
alDopplerVelocity = (alDopplerVelocityPROC) GetFunctionPointer("alDopplerVelocity");
|
||||
static bool LoadAL() {
|
||||
alEnable = (alEnablePROC) GetFunctionPointer("alEnable");
|
||||
alDisable = (alDisablePROC) GetFunctionPointer("alDisable");
|
||||
alIsEnabled = (alIsEnabledPROC) GetFunctionPointer("alIsEnabled");
|
||||
//alHint = (alHintPROC) GetFunctionPointer("alHint");
|
||||
alGetBoolean = (alGetBooleanPROC) GetFunctionPointer("alGetBoolean");
|
||||
alGetInteger = (alGetIntegerPROC) GetFunctionPointer("alGetInteger");
|
||||
alGetFloat = (alGetFloatPROC) GetFunctionPointer("alGetFloat");
|
||||
alGetDouble = (alGetDoublePROC) GetFunctionPointer("alGetDouble");
|
||||
alGetBooleanv = (alGetBooleanvPROC) GetFunctionPointer("alGetBooleanv");
|
||||
alGetIntegerv = (alGetIntegervPROC) GetFunctionPointer("alGetIntegerv");
|
||||
alGetFloatv = (alGetFloatvPROC) GetFunctionPointer("alGetFloatv");
|
||||
alGetDoublev = (alGetDoublevPROC) GetFunctionPointer("alGetDoublev");
|
||||
alGetString = (alGetStringPROC) GetFunctionPointer("alGetString");
|
||||
alGetError = (alGetErrorPROC) GetFunctionPointer("alGetError");
|
||||
alIsExtensionPresent = (alIsExtensionPresentPROC) GetFunctionPointer("alIsExtensionPresent");
|
||||
alGetProcAddress = (alGetProcAddressPROC) GetFunctionPointer("alGetProcAddress");
|
||||
alGetEnumValue = (alGetEnumValuePROC) GetFunctionPointer("alGetEnumValue");
|
||||
alListeneri = (alListeneriPROC) GetFunctionPointer("alListeneri");
|
||||
alListenerf = (alListenerfPROC) GetFunctionPointer("alListenerf");
|
||||
alListener3f = (alListener3fPROC) GetFunctionPointer("alListener3f");
|
||||
alListenerfv = (alListenerfvPROC) GetFunctionPointer("alListenerfv");
|
||||
alGetListeneri = (alGetListeneriPROC) GetFunctionPointer("alGetListeneri");
|
||||
alGetListenerf = (alGetListenerfPROC) GetFunctionPointer("alGetListenerf");
|
||||
alGetListener3f = (alGetListener3fPROC) GetFunctionPointer("alGetListener3f");
|
||||
alGetListenerfv = (alGetListenerfvPROC) GetFunctionPointer("alGetListenerfv");
|
||||
alGenSources = (alGenSourcesPROC) GetFunctionPointer("alGenSources");
|
||||
alDeleteSources = (alDeleteSourcesPROC) GetFunctionPointer("alDeleteSources");
|
||||
alIsSource = (alIsSourcePROC) GetFunctionPointer("alIsSource");
|
||||
alSourcei = (alSourceiPROC) GetFunctionPointer("alSourcei");
|
||||
alSourcef = (alSourcefPROC) GetFunctionPointer("alSourcef");
|
||||
alSource3f = (alSource3fPROC) GetFunctionPointer("alSource3f");
|
||||
alSourcefv = (alSourcefvPROC) GetFunctionPointer("alSourcefv");
|
||||
alGetSourcei = (alGetSourceiPROC) GetFunctionPointer("alGetSourcei");
|
||||
alGetSourcef = (alGetSourcefPROC) GetFunctionPointer("alGetSourcef");
|
||||
alGetSource3f = (alGetSource3fPROC) GetFunctionPointer("alGetSource3f");
|
||||
alGetSourcefv = (alGetSourcefvPROC) GetFunctionPointer("alGetSourcefv");
|
||||
alSourcePlayv = (alSourcePlayvPROC) GetFunctionPointer("alSourcePlayv");
|
||||
alSourcePausev = (alSourcePausevPROC) GetFunctionPointer("alSourcePausev");
|
||||
alSourceStopv = (alSourceStopvPROC) GetFunctionPointer("alSourceStopv");
|
||||
alSourceRewindv = (alSourceRewindvPROC) GetFunctionPointer("alSourceRewindv");
|
||||
alSourcePlay = (alSourcePlayPROC) GetFunctionPointer("alSourcePlay");
|
||||
alSourcePause = (alSourcePausePROC) GetFunctionPointer("alSourcePause");
|
||||
alSourceStop = (alSourceStopPROC) GetFunctionPointer("alSourceStop");
|
||||
alSourceRewind = (alSourceRewindPROC) GetFunctionPointer("alSourceRewind");
|
||||
alGenBuffers = (alGenBuffersPROC) GetFunctionPointer("alGenBuffers");
|
||||
alDeleteBuffers = (alDeleteBuffersPROC) GetFunctionPointer("alDeleteBuffers");
|
||||
alIsBuffer = (alIsBufferPROC) GetFunctionPointer("alIsBuffer");
|
||||
alBufferData = (alBufferDataPROC) GetFunctionPointer("alBufferData");
|
||||
alGetBufferi = (alGetBufferiPROC) GetFunctionPointer("alGetBufferi");
|
||||
alGetBufferf = (alGetBufferfPROC) GetFunctionPointer("alGetBufferf");
|
||||
alSourceQueueBuffers = (alSourceQueueBuffersPROC) GetFunctionPointer("alSourceQueueBuffers");
|
||||
alSourceUnqueueBuffers = (alSourceUnqueueBuffersPROC) GetFunctionPointer("alSourceUnqueueBuffers");
|
||||
alDistanceModel = (alDistanceModelPROC) GetFunctionPointer("alDistanceModel");
|
||||
alDopplerFactor = (alDopplerFactorPROC) GetFunctionPointer("alDopplerFactor");
|
||||
alDopplerVelocity = (alDopplerVelocityPROC) GetFunctionPointer("alDopplerVelocity");
|
||||
|
||||
return
|
||||
alEnable != NULL &&
|
||||
alDisable != NULL &&
|
||||
alIsEnabled != NULL &&
|
||||
//alHint != NULL &&
|
||||
alGetBoolean != NULL &&
|
||||
alGetInteger != NULL &&
|
||||
alGetFloat != NULL &&
|
||||
alGetDouble != NULL &&
|
||||
alGetBooleanv != NULL &&
|
||||
alGetIntegerv != NULL &&
|
||||
alGetFloatv != NULL &&
|
||||
alGetDoublev != NULL &&
|
||||
alGetString != NULL &&
|
||||
alGetError != NULL &&
|
||||
alIsExtensionPresent != NULL &&
|
||||
alGetProcAddress != NULL &&
|
||||
alGetEnumValue != NULL &&
|
||||
alListeneri != NULL &&
|
||||
alListenerf != NULL &&
|
||||
alListener3f != NULL &&
|
||||
alListenerfv != NULL &&
|
||||
alGetListeneri != NULL &&
|
||||
alGetListenerf != NULL &&
|
||||
alGetListener3f != NULL &&
|
||||
alGetListenerfv != NULL &&
|
||||
alGenSources != NULL &&
|
||||
alDeleteSources != NULL &&
|
||||
alIsSource != NULL &&
|
||||
alSourcei != NULL &&
|
||||
alSourcef != NULL &&
|
||||
alSource3f != NULL &&
|
||||
alSourcefv != NULL &&
|
||||
alGetSourcei != NULL &&
|
||||
alGetSourcef != NULL &&
|
||||
alGetSource3f != NULL &&
|
||||
alGetSourcefv != NULL &&
|
||||
alSourcePlayv != NULL &&
|
||||
alSourcePausev != NULL &&
|
||||
alSourceStopv != NULL &&
|
||||
alSourceRewindv != NULL &&
|
||||
alSourcePlay != NULL &&
|
||||
alSourcePause != NULL &&
|
||||
alSourceStop != NULL &&
|
||||
alSourceRewind != NULL &&
|
||||
alGenBuffers != NULL &&
|
||||
alDeleteBuffers != NULL &&
|
||||
alIsBuffer != NULL &&
|
||||
alBufferData != NULL &&
|
||||
alGetBufferi != NULL &&
|
||||
alGetBufferf != NULL &&
|
||||
alSourceQueueBuffers != NULL &&
|
||||
alSourceUnqueueBuffers != NULL &&
|
||||
alDistanceModel != NULL &&
|
||||
alDopplerFactor != NULL &&
|
||||
alDopplerVelocity != NULL;
|
||||
return
|
||||
alEnable != NULL &&
|
||||
alDisable != NULL &&
|
||||
alIsEnabled != NULL &&
|
||||
//alHint != NULL &&
|
||||
alGetBoolean != NULL &&
|
||||
alGetInteger != NULL &&
|
||||
alGetFloat != NULL &&
|
||||
alGetDouble != NULL &&
|
||||
alGetBooleanv != NULL &&
|
||||
alGetIntegerv != NULL &&
|
||||
alGetFloatv != NULL &&
|
||||
alGetDoublev != NULL &&
|
||||
alGetString != NULL &&
|
||||
alGetError != NULL &&
|
||||
alIsExtensionPresent != NULL &&
|
||||
alGetProcAddress != NULL &&
|
||||
alGetEnumValue != NULL &&
|
||||
alListeneri != NULL &&
|
||||
alListenerf != NULL &&
|
||||
alListener3f != NULL &&
|
||||
alListenerfv != NULL &&
|
||||
alGetListeneri != NULL &&
|
||||
alGetListenerf != NULL &&
|
||||
alGetListener3f != NULL &&
|
||||
alGetListenerfv != NULL &&
|
||||
alGenSources != NULL &&
|
||||
alDeleteSources != NULL &&
|
||||
alIsSource != NULL &&
|
||||
alSourcei != NULL &&
|
||||
alSourcef != NULL &&
|
||||
alSource3f != NULL &&
|
||||
alSourcefv != NULL &&
|
||||
alGetSourcei != NULL &&
|
||||
alGetSourcef != NULL &&
|
||||
alGetSource3f != NULL &&
|
||||
alGetSourcefv != NULL &&
|
||||
alSourcePlayv != NULL &&
|
||||
alSourcePausev != NULL &&
|
||||
alSourceStopv != NULL &&
|
||||
alSourceRewindv != NULL &&
|
||||
alSourcePlay != NULL &&
|
||||
alSourcePause != NULL &&
|
||||
alSourceStop != NULL &&
|
||||
alSourceRewind != NULL &&
|
||||
alGenBuffers != NULL &&
|
||||
alDeleteBuffers != NULL &&
|
||||
alIsBuffer != NULL &&
|
||||
alBufferData != NULL &&
|
||||
alGetBufferi != NULL &&
|
||||
alGetBufferf != NULL &&
|
||||
alSourceQueueBuffers != NULL &&
|
||||
alSourceUnqueueBuffers != NULL &&
|
||||
alDistanceModel != NULL &&
|
||||
alDopplerFactor != NULL &&
|
||||
alDopplerVelocity != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,39 +405,39 @@ int LoadAL() {
|
|||
*
|
||||
* @return true if all methods were loaded, false if one of the methods could not be loaded
|
||||
*/
|
||||
int LoadALC() {
|
||||
alcGetString = (alcGetStringPROC) GetFunctionPointer("alcGetString");
|
||||
alcGetIntegerv = (alcGetIntegervPROC) GetFunctionPointer("alcGetIntegerv");
|
||||
alcOpenDevice = (alcOpenDevicePROC) GetFunctionPointer("alcOpenDevice");
|
||||
alcCloseDevice = (alcCloseDevicePROC) GetFunctionPointer("alcCloseDevice");
|
||||
alcCreateContext = (alcCreateContextPROC) GetFunctionPointer("alcCreateContext");
|
||||
alcMakeContextCurrent = (alcMakeContextCurrentPROC) GetFunctionPointer("alcMakeContextCurrent");
|
||||
alcProcessContext = (alcProcessContextPROC) GetFunctionPointer("alcProcessContext");
|
||||
alcGetCurrentContext = (alcGetCurrentContextPROC) GetFunctionPointer("alcGetCurrentContext");
|
||||
alcGetContextsDevice = (alcGetContextsDevicePROC) GetFunctionPointer("alcGetContextsDevice");
|
||||
alcSuspendContext = (alcSuspendContextPROC) GetFunctionPointer("alcSuspendContext");
|
||||
alcDestroyContext = (alcDestroyContextPROC) GetFunctionPointer("alcDestroyContext");
|
||||
alcGetError = (alcGetErrorPROC) GetFunctionPointer("alcGetError");
|
||||
alcIsExtensionPresent = (alcIsExtensionPresentPROC) GetFunctionPointer("alcIsExtensionPresent");
|
||||
alcGetProcAddress = (alcGetProcAddressPROC) GetFunctionPointer("alcGetProcAddress");
|
||||
alcGetEnumValue = (alcGetEnumValuePROC) GetFunctionPointer("alcGetEnumValue");
|
||||
static bool LoadALC() {
|
||||
alcGetString = (alcGetStringPROC) GetFunctionPointer("alcGetString");
|
||||
alcGetIntegerv = (alcGetIntegervPROC) GetFunctionPointer("alcGetIntegerv");
|
||||
alcOpenDevice = (alcOpenDevicePROC) GetFunctionPointer("alcOpenDevice");
|
||||
alcCloseDevice = (alcCloseDevicePROC) GetFunctionPointer("alcCloseDevice");
|
||||
alcCreateContext = (alcCreateContextPROC) GetFunctionPointer("alcCreateContext");
|
||||
alcMakeContextCurrent = (alcMakeContextCurrentPROC) GetFunctionPointer("alcMakeContextCurrent");
|
||||
alcProcessContext = (alcProcessContextPROC) GetFunctionPointer("alcProcessContext");
|
||||
alcGetCurrentContext = (alcGetCurrentContextPROC) GetFunctionPointer("alcGetCurrentContext");
|
||||
alcGetContextsDevice = (alcGetContextsDevicePROC) GetFunctionPointer("alcGetContextsDevice");
|
||||
alcSuspendContext = (alcSuspendContextPROC) GetFunctionPointer("alcSuspendContext");
|
||||
alcDestroyContext = (alcDestroyContextPROC) GetFunctionPointer("alcDestroyContext");
|
||||
alcGetError = (alcGetErrorPROC) GetFunctionPointer("alcGetError");
|
||||
alcIsExtensionPresent = (alcIsExtensionPresentPROC) GetFunctionPointer("alcIsExtensionPresent");
|
||||
alcGetProcAddress = (alcGetProcAddressPROC) GetFunctionPointer("alcGetProcAddress");
|
||||
alcGetEnumValue = (alcGetEnumValuePROC) GetFunctionPointer("alcGetEnumValue");
|
||||
|
||||
return
|
||||
alcGetString != NULL &&
|
||||
alcGetIntegerv != NULL &&
|
||||
alcOpenDevice != NULL &&
|
||||
alcCloseDevice != NULL &&
|
||||
alcCreateContext != NULL &&
|
||||
alcMakeContextCurrent != NULL &&
|
||||
alcProcessContext != NULL &&
|
||||
alcGetCurrentContext != NULL &&
|
||||
alcGetContextsDevice != NULL &&
|
||||
alcSuspendContext != NULL &&
|
||||
alcDestroyContext != NULL &&
|
||||
alcGetError != NULL &&
|
||||
alcIsExtensionPresent != NULL &&
|
||||
alcGetProcAddress != NULL &&
|
||||
alcGetEnumValue != NULL;
|
||||
return
|
||||
alcGetString != NULL &&
|
||||
alcGetIntegerv != NULL &&
|
||||
alcOpenDevice != NULL &&
|
||||
alcCloseDevice != NULL &&
|
||||
alcCreateContext != NULL &&
|
||||
alcMakeContextCurrent != NULL &&
|
||||
alcProcessContext != NULL &&
|
||||
alcGetCurrentContext != NULL &&
|
||||
alcGetContextsDevice != NULL &&
|
||||
alcSuspendContext != NULL &&
|
||||
alcDestroyContext != NULL &&
|
||||
alcGetError != NULL &&
|
||||
alcIsExtensionPresent != NULL &&
|
||||
alcGetProcAddress != NULL &&
|
||||
alcGetEnumValue != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,86 +445,6 @@ int LoadALC() {
|
|||
*
|
||||
* @return true if all methods were loaded, false if one of the methods could not be loaded
|
||||
*/
|
||||
int LoadALExtensions() {
|
||||
return JNI_TRUE;
|
||||
static bool LoadALExtensions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef _AGL
|
||||
// -------------------------
|
||||
OSStatus oalInitEntryPoints (void)
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
const Str255 frameworkName = "\pOpenAL.framework";
|
||||
FSRefParam fileRefParam;
|
||||
FSRef fileRef;
|
||||
CFURLRef bundleURLOpenAL;
|
||||
memset(&fileRefParam, 0, sizeof(fileRefParam));
|
||||
memset(&fileRef, 0, sizeof(fileRef));
|
||||
fileRefParam.ioNamePtr = frameworkName;
|
||||
fileRefParam.newRef = &fileRef;
|
||||
|
||||
// Frameworks directory/folder
|
||||
//
|
||||
err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID);
|
||||
if (noErr != err)
|
||||
{
|
||||
DebugStr ("\pCould not find frameworks folder");
|
||||
return err;
|
||||
}
|
||||
|
||||
// make FSRef for folder
|
||||
//
|
||||
err = PBMakeFSRefSync (&fileRefParam);
|
||||
|
||||
|
||||
if (noErr != err)
|
||||
{
|
||||
DebugStr ("\pCould make FSref to frameworks folder");
|
||||
return err;
|
||||
}
|
||||
|
||||
// create URL to folder
|
||||
//
|
||||
bundleURLOpenAL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef);
|
||||
if (!bundleURLOpenAL)
|
||||
{
|
||||
DebugStr ("\pCould create OpenAL Framework bundle URL");
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
// create ref to GL's bundle
|
||||
//
|
||||
handleOAL = CFBundleCreate (kCFAllocatorDefault,bundleURLOpenAL);
|
||||
if (!handleOAL)
|
||||
{
|
||||
DebugStr ("\pCould not create OpenAL Framework bundle");
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
// release created bundle
|
||||
//
|
||||
CFRelease (bundleURLOpenAL);
|
||||
|
||||
// if the code was successfully loaded, look for our function.
|
||||
if (!CFBundleLoadExecutable (handleOAL))
|
||||
{
|
||||
DebugStr ("\pCould not load OpenAL MachO executable");
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
void oalDellocEntryPoints (void)
|
||||
{
|
||||
if (handleOAL != NULL)
|
||||
{
|
||||
// unload the bundle's code.
|
||||
CFBundleUnloadExecutable (handleOAL);
|
||||
CFRelease (handleOAL);
|
||||
handleOAL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -144,7 +144,7 @@ DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties,
|
|||
#define INITGUID
|
||||
#define OPENAL
|
||||
|
||||
int InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths);
|
||||
void InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths);
|
||||
void DeInitializeOpenAL();
|
||||
|
||||
//alc
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Lightweight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
|
@ -36,26 +36,10 @@
|
|||
#include "checkALerror.h"
|
||||
#include "extal.h"
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_openal_BaseAL
|
||||
* Method: nCreate
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_BaseAL_nCreate (JNIEnv *env, jclass clazz, jobjectArray oalPaths) {
|
||||
if(!InitializeOpenAL(env, oalPaths)) {
|
||||
jclass cls = env->FindClass("org/lwjgl/openal/OpenALException");
|
||||
env->ThrowNew(cls, "Unable to load function pointers to openal.");
|
||||
env->DeleteLocalRef(cls);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
return JNI_TRUE;
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_BaseAL_nCreate (JNIEnv *env, jclass clazz, jobjectArray oalPaths) {
|
||||
InitializeOpenAL(env, oalPaths);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_openal_BaseAL
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_BaseAL_nDestroy(JNIEnv *env, jclass clazz) {
|
||||
DeInitializeOpenAL();
|
||||
}
|
||||
DeInitializeOpenAL();
|
||||
}
|
||||
|
|
|
@ -1,35 +1,3 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Lightweight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_lwjgl_openal_BaseAL */
|
||||
|
@ -40,14 +8,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
/* Inaccessible static: created */
|
||||
/* Inaccessible static: class_000240 */
|
||||
/* Inaccessible static: class_000241 */
|
||||
/* Inaccessible static: class_00024org_00024lwjgl_00024openal_00024BaseAL */
|
||||
/* Inaccessible static: class_00024java_00024lang_00024String */
|
||||
/*
|
||||
* Class: org_lwjgl_openal_BaseAL
|
||||
* Method: nCreate
|
||||
* Signature: ([Ljava/lang/String;)Z
|
||||
* Signature: ([Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_BaseAL_nCreate
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_openal_BaseAL_nCreate
|
||||
(JNIEnv *, jclass, jobjectArray);
|
||||
|
||||
/*
|
||||
|
|
|
@ -30,7 +30,7 @@ AC_CANONICAL_HOST
|
|||
|
||||
case "$host_os" in
|
||||
darwin*) _BUILD_FLAGS="-D_AGL -fpascal-strings"
|
||||
LDFLAGS="-Xlinker -framework -Xlinker JavaVM -Xlinker -framework -Xlinker ApplicationServices -Xlinker -framework -Xlinker CoreServices"
|
||||
LDFLAGS="-Xlinker -framework -Xlinker JavaVM -Xlinker -framework -Xlinker ApplicationServices -Xlinker -framework -Xlinker CoreServices -Xlinker -framework -Xlinker Carbon"
|
||||
NATIVE_BUILD_DIR=macosx
|
||||
CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS"
|
||||
CFLAGS="$CFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS"
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
#define _LWJGL_WINDOW_H_INCLUDED_
|
||||
|
||||
#include <jni.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
extern void setQuitRequested(void);
|
||||
extern void resetMode(JNIEnv *env);
|
||||
extern void switchMode(JNIEnv *env, long width, long height, long bpp, long freq);
|
||||
extern void handleKeyboardEvent(EventRef event);
|
||||
|
||||
#endif /* _LWJGL_WINDOW_H_INCLUDED_ */
|
||||
|
|
|
@ -85,6 +85,7 @@ void switchMode(JNIEnv *env, long width, long height, long bpp, long freq) {
|
|||
}
|
||||
|
||||
void resetMode(JNIEnv *env) {
|
||||
init(env);
|
||||
CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode);
|
||||
CGDisplayRelease(kCGDirectMainDisplay);
|
||||
saveOriginalMode(env);
|
||||
|
|
|
@ -39,20 +39,19 @@
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
#include "org_lwjgl_input_Keyboard.h"
|
||||
#include "Window.h"
|
||||
#include "tools.h"
|
||||
#include "org_lwjgl_input_Keyboard.h"
|
||||
#include "common_tools.h"
|
||||
#include "hid.h"
|
||||
|
||||
#define KEYBOARD_SIZE 256
|
||||
#define UNICODE_BUFFER_SIZE 10
|
||||
|
||||
static unsigned char key_buf[KEYBOARD_SIZE];
|
||||
static unsigned char key_map[KEYBOARD_SIZE];
|
||||
static bool buffer_enabled = false;
|
||||
static bool translation_enabled = false;
|
||||
static event_queue_t event_queue;
|
||||
static hid_device_t hid_dev;
|
||||
|
||||
static bool handleMappedKey(unsigned char mapped_code, unsigned char state) {
|
||||
unsigned char old_state = key_buf[mapped_code];
|
||||
|
@ -61,13 +60,12 @@ static bool handleMappedKey(unsigned char mapped_code, unsigned char state) {
|
|||
if (buffer_enabled) {
|
||||
putEventElement(&event_queue, mapped_code);
|
||||
putEventElement(&event_queue, state);
|
||||
return translation_enabled;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
static bool handleKey(UInt32 key_code, unsigned char state) {
|
||||
if (key_code >= KEYBOARD_SIZE) {
|
||||
#ifdef _DEBUG
|
||||
|
@ -139,14 +137,14 @@ static bool handleUnicode(EventRef event) {
|
|||
return writeChars(num_chars, unicode_buffer);
|
||||
}
|
||||
|
||||
static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
|
||||
static void doKeyDown(EventRef event) {
|
||||
UInt32 key_code;
|
||||
OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code);
|
||||
if (err != noErr) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not get event key code\n");
|
||||
#endif
|
||||
return eventNotHandledErr;
|
||||
return;
|
||||
}
|
||||
if (handleKey(key_code, 1)) {
|
||||
if (translation_enabled) {
|
||||
|
@ -159,23 +157,22 @@ static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef even
|
|||
putEventElement(&event_queue, 0);
|
||||
}
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static pascal OSStatus doKeyUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
|
||||
static void doKeyUp(EventRef event) {
|
||||
UInt32 key_code;
|
||||
OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code);
|
||||
if (err != noErr) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not get event key code\n");
|
||||
#endif
|
||||
return eventNotHandledErr;
|
||||
return;
|
||||
}
|
||||
if (handleKey(key_code, 0)) {
|
||||
putEventElement(&event_queue, 0);
|
||||
putEventElement(&event_queue, 0);
|
||||
}
|
||||
return noErr;
|
||||
return;
|
||||
}
|
||||
|
||||
static void handleModifier(UInt32 modifier_bit_mask, UInt32 modifier_bit, unsigned char key_code) {
|
||||
|
@ -187,14 +184,14 @@ static void handleModifier(UInt32 modifier_bit_mask, UInt32 modifier_bit, unsign
|
|||
}
|
||||
}
|
||||
|
||||
static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
|
||||
static void doKeyModifier(EventRef event) {
|
||||
UInt32 modifier_bits;
|
||||
OSStatus err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifier_bits), NULL, &modifier_bits);
|
||||
if (err != noErr) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not get event key code\n");
|
||||
#endif
|
||||
return eventNotHandledErr;
|
||||
return;
|
||||
}
|
||||
handleModifier(modifier_bits, controlKey, 0x1d);
|
||||
handleModifier(modifier_bits, rightControlKey, 0x9d);
|
||||
|
@ -206,7 +203,22 @@ static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef
|
|||
handleModifier(modifier_bits, alphaLock, 0x3a);
|
||||
handleModifier(modifier_bits, kEventKeyModifierNumLockMask, 0x45);
|
||||
//handleModifier(modifier_bits, rightCmdKey, 0xdc);
|
||||
return noErr;
|
||||
return;
|
||||
}
|
||||
|
||||
void handleKeyboardEvent(EventRef event) {
|
||||
UInt32 event_kind = GetEventKind(event);
|
||||
switch (event_kind) {
|
||||
case kEventRawKeyDown:
|
||||
doKeyDown(event);
|
||||
break;
|
||||
case kEventRawKeyUp:
|
||||
doKeyUp(event);
|
||||
break;
|
||||
case kEventRawKeyModifiersChanged:
|
||||
doKeyModifier(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void setupMappings(void) {
|
||||
|
@ -300,156 +312,6 @@ static void setupMappings(void) {
|
|||
key_map[0x7d] = org_lwjgl_input_Keyboard_KEY_DOWN;
|
||||
key_map[0x79] = org_lwjgl_input_Keyboard_KEY_NEXT;
|
||||
}
|
||||
*/
|
||||
|
||||
static void initCookie(hid_cookie_t *hid_cookies, int index, long usage) {
|
||||
hid_cookies[index].usage_page = kHIDPage_KeyboardOrKeypad;
|
||||
hid_cookies[index].usage = usage;
|
||||
}
|
||||
|
||||
static void initCookies(hid_cookie_t *hid_cookies) {
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_ESCAPE, kHIDUsage_KeyboardEscape);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_1, kHIDUsage_Keyboard1);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_2, kHIDUsage_Keyboard2);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_3, kHIDUsage_Keyboard3);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_4, kHIDUsage_Keyboard4);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_5, kHIDUsage_Keyboard5);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_6, kHIDUsage_Keyboard6);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_7, kHIDUsage_Keyboard7);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_8, kHIDUsage_Keyboard8);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_9, kHIDUsage_Keyboard9);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_0, kHIDUsage_Keyboard0);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_MINUS, kHIDUsage_KeyboardHyphen);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_EQUALS, kHIDUsage_KeyboardEqualSign);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_BACK, kHIDUsage_KeyboardDeleteOrBackspace);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_TAB, kHIDUsage_KeyboardTab);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Q, kHIDUsage_KeyboardQ);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_W, kHIDUsage_KeyboardW);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_E, kHIDUsage_KeyboardE);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_R, kHIDUsage_KeyboardR);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_T, kHIDUsage_KeyboardT);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Y, kHIDUsage_KeyboardY);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_U, kHIDUsage_KeyboardU);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_I, kHIDUsage_KeyboardI);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_O, kHIDUsage_KeyboardO);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_P, kHIDUsage_KeyboardP);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LBRACKET, kHIDUsage_KeyboardOpenBracket);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RBRACKET, kHIDUsage_KeyboardCloseBracket);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RETURN, kHIDUsage_KeyboardReturnOrEnter);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LCONTROL, kHIDUsage_KeyboardLeftControl);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_A, kHIDUsage_KeyboardA);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_S, kHIDUsage_KeyboardS);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_D, kHIDUsage_KeyboardD);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F, kHIDUsage_KeyboardF);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_G, kHIDUsage_KeyboardG);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_H, kHIDUsage_KeyboardH);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_J, kHIDUsage_KeyboardJ);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_K, kHIDUsage_KeyboardK);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_L, kHIDUsage_KeyboardL);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SEMICOLON, kHIDUsage_KeyboardSemicolon);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_APOSTROPHE, kHIDUsage_KeyboardQuote);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_GRAVE, kHIDUsage_KeyboardGraveAccentAndTilde);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LSHIFT, kHIDUsage_KeyboardLeftShift);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_BACKSLASH, kHIDUsage_KeyboardBackslash);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Z, kHIDUsage_KeyboardZ);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_X, kHIDUsage_KeyboardX);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_C, kHIDUsage_KeyboardC);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_V, kHIDUsage_KeyboardV);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_B, kHIDUsage_KeyboardB);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_N, kHIDUsage_KeyboardN);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_M, kHIDUsage_KeyboardM);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_COMMA, kHIDUsage_KeyboardComma);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PERIOD, kHIDUsage_KeyboardPeriod);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SLASH, kHIDUsage_KeyboardSlash);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RSHIFT, kHIDUsage_KeyboardRightShift);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_MULTIPLY, kHIDUsage_KeypadAsterisk);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LMENU, kHIDUsage_KeyboardLeftGUI);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SPACE, kHIDUsage_KeyboardSpacebar);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CAPITAL, kHIDUsage_KeyboardCapsLock);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F1, kHIDUsage_KeyboardF1);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F2, kHIDUsage_KeyboardF2);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F3, kHIDUsage_KeyboardF3);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F4, kHIDUsage_KeyboardF4);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F5, kHIDUsage_KeyboardF5);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F6, kHIDUsage_KeyboardF6);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F7, kHIDUsage_KeyboardF7);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F8, kHIDUsage_KeyboardF8);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F9, kHIDUsage_KeyboardF9);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F10, kHIDUsage_KeyboardF10);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMLOCK, kHIDUsage_KeypadNumLock);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SCROLL, kHIDUsage_KeyboardScrollLock);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD7, kHIDUsage_Keypad7);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD8, kHIDUsage_Keypad8);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD9, kHIDUsage_Keypad9);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SUBTRACT, kHIDUsage_KeypadHyphen);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD4, kHIDUsage_Keypad4);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD5, kHIDUsage_Keypad5);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD6, kHIDUsage_Keypad6);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_ADD, kHIDUsage_KeypadPlus);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD1, kHIDUsage_Keypad1);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD2, kHIDUsage_Keypad2);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD3, kHIDUsage_Keypad3);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD0, kHIDUsage_Keypad0);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DECIMAL, kHIDUsage_KeypadPeriod);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F11, kHIDUsage_KeyboardF11);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F12, kHIDUsage_KeyboardF12);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F13, kHIDUsage_KeyboardF13);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F14, kHIDUsage_KeyboardF14);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F15, kHIDUsage_KeyboardF15);
|
||||
/* initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_KANA, kHIDUsage_KeyboardKANA);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CONVERT, kHIDUsage_KeyboardCONVERT);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NOCONVERT, kHIDUsage_KeyboardNOCONVERT);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_YEN, kHIDUsage_KeyboardYEN);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS, kHIDUsage_KeyboardNUMPADEQUALS);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX, kHIDUsage_KeyboardCIRCUMFLEX);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_AT, kHIDUsage_KeyboardAT);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_COLON, kHIDUsage_KeyboardCOLON);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UNDERLINE, kHIDUsage_KeyboardUNDERLINE);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_KANJI, kHIDUsage_KeyboardKANJI);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_STOP, kHIDUsage_KeyboardSTOP);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_AX, kHIDUsage_KeyboardAX);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UNLABELED, kHIDUsage_KeyboardUNLABELED);*/
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADENTER, kHIDUsage_KeypadEnter);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RCONTROL, kHIDUsage_KeyboardRightControl);
|
||||
// initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA, kHIDUsage_KeyboardNUMPADCOMMA);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DIVIDE, kHIDUsage_KeypadSlash);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SYSRQ, kHIDUsage_KeyboardSysReqOrAttention);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RMENU, kHIDUsage_KeyboardRightGUI);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PAUSE, kHIDUsage_KeyboardPause);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_HOME, kHIDUsage_KeyboardHome);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UP, kHIDUsage_KeyboardUpArrow);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PRIOR, kHIDUsage_KeyboardPageUp);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LEFT, kHIDUsage_KeyboardLeftArrow);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RIGHT, kHIDUsage_KeyboardRightArrow);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_END, kHIDUsage_KeyboardEnd);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DOWN, kHIDUsage_KeyboardDownArrow);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NEXT, kHIDUsage_KeyboardPageDown);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_INSERT, kHIDUsage_KeyboardInsert);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DELETE, kHIDUsage_KeyboardDeleteForward);
|
||||
/* initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LWIN, kHIDUsage_KeyboardLWIN);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RWIN, kHIDUsage_KeyboardRWIN);*/
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_APPS, kHIDUsage_KeyboardApplication);
|
||||
initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_POWER, kHIDUsage_KeyboardPower);
|
||||
//initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SLEEP, kHIDUsage_KeyboardSleep);
|
||||
}
|
||||
|
||||
static void pollKeyboardDevice(void) {
|
||||
hid_event_t event;
|
||||
while (nextDeviceEvent(&hid_dev, &event)) {
|
||||
if (event.cookie_index >= KEYBOARD_SIZE) {
|
||||
#ifdef _DEBUG
|
||||
printf("Uknown key code\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
unsigned char key_code = (unsigned char)event.cookie_index;
|
||||
unsigned char state = event.value != 0 ? 1 : 0;
|
||||
if (handleMappedKey(key_code, state)) {
|
||||
putEventElement(&event_queue, 0);
|
||||
putEventElement(&event_queue, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs(JNIEnv * env, jclass clazz) {
|
||||
}
|
||||
|
@ -459,24 +321,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate(JNIEnv * env, jclas
|
|||
translation_enabled = false;
|
||||
initEventQueue(&event_queue);
|
||||
memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char));
|
||||
hid_cookie_t hid_cookies[KEYBOARD_SIZE];
|
||||
for (int i = 0; i < KEYBOARD_SIZE; i++) {
|
||||
hid_cookies[i].usage_page = kHIDPage_Undefined;
|
||||
hid_cookies[i].usage = kHIDUsage_Undefined;
|
||||
}
|
||||
initCookies(hid_cookies);
|
||||
if (!findDevice(&hid_dev, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, KEYBOARD_SIZE, hid_cookies, EVENT_BUFFER_SIZE)) {
|
||||
throwException(env, "Could not find a keyboard device");
|
||||
return;
|
||||
}
|
||||
setupMappings();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy(JNIEnv * env, jclass clazz) {
|
||||
shutdownDevice(&hid_dev);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll(JNIEnv * env, jclass clazz, jobject buffer) {
|
||||
pollKeyboardDevice();
|
||||
unsigned char *new_keyboard_buffer = (unsigned char *)env->GetDirectBufferAddress(buffer);
|
||||
memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char));
|
||||
}
|
||||
|
|
|
@ -130,6 +130,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle(JNIEnv * env, jcla
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update(JNIEnv *env, jclass clazz) {
|
||||
EventRef event;
|
||||
OSStatus err = ReceiveNextEvent(0, NULL, 0, true, &event);
|
||||
if (err == noErr) {
|
||||
UInt32 event_class = GetEventClass(event);
|
||||
if (event_class == kEventClassKeyboard)
|
||||
handleKeyboardEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) {
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include <JavaVM/jni.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define lock() {lockLWJGL();
|
||||
#define unlock() unlockLWJGL();}
|
||||
|
||||
extern bool getDictLong(CFDictionaryRef dict, CFStringRef key, long *key_value);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue