~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libdevice/events/InputDevice.cpp

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-03-04 03:19:06 UTC
  • mfrom: (1.1.18) (3.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120304031906-p6q5rnb0xhgpof7o
Tags: 0.8.10-3ubuntu1
* Merge from Debian testing (FFe: LP: #940876), remaining changes:
  - Use mozilla-flashplugin as the alternative for now
  - Change xulrunner-dev build dep to firefox-dev
* Drop the plugin API porting patch, this has been fixed upstream
  - drop debian/patches*
* Drop the following change as we want Adobe's player to take priority
  if it's installed
  - Set alternative priority to 50 so that it matches Adobe Flash's priority

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// 
2
 
//   Copyright (C) 2010, 2011 Free Software Foundation, Inc
 
2
//   Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc
3
3
// 
4
4
// This program is free software; you can redistribute it and/or modify
5
5
// it under the terms of the GNU General Public License as published by
30
30
 
31
31
InputDevice::InputDevice()
32
32
    : _type(InputDevice::UNKNOWN),
33
 
      _fd(-1)
 
33
      _fd(-1),
 
34
      _screen_width(0),
 
35
      _screen_height(0)
 
36
{
 
37
    // GNASH_REPORT_FUNCTION;
 
38
    memset(&_input_data, 0, sizeof(InputDevice::input_data_t));
 
39
}
 
40
 
 
41
InputDevice::InputDevice(int x, int y)
 
42
    : _type(InputDevice::UNKNOWN),
 
43
      _fd(-1),
 
44
      _screen_width(x),
 
45
      _screen_height(y)
34
46
{
35
47
    // GNASH_REPORT_FUNCTION;
36
48
    memset(&_input_data, 0, sizeof(InputDevice::input_data_t));
116
128
    errno = 0;
117
129
    int ret = ::select(_fd+1, &fdset, NULL, NULL, &tval);
118
130
    if (ret == 0) {
119
 
//            log_debug ("The pipe for fd #%d timed out waiting to read", fd);
 
131
//            log_debug(_("The pipe for fd #%d timed out waiting to read"), fd);
120
132
        return inbuf;
121
133
    } else if (ret == 1) {
122
 
        // log_debug ("The device for fd #%d is ready", _fd);
 
134
        // log_debug(_("The device for fd #%d is ready"), _fd);
123
135
    } else {
124
 
        log_error("The device has this error: %s", strerror(errno));
 
136
        log_error(_("The device has this error: %s"), strerror(errno));
125
137
        return inbuf;
126
138
    }
127
139
    
128
140
    inbuf.reset(new boost::uint8_t[size]);
129
141
    ret = ::read(_fd, inbuf.get(), size);
130
142
    if (ret > 0) {
131
 
        // log_debug("Read %d bytes, %s", ret, hexify(inbuf.get(), ret, false));
 
143
        // log_debug(_("Read %d bytes, %s"), ret, hexify(inbuf.get(), ret, false));
132
144
    } else {
133
145
        inbuf.reset();
134
146
    }
141
153
{
142
154
    // Debug strings to make output more readable
143
155
    const char *debug[] = {
144
 
        "UNKNOWN",
 
156
        "Sleep Button",
145
157
        "Keyboard",
 
158
        "User mode Mouse",
146
159
        "Mouse",
147
160
        "Tablet",
148
161
        "Touchscreen",
159
172
//    std::cerr << "\tX is: " << _x << ", Y is: " << _y << std::endl;
160
173
}
161
174
 
162
 
// The Babbage touchscreen gives is absolute coordinates, but they don't
 
175
// The Babbage touchscreen gives is relative coordinates, but they don't
163
176
// match the actual screen resolution. So we convert the coordinates
164
177
// to a new absolute location.
165
 
// For example, if the LCD is 480 x 800, the tablet thinks this is 1010 x 960.
166
 
// This should really use a calibration function, but as we know the numbers...
167
178
boost::shared_array<int>
168
179
InputDevice::convertAbsCoords(int x, int y, int width, int height)
169
180
{
 
181
    // GNASH_REPORT_FUNCTION;
170
182
    boost::shared_array<int> coords(new int[2]);
171
183
 
172
 
    coords[0] = (x/width) * x;
173
 
    coords[1] = (y/height) * y;
 
184
    coords[0] = int((x/256) * width);
 
185
    coords[1] = int((y/256) * height);
174
186
    
175
187
    return coords;
176
188
}
195
207
    for (it=id.begin(); it!=id.end(); ++it) {
196
208
        devices.push_back(*it);
197
209
    }
 
210
#else
 
211
    log_debug(_("WARNING: PS/2 Mouse support disabled as it conflicts with the input event support."));
198
212
#endif
199
213
#if defined(HAVE_TSLIB_H) && defined(USE_TSLIB)
200
214
    id = TouchDevice::scanForDevices();