aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorelias <[email protected]>2006-07-05 08:51:36 +0000
committerelias <[email protected]>2006-07-05 08:51:36 +0000
commit37df5381227e5fdce1401630ebf5ca8ecfee2502 (patch)
tree88dc8e5e9328d74cb6858a0ec69c16aeaa67a4e7 /plugins
parent783c0784013b3b13d4b61ca12de1d79e88671191 (diff)
Windows Raw Plugin: Make sure DefWindowProc is called to clean up resources. Use MSG.time field instead of GetMessageTime.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@147 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins')
-rw-r--r--plugins/windows/src/native/raw/net_java_games_input_RawInputEventQueue.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/plugins/windows/src/native/raw/net_java_games_input_RawInputEventQueue.c b/plugins/windows/src/native/raw/net_java_games_input_RawInputEventQueue.c
index 130430f..d0a1564 100644
--- a/plugins/windows/src/native/raw/net_java_games_input_RawInputEventQueue.c
+++ b/plugins/windows/src/native/raw/net_java_games_input_RawInputEventQueue.c
@@ -58,6 +58,19 @@ JNIEXPORT void JNICALL Java_net_java_games_input_RawInputEventQueue_nRegisterDev
int i;
HWND hwnd = (HWND)(INT_PTR)hwnd_addr;
+/* res = GetRegisteredRawInputDevices(NULL, &num_devices, sizeof(RAWINPUTDEVICE));
+ if (num_devices > 0) {
+ devices = (RAWINPUTDEVICE *)malloc(num_devices*sizeof(RAWINPUTDEVICE));
+ res = GetRegisteredRawInputDevices(devices, &num_devices, sizeof(RAWINPUTDEVICE));
+ if (res == -1) {
+ throwIOException(env, "Failed to get registered raw devices (%d)\n", GetLastError());
+ return;
+ }
+ for (i = 0; i < num_devices; i++) {
+ printfJava(env, "from windows: registered: %d %d %p (of %d)\n", devices[i].usUsagePage, devices[i].usUsage, devices[i].hwndTarget, num_devices);
+ }
+ free(devices);
+ }*/
device_info_class = (*env)->FindClass(env, "net/java/games/input/RawDeviceInfo");
if (device_info_class == NULL)
return;
@@ -98,22 +111,6 @@ JNIEXPORT void JNICALL Java_net_java_games_input_RawInputEventQueue_nRegisterDev
free(devices);
if (!res)
throwIOException(env, "Failed to register raw devices (%d)\n", GetLastError());
-
-/*
-
-
-
- res = GetRegisteredRawInputDevices(NULL, &num_devices, sizeof(RAWINPUTDEVICE));
- devices = (RAWINPUTDEVICE *)malloc(num_devices*sizeof(RAWINPUTDEVICE));
- res = GetRegisteredRawInputDevices(devices, &num_devices, sizeof(RAWINPUTDEVICE));
- if (res == -1) {
- throwIOException(env, "Failed to get registered raw devices (%d)\n", GetLastError());
- return;
- }
- for (i = 0; i < num_devices; i++) {
-printfJava(env, "from windows: registered: %d %d %p (of %d)\n", devices[i].usUsagePage, devices[i].usUsage, devices[i].hwndTarget, num_devices);
- }
- free(devices);*/
}
JNIEXPORT void JNICALL Java_net_java_games_input_RawInputEventQueue_nPoll(JNIEnv *env, jobject self, jlong hwnd_handle) {
@@ -135,21 +132,26 @@ JNIEXPORT void JNICALL Java_net_java_games_input_RawInputEventQueue_nPoll(JNIEnv
if (addKeyboardEvent_method == NULL)
return;
if (GetMessage(&msg, hwnd, 0, 0) != 0) {
- if (msg.message != WM_INPUT)
+ if (msg.message != WM_INPUT) {
+ DefWindowProc(hwnd, msg.message, msg.wParam, msg.lParam);
return; // ignore it
- time = GetMessageTime();
+ }
+ time = msg.time;
if (GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, NULL, &input_size, sizeof(RAWINPUTHEADER)) == (UINT)-1) {
throwIOException(env, "Failed to get raw input data size (%d)\n", GetLastError());
+ DefWindowProc(hwnd, msg.message, msg.wParam, msg.lParam);
return;
}
input_data = (RAWINPUT *)malloc(input_size);
if (input_data == NULL) {
throwIOException(env, "Failed to allocate input data buffer\n");
+ DefWindowProc(hwnd, msg.message, msg.wParam, msg.lParam);
return;
}
if (GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, input_data, &input_size, sizeof(RAWINPUTHEADER)) == (UINT)-1) {
free(input_data);
throwIOException(env, "Failed to get raw input data (%d)\n", GetLastError());
+ DefWindowProc(hwnd, msg.message, msg.wParam, msg.lParam);
return;
}
switch (input_data->header.dwType) {
@@ -164,5 +166,6 @@ JNIEXPORT void JNICALL Java_net_java_games_input_RawInputEventQueue_nPoll(JNIEnv
break;
}
free(input_data);
+ DefWindowProc(hwnd, msg.message, msg.wParam, msg.lParam);
}
}