Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accept touch without moving mouse?

Tags:

c#

wpf

touch

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?

like image 888
Corey Ogburn Avatar asked Oct 24 '22 07:10

Corey Ogburn


1 Answers

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.

like image 164
bryanegr Avatar answered Nov 11 '22 06:11

bryanegr