diff options
author | endolf <[email protected]> | 2003-07-31 19:34:46 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2003-07-31 19:34:46 +0000 |
commit | b2f4c7ccd86474da65136f8fdf2cfd34d1e94841 (patch) | |
tree | b0ef45439e7f1f5955039bef8654e12e2094ee91 /plugins/linux/src/native | |
parent | 878c5df2d77ce39aac091ede505a3dd94d897dd7 (diff) |
Initial commit of Linux plugin
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@23 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins/linux/src/native')
-rw-r--r-- | plugins/linux/src/native/Device.h | 69 | ||||
-rw-r--r-- | plugins/linux/src/native/EventDevice.cpp | 364 | ||||
-rw-r--r-- | plugins/linux/src/native/EventDevice.h | 85 | ||||
-rw-r--r-- | plugins/linux/src/native/JoystickDevice.cpp | 178 | ||||
-rw-r--r-- | plugins/linux/src/native/JoystickDevice.h | 68 | ||||
-rw-r--r-- | plugins/linux/src/native/MixedDevice.cpp | 115 | ||||
-rw-r--r-- | plugins/linux/src/native/MixedDevice.h | 68 | ||||
-rw-r--r-- | plugins/linux/src/native/eventInterface.cpp | 131 | ||||
-rw-r--r-- | plugins/linux/src/native/eventInterface.h | 37 | ||||
-rw-r--r-- | plugins/linux/src/native/eventInterfaceTypes.h | 24 | ||||
-rw-r--r-- | plugins/linux/src/native/jinput.cpp | 333 | ||||
-rw-r--r-- | plugins/linux/src/native/joystickInterface.cpp | 132 | ||||
-rw-r--r-- | plugins/linux/src/native/joystickInterface.h | 37 | ||||
-rw-r--r-- | plugins/linux/src/native/net_java_games_input_LinuxDevice.h | 80 | ||||
-rw-r--r-- | plugins/linux/src/native/net_java_games_input_LinuxEnvironmentPlugin.h | 64 | ||||
-rw-r--r-- | plugins/linux/src/native/net_java_games_input_LinuxKeyboard.h | 42 |
16 files changed, 1827 insertions, 0 deletions
diff --git a/plugins/linux/src/native/Device.h b/plugins/linux/src/native/Device.h new file mode 100644 index 0000000..020df30 --- /dev/null +++ b/plugins/linux/src/native/Device.h @@ -0,0 +1,69 @@ +/** + * 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(eventInterface_Device_h) +#define eventInterface_Device_h + +/** + * Simple abstract device class + * + * @author Jeremy Booth ([email protected]) + */ +class Device { + + private: + + public: + /** Maximum name length for a device */ + const static int MAX_NAME_LENGTH = 256; + /** Return the number of relative axes for this device */ + virtual int getNumberRelAxes() = 0; + /** Return the number ofr absolute axes for this device */ + virtual int getNumberAbsAxes() = 0; + /** Return the number of buttons for this device */ + virtual int getNumberButtons() = 0; + /** Get the name of this device */ + virtual const char *getName() = 0; + /** get teh bus type */ + virtual int getBusType() = 0; + virtual int getVendorID() = 0; + virtual int getProductID() = 0; + virtual int getVersion() = 0; + /** Get the supported axes/button maps */ + virtual void getSupportedRelAxes(int supportedAxis[]) = 0; + virtual void getSupportedAbsAxes(int supportedAxis[]) = 0; + virtual void getSupportedButtons(int supportedButtons[]) = 0; + /** poll it */ + virtual int poll() = 0; + /** get the data */ + virtual void getPolledData(int relAxesData[], int absAxesData[], int buttonData[]) = 0; + /** Get axis details */ + virtual int getAbsAxisMinimum(int axisNumber) = 0; + virtual int getAbsAxisMaximum(int axisNumber) = 0; + virtual int getAbsAxisFuzz(int axisNumber) = 0; +}; + +#endif //eventInterface_Device_h diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp new file mode 100644 index 0000000..de9b5a4 --- /dev/null +++ b/plugins/linux/src/native/EventDevice.cpp @@ -0,0 +1,364 @@ +/** + * 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 "EventDevice.h" +#include <stdio.h> +#include <linux/input.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> +#include <malloc.h> +#include <errno.h> + +EventDevice::EventDevice(char *deviceFileName) { + char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown"; + int i; + + fd = open(deviceFileName, O_RDWR | O_NONBLOCK); + if(fd<0) { + char errorMessage[512]; + sprintf(errorMessage, "Error opening device %s\n", deviceFileName); + perror(errorMessage); + } + + if(ioctl(fd, EVIOCGNAME(sizeof(tempName)), tempName) < 0) { + 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); + + uint8_t evtype_bitmask[EV_MAX/8 + 1]; + memset(evtype_bitmask, 0, sizeof(evtype_bitmask)); + + if(ioctl(fd, EVIOCGBIT(0, EV_MAX), evtype_bitmask) < 0) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + + struct input_devinfo deviceInfo; + if(ioctl(fd, EVIOCGID, &deviceInfo) < 0) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + + bustype = deviceInfo.bustype; + vendor = deviceInfo.vendor; + product = deviceInfo.product; + version = deviceInfo.version; + + numButtons = -1; + numAbsAxes = -1; + numRelAxes = -1; + + if(!(getBit(EV_KEY, evtype_bitmask))) { + numButtons = 0; + } + if(!(getBit(EV_REL, evtype_bitmask))) { + numRelAxes = 0; + } + + if(!(getBit(EV_ABS, evtype_bitmask))) { + numAbsAxes = 0; + } + + if(getBit(EV_FF, evtype_bitmask)) { + ffSupported = 1; + } else { + ffSupported = 0; + } + + if(numButtons < 0) { + // This device supports keys, deal with it. + if(ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask) < 0) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + for(i=0;i<KEY_MAX;i++) { + buttonLookup[i]=-1; + } + short tempSupportedButtons[KEY_MAX]; + numButtons = 0; + for(i=0;i<KEY_MAX;i++) { + if(getBit(i,key_bitmask)) { + tempSupportedButtons[numButtons] = i; + numButtons++; + } + } + supportedButtons = (short *)malloc(numButtons * sizeof(short)); + buttonData = (uint8_t *)malloc(numButtons * sizeof(uint8_t)); + for(i=0;i<numButtons;i++) { + buttonData[i] = 0; + supportedButtons[i] = tempSupportedButtons[i]; + buttonLookup[supportedButtons[i]] = i; + } + } + + if(numRelAxes < 0) { + // This device supports axes, deal with it. + if(ioctl(fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask) < 0) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + for(i=0;i<REL_MAX;i++) { + relAxisLookup[i]=-1; + } + short tempSupportedAxes[REL_MAX]; + numRelAxes=0; + for(i=0;i<REL_MAX;i++) { + if(getBit(i,rel_bitmask)) { + tempSupportedAxes[numRelAxes] = i; + numRelAxes++; + } + } + relAxesData = (int *)malloc(numRelAxes * sizeof(int)); + supportedRelAxes = (short *)malloc(numRelAxes * sizeof(short)); + for(i=0;i<numRelAxes;i++) { + relAxesData[i]=0; + supportedRelAxes[i] = tempSupportedAxes[i]; + relAxisLookup[supportedRelAxes[i]] = i; + } + } + + + if(numAbsAxes < 0) { + if(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) < 0) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + for(i=0;i<ABS_MAX;i++) { + absAxisLookup[i] = -1; + } + short tempSupportedAxes[ABS_MAX]; + numAbsAxes=0; + for(i=0;i<ABS_MAX;i++) { + if(getBit(i,abs_bitmask)) { + tempSupportedAxes[numAbsAxes] = i; + numAbsAxes++; + } + } + + absAxesData = (int *)malloc(numAbsAxes * sizeof(int)); + supportedAbsAxes = (short *)malloc(numAbsAxes * sizeof(short)); + for(i=0;i<numAbsAxes;i++) { + supportedAbsAxes[i] = tempSupportedAxes[i]; + absAxisLookup[supportedAbsAxes[i]] = i; + } + + abs_features = (struct input_absinfo *)malloc(numAbsAxes * sizeof(struct input_absinfo)); + for(i=0;i<numAbsAxes;i++) { + if(ioctl(fd, EVIOCGABS(supportedAbsAxes[i]), &(abs_features[i]))) { + char errorMessage[512]; + sprintf(errorMessage, "Error reading device %s\n", deviceFileName); + perror(errorMessage); + } + absAxesData[i] = abs_features[i].curr_value; + } + } + + inited = 1; +} + +int EventDevice::getNumberRelAxes(){ + if(inited!=1) return -1; + return numRelAxes; +} + +int EventDevice::getNumberAbsAxes(){ + if(inited!=1) return -1; + return numAbsAxes; +} + +int EventDevice::getNumberButtons(){ + if(inited!=1) return -1; + return numButtons; +} + +const char *EventDevice::getName(){ + return name; +} + +int EventDevice::getBusType(){ + if(inited!=1) return -1; + return bustype; +} + +int EventDevice::getVendorID(){ + if(inited!=1) return -1; + return vendor; +} + +int EventDevice::getProductID(){ + if(inited!=1) return -1; + return product; +} + +int EventDevice::getVersion(){ + if(inited!=1) return -1; + return version; +} + +void EventDevice::getSupportedRelAxes(int supportedAxis[]){ + int i; + + if(inited!=1) return; + for(i=0;i<numRelAxes; i++) { + (supportedAxis)[i] = supportedRelAxes[i]; + } +} + +void EventDevice::getSupportedAbsAxes(int supportedAxis[]){ + int i; + + if(inited!=1) return; + for(i=0;i<numAbsAxes; i++) { + (supportedAxis)[i] = supportedAbsAxes[i]; + } +} + +void EventDevice::getSupportedButtons(int supportedButtons[]){ + int i; + + if(inited!=1) return; + for(i=0;i<numButtons; i++) { + (supportedButtons)[i] = this->supportedButtons[i]; + } +} + +/** + * 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 EventDevice::poll(){ + size_t read_bytes; + struct input_event events[64]; + int dataChanged=0; + + if(inited!=1) return -1; + + // first thing to do is reset all relative axis as mice never seem to do it + int i; + for(i=0;i<numRelAxes;i++){ + if(relAxesData[i]!=0) { + dataChanged=1; + relAxesData[i]=0; + } + } + + read_bytes = read(fd, events, sizeof(struct input_event) * 64); + + if(read_bytes == 0) { + // no sweat, just return; + return 0; + } + + if(read_bytes == -1) { + if(errno == EAGAIN) { + // No worries, we are in non blocking and noting is ready + return 0; + } else { + perror("Error reading events: "); + return -1; + } + } + + if (read_bytes < (int) sizeof(struct input_event)) { + perror("Error reading events: "); + return -1; + } + + int numEventsRead = (int) (read_bytes / sizeof(struct input_event)); + for(i=0;i<numEventsRead;i++) { + switch(events[i].type) { + case EV_KEY: { + dataChanged = 1; + int buttonIndex = buttonLookup[events[i].code]; + buttonData[buttonIndex] = events[i].value; + //printf("button %d translates to button %d on this device\n", events[i].code, buttonIndex); + break; + } + case EV_REL: { + dataChanged = 1; + int axisIndex = relAxisLookup[events[i].code]; + relAxesData[axisIndex] += events[i].value; + //printf("rel axis %d translates to rel axis %d on this device\n", events[i].code, axisIndex); + break; + } + case EV_ABS: { + dataChanged = 1; + int axisIndex = absAxisLookup[events[i].code]; + absAxesData[axisIndex] = events[i].value; + //printf("abs axis %d translates to abs axis %d on this device\n", events[i].code, axisIndex); + break; + } + case EV_RST: + // not sure what to do here, doing nothing seems to work :) + break; + case EV_LED: + // reveiced for things like numlock led change + break; + default: + fprintf(stderr, "Received event of type 0x%02X from %s, which I wasn't expecting, please report it to [email protected]\n", events[i].type, name); + } + } + return dataChanged; +} + +void EventDevice::getPolledData(int relAxesData[], int absAxesData[], int buttonData[]){ + int i; + + if(inited!=1) return; + for(i=0;i<numRelAxes;i++) { + (relAxesData)[i] = this->relAxesData[i]; + } + for(i=0;i<numAbsAxes;i++) { + (absAxesData)[i] = this->absAxesData[i]; + } + for(i=0;i<numButtons;i++) { + (buttonData)[i] = this->buttonData[i]; + } +} + +int EventDevice::getAbsAxisMinimum(int axisNumber) { + return abs_features[axisNumber].min_value; +} + +int EventDevice::getAbsAxisMaximum(int axisNumber) { + return abs_features[axisNumber].max_value; +} + +int EventDevice::getAbsAxisFuzz(int axisNumber) { + return abs_features[axisNumber].fuzz; +} diff --git a/plugins/linux/src/native/EventDevice.h b/plugins/linux/src/native/EventDevice.h new file mode 100644 index 0000000..1174a5f --- /dev/null +++ b/plugins/linux/src/native/EventDevice.h @@ -0,0 +1,85 @@ +/** + * 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(eventInterface_eventDevice_h) +#define eventInterface_eventDevice_h + +#include <stdint.h> +#include <linux/input.h> +#include "eventInterfaceTypes.h" +#include "Device.h" + +class EventDevice : public Device { + + private: + int fd; + int inited; + char *name; + int numButtons; + uint16_t bustype; + uint16_t vendor; + uint16_t product; + uint16_t version; + short *supportedRelAxes; + short *supportedAbsAxes; + short *supportedButtons; + int *relAxesData; + int *absAxesData; + uint8_t *buttonData; + int ffSupported; + int numRelAxes; + int numAbsAxes; + uint8_t evtype_bitmask[EV_MAX/8 + 1]; + uint8_t key_bitmask[KEY_MAX/8 + 1]; + uint8_t rel_bitmask[REL_MAX/8 + 1]; + uint8_t abs_bitmask[ABS_MAX/8 + 1]; + struct input_absinfo *abs_features; + int absAxisLookup[ABS_MAX]; + int relAxisLookup[REL_MAX]; + int buttonLookup[KEY_MAX]; + + public: + EventDevice(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); + +}; + +#endif //eventInterface_eventDevice_h diff --git a/plugins/linux/src/native/JoystickDevice.cpp b/plugins/linux/src/native/JoystickDevice.cpp new file mode 100644 index 0000000..c20fc22 --- /dev/null +++ b/plugins/linux/src/native/JoystickDevice.cpp @@ -0,0 +1,178 @@ +/** + * 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> + +JoystickDevice::JoystickDevice(char *deviceFileName) { + char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown"; + int i; + + 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){ + if(ioctl(fd, JSIOCGNAME(sizeof(tempName)), tempName) < 0) { + 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; + 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]; + + inited = 1; + } +} + +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; +} diff --git a/plugins/linux/src/native/JoystickDevice.h b/plugins/linux/src/native/JoystickDevice.h new file mode 100644 index 0000000..642087d --- /dev/null +++ b/plugins/linux/src/native/JoystickDevice.h @@ -0,0 +1,68 @@ +/** + * 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(); + +}; + +#endif //eventInterface_eventDevice_h diff --git a/plugins/linux/src/native/MixedDevice.cpp b/plugins/linux/src/native/MixedDevice.cpp new file mode 100644 index 0000000..7f402ec --- /dev/null +++ b/plugins/linux/src/native/MixedDevice.cpp @@ -0,0 +1,115 @@ +/** + * 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); +} diff --git a/plugins/linux/src/native/MixedDevice.h b/plugins/linux/src/native/MixedDevice.h new file mode 100644 index 0000000..be468d6 --- /dev/null +++ b/plugins/linux/src/native/MixedDevice.h @@ -0,0 +1,68 @@ +/** + * 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); + +}; + +#endif //eventInterface_eventDevice_h diff --git a/plugins/linux/src/native/eventInterface.cpp b/plugins/linux/src/native/eventInterface.cpp new file mode 100644 index 0000000..303c667 --- /dev/null +++ b/plugins/linux/src/native/eventInterface.cpp @@ -0,0 +1,131 @@ +/** + * 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/input.h> +#include <string.h> +#include <malloc.h> +#include <unistd.h> +#include "Device.h" +#include "EventDevice.h" + +int evNumDevices; +int eventInterfaceVersion; +Device **evDeviceList; +int evInited = 0; + +int evFileFilter(const struct direct *entry) { + if (strncmp(entry->d_name, "event", 5) == 0) { + return 1; + } + return 0; + } + +int evGetDeviceFiles(char ***filenames) { + struct direct **files; + int num_files, i; + char dirName[] = {"/dev/input"}; + + num_files = scandir(dirName, &files, &evFileFilter, 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 evInit() { + int fd=-1; + int i; + char **deviceFileNames; + int numDeviceFiles; + + numDeviceFiles = evGetDeviceFiles(&deviceFileNames); + if(numDeviceFiles<0) { + return -1; + } + + if ((fd = open(deviceFileNames[0], O_RDONLY)) <0) { + return -1; + } + + if (ioctl(fd, EVIOCGVERSION, &eventInterfaceVersion)) { + close(fd); + return -1; + } + + close(fd); + + Device *tempDeviceList[numDeviceFiles]; + + evNumDevices = 0; + for(i=0;i<numDeviceFiles;i++) { + tempDeviceList[i] = new EventDevice(deviceFileNames[i]); + if(tempDeviceList[i]->getBusType()!=-1) { + evNumDevices++; + } + } + + // Now we know for certain which devices are open, we can take notes + evDeviceList = (Device **)malloc(evNumDevices * sizeof(Device *)); + for(i=0;i<evNumDevices;i++) { + evDeviceList[i] = tempDeviceList[i]; + } + + evInited=1; + + return 0; +} + +int evGetEventInterfaceVersionNumber() { + return eventInterfaceVersion; +} + +int evGetNumberDevices() { + if(evInited) { + return evNumDevices; + } + return -1; +} + +void evGetDevices(Device **theirDeviceList) { + int i; + for(i=0;i<evNumDevices;i++) { + theirDeviceList[i] = evDeviceList[i]; + } +} diff --git a/plugins/linux/src/native/eventInterface.h b/plugins/linux/src/native/eventInterface.h new file mode 100644 index 0000000..92e421c --- /dev/null +++ b/plugins/linux/src/native/eventInterface.h @@ -0,0 +1,37 @@ +/** + * 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(eventInterface_h) +#define eventInterface_h + +#include "Device.h" + +int evGetEventInterfaceVersionNumber(); +int evInit(); +int evGetNumberDevices(); +void evGetDevices(Device **deviceList); + +#endif //eventInterface_h diff --git a/plugins/linux/src/native/eventInterfaceTypes.h b/plugins/linux/src/native/eventInterfaceTypes.h new file mode 100644 index 0000000..2f1f936 --- /dev/null +++ b/plugins/linux/src/native/eventInterfaceTypes.h @@ -0,0 +1,24 @@ +#if !defined(eventInterfaceTypes_h) +#define eventInterfaceTypes_h + +#include <linux/input.h> +#include <stdint.h> + +#define getBit(bit, bitField) (bitField[bit/8] & (1 << (bit%8))) + +struct input_devinfo { + uint16_t bustype; + uint16_t vendor; + uint16_t product; + uint16_t version; +}; + +struct input_absinfo { + int curr_value; + int min_value; + int max_value; + int fuzz; + int flat; +}; + +#endif //eventInterfaceTypes_h diff --git a/plugins/linux/src/native/jinput.cpp b/plugins/linux/src/native/jinput.cpp new file mode 100644 index 0000000..e20feeb --- /dev/null +++ b/plugins/linux/src/native/jinput.cpp @@ -0,0 +1,333 @@ +/** + * 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 "Device.h" +#include "EventDevice.h" +#include "JoystickDevice.h" +#include "MixedDevice.h" +#include "eventInterface.h" +#include "joystickInterface.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) { + + if(evInit()!=0) { + fprintf(stderr, "Failed to init native jinput\n"); + return -1; + } + if(jsInit()!=0) { + fprintf(stderr, "Failed to init native jinput\n"); + return -1; + } + + int numEventDevices = evGetNumberDevices(); + EventDevice *eventDevices[numEventDevices]; + + evGetDevices((Device **)eventDevices); + + int numJoysticks = jsGetNumberDevices(); + JoystickDevice *jsDevices[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]; + 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 + 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) { + + 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) { + + 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) { + + 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) { + + 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); + + 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); + + 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); + + 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); + + int retval = jinputDeviceList[deviceID]->poll(); + 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) { + + 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) { + + 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) { + + 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) { + + 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); + + 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); + + int retval = jinputDeviceList[deviceID]->poll(); + 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) { + + jinputDeviceList[deviceID]->getBusType(); +} diff --git a/plugins/linux/src/native/joystickInterface.cpp b/plugins/linux/src/native/joystickInterface.cpp new file mode 100644 index 0000000..2bcc8bc --- /dev/null +++ b/plugins/linux/src/native/joystickInterface.cpp @@ -0,0 +1,132 @@ +/** + * 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) { + return -1; + } + + if (ioctl(fd, JSIOCGVERSION, &joystickInterfaceVersion)) { + close(fd); + return -1; + } + + 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++; + } + } + + // 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++) { + jsDeviceList[i] = tempDeviceList[i]; + } + + 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 new file mode 100644 index 0000000..01b8c58 --- /dev/null +++ b/plugins/linux/src/native/joystickInterface.h @@ -0,0 +1,37 @@ +/** + * 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_LinuxDevice.h b/plugins/linux/src/native/net_java_games_input_LinuxDevice.h new file mode 100644 index 0000000..50a4e8b --- /dev/null +++ b/plugins/linux/src/native/net_java_games_input_LinuxDevice.h @@ -0,0 +1,80 @@ +/* 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); + +#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 new file mode 100644 index 0000000..6e68a97 --- /dev/null +++ b/plugins/linux/src/native/net_java_games_input_LinuxEnvironmentPlugin.h @@ -0,0 +1,64 @@ +/* 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 new file mode 100644 index 0000000..041f416 --- /dev/null +++ b/plugins/linux/src/native/net_java_games_input_LinuxKeyboard.h @@ -0,0 +1,42 @@ +/* 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 |