From ab7bba58d686438546598efeb11e17e64f215f25 Mon Sep 17 00:00:00 2001 From: endolf Date: Sun, 8 May 2005 09:58:31 +0000 Subject: [PATCH] Will try to open the device for read/write first, if that fails, trys read only and displays a message about not being enabled for force feedback --- plugins/linux/src/native/EventDevice.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp index 64ac8cb..10428b1 100644 --- a/plugins/linux/src/native/EventDevice.cpp +++ b/plugins/linux/src/native/EventDevice.cpp @@ -40,13 +40,21 @@ EventDevice::EventDevice(char *deviceFileName) { char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown"; int i; - fd = open(deviceFileName, O_RDONLY | O_NONBLOCK); + fd = open(deviceFileName, O_RDWR | O_NONBLOCK); if(fd<0) { - /*char errorMessage[512]; - sprintf(errorMessage, "Error opening device %s\n", deviceFileName); - perror(errorMessage);*/ - inited = 0; - return; + + char errorMessage[512]; + sprintf(errorMessage, "Error opening device %s read/write, Force Feedback disabled for this device\n", deviceFileName); + perror(errorMessage); + + fd = open(deviceFileName, O_RDONLY | O_NONBLOCK); + if(fd<0) { + /*char errorMessage[512]; + sprintf(errorMessage, "Error opening device %s\n", deviceFileName); + perror(errorMessage);*/ + inited = 0; + return; + } } if(ioctl(fd, EVIOCGNAME(sizeof(tempName)), tempName) < 0) {