7static Gpm_Connect gpmconn;
11 static char cmdbuf[20];
17 const int space =
sizeof(cmdbuf) - 3;
19 if(!Gpm_GetEvent(&gev)){
20 logerror(
"error reading from gpm daemon");
23 loginfo(
"got gpm event y=%hd x=%hd mod=%u butt=%u", gev.y, gev.x,
24 (
unsigned)gev.modifiers, (
unsigned)gev.buttons);
25 if(gev.y < 0 || gev.x < 0){
26 logwarn(
"negative input %hd %hd", gev.x, gev.y);
31 if(snprintf(cmdbuf + 3, space,
"%hd;%hd;%hdM", 0, gev.x + 1, gev.y + 1) >= space){
32 logwarn(
"input overflowed %hd %hd", gev.x, gev.y);
43 gpmconn.eventMask = GPM_DRAG | GPM_DOWN | GPM_UP;
44 gpmconn.defaultMask = 0;
47 if(Gpm_Open(&gpmconn, 0) == -1){
52 logerror(
"couldn't spawn gpm thread");
54 memset(&gpmconn, 0,
sizeof(gpmconn));
57 loginfo(
"connected to gpm on %d", gpm_fd);
69 cancel_and_join(
"gpm", ti->
gpmthread, &thrres);
71 memset(&gpmconn, 0,
sizeof(gpmconn));
76 return Gpm_GetLibVersion(
NULL);
const char * gpm_version(void)
int gpm_read(tinfo *ti, ncinput *ni)
int gpm_connect(tinfo *ti)
int ncinput_shovel(inputctx *ictx, const void *buf, int len)
#define logerror(fmt,...)