bugGnash - The GNU Flash player - Bugs: bug #32406, env var TSLIB_TSDEVICE ignored

 
 

bug #32406: env var TSLIB_TSDEVICE ignored

Submitted by:  Gabriele Mondada <gmondada>
Submitted on:  Thu 10 Feb 2011 08:18:01 AM UTC  
 
Category: gui-fbSeverity: 3 - Normal
Release: 0.8.8Status: None
Privacy: PublicAssigned to: Rob Savoye <rsavoye>
Open/Closed: Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 09 Jun 2011 11:39:04 AM UTC, comment #5:

Here is a patch for version 0.8.9 with some not-so-clean code inside:

<pre>
diff -ru gnash-0.8.9/gui/fb/TouchDevice.cpp gnash-0.8.9.modified/gui/fb/TouchDevice.cpp
--- gnash-0.8.9/gui/fb/TouchDevice.cpp 2011-02-26 19:11:07.000000000 +0100
+++ gnash-0.8.9.modified/gui/fb/TouchDevice.cpp 2011-06-09 10:09:13.000000000 +0200
@@ -80,15 +80,12 @@
_type = TouchDevice::TOUCHSCREEN;
_filespec = filespec;

- char *devname = getenv(TSLIB_DEVICE_ENV);
+ const char *devname = getenv(TSLIB_DEVICE_ENV);
if (!devname) {
- devname = const_cast<char *>(TSLIB_DEVICE_NAME);
- } else {
- if (!filespec.empty()) {
- devname = const_cast<char *>(_filespec.c_str());
- } else {
+ if (!filespec.empty())
+ devname = _filespec.c_str();
+ else
log_error("No filespec specified for the touchscreen device.");
- }
}

_tsDev = ts_open(devname, 1); //Open tslib non-blocking
@@ -134,10 +131,8 @@
if (event.y > static_cast<int>(_gui->getStage()->getStageHeight())) {
event.y = static_cast<int>(_gui->getStage()->getStageHeight());
}
- // FIXME: the API for these mouse events has changed, so this needs to be
- // updated.
- _gui->notifyMouseMove(int(event.x / _gui->getXScale()),
- int(event.y / _gui->getYScale()));
+
+ _gui->notifyMouseMove(int(event.x), int(event.y));
_gui->notifyMouseClick(true); //fire mouse click event into Gnash

log_debug("Touched x: %d y: %d width: %d height: %d",
@@ -285,9 +280,16 @@

struct ts_types touch[] = {
InputDevice::TOUCHSCREEN, "/dev/ts",
+ InputDevice::UNKNOWN, 0,
InputDevice::UNKNOWN, 0
};

+ const char *devname = getenv(TSLIB_DEVICE_ENV);
+ if (devname) {
+ touch[1].type = InputDevice::TOUCHSCREEN;
+ touch[1].filespec = devname;
+ }
+
int i = 0;
while (touch[i].type != InputDevice::UNKNOWN) {
int fd = 0;
</pre>

Gabriele Mondada <gmondada>
Fri 11 Feb 2011 11:50:22 AM UTC, comment #4:

My proposal is not enough to solve the problem because the scanForDevices() function also prevents the usage of the TSLIB_TSDEVICE. So, here is a patched version (not so well done) of this function (gui/TouchDevice.cpp):

std::vector<boost::shared_ptr<InputDevice> >
TouchDevice::scanForDevices(Gui *gui)
{
// GNASH_REPORT_FUNCTION;

struct stat st;

std::vector<boost::shared_ptr<InputDevice> > devices;

// Debug strings to make output more readable
const char *debug[] = {
"TSlib"
};

// Look for these files for mouse input
struct ts_types {
InputDevice::devicetype_e type;
const char *filespec;
};

struct ts_types touch[] = {
InputDevice::TOUCHSCREEN, "/dev/ts",
InputDevice::UNKNOWN, 0,
InputDevice::UNKNOWN, 0
};

const char *devname = getenv(TSLIB_DEVICE_ENV);
if (devname) {
touch[1].type = InputDevice::TOUCHSCREEN;
touch[1].filespec = devname;
}

int i = 0;
while (touch[i].type != InputDevice::UNKNOWN) {
int fd = 0;
if (stat(touch[i].filespec, &st) == 0) {
// Then see if we can open it
if ((fd = open(touch[i].filespec, O_RDWR)) < 0) {
log_error("You don't have the proper permissions to open %s",
touch[i].filespec);
i++;
continue;
} // open()
log_debug("Found a %s device for mouse input using %s",
debug[touch[i].type], touch[i].filespec);
boost::shared_ptr<InputDevice> dev;
dev = boost::shared_ptr<InputDevice>(new TouchDevice(gui));
if (dev->init(touch[i].filespec, DEFAULT_BUFFER_SIZE)) {
devices.push_back(dev);
}
dev->dump();

devices.push_back(dev);
} // stat()
close(fd);
i++;
} // while()

return devices;
}

Gabriele Mondada <gmondada>
Thu 10 Feb 2011 02:21:54 PM UTC, comment #3:

Although this won't be in 0.8.9, in a branch I have entirely refactored code for handling touchscreens. This branch will get migrated to master after the release, which will fix this for good.

Rob Savoye <rsavoye>
Project AdministratorIn charge of this item.
Thu 10 Feb 2011 01:31:55 PM UTC, comment #2:

No reason to be non-const. So, devname can be const char *.

Gabriele Mondada <gmondada>
Thu 10 Feb 2011 08:20:40 AM UTC, comment #1:

Unless there's a specific reason for devname to be non-const, may I suggest to make it 'const char *devname' and avoid the const_cast below ?

Sandro Santilli <strk>
Project Member
Thu 10 Feb 2011 08:18:01 AM UTC, original submission:

When gnash (0.8.8) is configured to use a touch screen via tslib, the TSLIB_TSDEVICE env variable should define the ts device.
In the source code, TSLIB_TSDEVICE is read but the content is then ignored.
Here is the code (gui/TouchDevice.cpp):

static const char *TSLIB_DEVICE_ENV = "TSLIB_TSDEVICE";
...
char *devname = getenv(TSLIB_DEVICE_ENV);
if (!devname) {
devname = const_cast<char *>(TSLIB_DEVICE_NAME);
} else {
if (!filespec.empty()) {
devname = const_cast<char *>(_filespec.c_str());
} else {
log_error("No filespec specified for the touchscreen device.");
}
}

In this code, getenv(TSLIB_DEVICE_ENV) is never used.

Proposed alternative:

char *devname = getenv(TSLIB_DEVICE_ENV);
if (!devname) {
if (!filespec.empty()) {
devname = const_cast<char *>(_filespec.c_str());
} else {
log_error("No filespec specified for the touchscreen device.");
}
}

Gabriele Mondada <gmondada>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by strk (Posted a comment)
  • -unavailable- added by gmondada (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 10 Feb 2011 02:18:42 PM UTCstrkReleaseNone=>0.8.8
      Assigned toNone=>rsavoye

    Back to the top


    Powered by Savane 3.1-cleanup1