bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ Mouse-click listener in headless Ubuntu (Ubuntu Server Edition)


From: dinamex
Subject: C++ Mouse-click listener in headless Ubuntu (Ubuntu Server Edition)
Date: Mon, 12 Nov 2012 07:19:12 -0800 (PST)

I want to solve a pretty easy problem. I just want to detect a mouse click
under Ubuntu Server(without GUI respectively windows management). Therefore,
I use Ncurses and following code snippet, but it doesn't detect any mouse
actions. I looked up the web for 2 days now without success. would be great
to get your help.
 

    #include <ncurses.h>
    
    int main(int argc, char **argv){
    
    while(1)
    {
    
        mousemask( ALL_MOUSE_EVENTS, NULL);
            int c = getch();
            MEVENT event;
            switch(c)
            {
                case KEY_UP:
                        printf("keyup");
                    break;
                case KEY_DOWN:
                        printf("keydown");
                    break;
                case KEY_MOUSE:
                    if(getmouse(&event) == OK)
                    {
                        if(event.bstate & BUTTON1_PRESSED) // This works for
left-click
                        {
                                printf("button1");
                        }
                        else if(event.bstate & BUTTON2_PRESSED) // This
doesn't capture right-click
                        {
                                printf("button2");
                        }
                        else
                            printf("Event: %i", event.bstate); // Doesn't
print anything on right-click
                    }
                    break;
            }
    }
    return 0;
    }

-- 
View this message in context: 
http://old.nabble.com/C%2B%2B-Mouse-click-listener-in-headless-Ubuntu-%28Ubuntu-Server-Edition%29-tp34669785p34669785.html
Sent from the Gnu - Ncurses mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]