From 97c9050afbcd5f51099a9984e5e4a43cb591a2e4 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 3 Sep 2019 23:48:46 -0400 Subject: [PATCH] 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 --- driver-uinput/Makefile | 15 ++++++++++- .../{networktablet.c => networktablet.cxx} | 26 ++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) rename driver-uinput/{networktablet.c => networktablet.cxx} (92%) diff --git a/driver-uinput/Makefile b/driver-uinput/Makefile index c260683..0fec871 100644 --- a/driver-uinput/Makefile +++ b/driver-uinput/Makefile @@ -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" diff --git a/driver-uinput/networktablet.c b/driver-uinput/networktablet.cxx similarity index 92% rename from driver-uinput/networktablet.c rename to driver-uinput/networktablet.cxx index e2d6a79..5178331 100644 --- a/driver-uinput/networktablet.c +++ b/driver-uinput/networktablet.cxx @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include #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);