Permalink
Browse files

Minor changes

  • Loading branch information...
Izzatbek committed Sep 7, 2016
1 parent d184fa9 commit 5c137a60e3b5545fe56e77270b38f42a1c0f60e3
Showing with 57 additions and 59 deletions.
  1. +36 −34 README.md
  2. +21 −19 bindings/Node/libpointing/README.md
  3. +0 −6 pointing-xorg/Readme.txt
@@ -59,51 +59,53 @@ Please visit our [wiki](https://github.com/INRIA/libpointing/wiki).

Once you correctly installed *libpointing* and linked it to your project, simply write `#include <pointing/pointing.h>` and start coding. Here is the console example which applies system specific transfer function to an input device and outputs the results to console:

#include <iostream>
#include <pointing/pointing.h>
```C++
#include <iostream>
#include <pointing/pointing.h>
using namespace pointing;
using namespace pointing;
TransferFunction *func = 0;
TransferFunction *func = 0;
// context is user data, timestamp is a moment at which the event was received
// input_dx, input_dy are displacements in horizontal and vertical directions
// buttons is a variable indicating which buttons of the pointing device were pressed.
void pointingCallback(void *, TimeStamp::inttime timestamp, int input_dx, int input_dy, int buttons) {
if (!func) return;
// context is user data, timestamp is a moment at which the event was received
// input_dx, input_dy are displacements in horizontal and vertical directions
// buttons is a variable indicating which buttons of the pointing device were pressed.
void pointingCallback(void *, TimeStamp::inttime timestamp, int input_dx, int input_dy, int buttons) {
if (!func) return;
int output_dx = 0, output_dy = 0;
// In order to use a particular transfer function, its applyi method must be called.
func->applyi(input_dx, input_dy, &output_dx, &output_dy, timestamp);
int output_dx = 0, output_dy = 0;
// In order to use a particular transfer function, its applyi method must be called.
func->applyi(input_dx, input_dy, &output_dx, &output_dy, timestamp);
std::cout << "Displacements in x and y: " << input_dx << " " << input_dy << std::endl;
std::cout << "Corresponding pixel displacements: " << output_dx << " " << output_dy << std::endl;
}
std::cout << "Displacements in x and y: " << input_dx << " " << input_dy << std::endl;
std::cout << "Corresponding pixel displacements: " << output_dx << " " << output_dy << std::endl;
}
int main() {
// Basically, to start using main functionality of libpointing
// one needs to create objects of PointingDevice, DisplayDevice classes,
// connect them passing to TransferFunction class object.
int main() {
// Basically, to start using main functionality of libpointing
// one needs to create objects of PointingDevice, DisplayDevice classes,
// connect them passing to TransferFunction class object.
// Any available pointing and display devices
// if debugLevel > 0, the list of available devices
// and extended information will be output.
PointingDevice *input = PointingDevice::create("any:?debugLevel=1");
DisplayDevice *output = DisplayDevice::create("any:?debugLevel=1");
// Any available pointing and display devices
// if debugLevel > 0, the list of available devices
// and extended information will be output.
PointingDevice *input = PointingDevice::create("any:?debugLevel=1");
DisplayDevice *output = DisplayDevice::create("any:?debugLevel=1");
func = TransferFunction::create("sigmoid:?debugLevel=2", input, output);
func = TransferFunction::create("sigmoid:?debugLevel=2", input, output);
// To receive events from PointingDevice object, a callback function must be set.
input->setPointingCallback(pointingCallback);
while (1)
PointingDevice::idle(100); // milliseconds
// To receive events from PointingDevice object, a callback function must be set.
input->setPointingCallback(pointingCallback);
while (1)
PointingDevice::idle(100); // milliseconds
delete input;
delete output;
delete func;
delete input;
delete output;
delete func;
return 0;
}
return 0;
}
```
## Contributors
@@ -15,25 +15,27 @@ Note that, `libpointing` with npm can be installed only on Mac OS and Linux.

## Example

var pointing = require('libpointing');

if (process.argv.length < 5)
console.log("Usage: node", process.argv[1], "[inputdeviceURI [outputdeviceURI [transferfunctionURI]]]")

var input = new pointing.PointingDevice((process.argv[2]) ? process.argv[2] : "any:")
var output = new pointing.DisplayDevice((process.argv[3]) ? process.argv[3] : "any:");
var tFunc = new pointing.TransferFunction((process.argv[4]) ? process.argv[4] : "system:", input, output);

input.setPointingCallback(function(timestamp, dx, dy, buttons) {
var pixels = tFunc.applyi(dx, dy, timestamp);
console.log(timestamp, dx, dy, buttons, " -> ", pixels.dx, pixels.dy);
});

var manager = new pointing.PointingDeviceManager().addDeviceUpdateCallback(
function(deviceDescriptor, wasAdded) {
console.log(deviceDescriptor, wasAdded);
}
);
```javascript
var pointing = require('libpointing');
if (process.argv.length < 5)
console.log("Usage: node", process.argv[1], "[inputdeviceURI [outputdeviceURI [transferfunctionURI]]]")
var input = new pointing.PointingDevice((process.argv[2]) ? process.argv[2] : "any:")
var output = new pointing.DisplayDevice((process.argv[3]) ? process.argv[3] : "any:");
var tFunc = new pointing.TransferFunction((process.argv[4]) ? process.argv[4] : "system:", input, output);
input.setPointingCallback(function(timestamp, dx, dy, buttons) {
var pixels = tFunc.applyi(dx, dy, timestamp);
console.log(timestamp, dx, dy, buttons, " -> ", pixels.dx, pixels.dy);
});
var manager = new pointing.PointingDeviceManager().addDeviceUpdateCallback(
function(deviceDescriptor, wasAdded) {
console.log(deviceDescriptor, wasAdded);
}
);
```

## License

This file was deleted.

Oops, something went wrong.

0 comments on commit 5c137a6

Please sign in to comment.