Fixed win9x keyboard translation
This commit is contained in:
parent
e148f01ba9
commit
71f46bfce9
|
@ -51,8 +51,8 @@ if test "x$JAVA_HOME" = x; then
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT($JAVA_HOME)
|
AC_MSG_RESULT($JAVA_HOME)
|
||||||
JAVA_HOME="$JAVA_HOME"
|
JAVA_HOME="$JAVA_HOME"
|
||||||
CPPFLAGS="$CPPFLAGS -D_DEBUG -fno-rtti -fno-exceptions -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
CPPFLAGS="$CPPFLAGS -fno-rtti -fno-exceptions -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||||
CFLAGS="$CFLAGS -D_DEBUG -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
CFLAGS="$CFLAGS -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
|
|
|
@ -299,10 +299,11 @@ JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
* Method: nEnableTranslation
|
* Method: nEnableTranslation
|
||||||
* Signature: ()I
|
* Signature: ()I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
||||||
(JNIEnv *env, jclass clazz)
|
(JNIEnv *env, jclass clazz)
|
||||||
{
|
{
|
||||||
translation_enabled = true;
|
translation_enabled = true;
|
||||||
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -53,6 +53,7 @@ static BYTE readBuffer[KEYBOARD_BUFFER_SIZE*4];
|
||||||
static LPDIRECTINPUTDEVICE lpdiKeyboard = NULL;
|
static LPDIRECTINPUTDEVICE lpdiKeyboard = NULL;
|
||||||
static jfieldID fid_readBuffer;
|
static jfieldID fid_readBuffer;
|
||||||
static bool translationEnabled;
|
static bool translationEnabled;
|
||||||
|
static bool useUnicode;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -188,7 +189,8 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
{
|
{
|
||||||
|
|
||||||
static DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE];
|
static DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE];
|
||||||
wchar_t transBuf[KEYBOARD_BUFFER_SIZE];
|
wchar_t transBufUnicode[KEYBOARD_BUFFER_SIZE];
|
||||||
|
WORD transBufAscii[KEYBOARD_BUFFER_SIZE];
|
||||||
|
|
||||||
BYTE state[256];
|
BYTE state[256];
|
||||||
DWORD bufsize = KEYBOARD_BUFFER_SIZE;
|
DWORD bufsize = KEYBOARD_BUFFER_SIZE;
|
||||||
|
@ -220,28 +222,35 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||||
*buf++ = (unsigned char) rgdod[i].dwData;
|
*buf++ = (unsigned char) rgdod[i].dwData;
|
||||||
if (translationEnabled) {
|
if (translationEnabled) {
|
||||||
UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1);
|
UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1);
|
||||||
if (virt_key != 0) {
|
if (virt_key != 0 && GetKeyboardState(state)) {
|
||||||
if (!GetKeyboardState(state)) {
|
if (useUnicode) {
|
||||||
*buf++ = 0;
|
num_chars = ToUnicode(virt_key,
|
||||||
*buf++ = 0;
|
rgdod[i].dwOfs,
|
||||||
continue;
|
state,
|
||||||
|
transBufUnicode,
|
||||||
|
KEYBOARD_BUFFER_SIZE, 0);
|
||||||
|
} else {
|
||||||
|
num_chars = ToAscii(virt_key,
|
||||||
|
rgdod[i].dwOfs,
|
||||||
|
state,
|
||||||
|
transBufAscii,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
num_chars = ToUnicode(virt_key,
|
|
||||||
rgdod[i].dwOfs,
|
|
||||||
state,
|
|
||||||
transBuf,
|
|
||||||
KEYBOARD_BUFFER_SIZE, 0);
|
|
||||||
if (num_chars > 0) {
|
if (num_chars > 0) {
|
||||||
wchar_t ch = transBuf[0];
|
for (int i = 0; i < num_chars; i++) {
|
||||||
*buf++ = (unsigned char) (ch & 0xff);
|
if (i >= 1) {
|
||||||
*buf++ = (unsigned char) ((ch & 0xff00) >> 8);
|
num_events++;
|
||||||
for (int i = 1; i < num_chars; i++) {
|
*buf++ = 0;
|
||||||
num_events++;
|
*buf++ = 0;
|
||||||
ch = transBuf[i];
|
}
|
||||||
*buf++ = 0;
|
if (useUnicode) {
|
||||||
*buf++ = 0;
|
wchar_t ch = transBufUnicode[i];
|
||||||
*buf++ = (unsigned char) (ch & 0xff);
|
*buf++ = (unsigned char) (ch & 0xff);
|
||||||
*buf++ = (unsigned char) ((ch & 0xff00) >> 8);
|
*buf++ = (unsigned char) ((ch & 0xff00) >> 8);
|
||||||
|
} else {
|
||||||
|
*buf++ = (unsigned char)transBufAscii[0];
|
||||||
|
*buf++ = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*buf++ = 0;
|
*buf++ = 0;
|
||||||
|
@ -301,12 +310,12 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
|
||||||
GetVersionEx(&osvi);
|
GetVersionEx(&osvi);
|
||||||
|
|
||||||
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
||||||
translationEnabled = true;
|
useUnicode = true;
|
||||||
return JNI_TRUE;
|
|
||||||
} else {
|
} else {
|
||||||
translationEnabled = false;
|
useUnicode = false;
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
}
|
||||||
|
translationEnabled = true;
|
||||||
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue