diff options
22 files changed, 619 insertions, 1449 deletions
diff --git a/plugins/linux/build.xml b/plugins/linux/build.xml index 89c4eeb..977753d 100644 --- a/plugins/linux/build.xml +++ b/plugins/linux/build.xml @@ -59,14 +59,12 @@ </target> <target depends="init,compile" name="createJNIHeaders"> - <javah> + <javah destdir="src/native"> <classpath> - <pathelement path="src/java"/> - <pathelement location="jinput.jar"/> + <pathelement path="classes"/> + <pathelement location="../../coreAPI/bin/jinput.jar"/> </classpath> - <class name="net.java.games.input.LinuxDevice"/> - <class name="net.java.games.input.LinuxEnvironmentPlugin"/> - <class name="net.java.games.input.LinuxKeyboard"/> + <class name="net.java.games.input.EventInterface"/> </javah> </target> diff --git a/plugins/linux/src/java/net/java/games/input/EventInterface.java b/plugins/linux/src/java/net/java/games/input/EventInterface.java new file mode 100644 index 0000000..d47859c --- /dev/null +++ b/plugins/linux/src/java/net/java/games/input/EventInterface.java @@ -0,0 +1,71 @@ +package net.java.games.input; + +public class EventInterface { + + static { + System.out.println("Loading jinput-linux"); + System.loadLibrary("jinput-linux"); + } + + public static native void eventInit(); + public static native int getNumDevices(); + public static native boolean getFFEnabled(int device); + public static native String getName(int device); + public static native void rumble(int device, float force); + public static native int getBusType(int device); + public static native int getVendorID(int device); + public static native int getProductID(int device); + public static native int getVersion(int device); + public static native void getSupportedRelAxes(int device, int supportedAxis[]); + public static native void getSupportedAbsAxes(int device, int supportedAxis[]); + public static native void getSupportedButtons(int device, int supportedButtons[]); + public static native int poll(int device); + public static native void getPolledData(int device, int relAxesData[], int absAxesData[], int buttonData[]); + public static native int getAbsAxisMinimum(int device, int axisNumber); + public static native int getAbsAxisMaximum(int device, int axisNumber); + public static native int getAbsAxisFuzz(int device, int axisNumber); + public static native int isValidDevice(int device); + public static native void cleanup(int device); + public static native int getNumberRelAxes(int device); + public static native int getNumberAbsAxes(int device); + public static native int getNumberButtons(int device); + + public static void main(String args[]) { + eventInit(); + int numDevices = getNumDevices(); + + for(int i=0;i<numDevices;i++) { + System.out.println("Device name: " + getName(i)); + if(getFFEnabled(i)) { + try { + rumble(i,1f); + Thread.sleep(1000); + rumble(i,0.9f); + Thread.sleep(1000); + rumble(i,0.8f); + Thread.sleep(1000); + rumble(i,0.7f); + Thread.sleep(1000); + rumble(i,0.6f); + Thread.sleep(1000); + rumble(i,0.5f); + Thread.sleep(1000); + rumble(i,0.4f); + Thread.sleep(1000); + rumble(i,0.3f); + Thread.sleep(1000); + rumble(i,0.2f); + Thread.sleep(1000); + rumble(i,0.1f); + Thread.sleep(1000); + rumble(i,0f); + Thread.sleep(1000); + cleanup(i); + } catch (InterruptedException e) { + + } + } + } + } + +} diff --git a/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java b/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java new file mode 100644 index 0000000..5bf5e6a --- /dev/null +++ b/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java @@ -0,0 +1,52 @@ +package net.java.games.input; + +public class EventInterfaceTest { + + public static void main(String args[]) { + EventInterface.eventInit(); + int numDevices = EventInterface.getNumDevices(); + + for(int i=0;i<numDevices;i++) { + System.out.println("Device name: " + EventInterface.getName(i)); + if(EventInterface.getFFEnabled(i)) { + try { + EventInterface.rumble(i,1f); + Thread.sleep(1000); + EventInterface.rumble(i,0.8f); + Thread.sleep(1000); + EventInterface.rumble(i,0.6f); + Thread.sleep(1000); + EventInterface.rumble(i,0.4f); + Thread.sleep(1000); + + int numAbsAxis = EventInterface.getNumberAbsAxes(i); + int numRelAxis = EventInterface.getNumberRelAxes(i); + int numButtons = EventInterface.getNumberButtons(i); + + int absSupported[] = new int[numAbsAxis]; + int relSupported[] = new int[numRelAxis]; + int buttonsSupported[] = new int[numButtons]; + + EventInterface.getSupportedAbsAxes(i, absSupported); + EventInterface.getSupportedRelAxes(i, relSupported); + EventInterface.getSupportedButtons(i, buttonsSupported); + + EventInterface.poll(i); + int absAxisData[] = new int[numAbsAxis]; + int relAxisData[] = new int[numRelAxis]; + int buttonData[] = new int[numButtons]; + EventInterface.getPolledData(i, relAxisData, absAxisData, buttonData); + + EventInterface.rumble(i,0.2f); + Thread.sleep(1000); + EventInterface.rumble(i,0f); + Thread.sleep(1000); + EventInterface.cleanup(i); + } catch (InterruptedException e) { + + } + } + } + } +} + diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java index 228886e..a4071fb 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java @@ -112,7 +112,7 @@ public class LinuxDevice extends AbstractController { this.nativeID = nativeID; - portType = LinuxNativeTypesMap.getPortType(getNativePortType(nativeID)); + portType = LinuxNativeTypesMap.getPortType(EventInterface.getBusType(nativeID)); for(int i=0;i<8;i++) { hatAxisIDs[i] = -1; @@ -493,9 +493,13 @@ public class LinuxDevice extends AbstractController { * @return false if the controller is no longer valid. */ public boolean poll() { - int retval = nativePoll(nativeID, buttonData, relAxesData, absAxesData); - if(retval>=0) return true; - return false; + int retval = EventInterface.poll(nativeID); + if(retval<0) { + System.out.println("poll returned " + retval); + return false; + } + EventInterface.getPolledData(nativeID, relAxesData, absAxesData, buttonData); + return true; } /** @@ -532,7 +536,7 @@ public class LinuxDevice extends AbstractController { * @return The axis fuzz. */ public float getAbsAxisFuzz(int axisID) { - return (float) getNativeAbsAxisFuzz(nativeID, axisID); + return (float) EventInterface.getAbsAxisFuzz(nativeID, axisID); } /** @@ -541,7 +545,7 @@ public class LinuxDevice extends AbstractController { * @return The maximum value */ public float getAbsAxisMaximum(int axisID) { - return (float) getNativeAbsAxisMaximum(nativeID, axisID); + return (float) EventInterface.getAbsAxisMaximum(nativeID, axisID); } /** @@ -550,7 +554,7 @@ public class LinuxDevice extends AbstractController { * @return The minimum axis value */ public float getAbsAxisMinimum(int axisID) { - return (float) getNativeAbsAxisMinimum(nativeID, axisID); + return (float) EventInterface.getAbsAxisMinimum(nativeID, axisID); } /** Return the enumeration of supported button types for this device @@ -560,83 +564,30 @@ public class LinuxDevice extends AbstractController { if(supportedButtons.length==0) { return; } - getNativeSupportedButtons(nativeID, supportedButtons); + EventInterface.getSupportedButtons(nativeID, supportedButtons); } /** Return the enumeration of supported absolute axis types for this device * @param suportedAbsAxes The array to populate */ private void getSupportedAbsAxes(int suportedAbsAxes[]) { - getNativeSupportedAbsAxes(nativeID, suportedAbsAxes); + EventInterface.getSupportedAbsAxes(nativeID, suportedAbsAxes); } /** Return the enumeration of supported relative axis types for this device * @param supportedRelAxes The array to populate */ private void getSupportedRelAxes(int supportedRelAxes[]) { - getNativeSupportedRelAxes(nativeID, supportedRelAxes); + EventInterface.getSupportedRelAxes(nativeID, supportedRelAxes); } /** Returns the status of FF support for this device * */ private boolean getFFEnabled() { - return getNativeFFEnabled(nativeID); + return EventInterface.getFFEnabled(nativeID); } - - /** Native call to get the supported absolute axes for a device - * @param deviceID The native device number - * @param supportedAbsAxes aray to populate - */ - private native void getNativeSupportedAbsAxes(int deviceID, int supportedAbsAxes[]); - /** Native call to get the supported relative axes for a device - * @param deviceID The native device ID - * @param supportedRelAxes the array to populate - */ - private native void getNativeSupportedRelAxes(int deviceID, int supportedRelAxes[]); - /** Native call to get the supported buttons for a device - * @param deviceID The native device ID - * @param supportedButtons The array to populate - */ - private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]); - /** Call to poll the device at the native library - * @param deviceID The native device ID - * @param buttonData Array to populate with button values - * @param relAxesData Array to populate with relative axes values - * @param absAxesData Array to populate with absolute axes values - * @return the number of events read - */ - private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]); - /** Returns the fuzz of an axis fro mthe native lib - * @param deviceID The native device id - * @param axisID The native axis ID - * @return The fuzz - */ - private native int getNativeAbsAxisFuzz(int deviceID, int axisID); - /** Gets the maximum value for an absloute axis fr omthe native library - * @param deviceID The native device ID - * @param axisID The native axis ID - * @return The Max value - */ - private native int getNativeAbsAxisMaximum(int deviceID, int axisID); - /** Gets the minimum value for an absloute axis from the native library - * @param deviceID The native device ID - * @param axisID The native axis number - * @return The min value - */ - private native int getNativeAbsAxisMinimum(int deviceID, int axisID); - /** Gets the port type from the native lib - * @param deviceID The device to get the port type for - * @return The port type - */ - private native int getNativePortType(int deviceID); - - /** Gets the status of FF support for this device - * @param deviceID The device to get the port type for - * @return The port type - */ - private native boolean getNativeFFEnabled(int deviceID); - + /** * A device that represents a joystick coolie hat. * @author Jeremy Booth ([email protected]) diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java index 48d0502..b1d15dc 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java @@ -18,7 +18,7 @@ public class LinuxDeviceRumbler implements Rumbler { public void rumble(float intensity) { // TODO Auto-generated method stub - nativeRumble(deviceID, intensity); + EventInterface.rumble(deviceID, intensity); } public String getAxisName() { @@ -32,11 +32,13 @@ public class LinuxDeviceRumbler implements Rumbler { } private void cleanup() { - nativeCleanup(deviceID); + System.out.println("LinuxDeviceRumbler.cleanup"); + rumble(0f); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + //ignore + } + EventInterface.cleanup(deviceID); } - - private native void nativeRumble(int deviceID, float intensity); - - private native void nativeCleanup(int deviceID); - } diff --git a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java index fc19780..a8646a8 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java @@ -32,12 +32,6 @@ import net.java.games.util.plugins.Plugin; */ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin { - static { - if(isSupported()) { - System.loadLibrary("jinput-linux"); - } - } - /** List of controllers */ private Controller[] controllers; @@ -46,7 +40,7 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu public LinuxEnvironmentPlugin() { if(isSupported()) { LinuxNativeTypesMap.init(); - init(); + EventInterface.eventInit(); createControllers(); } else { controllers = new Controller[0]; @@ -75,7 +69,7 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu /** Create the controllers */ private void createControllers() { - int numDevices = getNumberOfDevices(); + int numDevices = EventInterface.getNumDevices(); Controller[] tempControllers = new Controller[numDevices]; @@ -103,10 +97,10 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu * @return The new device */ private Controller createDevice(int deviceNumber) { - String name = getDeviceName(deviceNumber); - int numAbsAxes = getNumAbsAxes(deviceNumber); - int numRelAxes = getNumRelAxes(deviceNumber); - int numButtons = getNumButtons(deviceNumber); + String name = EventInterface.getName(deviceNumber); + int numAbsAxes = EventInterface.getNumberAbsAxes(deviceNumber); + int numRelAxes = EventInterface.getNumberRelAxes(deviceNumber); + int numButtons = EventInterface.getNumberButtons(deviceNumber); Controller device = null; int mouseCharacteristic = 0; @@ -152,34 +146,5 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu } return device; } - - /** Get the name of a device from the native library - * @param deviceID The device id - * @return The devices name - */ - private native String getDeviceName(int deviceID); - /** Get the number of absolute axes for the requested device - * @param deviceID The device ID - * @return The number of abs axes - */ - private native int getNumAbsAxes(int deviceID); - /** Get the nmber or relative axes from the native library - * @param deviceID The native device ID - * @return The number of raltive axes for the device - */ - private native int getNumRelAxes(int deviceID); - /** Gets the number of buttons for the requested devce from the native library - * @param deviceID The device ID - * @return The number of buttons - */ - private native int getNumButtons(int deviceID); - /** Initialises the native library - * @return <0 if something went wrong - */ - private native int init(); - /** Gets the number of devices the native library found - * @return Th number of devices - */ - private native int getNumberOfDevices(); - + } diff --git a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java index f6533bd..5da3092 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java @@ -115,7 +115,8 @@ public class LinuxKeyboard extends StandardKeyboard { * @return False if this device is invalid. */ public boolean poll() { - int retval = nativePoll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData); + int retval = EventInterface.poll(nativeID); + EventInterface.getPolledData(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData); if(retval>=0) return true; return false; } @@ -169,25 +170,6 @@ public class LinuxKeyboard extends StandardKeyboard { * @param supportedButtons The array if key types to populate */ private void getSupportedButtons(int supportedButtons[]) { - getNativeSupportedButtons(nativeID, supportedButtons); + EventInterface.getSupportedButtons(nativeID, supportedButtons); } - - /** Gets the supported key types for a particular native device - * @param deviceID The device ID - * @param supportedButtons The array to populate with teh supported key ids - */ - private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]); - /** Calls the native library to poll the device - * @param deviceID The device ID - * @param buttonData Aray to populate with button values - * @param relAxesData Array to populate with relative axis values - * @param absAxesData Array to populate with absolute axes values - * @return <0 if soething went wrong - */ - private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]); - /** Gets the port type from the native library for a particular keyboard - * @param deviceID The keybaord id - * @return native port ype - */ - private native int getNativePortType(int deviceID); } diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp index a0b0888..71779cc 100644 --- a/plugins/linux/src/native/EventDevice.cpp +++ b/plugins/linux/src/native/EventDevice.cpp @@ -83,6 +83,7 @@ EventDevice::EventDevice(char *deviceFileName) { if (ioctl(fd, EVIOCSFF, &effect) == -1) { perror("Upload effect"); } + LOG_TRACE("Uploaded effect to id %d\n", effect.id); } else { @@ -243,21 +244,24 @@ int EventDevice::isValidDevice() { int EventDevice::getNumberRelAxes(){ if(inited!=1) return -1; + LOG_TRACE("EventDevice::getNumberRelAxes (%s) %d\n", name, numRelAxes); return numRelAxes; } int EventDevice::getNumberAbsAxes(){ if(inited!=1) return -1; + LOG_TRACE("EventDevice::getNumberAbsAxes (%s) %d\n", name, numAbsAxes); return numAbsAxes; } int EventDevice::getNumberButtons(){ if(inited!=1) return -1; + LOG_TRACE("EventDevice::getNumberButtons (%s) %d\n", name, numButtons); return numButtons; } const char *EventDevice::getName(){ - LOG_TRACE("EventDevice::getName()\n"); + LOG_TRACE("EventDevice::getName() %s\n", name); return name; } @@ -284,6 +288,7 @@ int EventDevice::getVersion(){ void EventDevice::getSupportedRelAxes(int supportedAxis[]){ int i; + //LOG_TRACE("EventDevice::getSupportedRelAxes\n"); if(inited!=1) return; for(i=0;i<numRelAxes; i++) { (supportedAxis)[i] = supportedRelAxes[i]; @@ -318,6 +323,7 @@ int EventDevice::poll(){ int dataChanged=0; if(inited!=1) return -1; + //LOG_TRACE("EventDevice::poll inited (%s)\n",name); // first thing to do is reset all relative axis as mice never seem to do it int i; @@ -392,13 +398,17 @@ void EventDevice::getPolledData(int relAxesData[], int absAxesData[], int button int i; if(inited!=1) return; + //LOG_TRACE("EventDevice::getPolledData inited (%s)\n",name); for(i=0;i<numRelAxes;i++) { + //LOG_TRACE("EventDevice::getPolledData rel axis %d\n",i); (relAxesData)[i] = this->relAxesData[i]; } for(i=0;i<numAbsAxes;i++) { + //LOG_TRACE("EventDevice::getPolledData abs axis %d\n",i); (absAxesData)[i] = this->absAxesData[i]; } for(i=0;i<numButtons;i++) { + //LOG_TRACE("EventDevice::getPolledData button %d\n",i); (buttonData)[i] = this->buttonData[i]; } } @@ -425,11 +435,11 @@ bool EventDevice::getFFEnabled() { } void EventDevice::rumble(float force) { + if(force<0) force=-force; if(force>1) force=1; - if(force<-1) force=-1; //LOG_TRACE("Rumbling at %d%%, (shh, pretend)\n", (int)(force*100)); - if(effect_playing==true && force==0) { + if(effect_playing==true) { stop.type=EV_FF; stop.code = effect.id; stop.value=0; @@ -441,6 +451,24 @@ void EventDevice::rumble(float force) { } } if(effect_playing==false && force!=0) { + if(force>=0.666) { + effect.u.rumble.strong_magnitude = (int)(0x8000*force); + effect.u.rumble.weak_magnitude = (int)(0xc000*force); + } else if(force>=0.333) { + effect.u.rumble.strong_magnitude = (int)(0x8000*force); + effect.u.rumble.weak_magnitude = (int)(0xc000*0); + } else { + effect.u.rumble.strong_magnitude = (int)(0x8000*0); + effect.u.rumble.weak_magnitude = (int)(0xc000*force); + } + + LOG_TRACE("Setting strong_mag to 0x%x, and weak_mag to 0x%x\n", effect.u.rumble.strong_magnitude, effect.u.rumble.weak_magnitude); + + LOG_TRACE("Uploading effect %d\n", effect.id); + if (ioctl(fd, EVIOCSFF, &effect) == -1) { + perror("Upload effect"); + } + play.type = EV_FF; play.code=effect.id; play.value=1; diff --git a/plugins/linux/src/native/JoystickDevice.cpp b/plugins/linux/src/native/JoystickDevice.cpp deleted file mode 100644 index 59d69eb..0000000 --- a/plugins/linux/src/native/JoystickDevice.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#include "eventInterfaceTypes.h" -#include "JoystickDevice.h" -#include <stdio.h> -#include <linux/input.h> -#include <linux/joystick.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <malloc.h> -#include <errno.h> - -#include "logger.h" - -JoystickDevice::JoystickDevice(char *deviceFileName) { - char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown"; - int i; - - LOG_TRACE("Trying to open %s\n", deviceFileName); - fd = open(deviceFileName, O_RDWR | O_NONBLOCK); - /*if(fd<0) { - char errorMessage[512]; - sprintf(errorMessage, "Error opening device %s\n", deviceFileName); - perror(errorMessage); - }*/ - - if(fd>0){ - LOG_TRACE("Opened %s, trying to get device name\n", deviceFileName); - if(ioctl(fd, JSIOCGNAME(sizeof(tempName)), tempName) < 0) { - LOG_TRACE("Failed to get device name for %s\n", deviceFileName); - char errorMessage[512]; - sprintf(errorMessage, "Error reading device %s\n", deviceFileName); - perror(errorMessage); - } - - int namelength=strlen(tempName); - name = (char *)malloc(namelength+1); - strncpy(name,tempName, namelength+1); - - char tempNumButtons; - char tempNumAxes; - LOG_TRACE("Getting button and axes information for %s\n", deviceFileName); - ioctl (fd, JSIOCGBUTTONS, &tempNumButtons); - ioctl (fd, JSIOCGAXES, &tempNumAxes); - - numButtons = tempNumButtons; - numAbsAxes = tempNumAxes; - - //fprintf(stderr, "Got joystick %s with %d buttons and %d axes\n", tempName, numButtons, numAbsAxes); - - //buttonData = (uint8_t *)malloc(numButtons * sizeof(uint8_t)); - buttonData = new uint8_t[numButtons]; - //absAxesData = (int *)malloc(numAbsAxes * sizeof(int)); - absAxesData = new int[numAbsAxes]; - - LOG_TRACE("Initialisation of %s completed\n", deviceFileName); - inited = 1; - } else { - LOG_TRACE("Failed to open device %s\n", deviceFileName); - inited = 0; - } -} - -int JoystickDevice::isValidDevice() { - return inited; -} - -int JoystickDevice::getNumberRelAxes(){ - if(inited!=1) return -1; - return 0; -} - -int JoystickDevice::getNumberAbsAxes(){ - if(inited!=1) return -1; - return numAbsAxes; -} - -int JoystickDevice::getNumberButtons(){ - if(inited!=1) return -1; - return numButtons; -} - -const char *JoystickDevice::getName(){ - return name; -} - -int JoystickDevice::getBusType(){ - if(inited!=1) return -1; - return 0; -} - -int JoystickDevice::getVendorID(){ - if(inited!=1) return -1; - return 0; -} - -int JoystickDevice::getProductID(){ - if(inited!=1) return -1; - return 0; -} - -int JoystickDevice::getVersion(){ - if(inited!=1) return -1; - return 0; -} - -void JoystickDevice::getSupportedRelAxes(int supportedAxis[]){ -} - -void JoystickDevice::getSupportedAbsAxes(int supportedAxis[]){ -} - -void JoystickDevice::getSupportedButtons(int supportedButtons[]){ -} - -/** - * A return value of -1 means error, 0 means ok, but no change - * a return of >0 means the data for this device has changed - */ -int JoystickDevice::poll(){ - struct js_event event; - int numEvents = 0; - while(read(fd, &event, sizeof event) > 0) { - numEvents++; - event.type &= ~JS_EVENT_INIT; - if(event.type == JS_EVENT_BUTTON) { - buttonData[event.number] = event.value; - } else if(event.type == JS_EVENT_AXIS) { - absAxesData[event.number] = event.value; - } - - } - // EAGAIN is returned when the queue is empty - if(errno != EAGAIN) { - printf("Something went wrong getting an event\n"); - } - - return numEvents; -} - -void JoystickDevice::getPolledData(int relAxesData[], int absAxesData[], int buttonData[]){ - int i; - - if(inited!=1) return; - for(i=0;i<numAbsAxes;i++) { - (absAxesData)[i] = this->absAxesData[i]; - } - for(i=0;i<numButtons;i++) { - (buttonData)[i] = this->buttonData[i]; - } -} - -int JoystickDevice::getAbsAxisMinimum(int axisNumber) { - return -32767; -} - -int JoystickDevice::getAbsAxisMaximum(int axisNumber) { - return 32767; -} - -int JoystickDevice::getAbsAxisFuzz(int axisNumber) { - return 0; -} - -bool JoystickDevice::getFFEnabled() { - return false; -} - -void JoystickDevice::rumble(float force) { - return; -} - -void JoystickDevice::cleanup() { - close(fd); -} diff --git a/plugins/linux/src/native/JoystickDevice.h b/plugins/linux/src/native/JoystickDevice.h deleted file mode 100644 index 87afa4d..0000000 --- a/plugins/linux/src/native/JoystickDevice.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#ifndef JoystickDevice_h -#define JoystickDevice_h - -#include <stdint.h> -#include <linux/input.h> -#include "eventInterfaceTypes.h" -#include "Device.h" - -class JoystickDevice : public Device { - - private: - int fd; - int inited; - char *name; - int numButtons; - int *absAxesData; - uint8_t *buttonData; - int numAbsAxes; - - public: - JoystickDevice(char *deviceFilename); - int getNumberRelAxes(); - int getNumberAbsAxes(); - int getNumberButtons(); - const char *getName(); - int getBusType(); - int getVendorID(); - int getProductID(); - int getVersion(); - void getSupportedRelAxes(int supportedAxis[]); - void getSupportedAbsAxes(int supportedAxis[]); - void getSupportedButtons(int supportedButtons[]); - int poll(); - void getPolledData(int relAxesData[], int absAxesData[], int buttonData[]); - int getAbsAxisMinimum(int axisNumber); - int getAbsAxisMaximum(int axisNumber); - int getAbsAxisFuzz(int axisNumber); - int isValidDevice(); - bool getFFEnabled(); - void rumble(float force); - void cleanup(); -}; - -#endif //eventInterface_eventDevice_h diff --git a/plugins/linux/src/native/MixedDevice.cpp b/plugins/linux/src/native/MixedDevice.cpp deleted file mode 100644 index bb113ea..0000000 --- a/plugins/linux/src/native/MixedDevice.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#include "eventInterfaceTypes.h" -#include "JoystickDevice.h" -#include "MixedDevice.h" -#include <stdio.h> -#include <linux/input.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <malloc.h> -#include <errno.h> - -MixedDevice::MixedDevice(JoystickDevice *jsDevice, EventDevice *evDevice) { - - joystickDevice = jsDevice; - eventDevice = evDevice; -} - -int MixedDevice::getNumberRelAxes(){ - eventDevice->getNumberRelAxes(); -} - -int MixedDevice::getNumberAbsAxes(){ - return eventDevice->getNumberAbsAxes(); -} - -int MixedDevice::getNumberButtons(){ - return eventDevice->getNumberButtons(); -} - -const char *MixedDevice::getName(){ - return eventDevice->getName(); -} - -int MixedDevice::getBusType(){ - return eventDevice->getBusType(); -} - -int MixedDevice::getVendorID(){ - return eventDevice->getVendorID(); -} - -int MixedDevice::getProductID(){ - return eventDevice->getProductID(); -} - -int MixedDevice::getVersion(){ - return eventDevice->getVersion(); -} - -void MixedDevice::getSupportedRelAxes(int supportedAxis[]){ - return eventDevice->getSupportedRelAxes(supportedAxis); -} - -void MixedDevice::getSupportedAbsAxes(int supportedAxis[]){ - return eventDevice->getSupportedAbsAxes(supportedAxis); -} - -void MixedDevice::getSupportedButtons(int supportedButtons[]){ - return eventDevice->getSupportedButtons(supportedButtons); -} - -/** - * A return value of -1 means error, 0 means ok, but no change - * a return of >0 means the data for this device has changed - */ -int MixedDevice::poll(){ - eventDevice->poll(); - return joystickDevice->poll(); -} - -void MixedDevice::getPolledData(int relAxesData[], int absAxesData[], int buttonData[]){ - int i; - - joystickDevice->getPolledData(new int[joystickDevice->getNumberRelAxes()], absAxesData, new int[joystickDevice->getNumberButtons()]); - eventDevice->getPolledData(relAxesData, new int[eventDevice->getNumberAbsAxes()], buttonData); - -} - -int MixedDevice::getAbsAxisMinimum(int axisNumber) { - return joystickDevice->getAbsAxisMinimum(axisNumber); -} - -int MixedDevice::getAbsAxisMaximum(int axisNumber) { - return joystickDevice->getAbsAxisMaximum(axisNumber); -} - -int MixedDevice::getAbsAxisFuzz(int axisNumber) { - return joystickDevice->getAbsAxisFuzz(axisNumber); -} - -bool MixedDevice::getFFEnabled() { - return eventDevice->getFFEnabled(); -} - -void MixedDevice::rumble(float force) { - eventDevice->rumble(force); -} - -void MixedDevice::cleanup() { - joystickDevice->cleanup(); - eventDevice->cleanup(); -} diff --git a/plugins/linux/src/native/MixedDevice.h b/plugins/linux/src/native/MixedDevice.h deleted file mode 100644 index 3239ed4..0000000 --- a/plugins/linux/src/native/MixedDevice.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#ifndef MixedDevice_h -#define MixedDevice_h - -#include <stdint.h> -#include <linux/input.h> -#include "eventInterfaceTypes.h" -#include "Device.h" -#include "EventDevice.h" -#include "JoystickDevice.h" -#include "MixedDevice.h" - -class MixedDevice : public Device { - - private: - JoystickDevice *joystickDevice; - EventDevice *eventDevice; - - public: - MixedDevice(JoystickDevice *joystickDevice, EventDevice *eventDevice); - int getNumberRelAxes(); - int getNumberAbsAxes(); - int getNumberButtons(); - const char *getName(); - int getBusType(); - int getVendorID(); - int getProductID(); - int getVersion(); - void getSupportedRelAxes(int supportedAxis[]); - void getSupportedAbsAxes(int supportedAxis[]); - void getSupportedButtons(int supportedButtons[]); - void getSupportedRelAxes(short supportedAxis[]); - void getSupportedAbsAxes(short supportedAxis[]); - void getSupportedButtons(short supportedButtons[]); - int poll(); - void getPolledData(int relAxesData[], int absAxesData[], int buttonData[]); - int getAbsAxisMinimum(int axisNumber); - int getAbsAxisMaximum(int axisNumber); - int getAbsAxisFuzz(int axisNumber); - bool getFFEnabled(); - void rumble(float force); - void cleanup(); -}; - -#endif //eventInterface_eventDevice_h diff --git a/plugins/linux/src/native/build.xml b/plugins/linux/src/native/build.xml index f055249..d976c57 100644 --- a/plugins/linux/src/native/build.xml +++ b/plugins/linux/src/native/build.xml @@ -1,25 +1,8 @@ <?xml version="1.0"?> -<!-- Written to assume that classpath is rooted in the current directory. --> -<!-- So this should be OK if you make this script in the root of a filesystem. --> -<!-- If not, you may prefer to adjust the basedir, or move some directories around. --> -<!-- The idea is that both Ant and NetBeans have to know what the package root is --> -<!-- for the classes in your application. --> <project name="JInput Linux port, Native code" basedir="." default="compileNativeJinputLib"> - <!-- Don't worry if you don't know the Ant syntax completely or need help on some tasks! --> - <!-- The standard Ant documentation is bundled. See Help | Help Sets | Ant 1.4.1 Manual. --> - <target name="init"> - <!-- You can set up any variables you want used throughout the script here. --> - <!-- property name="hello" value="world"/--> - <!-- To use e.g. Jikes, uncomment this line. --> - <!-- (Or make the same change in Tools | Options | Ant Settings | Properties.) --> - <!-- <property name="build.compiler" value="jikes"/> --> - <!-- You might like to set up some overridable paths, etc.: --> - <!-- <property name="mylib" value="../lib/mylib.jar"/> --> - <mkdir dir="build"/> - <mkdir dir="apidoc"/> </target> <target name="createNativeDefinitions.java" depends="init"> @@ -28,27 +11,9 @@ </exec> </target> - <target name="createJNIHeaders" depends="init"> - <javah> - <classpath> - <pathelement path="."/> - <pathelement location="jinput.jar"/> - </classpath> - <class name="net.java.games.input.LinuxDevice"/> - <class name="net.java.games.input.LinuxEnvironmentPlugin"/> - <class name="net.java.games.input.LinuxKeyboard"/> - </javah> - </target> - - <target name="compileNativeEventLib" depends="init"> - <exec dir="." executable="g++" os="Linux"> - <arg line="--shared -DLOGTRACE -o libeventInterface.so eventInterface.cpp EventDevice.cpp"/> - </exec> - </target> - <target name="compileNativeJinputLib" depends="init"> <exec dir="." executable="g++" os="Linux"> - <arg line="-I${java.home}/include -I${java.home}/include/linux -I${java.home}/../include -I${java.home}/../include/linux --shared -DLOGTRACE -o libjinput-linux.so jinput.cpp eventInterface.cpp EventDevice.cpp joystickInterface.cpp JoystickDevice.cpp MixedDevice.cpp"/> + <arg line="-I${java.home}/include -I${java.home}/include/linux -I${java.home}/../include -I${java.home}/../include/linux --shared -DLOGTRACE -o libjinput-linux.so eventInterface.cpp EventDevice.cpp eventInterfaceJNI.c"/> </exec> </target> </project> diff --git a/plugins/linux/src/native/eventInterfaceJNI.c b/plugins/linux/src/native/eventInterfaceJNI.c new file mode 100644 index 0000000..ab9fbc2 --- /dev/null +++ b/plugins/linux/src/native/eventInterfaceJNI.c @@ -0,0 +1,236 @@ +#include "net_java_games_input_EventInterface.h" +#include "eventInterface.c" + +/* + * Class: net_java_games_input_EventInterface + * Method: eventInit + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_eventInit + (JNIEnv *, jclass){ + eventInit(); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumDevices + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumDevices + (JNIEnv *, jclass) { + return getNumDevices(); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getFFEnabled + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_net_java_games_input_EventInterface_getFFEnabled + (JNIEnv *, jclass, jint device) { + return getFFEnabled(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getName + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_net_java_games_input_EventInterface_getName + (JNIEnv *env, jclass, jint device) { + return env->NewStringUTF(getName(device)); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: rumble + * Signature: (IF)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_rumble + (JNIEnv *, jclass, jint device, jfloat force) { + rumble(device, force); + } + + +/* + * Class: net_java_games_input_EventInterface + * Method: getBusType + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getBusType + (JNIEnv *, jclass, jint device){ + return getBusType(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getVendorID + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getVendorID + (JNIEnv *, jclass, jint device){ + return getVendorID(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getProductID + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getProductID + (JNIEnv *, jclass, jint device){ + return getProductID(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getVersion + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getVersion + (JNIEnv *, jclass, jint device){ + getVersion(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedRelAxes + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedRelAxes + (JNIEnv *env, jclass, jint device, jintArray axesData){ + jint *axisReturns = env->GetIntArrayElements(axesData, 0); + getSupportedRelAxes(device, axisReturns); + env->ReleaseIntArrayElements(axesData, axisReturns, 0); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedAbsAxes + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedAbsAxes + (JNIEnv *env, jclass, jint device, jintArray axesData){ + jint *axisReturns = env->GetIntArrayElements(axesData, 0); + getSupportedAbsAxes(device, axisReturns); + env->ReleaseIntArrayElements(axesData, axisReturns, 0); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedButtons + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedButtons + (JNIEnv *env, jclass, jint device, jintArray buttonData){ + jint *buttonReturns = env->GetIntArrayElements(buttonData, 0); + getSupportedButtons(device, buttonReturns); + env->ReleaseIntArrayElements(buttonData, buttonReturns, 0); +} +/* + * Class: net_java_games_input_EventInterface + * Method: poll + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_poll + (JNIEnv *, jclass, jint device){ + return poll(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getPolledData + * Signature: (I[I[I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getPolledData + (JNIEnv *env, jclass, jint device, jintArray relAxisData, jintArray absAxisData, jintArray buttonData) { + jint *buttonElements = env->GetIntArrayElements(buttonData, 0); + jint *relAxesElements = env->GetIntArrayElements(relAxisData, 0); + jint *absAxesElements = env->GetIntArrayElements(absAxisData, 0); + + getPolledData(device, relAxesElements, absAxesElements, buttonElements); + + env->ReleaseIntArrayElements(buttonData, buttonElements, 0); + env->ReleaseIntArrayElements(relAxisData, relAxesElements, 0); + env->ReleaseIntArrayElements(absAxisData, absAxesElements, 0); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisMinimum + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisMinimum + (JNIEnv *, jclass, jint device, jint axis) { + return getAbsAxisMinimum(device,axis); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisMaximum + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisMaximum + (JNIEnv *, jclass, jint device, jint axis) { + return getAbsAxisMaximum(device,axis); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisFuzz + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisFuzz + (JNIEnv *, jclass, jint device, jint axis) { + return getAbsAxisFuzz(device,axis); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: isValidDevice + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_isValidDevice + (JNIEnv *, jclass, jint device) { + return isValidDevice(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: cleanup + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_cleanup + (JNIEnv *, jclass, jint device) { + cleanup(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberRelAxes + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberRelAxes + (JNIEnv *, jclass, jint device) { + return getNumberRelAxes(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberAbsAxes + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberAbsAxes + (JNIEnv *, jclass, jint device) { + return getNumberAbsAxes(device); + } + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberButtons + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberButtons + (JNIEnv *, jclass, jint device) { + return getNumberButtons(device); + } diff --git a/plugins/linux/src/native/jinput.cpp b/plugins/linux/src/native/jinput.cpp deleted file mode 100644 index 2b8128f..0000000 --- a/plugins/linux/src/native/jinput.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <string.h> - -#include "net_java_games_input_LinuxDevice.h" -#include "net_java_games_input_LinuxEnvironmentPlugin.h" -#include "net_java_games_input_LinuxKeyboard.h" -#include "net_java_games_input_LinuxDeviceRumbler.h" - -#include "Device.h" -#include "EventDevice.h" -#include "JoystickDevice.h" -#include "MixedDevice.h" -#include "eventInterface.h" -#include "joystickInterface.h" -#include "logger.h" - -Device **jinputDeviceList; -int jinputNumDevices; - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: init - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init - (JNIEnv *, jobject) { - - LOG_TRACE("Initing event interface\n"); - if(evInit()!=0) { - fprintf(stderr, "Could not find any working event devices\n"); -// return -1; - } - LOG_TRACE("Initing joystick interface\n"); - if(jsInit()!=0) { - fprintf(stderr, "Could not find any working joystick devices\n"); -// return -1; - } - - LOG_TRACE("Getting the number of event devices\n"); - int numEventDevices = evGetNumberDevices(); - EventDevice *eventDevices[numEventDevices]; - - LOG_TRACE("Getting %d event devices\n", numEventDevices); - evGetDevices((Device **)eventDevices); - - LOG_TRACE("Getting the number of joystick devices\n"); - int numJoysticks = jsGetNumberDevices(); - JoystickDevice *jsDevices[numJoysticks]; - LOG_TRACE("Getting %d joystick devices\n", numJoysticks); - jsGetDevices((Device **)jsDevices); - - - int i; - int j; - int joystickPtr = 0; - jinputDeviceList = (Device **)malloc(numEventDevices * sizeof(Device *)); - for(i=0;i<numEventDevices;i++) { - EventDevice *eventDevice = eventDevices[i]; - int deviceCountCache = jinputNumDevices; - - for(j=joystickPtr;j<numJoysticks;j++) { - JoystickDevice *jsDevice = jsDevices[j]; - LOG_TRACE("Getting device information for event device %d and joystick %d\n", i, j); - if((jsDevice->getNumberButtons() == eventDevice->getNumberButtons()) && (jsDevice->getNumberAbsAxes() == (eventDevice->getNumberAbsAxes() + eventDevice->getNumberRelAxes()))) { - const char *jsName = jsDevice->getName(); - const char *eventDeviceName = eventDevice->getName(); - - if(strcmp(jsName, eventDeviceName) == 0) { - // The current event device is the curre joystick device too - LOG_TRACE("Creating a mixed device with id %d, combining event device %d and joystick device %d\n", jinputNumDevices, i, j); - jinputDeviceList[jinputNumDevices] = new MixedDevice(jsDevice, eventDevice); - jinputNumDevices++; - joystickPtr = j; - j = numJoysticks; - } - } - /*if(jinputNumDevices == deviceCountCache) { - fprintf(stderr, "event device \"%s\" doesn't match js \"%s\"\n", eventDevice->getName(), jsDevice->getName()); - fprintf(stderr, "event device has %d rel axes, %d abs axis and %d buttons\n", eventDevice->getNumberRelAxes(), eventDevice->getNumberAbsAxes(), eventDevice->getNumberButtons()); - fprintf(stderr, "js device has %d axes and %d buttons\n", jsDevice->getNumberAbsAxes(), jsDevice->getNumberButtons()); - } else { - fprintf(stderr, "event device %s did match js %s\n", eventDevice->getName(), jsDevice->getName()); - }*/ - - } - - if(jinputNumDevices == deviceCountCache) { - jinputDeviceList[jinputNumDevices] = eventDevice; - jinputNumDevices++; - } - } - - - return(0); - -} - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getDeviceName - * Signature: (I)Ljava/lang/String; - */ - -JNIEXPORT jstring JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getDeviceName - (JNIEnv *env, jobject, jint deviceID) { - - LOG_TRACE("Gettign device name for jinput device %d.\n", deviceID); - LOG_TRACE("jinput device %d is %d\n", deviceID, jinputDeviceList[deviceID]); - LOG_TRACE("Gettign device name for jinput device %d, (%s)\n", deviceID, jinputDeviceList[deviceID]->getName()); - return env->NewStringUTF(jinputDeviceList[deviceID]->getName()); -} - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumAbsAxes - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumAbsAxes - (JNIEnv *env, jobject, jint deviceID) { - - LOG_TRACE("Gettign number of absolute axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberAbsAxes()); - return jinputDeviceList[deviceID]->getNumberAbsAxes(); -} - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumRelAxes - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumRelAxes - (JNIEnv *env, jobject, jint deviceID) { - - LOG_TRACE("Gettign number of relative axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberRelAxes()); - return jinputDeviceList[deviceID]->getNumberRelAxes(); -} - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumButtons - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumButtons - (JNIEnv *, jobject, jint deviceID) { - - LOG_TRACE("Gettign number of buttons for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberButtons()); - return jinputDeviceList[deviceID]->getNumberButtons(); -} - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumberOfDevices - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumberOfDevices - (JNIEnv *, jobject) { - - return jinputNumDevices; -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedAbsAxes - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedAbsAxes - (JNIEnv *env, jobject, jint deviceID, jintArray axesData) { - - jint *axisReturns = env->GetIntArrayElements(axesData, 0); - - LOG_TRACE("Getting suported absolute axes for jinput device %d\n", deviceID); - jinputDeviceList[deviceID]->getSupportedAbsAxes(axisReturns); - - env->ReleaseIntArrayElements(axesData, axisReturns, 0); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedRelAxes - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedRelAxes - (JNIEnv *env, jobject, jint deviceID, jintArray axesData) { - - jint *axisReturns = env->GetIntArrayElements(axesData, 0); - - LOG_TRACE("Getting suported relative axes for jinput device %d\n", deviceID); - jinputDeviceList[deviceID]->getSupportedRelAxes(axisReturns); - - env->ReleaseIntArrayElements(axesData, axisReturns, 0); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedButtons - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedButtons - (JNIEnv *env, jobject, jint deviceID, jintArray buttonData) { - - jint *buttonDataElements = env->GetIntArrayElements(buttonData, 0); - - LOG_TRACE("Getting supported buttons for jinput device %d\n", deviceID); - jinputDeviceList[deviceID]->getSupportedButtons(buttonDataElements); - - env->ReleaseIntArrayElements(buttonData, buttonDataElements, 0); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: nativePoll - * Signature: (I[I[I[I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_nativePoll - (JNIEnv *env, jobject, jint deviceID, jintArray buttons, jintArray relAxes, jintArray absAxes) { - - jint *buttonElements = env->GetIntArrayElements(buttons, 0); - jint *relAxesElements = env->GetIntArrayElements(relAxes, 0); - jint *absAxesElements = env->GetIntArrayElements(absAxes, 0); - - LOG_POLL_TRACE("Polling jinput device %d\n", deviceID); - int retval = jinputDeviceList[deviceID]->poll(); - LOG_POLL_TRACE("Getting polled data for device %d\n", deviceID); - jinputDeviceList[deviceID]->getPolledData(relAxesElements, absAxesElements, buttonElements); - - env->ReleaseIntArrayElements(buttons, buttonElements, 0); - env->ReleaseIntArrayElements(relAxes, relAxesElements, 0); - env->ReleaseIntArrayElements(absAxes, absAxesElements, 0); - - return retval; -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisFuzz - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisFuzz - (JNIEnv *, jobject, jint deviceID, jint axisID) { - - LOG_TRACE("Getting fuzz data for axis %d on device %d\n", axisID, deviceID); - return jinputDeviceList[deviceID]->getAbsAxisFuzz(axisID); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisMaximum - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisMaximum - (JNIEnv *, jobject, jint deviceID, jint axisID) { - - LOG_TRACE("Getting absolute axes maximum value data for axis %d on device %d\n", axisID, deviceID); - return jinputDeviceList[deviceID]->getAbsAxisMaximum(axisID); -} - - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisMinimum - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisMinimum - (JNIEnv *, jobject, jint deviceID, jint axisID) { - - LOG_TRACE("Getting absolute axes minimum value data for axis %d on device %d\n", axisID, deviceID); - return jinputDeviceList[deviceID]->getAbsAxisMinimum(axisID); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativePortType - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativePortType - (JNIEnv *, jobject, jint deviceID) { - - LOG_TRACE("Getting bus type for device %d\n", deviceID); - return jinputDeviceList[deviceID]->getBusType(); -} - -/* Inaccessible static: NO_RUMBLERS */ -/* Inaccessible static: _00024assertionsDisabled */ -/* Inaccessible static: class_00024net_00024java_00024games_00024input_00024Keyboard */ -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: getNativeSupportedButtons - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxKeyboard_getNativeSupportedButtons - (JNIEnv *env, jobject, jint deviceID, jintArray buttons) { - - jint *buttonDataElements = env->GetIntArrayElements(buttons, 0); - - LOG_TRACE("Gettign number of buttons for jinput keyboard device %d\n", deviceID); - jinputDeviceList[deviceID]->getSupportedButtons(buttonDataElements); - - env->ReleaseIntArrayElements(buttons, buttonDataElements, 0); -} - -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: nativePoll - * Signature: (I[I[I[I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxKeyboard_nativePoll - (JNIEnv *env, jobject, jint deviceID, jintArray buttons, jintArray relAxes, jintArray absAxes) { - - jint *buttonElements = env->GetIntArrayElements(buttons, 0); - jint *relAxesElements = env->GetIntArrayElements(relAxes, 0); - jint *absAxesElements = env->GetIntArrayElements(absAxes, 0); - - LOG_POLL_TRACE("Polling jinput keyboard device %d\n", deviceID); - int retval = jinputDeviceList[deviceID]->poll(); - LOG_POLL_TRACE("Getting polled data for keyboard device %d\n", deviceID); - jinputDeviceList[deviceID]->getPolledData(relAxesElements, absAxesElements, buttonElements); - - env->ReleaseIntArrayElements(buttons, buttonElements, 0); - env->ReleaseIntArrayElements(relAxes, relAxesElements, 0); - env->ReleaseIntArrayElements(absAxes, absAxesElements, 0); - - return retval; -} - -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: getNativePortType - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxKeyboard_getNativePortType - (JNIEnv *, jobject, jint deviceID) { - - LOG_TRACE("Getting bus type for keyboard device %d\n", deviceID); - return jinputDeviceList[deviceID]->getBusType(); -} - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getFFEnabled - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_input_LinuxDevice_getNativeFFEnabled - (JNIEnv *, jobject, jint deviceID) { - - LOG_TRACE("Getting FFEnabled status for device %d\n", deviceID); - if(jinputDeviceList[deviceID]->getFFEnabled()) { - //LOG_TRACE("jinput lib thinks device %d is ff enabled\n", deviceID); - return JNI_TRUE; - } - //LOG_TRACE("jinput lib thinks device %d is ff disabled\n", deviceID); - return JNI_FALSE; -} - -/* - * Class: net_java_games_input_LinuxRumblerDevice - * Method: nativeRumble - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDeviceRumbler_nativeRumble - (JNIEnv *, jobject, jint deviceID, jfloat force) { - jinputDeviceList[deviceID]->rumble(force); -} - -/* - * Class: net_java_games_input_LinuxRumblerDevice - * Method: nativeCleanup - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDeviceRumbler_nativeCleanup - (JNIEnv *, jobject, jint deviceID) { - jinputDeviceList[deviceID]->cleanup(); -} diff --git a/plugins/linux/src/native/joystickInterface.cpp b/plugins/linux/src/native/joystickInterface.cpp deleted file mode 100644 index dc4f274..0000000 --- a/plugins/linux/src/native/joystickInterface.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#include <sys/dir.h> -#include <stdio.h> -#include <dirent.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <linux/joystick.h> -#include <string.h> -#include <malloc.h> -#include <unistd.h> -#include "Device.h" -#include "JoystickDevice.h" - -int jsNumDevices; -int joystickInterfaceVersion; -Device **jsDeviceList; -int jsInited = 0; - -int jsFileFilter(const struct direct *entry) { - if (strncmp(entry->d_name, "js", 2) == 0) { - return 1; - } - return 0; - } - -int jsGetDeviceFiles(char ***filenames) { - struct direct **files; - int num_files, i; - char dirName[] = {"/dev/input"}; - - num_files = scandir(dirName, &files, &jsFileFilter, alphasort); - - *filenames = (char **)malloc(num_files * sizeof(char *)); - - for(i=0;i<num_files;i++) { - char *filename = files[i]->d_name; - char *fullFileName; - - fullFileName = (char *)malloc((strlen(dirName) + 1 + strlen(filename) + 1)); - sprintf(fullFileName, "%s/%s", dirName, filename); - (*filenames)[i] = fullFileName; - } - - return num_files; -} - -int jsInit() { - int fd=-1; - int i; - char **deviceFileNames; - int numDeviceFiles; - - numDeviceFiles = jsGetDeviceFiles(&deviceFileNames); - if(numDeviceFiles<0) { - return -1; - } - - if ((fd = open(deviceFileNames[0], O_RDONLY)) <0) { - jsNumDevices = 0; - jsInited=1; - return 0; - } - - if (ioctl(fd, JSIOCGVERSION, &joystickInterfaceVersion)) { - close(fd); - jsNumDevices = 0; - jsInited=1; - return 0; - } - - if(fd>=0) {close(fd);} - - Device *tempDeviceList[numDeviceFiles]; - - jsNumDevices = 0; - for(i=0;i<numDeviceFiles;i++) { - JoystickDevice *tempDevice = new JoystickDevice(deviceFileNames[i]); - if(tempDevice->isValidDevice()==1) { - tempDeviceList[i] = tempDevice; - jsNumDevices++; - } - } - - int highDeviceCountNumber = i; - int jsTempDeviceCount = 0; - // Now we know for certain which devices are open, we can take notes - jsDeviceList = (Device **)malloc(jsNumDevices * sizeof(Device *)); - for(i=0;i<jsNumDevices;i++) { - while(tempDeviceList[jsTempDeviceCount] == NULL) { - jsTempDeviceCount++; - } - jsDeviceList[i] = tempDeviceList[jsTempDeviceCount]; - //printf("Copied joystick %d to %d\n", jsTempDeviceCount, i); - jsTempDeviceCount++; - } - - jsInited=1; - - return 0; -} - -int jsGetJoystickInterfaceVersionNumber() { - return joystickInterfaceVersion; -} - -int jsGetNumberDevices() { - if(jsInited) { - return jsNumDevices; - } - return -1; -} - -void jsGetDevices(Device **theirDeviceList) { - int i; - for(i=0;i<jsNumDevices;i++) { - theirDeviceList[i] = jsDeviceList[i]; - } -} diff --git a/plugins/linux/src/native/joystickInterface.h b/plugins/linux/src/native/joystickInterface.h deleted file mode 100644 index 01b8c58..0000000 --- a/plugins/linux/src/native/joystickInterface.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (C) 2003 Jeremy Booth ([email protected]) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. Redistributions in binary - * form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * The name of the author may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE - */ - -#if !defined(joystickInterface_h) -#define joystickInterface_h - -#include "Device.h" - -int jsGetJoystickInterfaceVersionNumber(); -int jsInit(); -int jsGetNumberDevices(); -void jsGetDevices(Device **deviceList); - -#endif //joystickInterface_h diff --git a/plugins/linux/src/native/net_java_games_input_EventInterface.h b/plugins/linux/src/native/net_java_games_input_EventInterface.h new file mode 100644 index 0000000..be88325 --- /dev/null +++ b/plugins/linux/src/native/net_java_games_input_EventInterface.h @@ -0,0 +1,189 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class net_java_games_input_EventInterface */ + +#ifndef _Included_net_java_games_input_EventInterface +#define _Included_net_java_games_input_EventInterface +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: net_java_games_input_EventInterface + * Method: eventInit + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_eventInit + (JNIEnv *, jclass); + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumDevices + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumDevices + (JNIEnv *, jclass); + +/* + * Class: net_java_games_input_EventInterface + * Method: getFFEnabled + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_net_java_games_input_EventInterface_getFFEnabled + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getName + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_net_java_games_input_EventInterface_getName + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: rumble + * Signature: (IF)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_rumble + (JNIEnv *, jclass, jint, jfloat); + +/* + * Class: net_java_games_input_EventInterface + * Method: getBusType + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getBusType + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getVendorID + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getVendorID + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getProductID + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getProductID + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getVersion + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getVersion + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedRelAxes + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedRelAxes + (JNIEnv *, jclass, jint, jintArray); + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedAbsAxes + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedAbsAxes + (JNIEnv *, jclass, jint, jintArray); + +/* + * Class: net_java_games_input_EventInterface + * Method: getSupportedButtons + * Signature: (I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getSupportedButtons + (JNIEnv *, jclass, jint, jintArray); + +/* + * Class: net_java_games_input_EventInterface + * Method: poll + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_poll + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getPolledData + * Signature: (I[I[I[I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_getPolledData + (JNIEnv *, jclass, jint, jintArray, jintArray, jintArray); + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisMinimum + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisMinimum + (JNIEnv *, jclass, jint, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisMaximum + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisMaximum + (JNIEnv *, jclass, jint, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getAbsAxisFuzz + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getAbsAxisFuzz + (JNIEnv *, jclass, jint, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: isValidDevice + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_isValidDevice + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: cleanup + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_net_java_games_input_EventInterface_cleanup + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberRelAxes + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberRelAxes + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberAbsAxes + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberAbsAxes + (JNIEnv *, jclass, jint); + +/* + * Class: net_java_games_input_EventInterface + * Method: getNumberButtons + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_net_java_games_input_EventInterface_getNumberButtons + (JNIEnv *, jclass, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/plugins/linux/src/native/net_java_games_input_LinuxDevice.h b/plugins/linux/src/native/net_java_games_input_LinuxDevice.h deleted file mode 100644 index 13cba3e..0000000 --- a/plugins/linux/src/native/net_java_games_input_LinuxDevice.h +++ /dev/null @@ -1,88 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_input_LinuxDevice */ - -#ifndef _Included_net_java_games_input_LinuxDevice -#define _Included_net_java_games_input_LinuxDevice -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: NO_AXES */ -/* Inaccessible static: NO_CONTROLLERS */ -/* Inaccessible static: NO_RUMBLERS */ -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedAbsAxes - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedAbsAxes - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedRelAxes - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedRelAxes - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeSupportedButtons - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedButtons - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: nativePoll - * Signature: (I[I[I[I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_nativePoll - (JNIEnv *, jobject, jint, jintArray, jintArray, jintArray); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisFuzz - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisFuzz - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisMaximum - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisMaximum - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativeAbsAxisMinimum - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativeAbsAxisMinimum - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getNativePortType - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxDevice_getNativePortType - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_input_LinuxDevice - * Method: getFFEnabled - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_input_LinuxDevice_getNativeFFEnabled - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/plugins/linux/src/native/net_java_games_input_LinuxDeviceRumbler.h b/plugins/linux/src/native/net_java_games_input_LinuxDeviceRumbler.h deleted file mode 100644 index 085f22d..0000000 --- a/plugins/linux/src/native/net_java_games_input_LinuxDeviceRumbler.h +++ /dev/null @@ -1,28 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_input_LinuxDeviceRumbler */ - -#ifndef _Included_net_java_games_input_LinuxDeviceRumbler -#define _Included_net_java_games_input_LinuxDeviceRumbler -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: net_java_games_input_LinuxDeviceRumbler - * Method: nativeRumble - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDeviceRumbler_nativeRumble - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: net_java_games_input_LinuxDeviceRumbler - * Method: nativeCleanup - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDeviceRumbler_nativeCleanup - (JNIEnv *, jobject, jint); -#ifdef __cplusplus -} -#endif -#endif diff --git a/plugins/linux/src/native/net_java_games_input_LinuxEnvironmentPlugin.h b/plugins/linux/src/native/net_java_games_input_LinuxEnvironmentPlugin.h deleted file mode 100644 index 6e68a97..0000000 --- a/plugins/linux/src/native/net_java_games_input_LinuxEnvironmentPlugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_input_LinuxEnvironmentPlugin */ - -#ifndef _Included_net_java_games_input_LinuxEnvironmentPlugin -#define _Included_net_java_games_input_LinuxEnvironmentPlugin -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: _00024assertionsDisabled */ -/* Inaccessible static: defaultEnvironment */ -/* Inaccessible static: class_00024net_00024java_00024games_00024input_00024ControllerEnvironment */ -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getDeviceName - * Signature: (I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getDeviceName - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumAbsAxes - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumAbsAxes - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumRelAxes - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumRelAxes - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumButtons - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumButtons - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: init - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init - (JNIEnv *, jobject); - -/* - * Class: net_java_games_input_LinuxEnvironmentPlugin - * Method: getNumberOfDevices - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumberOfDevices - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/plugins/linux/src/native/net_java_games_input_LinuxKeyboard.h b/plugins/linux/src/native/net_java_games_input_LinuxKeyboard.h deleted file mode 100644 index 041f416..0000000 --- a/plugins/linux/src/native/net_java_games_input_LinuxKeyboard.h +++ /dev/null @@ -1,42 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_input_LinuxKeyboard */ - -#ifndef _Included_net_java_games_input_LinuxKeyboard -#define _Included_net_java_games_input_LinuxKeyboard -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: NO_AXES */ -/* Inaccessible static: NO_CONTROLLERS */ -/* Inaccessible static: NO_RUMBLERS */ -/* Inaccessible static: _00024assertionsDisabled */ -/* Inaccessible static: class_00024net_00024java_00024games_00024input_00024Keyboard */ -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: getNativeSupportedButtons - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_input_LinuxKeyboard_getNativeSupportedButtons - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: nativePoll - * Signature: (I[I[I[I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxKeyboard_nativePoll - (JNIEnv *, jobject, jint, jintArray, jintArray, jintArray); - -/* - * Class: net_java_games_input_LinuxKeyboard - * Method: getNativePortType - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxKeyboard_getNativePortType - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif |