LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-13-2005, 03:33 AM   #1
bastin_gh
LQ Newbie
 
Registered: May 2005
Location: Trivandrum
Distribution: Fedora core 3
Posts: 6

Rep: Reputation: 0
how to use mouse in C graphics programming...


hi.. i have done many graphics programs in C using the Turbo C editor.. but till now, i haven't used mouse in my programs. how do we use the mouse. if possible, please have a sample program to explain the procedure for using the mouse.....
 
Old 07-13-2005, 08:55 AM   #2
meDream
Member
 
Registered: Jan 2005
Distribution: Mandrake 10.1
Posts: 47

Rep: Reputation: 15
if you use SDL library then it is easy!!
just look the following link
ftp://ptah.lnf.kth.se/pub/misc/sdl-env-vars

anyway you'll find a lot of stuff with googling around
 
Old 07-13-2005, 09:12 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Is it for use with X ?

If yes, this is an example to move the x pointer :
Code:
#include <X11/Xlib.h>
#include <stdio.h>

int main(int argc, char * argv[]) {
    Display *display;
    Window root;

    display = XOpenDisplay(NULL);

    if(display == 0) {
        printf("Could not open default display\n");
        return 1;
    }

    root = DefaultRootWindow(display);

    /* move the pointer to (250, 250) */
    XWarpPointer(display, None, root, None, None, None, None, 250, 250);

    XCloseDisplay(display);
    return 0;
}
If you saved it as mouse.c, compile with :
gcc -o mouse mouse.c -L/usr/X11R6/lib -lX11 -lXtst

Last edited by keefaz; 07-13-2005 at 09:13 AM.
 
Old 07-13-2005, 09:28 AM   #4
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Turbo C/C++? My guess is the OP is programming in MS-DOS.
 
Old 07-13-2005, 11:00 AM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, bastin_gh -

How to use the mouse depends on:

1. What OS you're running (using the "system pointer" in a graphical environment like MS-Windows or the Linux GUI is light years away from doing serial I/O with "mouse input" under DOS)

2. Your choice of language and programming library (C? C++? Python? Java?)

Since you're probably running under some kind of GUI (either Linux or Windows), and since it doesn't sound like programming language is too much of an issue, you might want to consider learning Java (which has GUI libraries - including mouse support - built in).

IMHO .. Paul Santa Maria
 
Old 07-13-2005, 11:47 AM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
PUT DOWN THE TC++ COMPILER, AND BACK AWAY!!!

Seriously, you should consider checking out one of the many free compilers available. TC++ not only creates binaries for an outdated OS (DOS), but it is not very ANSI compliant as it has been around long before the days of the final ANSI/ISO standards were put in place.

If switching compilers isn't an option... Well, I seem to remember needing to do some interrupt work to interact with the mouse drivers in TC++. Since you are probably running it with DOS emulation under XP or something of the sort, I'm not sure how well that works anymore.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphics Programming on linux using C hazzyb Programming 5 07-15-2005 03:11 PM
graphics programming with gcc mamta_k Linux - Software 1 06-01-2004 07:28 AM
Graphics Programming Language renjith Programming 7 08-16-2003 10:08 AM
Graphics programming in linux juby Programming 15 01-25-2003 05:49 AM
Graphics Driver Programming XoSkely10 Programming 1 07-31-2002 02:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration