HTP Low Level

Low Level Concepts

Programming with the low level of the HTP API represents the most versatility behind using the device, but at the same time introduces more complex programming for the user. The haptic tabletop puck makes use of three main aspects: height, pressure and friction, ranging between 0 and 1, all which can be accessed and modified (except for pressure, which cannot be changed).

When using the low level, the user is not granted the common events of an HTP being down, moved or lifted up, so they will have to make use of regular contact events provided by the Microsoft Surface SDK.

Low level programming is disabled by default, but the user can enable it by activating the manual control flag (refer to examples for more information).

Programming with the Low Level

Low level programming can be more complicated, but at the same time allows for fine grained, detailed operations that may not be possible with the higher levels. In these examples, we illustrate some simple uses of the low level.

Basic Example

The following example makes use of the low level to change the height of the rod of the HTP while the user applies pressure.

  1. HTPManager manager = HTPManager.Instance;
  2. // Retrieve HTP
  3. HTP htp = HTPManager.GetHTP(0xEF);
  5. HTPManager.ManualControl = true;
  7. while(true)
  8. {
  9.      Console.WriteLine(htp.Pressure);
  10.      htp.Height = 1 htp.Pressure;
  11. }

Example Using the Tabletop

The following example makes use of the location of an HTP on the table and changes its height accordingly.

  1. public HTPWindow()
  2. {
  3.   InitializeComponent();
  5.   // Add handlers for Application activation events
  6.   AddActivationHandlers();
  7.   // Default Window Registration
  8.   this.manager.RegisterWindow(this, this.HTPCanvas);
  10.   this.manager.ManualControl = true;
  11.   this.ContactDown += new ContactEventHandler(HTPWindow_ContactDown);
  12.   this.ContactChanged += new ContactEventHandler(HTPWindow_ContactDown);
  13. }
  15. void HTPWindow_ContactDown(object sender, ContactEventArgs e)
  16. {
  17.   manager.GetHTP(0x10).Height = e.GetPosition(this.HTPCanvas).X / 1024;
  18. }