Detect mouse movement in C

This is a discussion on Detect mouse movement in C within the C Programming forums, part of the General Programming Boards category; i was trying to write a programme in c language which can detect mouse movement, but the prograame which i ...

  1. #1
    Registered User wakeupsiddharth's Avatar
    Join Date
    Aug 2013
    Posts
    1

    Exclamation Detect mouse movement in C

    i was trying to write a programme in c language which can detect mouse movement, but the prograame which i have written can only detect the mouse click or scroll...

    the programme which i have written given below..

    Code:
    #include<stdio.h>
    #include<string.h>
    #include <ncurses.h>
    
    
    int main() {
    
        int ch, count=0;
        mmask_t old;
        MEVENT event;
        
        initscr ();
        start_color();
        noecho ();
        cbreak ();
        keypad (stdscr, TRUE);
    
        init_pair(1, COLOR_GREEN, COLOR_WHITE );
        
        mousemask (ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, &old);
    
        while ((ch = wgetch(stdscr)) != 'q') {
            count++;
            switch(ch) {
                case KEY_MOUSE:
                
                    if(getmouse (&event) == OK) {
                        mvprintw (count, 0, "Mouse Event %d\n",count);
                    }
                    
                    attron( COLOR_PAIR(1) | A_BLINK );
                    bkgd(COLOR_PAIR(1) | A_BLINK );
                    mvprintw (event.y,event.x, "hey.");
                    refresh();
                break;
            }
        }
    
        endwin();
        return 0;
    }
    run the programme with linked -lncurses.




    pls help me to improve my programme which also detect when the mouse moves.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to get mouse movement? e.g. (up, down, left, right)
    By anne03 in forum Windows Programming
    Replies: 6
    Last Post: 08-12-2010, 03:52 AM
  2. mouse movement
    By peacealida in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2008, 09:16 AM
  3. Mouse Movement
    By DeepFyre in forum C++ Programming
    Replies: 3
    Last Post: 10-18-2004, 04:05 PM
  4. Mouse Movement
    By Extol in forum Windows Programming
    Replies: 6
    Last Post: 04-22-2003, 08:48 PM
  5. Movement of the mouse
    By nep in forum Windows Programming
    Replies: 1
    Last Post: 05-19-2002, 05:32 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21