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.
- HTPManager manager = HTPManager.Instance;
- // Retrieve HTP
- HTP htp = HTPManager.GetHTP(0xEF);
- HTPManager.ManualControl = true;
- while(true)
- {
- Console.WriteLine(htp.Pressure);
- htp.Height = 1 – htp.Pressure;
- }
Example Using the Tabletop
The following example makes use of the location of an HTP on the table and changes its height accordingly.
- public HTPWindow()
- {
- InitializeComponent();
- // Add handlers for Application activation events
- AddActivationHandlers();
- // Default Window Registration
- this.manager.RegisterWindow(this, this.HTPCanvas);
- this.manager.ManualControl = true;
- }
- void HTPWindow_ContactDown(object sender, ContactEventArgs e)
- {
- manager.GetHTP(0x10).Height = e.GetPosition(this.HTPCanvas).X / 1024;
- }