mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-04-21 06:14:11 +00:00
fixes for issues 25 and 26
Sigsgv with logitec USB keyboard with volume controls and mouse wheel when valid event device list in /dev/input/event* has invalid devices in the middle of the sequence, a sigsegv is seen
This commit is contained in:
parent
54ecf9687a
commit
2dc9aae5e2
7 changed files with 32 additions and 26 deletions
|
|
@ -34,6 +34,8 @@
|
|||
#include <malloc.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
EventDevice::EventDevice(char *deviceFileName) {
|
||||
char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown";
|
||||
int i;
|
||||
|
|
@ -57,6 +59,8 @@ EventDevice::EventDevice(char *deviceFileName) {
|
|||
name = (char *)malloc(namelength+1);
|
||||
strncpy(name,tempName, namelength+1);
|
||||
|
||||
LOG_TRACE("Device name for device file %s is %s\n", deviceFileName, name);
|
||||
|
||||
uint8_t evtype_bitmask[EV_MAX/8 + 1];
|
||||
memset(evtype_bitmask, 0, sizeof(evtype_bitmask));
|
||||
|
||||
|
|
@ -213,6 +217,7 @@ int EventDevice::getNumberButtons(){
|
|||
}
|
||||
|
||||
const char *EventDevice::getName(){
|
||||
LOG_TRACE("EventDevice::getName()\n");
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +341,7 @@ int EventDevice::poll(){
|
|||
// 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 jinput@computerbooth.com\n", events[i].type, name);
|
||||
fprintf(stderr, "Received event of type 0x%02X from %s, which I wasn't expecting, please report it to jinput forum at www.javagaming.org\n", events[i].type, name);
|
||||
}
|
||||
}
|
||||
return dataChanged;
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@
|
|||
|
||||
<target name="compileNativeEventLib" depends="init">
|
||||
<exec dir="." executable="g++" os="Linux">
|
||||
<arg line="--shared -o libeventInterface.so eventInterface.cpp EventDevice.cpp"/>
|
||||
<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 --shared -o libjinput.so jinput.cpp eventInterface.cpp EventDevice.cpp joystickInterface.cpp JoystickDevice.cpp MixedDevice.cpp"/>
|
||||
<arg line="-I${java.home}/include -I${java.home}/include/linux --shared -DLOGTRACE -o libjinput.so jinput.cpp eventInterface.cpp EventDevice.cpp joystickInterface.cpp JoystickDevice.cpp MixedDevice.cpp"/>
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
#include "Device.h"
|
||||
#include "EventDevice.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
int evNumDevices;
|
||||
int eventInterfaceVersion;
|
||||
Device **evDeviceList;
|
||||
|
|
@ -103,6 +105,8 @@ int evInit() {
|
|||
if(tempDevice->isValidDevice()==1) {
|
||||
tempDeviceList[i] = tempDevice;
|
||||
evNumDevices++;
|
||||
} else {
|
||||
tempDeviceList[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +119,7 @@ int evInit() {
|
|||
evTempDeviceCount++;
|
||||
}
|
||||
evDeviceList[i] = tempDeviceList[evTempDeviceCount];
|
||||
//printf("Copied device %d to %d\n", evTempDeviceCount, i);
|
||||
LOG_TRACE("Copied temp event device %d to event device %d\n", evTempDeviceCount, i);
|
||||
evTempDeviceCount++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init
|
|||
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("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());
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +145,7 @@ JNIEXPORT jstring JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getDe
|
|||
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\n", deviceID);
|
||||
LOG_TRACE("Gettign number of absolute axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberAbsAxes());
|
||||
return jinputDeviceList[deviceID]->getNumberAbsAxes();
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +157,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumAb
|
|||
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\n", deviceID);
|
||||
LOG_TRACE("Gettign number of relative axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberRelAxes());
|
||||
return jinputDeviceList[deviceID]->getNumberRelAxes();
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +169,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumRe
|
|||
JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumButtons
|
||||
(JNIEnv *, jobject, jint deviceID) {
|
||||
|
||||
LOG_TRACE("Gettign number of buttons for jinput device %d\n", deviceID);
|
||||
LOG_TRACE("Gettign number of buttons for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberButtons());
|
||||
return jinputDeviceList[deviceID]->getNumberButtons();
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +226,7 @@ JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedB
|
|||
|
||||
jint *buttonDataElements = env->GetIntArrayElements(buttonData, 0);
|
||||
|
||||
LOG_TRACE("Getting suported buttons for jinput device %d\n", deviceID);
|
||||
LOG_TRACE("Getting supported buttons for jinput device %d\n", deviceID);
|
||||
jinputDeviceList[deviceID]->getSupportedButtons(buttonDataElements);
|
||||
|
||||
env->ReleaseIntArrayElements(buttonData, buttonDataElements, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue