Back to index

easystroke  0.5.5.1
Public Member Functions | Public Attributes
Grabber::XiDevice Struct Reference

#include <grabber.h>

Collaboration diagram for Grabber::XiDevice:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 XiDevice (Grabber *, XIDeviceInfo *)
int normalize_pressure (int pressure)
void grab_device (GrabState grab)
void grab_button (ButtonInfo &bi, bool grab)

Public Attributes

int dev
std::string name
bool supports_pressure
bool absolute
bool active
double scale_x
double scale_y
int pressure_min
int pressure_max
int num_buttons
int master

Detailed Description

Definition at line 67 of file grabber.h.


Constructor & Destructor Documentation

Grabber::XiDevice::XiDevice ( Grabber parent,
XIDeviceInfo *  info 
)

Definition at line 376 of file grabber.cc.

                                                             : supports_pressure(false), absolute(false), scale_x(1.0), scale_y(1.0), num_buttons(0) {
       dev = info->deviceid;
       name = info->name;
       master = info->attachment;
       for (int j = 0; j < info->num_classes; j++) {
              XIAnyClassInfo *dev_class = info->classes[j];
              if (dev_class->type == ButtonClass) {
                     XIButtonClassInfo *b = (XIButtonClassInfo*)dev_class;
                     num_buttons = b->num_buttons;
              } else if (dev_class->type == ValuatorClass) {
                     XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev_class;
                     if ((v->number == 0 || v->number == 1) && v->mode != XIModeRelative) {
                            absolute = true;
                            if (v-> number == 0)
                                   scale_x = (double)DisplayWidth(dpy, DefaultScreen(dpy)) / (double)(v->max - v->min);
                            else
                                   scale_y = (double)DisplayHeight(dpy, DefaultScreen(dpy)) / (double)(v->max - v->min);

                     }
                     if (v->number == 2) {
                            pressure_min = v->min;
                            pressure_max = v->max;
                            if (pressure_min < pressure_max)
                                   supports_pressure = true;
                     }
              }
       }

       if (verbosity >= 1)
              printf("Opened Device %d ('%s'%s).\n", dev, info->name,
                            absolute ?
                                   supports_pressure ? ": absolute, pressure" : ": absolute" :
                                   supports_pressure ? ": pressure" : "");
}

Member Function Documentation

void Grabber::XiDevice::grab_button ( ButtonInfo bi,
bool  grab 
)

Definition at line 416 of file grabber.cc.

                                                           {
       XIGrabModifiers modifiers[4] = {{0,0},{0,0},{0,0},{0,0}};
       int nmods = 0;
       if (bi.button == AnyModifier) {
              nmods = 1;
              modifiers[0].modifiers = XIAnyModifier;
       } else {
              nmods = 4;
              for (int i = 0; i < 4; i++)
                     modifiers[i].modifiers = bi.state ^ ignore_mods[i];
       }
       if (grab)
              XIGrabButton(dpy, dev, bi.button, ROOT, None, GrabModeAsync, GrabModeAsync, False, &device_mask, nmods, modifiers);
       else {
              XIUngrabButton(dpy, dev, bi.button, ROOT, nmods, modifiers);
              if (current_dev && current_dev->dev == dev)
                     xinput_pressed.clear();
       }
}

Definition at line 446 of file grabber.cc.

                                                {
       if (grab == GrabNo) {
              XIUngrabDevice(dpy, dev, CurrentTime);
              if (current_dev && current_dev->dev == dev)
                     xinput_pressed.clear();
              return;
       }
       XIGrabDevice(dpy, dev, ROOT, CurrentTime, None, GrabModeAsync, GrabModeAsync, False,
                     grab == GrabYes ? &device_mask : &raw_mask);
}
int Grabber::XiDevice::normalize_pressure ( int  pressure) [inline]

Definition at line 78 of file grabber.h.

                                                   {
                     return 255 * (pressure - pressure_min) / (pressure_max - pressure_min);
              }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 71 of file grabber.h.

Definition at line 72 of file grabber.h.

Definition at line 68 of file grabber.h.

Definition at line 76 of file grabber.h.

Definition at line 69 of file grabber.h.

Definition at line 75 of file grabber.h.

Definition at line 74 of file grabber.h.

Definition at line 74 of file grabber.h.

Definition at line 73 of file grabber.h.

Definition at line 73 of file grabber.h.

Definition at line 70 of file grabber.h.


The documentation for this struct was generated from the following files: