Reputation: 24717
I'm writing a joy pad emulator for my tablet for fun and for a challenge. I can touch buttons drawn on my form and have keypresses activate in another form. The problem is that many games (I'm testing on minecraft) use mouse offset to let the player look around the world. My problem is that when I touch a button, the mouse moves there and the player in the game looks around wildly.
How can I accept touch input in C# using WPF without moving the mouse?
Upvotes: 5
Views: 534
Reputation: 351
A method used to gather relative mouse movement sometimes is to read the cursor position, and then reset its position to the centre of the screen, thus giving you the relative moment. This method can be modified to fit your needs.
I found this on how to import function to change the cursor position: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6be8299a-9616-43f4-a72f-799da1193889/
Essentially, what you do is whenever a button is pressed, you call the method to reset the cursor position to the centre of your target window, this should happen fast enough that the target application shouldn't notice at all.
Upvotes: 2
Reputation: 3505
I don't think you can do what you want to do. The mouse & touch input are bound together by the OS, there's nothing you can do to decouple them from within the application.
Upvotes: 1