mirror of
https://github.com/rfc2822/GfxTablet
synced 2025-10-03 01:29:17 +02:00
uinput driver: some status messages
This commit is contained in:
parent
edc3c99a95
commit
7f9be5ecf0
2 changed files with 25 additions and 8 deletions
|
@ -75,7 +75,7 @@ Part 1: uinput driver
|
||||||
|
|
||||||
On your PC, either download one of these binaries (don't forget to `chmod a+x` it):
|
On your PC, either download one of these binaries (don't forget to `chmod a+x` it):
|
||||||
|
|
||||||
* [uinput-networktablet 64-bit, dynamically linked, tested with Fedora 18 and Ubuntu 12.10](https://github.com/rfc2822/GfxTablet/blob/binaries/uinput-networktablet-x86_64?raw=true)
|
* [networktablet 64-bit, dynamically linked, tested with Fedora 18 and Ubuntu 12.10](https://github.com/rfc2822/GfxTablet/blob/binaries/networktablet-x86_64?raw=true)
|
||||||
|
|
||||||
or compile it yourself (don't be afraid, it's only one file)
|
or compile it yourself (don't be afraid, it's only one file)
|
||||||
|
|
||||||
|
@ -90,12 +90,13 @@ uinput access, you'll need to do it yourself or just run the driver as root:
|
||||||
|
|
||||||
`sudo ./networktablet`
|
`sudo ./networktablet`
|
||||||
|
|
||||||
Then, `xinput list` should show a "Network Tablet" device.
|
Then you should see a status message saying the driver is ready. If you do `xinput list` in a separate
|
||||||
|
terminal, should show a "Network Tablet" device.
|
||||||
|
|
||||||
You can start and stop (Ctrl+C) the Network Tablet at any time, but please be aware that applications
|
You can start and stop (Ctrl+C) the Network Tablet at any time, but please be aware that applications
|
||||||
which use the device may be confused by that and could crash.
|
which use the device may be confused by that and could crash.
|
||||||
|
|
||||||
`networktablet` will display a dot for every touch/motion event it receives.
|
`networktablet` will display a status line for every touch/motion event it receives.
|
||||||
|
|
||||||
|
|
||||||
Part 2: App
|
Part 2: App
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -17,6 +18,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int udp_socket;
|
||||||
|
|
||||||
|
|
||||||
void init_device(int fd)
|
void init_device(int fd)
|
||||||
{
|
{
|
||||||
struct uinput_user_dev uidev;
|
struct uinput_user_dev uidev;
|
||||||
|
@ -85,19 +89,29 @@ void send_event(int device, int type, int code, int value)
|
||||||
error("error: write()");
|
error("error: write()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void quit(int signal) {
|
||||||
|
close(udp_socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int device, socket;
|
int device;
|
||||||
struct event_packet ev_pkt;
|
struct event_packet ev_pkt;
|
||||||
|
|
||||||
if ((device = open("/dev/uinput", O_WRONLY | O_NONBLOCK)) < 0)
|
if ((device = open("/dev/uinput", O_WRONLY | O_NONBLOCK)) < 0)
|
||||||
die("error: open");
|
die("error: open");
|
||||||
|
|
||||||
init_device(device);
|
init_device(device);
|
||||||
socket = prepare_socket();
|
udp_socket = prepare_socket();
|
||||||
|
|
||||||
while (recv(socket, &ev_pkt, sizeof(ev_pkt), 0) >= 9) { // every packet has at least 9 bytes
|
printf("GfxTablet driver (protocol version %u) is ready and listening on 0.0.0.0:%u (UDP)\n"
|
||||||
|
"Hint: Make sure that this port is not blocked by your firewall.\n", PROTOCOL_VERSION, GFXTABLET_PORT);
|
||||||
|
|
||||||
|
signal(SIGINT, quit);
|
||||||
|
signal(SIGTERM, quit);
|
||||||
|
|
||||||
|
while (recv(udp_socket, &ev_pkt, sizeof(ev_pkt), 0) >= 9) { // every packet has at least 9 bytes
|
||||||
printf("."); fflush(0);
|
printf("."); fflush(0);
|
||||||
|
|
||||||
if (memcmp(ev_pkt.signature, "GfxTablet", 9) != 0) {
|
if (memcmp(ev_pkt.signature, "GfxTablet", 9) != 0) {
|
||||||
|
@ -132,10 +146,12 @@ int main(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close(udp_socket);
|
||||||
|
|
||||||
close(socket);
|
printf("Removing network tablet from device list\n");
|
||||||
|
|
||||||
ioctl(device, UI_DEV_DESTROY);
|
ioctl(device, UI_DEV_DESTROY);
|
||||||
close(device);
|
close(device);
|
||||||
|
|
||||||
|
printf("GfxTablet driver shut down gracefully\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue