Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I am creating a program which uses a smartphone as a trackpad to control a Ubuntu Desktop. Basically it is another derivation of a virtual trackpad so that the ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4

    Current coordinates for mouse using uinput

    Hi,
    I am creating a program which uses a smartphone as a trackpad to control a Ubuntu Desktop. Basically it is another derivation of a virtual trackpad so that the user can control his mouse pointer from his phone. I am writing to a uinput driver which helps users to inject data such as mouse, keyboard events to the Linux kernel. I have successfully been able to do this, but am having a problem making the mouse pointer move as I want it to. I have researched that a mouse only supports Relative coordinates, NOT absolute ones, thus there is no way for me to know where the current position of the mouse is on the screen. I do not want to use X11, GTK etc, since it does not make sense for my application. It is essential that I know the current mouse position so that I can calculate where the mouse should move based on user input on the trackpad. I would appreciate some sort of guidance as I've been unable to find any relevant information online.

    Thanks

  2. #2
    Just Joined! DaGoomba's Avatar
    Join Date
    Oct 2009
    Location
    In Space
    Posts
    57
    It sounds like a great idea to me. I think the problem might be the difference in size between the monitor and the screen on your phone. This is why the mouse is in a relevant location.

    (NOTE: This sounded good in my head, so I am probably a little (VERY) off.)

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    Sure I agree with you, but I have come up with a way to deal with that. The only problem is that the mouse pointer only accepts relative coordinates. So no matter where my mouse is on the screen, it is at (0,0). If the trackpad hits (30,20) this will move the mouse 30 px horizontally and 20 vertically instead of moving to the absolute coordinate (30,20). I want to know how to move the mouse to (30,20) if it makes any sense?

  4. #4
    Just Joined! DaGoomba's Avatar
    Join Date
    Oct 2009
    Location
    In Space
    Posts
    57
    Your problem is the way the mouse measures distance. Hmm..what is the measurement for (30, 20)? (i.e. Pixels, centimeters, etc.)

  5. #5
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    It measures it in pixels. My problem is that the mouse pointer at a given point in time, has no idea what coordinate it is at, so it assumes (0,0) and whatever coordinates you feed it, it only works as Relative Coordinates. I need my mouse to move to 30,20 on the screen if I hit 30,20 on my trackpad.

  6. #6
    Just Joined! DaGoomba's Avatar
    Join Date
    Oct 2009
    Location
    In Space
    Posts
    57
    You said you are creating this, are you making it from scratch or are you using another program with it?

  7. #7
    Linux Guru
    Join Date
    Jan 2009
    Location
    Dover, NH
    Posts
    1,633
    I have sort of an idea... though it will not work if the button is virtually pressed (like file selection)...

    Get the remote screen resolution.
    Send negative values of the screen resolution to the mouse driver, forcing the pointer into the 0,0 corner.
    Feed the mouse driver the absolute value you seek (e.g. 30,20).

    The theory seems to work in my head.. but as I said, as long as you're not trying to drag something.

  8. #8
    Just Joined! DaGoomba's Avatar
    Join Date
    Oct 2009
    Location
    In Space
    Posts
    57
    To drag files, I would try creating a "move to" command in a drop-menu.

  9. #9
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    Thanks guys. I decided to use relative movements for my mouse pointer since it is not possible to use absolute coordinates for the mouse. The way X-Windows works is that it stores the current mouse position as 0,0 and everything else is relative. Now I am trying to get keyboard events but it is not responding successfully.

Posting Permissions

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