mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
complete initial libgpm support #1405
This commit is contained in:
parent
1463049d32
commit
582e7b24c5
@ -65,6 +65,9 @@ using `USE_MULTIMEDIA`. Valid values are `ffmpeg`, `oiio` (for OpenImageIO),
|
||||
or `none`. Without a multimedia engine, Notcurses will be unable to decode
|
||||
images and videos.
|
||||
|
||||
To get mouse events in the Linux console, you'll need the GPM daemon running,
|
||||
and you'll need run `cmake` with `-DUSE_GPM=on`.
|
||||
|
||||
Run unit tests with `make test` following a successful build. If you have unit
|
||||
test failures, *please* file a bug including the output of
|
||||
|
||||
|
4
NEWS.md
4
NEWS.md
@ -1,6 +1,10 @@
|
||||
This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 2.3.19 (not yet released)
|
||||
* Mouse events in the Linux console are now reported from GPM when built
|
||||
with `-DUSE_GPM=on`.
|
||||
|
||||
* 2.3.18 (2021-08-31)
|
||||
* No user-visible changes.
|
||||
|
||||
|
@ -8,9 +8,13 @@ static Gpm_Connect gpmconn; // gpm server handle
|
||||
|
||||
static void*
|
||||
gpmwatcher(void* vti){
|
||||
static char cmdbuf[20]; // max is '\x1b[<int;int;intM'
|
||||
cmdbuf[0] = '\x1b';
|
||||
cmdbuf[1] = '[';
|
||||
cmdbuf[2] = '<';
|
||||
tinfo* ti = vti;
|
||||
(void)ti; // FIXME
|
||||
Gpm_Event gev;
|
||||
const int space = sizeof(cmdbuf) - 3;
|
||||
while(true){
|
||||
if(!Gpm_GetEvent(&gev)){
|
||||
logerror("error reading from gpm daemon\n");
|
||||
@ -18,7 +22,17 @@ gpmwatcher(void* vti){
|
||||
}
|
||||
loginfo("got gpm event y=%hd x=%hd mod=%u butt=%u\n", gev.y, gev.x,
|
||||
(unsigned)gev.modifiers, (unsigned)gev.buttons);
|
||||
// FIXME decode event and enqueue to input layer
|
||||
if(gev.y < 0 || gev.x < 0){
|
||||
logwarn("negative input %hd %hd", gev.x, gev.y);
|
||||
continue;
|
||||
}
|
||||
++gev.x;
|
||||
++gev.y;
|
||||
if(snprintf(cmdbuf + 3, space, "%hd;%hd;%hdM", 0, gev.x, gev.y) >= space){
|
||||
logwarn("input overflowed %hd %hd\n", gev.x, gev.y);
|
||||
continue;
|
||||
}
|
||||
ncinput_shovel(&ti->input, cmdbuf, strlen(cmdbuf));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -535,12 +535,15 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ncinput_shovel(ncinputlayer* ni, const unsigned char* buf, size_t len){
|
||||
int ncinput_shovel(ncinputlayer* ni, const char* buf, size_t len){
|
||||
int ret = -1;
|
||||
pthread_mutex_lock(&ni->lock);
|
||||
size_t space = input_queue_space(ni);
|
||||
if(len < space){
|
||||
size_t spaceback = sizeof(ni->inputbuf) / sizeof(*ni->inputbuf) - ni->inputbuf_write_at;
|
||||
if(spaceback > len){
|
||||
spaceback = len;
|
||||
}
|
||||
memcpy(ni->inputbuf + ni->inputbuf_write_at, buf, spaceback);
|
||||
len -= spaceback;
|
||||
ni->inputbuf_write_at += spaceback;
|
||||
|
@ -60,7 +60,7 @@ int cbreak_mode(struct tinfo* ti);
|
||||
// appropriate. we can be interrupted by a new user context.
|
||||
void ncinput_extract_clrs(struct tinfo* ti);
|
||||
|
||||
int ncinput_shovel(struct ncinputlayer* ni, const unsigned char* buf, size_t len);
|
||||
int ncinput_shovel(struct ncinputlayer* ni, const char* buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user