Linux:Moved NUM_BUTTONS up into java
This commit is contained in:
parent
c977ceda08
commit
f8ae518d0f
|
@ -50,6 +50,7 @@ import org.lwjgl.LWJGLException;
|
||||||
final class LinuxDisplay implements DisplayImplementation {
|
final class LinuxDisplay implements DisplayImplementation {
|
||||||
private static final int CURSOR_HANDLE_SIZE = 8;
|
private static final int CURSOR_HANDLE_SIZE = 8;
|
||||||
private static final int PBUFFER_HANDLE_SIZE = 24;
|
private static final int PBUFFER_HANDLE_SIZE = 24;
|
||||||
|
private static final int NUM_BUTTONS = 3;
|
||||||
|
|
||||||
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
|
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
|
||||||
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements LockAWT and UnlockAWT(), to
|
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements LockAWT and UnlockAWT(), to
|
||||||
|
@ -220,12 +221,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getButtonCount() {
|
public int getButtonCount() {
|
||||||
lockAWT();
|
return NUM_BUTTONS;
|
||||||
int num_buttons = nGetButtonCount();
|
|
||||||
unlockAWT();
|
|
||||||
return num_buttons;
|
|
||||||
}
|
}
|
||||||
public native int nGetButtonCount();
|
|
||||||
|
|
||||||
public void createMouse() {
|
public void createMouse() {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
|
|
|
@ -51,8 +51,6 @@
|
||||||
#include "org_lwjgl_input_Mouse.h"
|
#include "org_lwjgl_input_Mouse.h"
|
||||||
#include "org_lwjgl_opengl_LinuxDisplay.h"
|
#include "org_lwjgl_opengl_LinuxDisplay.h"
|
||||||
|
|
||||||
#define NUM_BUTTONS 3
|
|
||||||
|
|
||||||
#define EVENT_SIZE 5
|
#define EVENT_SIZE 5
|
||||||
|
|
||||||
#define POINTER_WARP_BORDER 10
|
#define POINTER_WARP_BORDER 10
|
||||||
|
@ -67,7 +65,7 @@ static int accum_dy;
|
||||||
static int accum_dz;
|
static int accum_dz;
|
||||||
static int last_x;
|
static int last_x;
|
||||||
static int last_y;
|
static int last_y;
|
||||||
static jbyte buttons[NUM_BUTTONS];
|
static jbyte buttons[org_lwjgl_opengl_LinuxDisplay_NUM_BUTTONS];
|
||||||
static event_queue_t event_queue;
|
static event_queue_t event_queue;
|
||||||
|
|
||||||
static Cursor blank_cursor;
|
static Cursor blank_cursor;
|
||||||
|
@ -201,10 +199,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetNativeCursor(JNIEn
|
||||||
updateCursor();
|
updateCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetButtonCount(JNIEnv *env, jobject this) {
|
|
||||||
return NUM_BUTTONS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset(void) {
|
static void reset(void) {
|
||||||
initEventQueue(&event_queue, EVENT_SIZE);
|
initEventQueue(&event_queue, EVENT_SIZE);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +212,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateMouse
|
||||||
int i;
|
int i;
|
||||||
last_y = last_x = accum_dx = accum_dy = accum_dz = 0;
|
last_y = last_x = accum_dx = accum_dy = accum_dz = 0;
|
||||||
reset();
|
reset();
|
||||||
for (i = 0; i < NUM_BUTTONS; i++)
|
for (i = 0; i < org_lwjgl_opengl_LinuxDisplay_NUM_BUTTONS; i++)
|
||||||
buttons[i] = 0;
|
buttons[i] = 0;
|
||||||
if (!blankCursor(env)) {
|
if (!blankCursor(env)) {
|
||||||
decDisplay();
|
decDisplay();
|
||||||
|
@ -248,13 +242,13 @@ static unsigned char mapButton(XButtonEvent *event) {
|
||||||
return 2;
|
return 2;
|
||||||
case Button3:
|
case Button3:
|
||||||
return 1;
|
return 1;
|
||||||
default: return NUM_BUTTONS;
|
default: return org_lwjgl_opengl_LinuxDisplay_NUM_BUTTONS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleButton(XButtonEvent *event, unsigned char state) {
|
static void handleButton(XButtonEvent *event, unsigned char state) {
|
||||||
unsigned char button_num = mapButton(event);
|
unsigned char button_num = mapButton(event);
|
||||||
if (button_num == NUM_BUTTONS)
|
if (button_num == org_lwjgl_opengl_LinuxDisplay_NUM_BUTTONS)
|
||||||
return;
|
return;
|
||||||
buttons[button_num] = state;
|
buttons[button_num] = state;
|
||||||
putMouseEvent(button_num, state, 0);
|
putMouseEvent(button_num, state, 0);
|
||||||
|
@ -338,7 +332,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nPollMouse(JNIEnv * en
|
||||||
}
|
}
|
||||||
coords[2] = accum_dz;
|
coords[2] = accum_dz;
|
||||||
accum_dx = accum_dy = accum_dz = 0;
|
accum_dx = accum_dy = accum_dz = 0;
|
||||||
int num_buttons = NUM_BUTTONS;
|
int num_buttons = org_lwjgl_opengl_LinuxDisplay_NUM_BUTTONS;
|
||||||
if (num_buttons > buttons_length)
|
if (num_buttons > buttons_length)
|
||||||
num_buttons = buttons_length;
|
num_buttons = buttons_length;
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue