Find the answer to your Linux question:
Results 1 to 9 of 9
hi all... i want to develop a simple program to access the USB mouse(not just mounting .. i want to get the coordinates and clicks of mouse from my program)... ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Posts
    11

    program to access the USB mouse....


    hi all...
    i want to develop a simple program to access the USB mouse(not just mounting .. i want to get the coordinates and clicks of mouse from my program)...

    i dono how to start it.. what are things i must know.... i have little bit experince in modules programming... cud u anybody guide me... regarding this ...

    thanking u

  2. #2
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    You question is not specific, so don't get surprised that you don't have that many responses First, decide what programming language you are going to use, then maybe someone would recommend you what techniques you might need to know, to operate with pointing devices (mouse in your case).

    On the other hand, why you asked for USB mouse? You are not going to write low level application that will talk to mouse via USB port directly, are you? This could be too complex and difficult for such a simple application, anyway I hope you explicitly pointed "USB" in your post just by pour accident.

    Usually device drivers will take care of that (whether it's USB or COM or PS/2), for you it's just a mouse. In linux it's also a device file /dev/input/mice (in console type "cat /dev/input/mice" and move your mouse to see the output, funny ha? ). And what you might need is to use existing libraries for managing pointing devices. That "library" will give you an API, which will be simplified for your use, as a developer, while doing low level operations and interacting with device driver behind that API.

    Basically, mouse click and movement are events, and next what you need is a listener for those events, so that when such event happens, your program would be notified of it and could get required information about that event (event object). That object will contain information about attributes like what button was clicked or mouse x,y coordinates. Most common listener interfaces are prepared by SDK developers, and you might need to implement that listener in your program. Good luck!

  3. #3
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    To give a little more detail to this post, the original poster said to me that his/her intention is to create this program on an embedded device using the ARM architecture.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Sep 2005
    Posts
    11

    for evaluation purpose

    dear sir..
    yes there r commandline tool... but i want to develop programs for accessing USB mouse... coz i have to develop some applications which will run on embedded linux ARM development kit.. before that i want to evaluate in linux hosted PC..
    thats y i am trying to access the USB MOUSE... if i complete this one then i can develop similar applications in embedded linux... hope u got me..
    cud u guide me reagarding this one.. i am not funny.. this is for evaluation purpose...



    thanking you...

    regards

  6. #5
    Just Joined!
    Join Date
    Sep 2005
    Posts
    11

    well. i got one USB API..

    hi
    i got that USB API for linux .. they given full source code.. http://jusb.sourceforge.net/.. i am going to use java on linux for my application..

    thanking you..

  7. #6
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    Sorry, if I'm wrong, I just don't know enough about that embedded device and requirements for the software you'll write, but I don't understand yet, why you are talking about USB mouse again if you decided to use java? Does it really matter for your software how the mouse is connected, it's model, number of wheels and etc.? Your device (is it pda or mobile phone or toaster) has usb mouse, and jre installed, is that true? Then couldn't you just write the following class?
    Code:
    import java.awt.event.*;
    
    public class MyMouse implements MouseListener {
        
        public void mouseClicked(MouseEvent mouseEvent) {
        }
    
        public void mouseEntered(MouseEvent mouseEvent) {
        }
    
        public void mouseExited(MouseEvent mouseEvent) {
        }
    
        public void mousePressed(MouseEvent mouseEvent) {
        }
    
        public void mouseReleased(MouseEvent mouseEvent) {
        }
        
    }
    Then add this listener to the control, to JFrame for example...
    Code:
    import javax.swing.*;
    
    public class MouseTester extends JFrame {
    
        public MouseTester () {
            this.addMouseListener(new MyMouse());
        }
    
    }
    ...now mouseClicked() method of MyMouse class will be called when you'll click somewhere on MouseTester window.

  8. #7
    Just Joined!
    Join Date
    Sep 2005
    Posts
    11

    re:

    hi..
    no.. u r not wrong.. actually i didnt say specific.ok..
    and i have to develop hotplug drivers for any USB device(USB camera,speaker,mobile,PDA) anything.. and i am on embedded linux platform..
    now only i started to work on USB on linux.. so i decided to work first with USB human interface devices like mouse,keyboard,joystick..
    then i go for high end devices... after getting clear idea about USB drivers, then i move for those applications... hope. now u got me..

    thank u...

  9. #8
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    OIC Good luck!

  10. #9
    Just Joined!
    Join Date
    Sep 2005
    Posts
    11

    yeah.. thank u..

    thank u...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •