ctk-curses: Add mouse support to the ncurses CTK backend.
This commit is contained in:
parent
25e3f828aa
commit
db982f7b82
|
@ -76,6 +76,7 @@ ctrlhandler(int sig)
|
||||||
void
|
void
|
||||||
console_init(void)
|
console_init(void)
|
||||||
{
|
{
|
||||||
|
mmask_t oldmask;
|
||||||
static unsigned char done;
|
static unsigned char done;
|
||||||
if(done) {
|
if(done) {
|
||||||
return;
|
return;
|
||||||
|
@ -96,6 +97,9 @@ console_init(void)
|
||||||
intrflush(stdscr, FALSE);
|
intrflush(stdscr, FALSE);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
|
/* done here because ctk_mouse_init() is called before anyway */
|
||||||
|
mousemask(ALL_MOUSE_EVENTS, &oldmask);
|
||||||
|
|
||||||
screensize(&width, &height);
|
screensize(&width, &height);
|
||||||
|
|
||||||
/* curses color handling is weird... */
|
/* curses color handling is weird... */
|
||||||
|
@ -325,6 +329,20 @@ console_readkey(int k)
|
||||||
key = (ctk_arch_key_t)k;
|
key = (ctk_arch_key_t)k;
|
||||||
/*fprintf(stderr, "key: %d\n", k);*/
|
/*fprintf(stderr, "key: %d\n", k);*/
|
||||||
switch (k) {
|
switch (k) {
|
||||||
|
case KEY_MOUSE:
|
||||||
|
{
|
||||||
|
MEVENT event;
|
||||||
|
if (getmouse(&event) == OK) {
|
||||||
|
xpos = event.x;
|
||||||
|
ypos = event.y;
|
||||||
|
button = event.bstate & BUTTON1_PRESSED
|
||||||
|
|| event.bstate & BUTTON1_CLICKED
|
||||||
|
|| event.bstate & BUTTON1_DOUBLE_CLICKED;
|
||||||
|
/*fprintf(stderr, "mevent: %d: %d, %d, %d, %x ; %d\n",
|
||||||
|
event.id, event.x, event.y, event.z, (int)event.bstate, button);*/
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
key = CH_CURS_LEFT;
|
key = CH_CURS_LEFT;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue