mirror of
https://github.com/rfc2822/GfxTablet
synced 2025-10-03 01:29:17 +02:00
several additions
* added new make rules * debug : for debugging versions * uninstall : to uninstall for the user * portable : make a more portable, 64-bit version * added support for a sort of "buffer" so less pressure is needed to register a click
This commit is contained in:
parent
128060d724
commit
a0e9f07203
2 changed files with 37 additions and 4 deletions
|
@ -2,10 +2,23 @@ TARGET = networktablet
|
|||
PREFIX = /usr/local
|
||||
BINDIR = $(PREFIX)/bin
|
||||
|
||||
networktablet : networktablet.c
|
||||
networktablet :
|
||||
g++ -Wall -o "networktablet" "networktablet.cxx"
|
||||
|
||||
debug :
|
||||
g++ -Wall -g -o "networktablet-debug" "networktablet.cxx"
|
||||
|
||||
clean :
|
||||
rm -f networktablet
|
||||
|
||||
install :
|
||||
install -D networktablet $(DESTDIR)$(BINDIR)/networktablet
|
||||
|
||||
uninstall :
|
||||
rm -f networktablet networktablet-debug $(DESTDIR)$(BINDIR)/networktablet
|
||||
|
||||
portable64 :
|
||||
g++ -Wall -m64 -o "networktablet64" "networktablet.cxx"
|
||||
|
||||
portable32 :
|
||||
g++ -Wall -m32 -o "networktablet32" "networktablet.cxx"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include <linux/input.h>
|
||||
#include <linux/uinput.h>
|
||||
#include <stdint.h>
|
||||
#include <sstream>
|
||||
#include "protocol.h"
|
||||
|
||||
#define die(str, args...) { \
|
||||
|
@ -19,6 +21,8 @@
|
|||
}
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int udp_socket;
|
||||
|
||||
|
||||
|
@ -135,12 +139,28 @@ void quit(int signal) {
|
|||
close(udp_socket);
|
||||
}
|
||||
|
||||
int ConvertToInt(string &convert)
|
||||
{
|
||||
stringstream sti(convert);
|
||||
int output;
|
||||
sti >> output;
|
||||
return output;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int device;
|
||||
struct event_packet ev_pkt;
|
||||
|
||||
//add a sort of "cushion" so that less pressure is required to register as
|
||||
//a click and drag
|
||||
string cushion_string = "";
|
||||
int cushion = 0;
|
||||
if (argc == 2)
|
||||
{
|
||||
cushion_string = argv[1];
|
||||
cushion = ConvertToInt(cushion_string);
|
||||
}
|
||||
if ((device = open("/dev/uinput", O_WRONLY | O_NONBLOCK)) < 0)
|
||||
die("error: open");
|
||||
|
||||
|
@ -169,7 +189,7 @@ int main(void)
|
|||
|
||||
ev_pkt.x = ntohs(ev_pkt.x);
|
||||
ev_pkt.y = ntohs(ev_pkt.y);
|
||||
ev_pkt.pressure = ntohs(ev_pkt.pressure);
|
||||
ev_pkt.pressure = ntohs(ev_pkt.pressure) + cushion;
|
||||
printf("x: %hu, y: %hu, pressure: %hu\n", ev_pkt.x, ev_pkt.y, ev_pkt.pressure);
|
||||
|
||||
send_event(device, EV_ABS, ABS_X, ev_pkt.x);
|
Loading…
Add table
Add a link
Reference in a new issue