Use names that correspond with System.getProperty("os.name").

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3330 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-02-03 01:24:57 +00:00
parent 924ab5c9e6
commit 279849151c
6 changed files with 4 additions and 4 deletions
@@ -0,0 +1,44 @@
#
# $Id$
#
# Executable definitions
CC=gcc
RM=rm
CP=cp
MKDIR=mkdir
#
# Directory definitions
ROOT=../../../../../../..
LIBRARIES_PATH=-L/usr/X11R6/lib
INSTALL_PATH=${ROOT}/dist/lib/i686-Linux
#
# Parameter and file definitions
INCLUDES=-I.. -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux
LIBRARIES=-lX11
TARGET=libkeybd.so
#
# Target definitions
all: ${TARGET}
install: ${TARGET}
@${MKDIR} -p ${INSTALL_PATH}
cp ${TARGET} ${INSTALL_PATH}
${TARGET}: com_threerings_util_keybd_Keyboard.c
@echo Compiling Keyboard.c
@${CC} ${INCLUDES} -c com_threerings_util_keybd_Keyboard.c \
-o com_threerings_util_keybd_Keyboard.o
@echo Creating libkeybd.so
@${CC} -o ${TARGET} com_threerings_util_keybd_Keyboard.o \
${LIBRARIES} ${LIBRARIES_PATH} -shared
clean:
-${RM} -f *.o ${TARGET}
@@ -0,0 +1,87 @@
/*
* $Id$
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <jni.h>
#include "com_threerings_util_keybd_Keyboard.h"
/* defines */
#define MESSAGE_LENGTH (256)
/* prototype definitions */
Display* getXDisplay (JNIEnv* env);
JNIEXPORT jboolean JNICALL
Java_com_threerings_util_keybd_Keyboard_init (
JNIEnv* env, jclass class, jboolean enabled)
{
Display* display = getXDisplay(env);
if (display == NULL) {
/* If we are unable to open a display, we can't function. */
return JNI_FALSE;
} else {
XCloseDisplay(display);
return JNI_TRUE;
}
}
JNIEXPORT void JNICALL
Java_com_threerings_util_keybd_Keyboard_setKeyRepeat (
JNIEnv* env, jclass class, jboolean enabled)
{
Display* display = getXDisplay(env);
if (display == NULL) {
return;
}
/* set the desired key auto-repeat state. */
if (enabled) {
XAutoRepeatOn(display);
} else {
XAutoRepeatOff(display);
}
/* close the display to save our changes */
XCloseDisplay(display);
}
JNIEXPORT jboolean JNICALL
Java_com_threerings_util_keybd_Keyboard_isKeyRepeatEnabled (
JNIEnv* env, jclass class)
{
XKeyboardState values;
Display* display = getXDisplay(env);
if (display == NULL) {
/* for now, assume auto-repeat is enabled */
return JNI_TRUE;
}
/* get the current keyboard control information */
XGetKeyboardControl(display, &values);
/* close the display */
XCloseDisplay(display);
return (values.global_auto_repeat) ? JNI_TRUE : JNI_FALSE;
}
/*
* Returns a pointer to the X display, or null if an error occurred.
*/
Display*
getXDisplay (JNIEnv* env)
{
char* disp = NULL;
Display* dpy = XOpenDisplay(disp);
if (dpy == NULL) {
char message[MESSAGE_LENGTH];
snprintf(message, MESSAGE_LENGTH,
"Unable to open display [display=%s].\n", XDisplayName(disp));
return NULL;
}
/* printf("Opened display [disp=%s].\n", XDisplayName(disp)); */
return dpy;
}
Binary file not shown.