mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-01-02 14:59:57 +01:00
Fix and updated error messages for issue 20
This commit is contained in:
parent
46e48bb00e
commit
e749b96a4a
|
|
@ -40,9 +40,11 @@ EventDevice::EventDevice(char *deviceFileName) {
|
|||
|
||||
fd = open(deviceFileName, O_RDWR | O_NONBLOCK);
|
||||
if(fd<0) {
|
||||
char errorMessage[512];
|
||||
/*char errorMessage[512];
|
||||
sprintf(errorMessage, "Error opening device %s\n", deviceFileName);
|
||||
perror(errorMessage);
|
||||
perror(errorMessage);*/
|
||||
inited = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if(ioctl(fd, EVIOCGNAME(sizeof(tempName)), tempName) < 0) {
|
||||
|
|
@ -191,6 +193,10 @@ EventDevice::EventDevice(char *deviceFileName) {
|
|||
inited = 1;
|
||||
}
|
||||
|
||||
int EventDevice::isValidDevice() {
|
||||
return inited;
|
||||
}
|
||||
|
||||
int EventDevice::getNumberRelAxes(){
|
||||
if(inited!=1) return -1;
|
||||
return numRelAxes;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class EventDevice : public Device {
|
|||
int getAbsAxisMinimum(int axisNumber);
|
||||
int getAbsAxisMaximum(int axisNumber);
|
||||
int getAbsAxisFuzz(int axisNumber);
|
||||
int isValidDevice();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -95,16 +95,24 @@ int evInit() {
|
|||
|
||||
evNumDevices = 0;
|
||||
for(i=0;i<numDeviceFiles;i++) {
|
||||
tempDeviceList[i] = new EventDevice(deviceFileNames[i]);
|
||||
if(tempDeviceList[i]->getBusType()!=-1) {
|
||||
EventDevice *tempDevice = new EventDevice(deviceFileNames[i]);
|
||||
if(tempDevice->isValidDevice()==1) {
|
||||
tempDeviceList[i] = tempDevice;
|
||||
evNumDevices++;
|
||||
}
|
||||
}
|
||||
|
||||
int highDeviceCountNumber = i;
|
||||
int evTempDeviceCount = 0;
|
||||
// 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];
|
||||
while(tempDeviceList[evTempDeviceCount] == NULL) {
|
||||
evTempDeviceCount++;
|
||||
}
|
||||
evDeviceList[i] = tempDeviceList[evTempDeviceCount];
|
||||
//printf("Copied device %d to %d\n", evTempDeviceCount, i);
|
||||
evTempDeviceCount++;
|
||||
}
|
||||
|
||||
evInited=1;
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init
|
|||
(JNIEnv *, jobject) {
|
||||
|
||||
if(evInit()!=0) {
|
||||
fprintf(stderr, "Failed to init native jinput\n");
|
||||
fprintf(stderr, "Failed to init native event interface\n");
|
||||
return -1;
|
||||
}
|
||||
if(jsInit()!=0) {
|
||||
fprintf(stderr, "Failed to init native jinput\n");
|
||||
fprintf(stderr, "Failed to init native joystick interface\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,10 +102,17 @@ int jsInit() {
|
|||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
jsDeviceList[i] = tempDeviceList[i];
|
||||
while(tempDeviceList[jsTempDeviceCount] == NULL) {
|
||||
jsTempDeviceCount++;
|
||||
}
|
||||
jsDeviceList[i] = tempDeviceList[jsTempDeviceCount];
|
||||
//printf("Copied joystick %d to %d\n", jsTempDeviceCount, i);
|
||||
jsTempDeviceCount++;
|
||||
}
|
||||
|
||||
jsInited=1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue