*** empty log message ***
This commit is contained in:
parent
6e73a7a953
commit
e143541c01
|
@ -120,6 +120,7 @@ public abstract class Window {
|
||||||
* @param newTitle The new window title
|
* @param newTitle The new window title
|
||||||
*/
|
*/
|
||||||
public final void setTitle(String newTitle) {
|
public final void setTitle(String newTitle) {
|
||||||
|
assert isCreated();
|
||||||
title = newTitle;
|
title = newTitle;
|
||||||
nSetTitle(title);
|
nSetTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -134,6 +135,7 @@ public abstract class Window {
|
||||||
* @return true if the user or operating system has asked the window to close
|
* @return true if the user or operating system has asked the window to close
|
||||||
*/
|
*/
|
||||||
public final boolean isCloseRequested() {
|
public final boolean isCloseRequested() {
|
||||||
|
assert isCreated();
|
||||||
return closeRequested;
|
return closeRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +143,7 @@ public abstract class Window {
|
||||||
* @return true if the window is minimized or otherwise not visible
|
* @return true if the window is minimized or otherwise not visible
|
||||||
*/
|
*/
|
||||||
public final boolean isMinimized() {
|
public final boolean isMinimized() {
|
||||||
|
assert isCreated();
|
||||||
return minimized;
|
return minimized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +175,7 @@ public abstract class Window {
|
||||||
* and needs to repaint itself
|
* and needs to repaint itself
|
||||||
*/
|
*/
|
||||||
public final boolean isDirty() {
|
public final boolean isDirty() {
|
||||||
|
assert isCreated();
|
||||||
return dirty;
|
return dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +183,7 @@ public abstract class Window {
|
||||||
* Paint the window. This clears the dirty flag and swaps the buffers.
|
* Paint the window. This clears the dirty flag and swaps the buffers.
|
||||||
*/
|
*/
|
||||||
public final void paint() {
|
public final void paint() {
|
||||||
|
assert isCreated();
|
||||||
dirty = false;
|
dirty = false;
|
||||||
doPaint();
|
doPaint();
|
||||||
}
|
}
|
||||||
|
@ -194,6 +199,7 @@ public abstract class Window {
|
||||||
doCreate();
|
doCreate();
|
||||||
currentWindow = this;
|
currentWindow = this;
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,7 +211,7 @@ public abstract class Window {
|
||||||
/**
|
/**
|
||||||
* Destroy the window.
|
* Destroy the window.
|
||||||
*/
|
*/
|
||||||
public final synchronized void destroy() {
|
public final void destroy() {
|
||||||
if (!created)
|
if (!created)
|
||||||
return;
|
return;
|
||||||
doDestroy();
|
doDestroy();
|
||||||
|
@ -237,16 +243,7 @@ public abstract class Window {
|
||||||
* 'Tick' the window. This must be called at least once per video frame
|
* 'Tick' the window. This must be called at least once per video frame
|
||||||
* to handle window close requests, moves, paints, etc.
|
* to handle window close requests, moves, paints, etc.
|
||||||
*/
|
*/
|
||||||
public final native void tick();
|
public native void tick();
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#finalize()
|
|
||||||
*/
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
super.finalize();
|
|
||||||
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
|
|
|
@ -344,18 +344,20 @@ public class Keyboard {
|
||||||
/**
|
/**
|
||||||
* Enable keyboard translation. Must be called after the keyboard is created,
|
* Enable keyboard translation. Must be called after the keyboard is created,
|
||||||
* and keyboard buffering must be enabled.
|
* and keyboard buffering must be enabled.
|
||||||
|
* @return false if translation cannot be enabled; true if it can
|
||||||
*/
|
*/
|
||||||
public static void enableTranslation() {
|
public static boolean enableTranslation() {
|
||||||
assert created : "The keyboard has not been created.";
|
assert created : "The keyboard has not been created.";
|
||||||
assert readBuffer != null : "Keyboard buffering has not been enabled.";
|
assert readBuffer != null : "Keyboard buffering has not been enabled.";
|
||||||
nEnableTranslation();
|
|
||||||
translationEnabled = true;
|
translationEnabled = nEnableTranslation();
|
||||||
|
return translationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to enable the translation buffer
|
* Native method to enable the translation buffer
|
||||||
*/
|
*/
|
||||||
private static native void nEnableTranslation();
|
private static native boolean nEnableTranslation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable keyboard buffering. Must be called after the keyboard is created.
|
* Enable keyboard buffering. Must be called after the keyboard is created.
|
||||||
|
|
|
@ -313,7 +313,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
* Method: nEnableTranslation
|
* Method: nEnableTranslation
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
||||||
(JNIEnv *, jclass);
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -63,13 +63,14 @@ static bool translationEnabled;
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Get a global class instance, just to be sure
|
// Get a global class instance, just to be sure
|
||||||
static jobject globalClassLock = NULL;
|
static jobject globalClassLock = NULL;
|
||||||
|
|
||||||
if (globalClassLock == NULL) {
|
if (globalClassLock == NULL) {
|
||||||
globalClassLock = env->NewGlobalRef(clazz);
|
globalClassLock = env->NewGlobalRef(clazz);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;");
|
fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,17 +209,23 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
|
|
||||||
if (ret == DI_OK) {
|
if (ret == DI_OK) {
|
||||||
unsigned char * buf = readBuffer;
|
unsigned char * buf = readBuffer;
|
||||||
|
//#ifdef _DEBUG
|
||||||
|
// if (bufsize > 0) {
|
||||||
|
// printf("Got %d keyboard events.\n", bufsize);
|
||||||
|
// }
|
||||||
|
//#endif
|
||||||
for (unsigned int i = 0; i < bufsize; i ++) {
|
for (unsigned int i = 0; i < bufsize; i ++) {
|
||||||
num_events++;
|
num_events++;
|
||||||
*buf++ = (unsigned char) rgdod[i].dwOfs;
|
*buf++ = (unsigned char) rgdod[i].dwOfs;
|
||||||
*buf++ = (unsigned char) rgdod[i].dwData;
|
*buf++ = (unsigned char) rgdod[i].dwData;
|
||||||
if (translationEnabled) {
|
if (translationEnabled) {
|
||||||
// Cas: shouldn't need to call handleMessages any more
|
|
||||||
// handleMessages();
|
|
||||||
UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1);
|
UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1);
|
||||||
if (virt_key != 0) {
|
if (virt_key != 0) {
|
||||||
if (!GetKeyboardState(state))
|
if (!GetKeyboardState(state)) {
|
||||||
return 0;
|
*buf++ = 0;
|
||||||
|
*buf++ = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
num_chars = ToUnicode(virt_key,
|
num_chars = ToUnicode(virt_key,
|
||||||
rgdod[i].dwOfs,
|
rgdod[i].dwOfs,
|
||||||
state,
|
state,
|
||||||
|
@ -283,10 +290,23 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
* Method: nEnableTranslation
|
* Method: nEnableTranslation
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
||||||
(JNIEnv *, jclass)
|
(JNIEnv *, jclass)
|
||||||
{
|
{
|
||||||
|
// We can't do translation on DOS boxes it seems so we'll have to throw a wobbler
|
||||||
|
// here:
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||||
|
GetVersionEx(&osvi);
|
||||||
|
|
||||||
|
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
||||||
translationEnabled = true;
|
translationEnabled = true;
|
||||||
|
return JNI_TRUE;
|
||||||
|
} else {
|
||||||
|
translationEnabled = false;
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue