Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting / Remapping / Pre-filtering cursor input from touch screen

MY PROBLEM

Okay, well the basic answer to this would be using the:

Cursor.Clip = new Rectangle(x1, y1, x2, y2);

But my problem is a bit more complicated.

What I need it to do is correctly map itself to a specific windows bounds so that the touch input will be restricted to that window, but will properly clip itself to the window so that when I touch the top-left corner or the bottom-right corner of the touch screen, it will place the cursor to the top-left or bottom-right of the window. Using Cursor.Clip will not do that and everything I touch on the touchscreen that outside of that clipping zone will just get mapped to it's closest edge of the window from where I am touching.

Is there anything that will allow me to pre-filter the mouse position so I can adjust it's bounds correctly?

IF ALL ELSE FAILS

Alternatively, I could try to find some code that will convert the mouse feed into TUIO input and feed it into the application that way, but I was hoping I wouldn't have to do that. So if anyone knows of how I can do that, that would be helpful to if my original request is not possible.

FOR THOSE WHO WANT TO KNOW EXACTLY WHAT I AM DOING

If you need to know exactly why I am doing this, I am basically trying to feed the mouse events from a touch screen being fed in video into a 3D application that can take in touch inputs (through normal mouse events or TUIO) that will draw to that video, but has no way of maximizing to the full resolution of the screen because it will only render the size it is set to output at.

TO BE CLEAR

  • I don't mind a normal mouse being disrupted by any of this.
  • I am talking about a Windows 7 system using the default Windows 7 Touch
  • The input is coming in via USB, not serial or anything like that.
like image 611
corylulu Avatar asked Mar 23 '13 00:03

corylulu


1 Answers

You could use Reactive Extensions to clip the touch events

var movingEvents = 
      Observable.FromEventPattern<MouseEventHandler, MouseEventArgs>(
        h => this.MouseMove += h, h => this.MouseMove -= h)
          .Select(x => x.EventArgs.Location)
          .Where(location =>
               location.X >= viewPort.Location.X 
                  && location.X <= viewPort.Location.X + viewPort.Width
                  && location.Y >= viewPort.Location.Y 
                  && location.Y <= viewPort.Location.Y + viewPort.Height);

movingEvents.Subscribe(update);

public void update(Point p)
{
    textBox1.Text = p.ToString();
}

http://www.codeproject.com/Articles/52308/The-Rx-Framework-By-Example

like image 131
Madu Alikor Avatar answered Oct 10 '22 08:10

Madu Alikor