1
0
Fork 0
mirror of https://github.com/rfc2822/GfxTablet synced 2025-10-03 17:49: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
This commit is contained in:
Thomas Castleman 2019-09-03 23:48:46 -04:00
parent 128060d724
commit 97c9050afb
2 changed files with 37 additions and 4 deletions

View file

@ -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"

View file

@ -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);