Search code examples
c#trackpadpressure

How can I access my trackpad in C#?


I'm pretty bored this weekend.

I've decided to build a morse code application where I can use my trackpad to tap morse code in and have my app sound it out.

I told you I was bored! :D

Is there some defacto way to access a trackpad in C#? I mean using pressure graphs. Thanks!


Solution

  • I am not familiar 100% with the idea of the trackpad, but I am assuming that the machine you are working with is a laptop, and what you are referring to is something otherwise known as "mousepad".

    You can do a couple of things at least in windows. When you tap with your finger you are actually sending "click" events to the windows runtime. If you hold

    In .NET any object (Forms/UserControls) that inherits from System.Windows.Forms.Control can subscribe to the following events:

    • MouseDown
    • MouseUp
    • MouseEnter
    • MouseLeave
    • MouseClick
    • MouseDoubleClick

    You can time the Difference in time between MouseUp and MouseDown events and react to the resulting timespan ranges. For instance if you hold the mouse for 20 milliseconds then this is some morse-code character, while holding the mouse for 40 milliseconds is some other character.

    In the case of the mousepad/trackpad this would be the equivalent of holding your finger on the pad itself.