Thread: ncurses and touchpad support for Windows

  1. #1
    Registered User
    Join Date
    Mar 2024
    Posts
    12

    ncurses and touchpad support for Windows

    Hello, i tried ncurses and touchpad clicks from an ASUS laptop with Msys2 installed.
    It seems that ncurses for Windows do not support touchpad.

    How can i catch touchpad-mouse clicks for ncurses in windows ?
    I tried midnight commander on Windows and it support my touchpad, how does it do it ?

    Thanks in advance for your replies...
    DimK


    i posted this answer at C Programming thread but i was advised to post it here
    ncurses and touchpad support for Windows

  2. #2
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    i think this issue has nothing to do with Windows OS but ncurses for Linux or Windows do not support touchpad clicks as mouse clicks !

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Are you using ncurses itself or are you using pdcurses?
    Did you download a precompiled library or compile it yourself?
    Are you compiling your program through mingw or msys2, or just directly on Windows?
    You mentioned Linux, too. Have you also tried it on Linux?
    Post the shortest program that demonstrates the problem.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  4. #4
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    Quote Originally Posted by john.c View Post
    Are you using ncurses itself or are you using pdcurses?
    i use ncursesw from Msys2

    Did you download a precompiled library or compile it yourself?
    I use no library

    Are you compiling your program through mingw or msys2, or just directly on Windows?
    i use msys2 mingw64 gcc

    You mentioned Linux, too. Have you also tried it on Linux?
    i tried on virtual box with a Debian 13. On Linux the program works fine because the OS sees mouse as USB Tablet pointing device.

    Post the shortest program that demonstrates the problem.
    Code:
    #include <ncurses.h>
    
    
    int main() {
        initscr(); // Initialize ncurses
        cbreak(); // Line buffering disabled, Pass on everything to me
        noecho(); // Don't echo() while we do getch
        keypad(stdscr, TRUE); // Enable keypad mode
        mousemask(ALL_MOUSE_EVENTS, NULL); // Enable mouse events
    
    
        // Check if the terminal supports mouse
        if (!has_mouse())
        {
            endwin(); // Clean up ncurses
            printf("Mouse not supported.\n");
            return 1;
        }
    
    
        mvprintw(LINES / 2, (COLS - 21) / 2, "Click anywhere to exit");
        refresh();
    
    
        int ch;
        MEVENT event;
        while((ch = getch()) != KEY_F(1)) { // Exit loop on pressing F1
            if(ch == KEY_MOUSE) {
                if(getmouse(&event) == OK) {
                    if(event.bstate & BUTTON1_CLICKED) {
                        // Left button clicked
                        break;
                    }
                }
            }
        }
    
    
        endwin(); // Cleanup ncurses
        return 0;
    }
    Something else, chatgpt mentions that ncurses for win or linux has no native support for touchpad devices

  5. #5
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    I use no library
    Presumably you are using the ncurses library.
    What exactly is your compile line?

    chatgpt mentions that ncurses for win or linux has no native support for touchpad devices
    You say you tried it on Linux and it worked fine. So does it work on Linux or not?

    EDIT:
    Also, have you tried it with an actual mouse hooked up to your laptop? Does that work?
    Last edited by john.c; 3 Weeks Ago at 09:12 AM.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  6. #6
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    Quote Originally Posted by john.c View Post
    Presumably you are using the ncurses library.
    What exactly is your compile line?
    gcc.exe -Wall -g -IC:\msys64\mingw64\include\ncursesw -c C:\Users\demos\Documents\WORKSPACES\C\NCURSES\4_5\ main.c -o obj\Debug\main.o
    gcc.exe -o bin\Debug\4_5.exe obj\Debug\main.o -lncursesw

    You say you tried it on Linux and it worked fine. So does it work on Linux or not?
    Linux was in a virtual machine in virtual box which the OS sees mouse as usb device, that's why it worked there !!!

    EDIT:
    Also, have you tried it with an actual mouse hooked up to your laptop? Does that work?
    no i have not tried to plug in a usb mouse to laptop

  7. #7
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Try a mouse. Neither seems to work for me. The terminal seems to be eating the mouse clicks.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  8. #8
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    That is not a solution. If i use a usb mouse it will work.

    I tried a binary version for windows of midnight commander and there the touchpad works... i am wondering how they did it ?

  9. #9
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    That is not a solution. If i use a usb mouse it will work.
    I didn't say a mouse was a solution.
    I said to try it to see if it works.
    It DOES NOT work for me, with either the touchpad or the mouse.
    Anyway, you obviously don't want my help so I'll leave you to it.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  10. #10
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    of course I want any help...don't take it personally...

    for me it works with vm so that's enough

    on the other hand I don't have a mouse handy to try

    thanks for your time and feedback anyway

  11. #11
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    What terminal are you using? Mintty or something else?

    This might be relevant: ncurses on windows, can't receive KEY_MOUSE

  12. #12
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    Quote Originally Posted by christop View Post
    What terminal are you using? Mintty or something else?

    This might be relevant: ncurses on windows, can't receive KEY_MOUSE
    Yes this is the case...
    i use XTerm in Linux and cmd on Windows11

  13. #13
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    so john.c was right... it does not work on Windows also with a mouse nor touchpad...

    thanks for feedback

  14. #14
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    Quote Originally Posted by john.c View Post
    Try a mouse. Neither seems to work for me. The terminal seems to be eating the mouse clicks.
    You are correct !!! This is not touchpad issue but terminal issue.
    Windows cmd terminal does not accept mouse clicks. I tried on Windows 11 with a usb mouse.

  15. #15
    Registered User
    Join Date
    Mar 2024
    Posts
    12
    i have good news...
    i had success with cygwin64. In cygwin64 the mouse behaves as expected.
    i can compile the program, run it, and make clicks with touchpad from laptop, and the program behaves as wanted !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ncurses and touchpad support for Windows
    By demosthenesk in forum C Programming
    Replies: 2
    Last Post: 3 Weeks Ago, 09:31 AM
  2. ncurses & windows
    By gavra in forum C Programming
    Replies: 2
    Last Post: 07-22-2008, 09:26 AM
  3. ncurses and windows
    By Swarvy in forum Windows Programming
    Replies: 3
    Last Post: 04-10-2008, 08:24 PM
  4. ncurses, windows, and colors
    By subflood in forum Linux Programming
    Replies: 2
    Last Post: 08-26-2004, 10:14 AM
  5. Ncurses Windows
    By Karl in forum C Programming
    Replies: 0
    Last Post: 02-20-2004, 03:29 PM

Tags for this Thread