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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With