My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif


#include <jni.h>
#include <windows.h>
#include <xinput.h>


JNIEXPORT void JNICALL Java_com_esotericsoftware_controller_input_XInputXboxController_setEnabled
(JNIEnv* env, jclass c, jboolean enabled) {
XInputEnable((BOOL)enabled);
}


JNIEXPORT void JNICALL Java_com_esotericsoftware_controller_input_XInputXboxController_poll
(JNIEnv* env, jclass c, jint index, jobject byteBuffer) {
short *buffer = (short*)(*env)->GetDirectBufferAddress(env, byteBuffer);
XINPUT_STATE state;
DWORD result = XInputGetState((int)index, &state);
if (result != ERROR_SUCCESS) {
buffer[0] = 0;
return;
}
buffer[0] = 1;
buffer[1] = state.Gamepad.wButtons;
buffer[2] = state.Gamepad.bLeftTrigger;
buffer[3] = state.Gamepad.bRightTrigger;
buffer[4] = state.Gamepad.sThumbLX;
buffer[5] = state.Gamepad.sThumbLY;
buffer[6] = state.Gamepad.sThumbRX;
buffer[7] = state.Gamepad.sThumbRY;
}

Change log

r119 by nathan.sweet on Dec 25, 2009   Diff
Refactored the world to add support for
the XIM2.
Go to: 
Project members, sign in to write a code review

Older revisions

r82 by nathan.sweet on Dec 13, 2009   Diff
Drastically improved input system.
r81 by nathan.sweet on Dec 12, 2009   Diff
[No log message]
r80 by nathan.sweet on Dec 12, 2009   Diff
XInput native lib is working.
All revisions of this file

File info

Size: 977 bytes, 36 lines
Powered by Google Project Hosting