#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Angry 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..


    #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. :eek:
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,387
    Rep Power
    1871
    Also here

    Comments on this post

    • dwise1_aol agrees : So somebody else is on the case. Good! We don't have to try to help.
    • eramit2010 agrees
    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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0
    it depends in which substance the glass is made...

IMN logo majestic logo threadwatch logo seochat tools logo