Touch and Gesture Platform: Windows Runtime API surface Metro style app using HTML Metro style app using XAML ICoreWindow Windows Runtime Pointer events Pointer events Pointer events with PointerPoint Pointer events with PointerPoint PointerPoint Gesture.
Download
Report
Transcript Touch and Gesture Platform: Windows Runtime API surface Metro style app using HTML Metro style app using XAML ICoreWindow Windows Runtime Pointer events Pointer events Pointer events with PointerPoint Pointer events with PointerPoint PointerPoint Gesture.
Touch and Gesture Platform:
Windows Runtime
API surface
Metro style app
using HTML
Metro style app
using XAML
ICoreWindow
Windows Runtime
Pointer events
Pointer events
Pointer events with
PointerPoint
Pointer events with
PointerPoint
PointerPoint
Gesture events
Gesture events
Gesture events
GestureRecognizer
Device APIs
Targeting
PointerDevice &
Capabilities
Baked into
framework and
controls
Baked into
framework and
controls
TouchHitTesting
event
void GestureRecognizerSample::OnPointerPressed( ... )
{
// Hit testing: find the object under the pointer
...
if (iObject != -1)
{
// Assign the pointer to the object found in hit testing
_gestureRecognizers[iObject]->ProcessDownEvent(pointerPoint);
}
else
{
// No objects found in hit testing. Assign this pointer to background
_gestureRecognizers[_objects->Length]->ProcessDownEvent(pointerPoint);
}
}
void GestureRecognizerSample::OnPointerPressed( ... )
{
// Hit testing: find the object under the pointer
...
if (iObject != -1)
{
// Assign the pointer to the object found in hit testing
_gestureRecognizers[iObject]->ProcessDownEvent(pointerPoint);
}
else
{
// No objects found in hit testing. Assign this pointer to background
_gestureRecognizers[_objects->Length]->ProcessDownEvent(pointerPoint);
}
}
void Sample::OnPointerPressed(
_In_ Windows::UI::Core::CoreWindow^,
_In_ Windows::UI::Core::PointerEventArgs^ args)
{
Windows::UI::Input::PointerPoint^ pointerPoint = args->CurrentPoint;
bool fHasPressure;
INT32 vendorValue;
// Does the packet have pressure info?
pointerPoint->HasUsage(0x0D, 0x30, &fHasPressure);
// Get vendor defined usage from HID packet
pointerPoint->GetUsageValue(0x06, 0x01, &vendorValue);
}
void DrawingObject::Attach(_In_ Windows::UI::Input::GestureRecognizer^ gestureRecognizer)
{
// Configure gesture recognizer
gestureRecognizer->GestureSettings =
Windows::UI::Input::GestureSettings::Tap
|
Windows::UI::Input::GestureSettings::Hold
|
Windows::UI::Input::GestureSettings::RightTap
|
Windows::UI::Input::GestureSettings::ManipulationTranslateX
|
Windows::UI::Input::GestureSettings::ManipulationTranslateY
|
Windows::UI::Input::GestureSettings::ManipulationTranslateInertia;
...
// Register all the gesture event handlers
_tokenTapped = gestureRecognizer->Tapped::add(
ref new Windows::Foundation::TypedEventHandler<
Windows::UI::Input::GestureRecognizer^, Windows::UI::Input::TappedEventArgs^>(
this, &DrawingObject::OnTapped));
...
void GestureRecognizerSample::OnPointerMoved(
_In_ Windows::UI::Core::CoreWindow^,
_In_ Windows::UI::Core::PointerEventArgs^ args)
{
Windows::Foundation::Collections::IVector<Windows::UI::Input::PointerPoint^>^
pointerPoints = args->GetIntermediatePoints();
for (unsigned int i=0; i<_gestureRecognizers->Length; ++i)
{
_gestureRecognizers[i]->ProcessMoveEvents(pointerPoints);
}
// Render the latest position
OnRender();
}
void DrawingObject::OnTapped(
_In_ Windows::UI::Input::GestureRecognizer^,
_In_ Windows::UI::Input::TappedEventArgs^)
{
++_color;
if (_color >= Color::MaxCount)
{
_color = Color::First;
}
_parent->RequestRedraw(false);
}
void DrawingObject::Attach( ... )
{
// Configure gesture recognizer
gestureRecognizer->GestureSettings =
Windows::UI::Input::GestureSettings::Tap
Windows::UI::Input::GestureSettings::Hold
Windows::UI::Input::GestureSettings::RightTap
...
}
void DrawingObject::OnRightTapped(
_In_ Windows::UI::Input::GestureRecognizer^,
_In_ Windows::UI::Input::RightTappedEventArgs^)
{
Initialize(_initColor, _initX, _initY, _initDX, _initDY);
_parent->RequestRedraw(false);
}
|
|
|
void BackgroundObject::GetDeviceDescription()
{
Windows::Devices::Input::PointerDeviceType type =
_pointerDevice->PointerDeviceType;
boolean external = !_pointerDevice->IsIntegrated;
UINT32 maxContacts = _pointerDevice->MaxContacts;
Windows::Foundation::Rect rcPhysical = _pointerDevice->PhysicalDeviceRect;
Windows::Foundation::Rect rcScreen = _pointerDevice->ScreenRect;
// Build device description string
...
}
void Sample::GetDeviceSupportedUsages(UINT 32 pid)
{
Windows::Devices::Input::PointerDevice device;
IVectorView<PointerDeviceUsage> usages;
Windows::Devices::Input::PointerDevice::GetPointerDevice(pid, &device);
usages = device->SupportedUsages;
...
for (int i = 0; i < usages.length; i++)
{
UINT32 HIDUsagePage = usages[i].UsagePage;
UINT32 HIDUsage = usages[i].Usage;
...
}
}
bool Sample::IsMultiplayerSupported()
{
PenCapabilities ^pPenCapabilities = ref new PenCapabilities();
bool PenPresent = pPenCapabilities->PenPresent;
TouchCapabilities ^pTouchCapabilities = ref new TouchCapabilities();
UINT32 TotalContacts = pTouchCapabilities->Contacts;
return PenPresent && (TotalContacts >= 8);
}
void CProgram::OnTouchHitTesting(_In_ Windows::UI::Core::CoreWindow^ /*sender*/,
_In_ Windows::UI::Core::TouchHitTestingEventArgs^ touchHitTestingArgs)
{
// Current and best touch hit testing results
Windows::UI::Core::CoreProximityEvaluation bestResult;
Windows::UI::Core::CoreProximityEvaluation currentResult;
// Initialize best result and best touch hit testing target from input arguments
bestResult = touchHitTestingArgs->ProximityEvaluation;
bestResult.AdjustedPoint = touchHitTestingArgs->Point;
// Use appropriate logic to find best target – see ShapesPuzzle sample
...
// Set best target
touchHitTestingArgs->ProximityEvaluation = bestResult;
// Event is handled
touchHitTestingArgs->Handled = true;
}
Touch and Gesture Platform:
Win32
Q&A
http://dev.windows.com
[email protected]
http://forums.dev.windows.com
http://bldw.in/SessionFeedback
Metro style Apps
Core
System Services
Model
Controller
View
XAML
C
C++
Desktop Apps
HTML / CSS
C#
VB
JavaScript
(Chakra)
HTML
C
C++
C#
VB
Internet
Explorer
Win32
.NET
/ SL
JavaScript
WinRT APIs
Communication
& Data
Graphics &
Media
Application Model
Devices &
Printing
Windows Core OS Services
API behavior
WM_TOUCH
WM_POINTER
Exclusivity of gestures and raw data
WM_TOUCH and WM_GESTURE are exclusive
WM_POINTER can be used in conjunction with TIE
Input delays
WM_TOUCH has palm rejection delays by default
WM_POINTER has no input delays
Multiple window support
WM_TOUCH can only be delivered to one window.
Contacts in other windows are dropped after the
initial target window is determined.
WM_TOUCH is frame-based
WM_POINTER messages can be delivered to
multiple windows simultaneously. Capture APIs
provide additional functionality here as well.
WM_POINTER is non-frame-based by default, but
developers can consume frames if they choose.
Frame vs non-frame
Rich data
Tying touch to mouse data
Capture support
WM_TOUCH contains basic contact geometry
(height and width only)
WM_POINTER supports more detailed contact
geometry data as well as other richer information in
the associated structs such as TOUCH_INFO
WM_TOUCH always promotes the primary contact WM_POINTER does no mouse promotion by
to mouse
default. WM_POINTER has a separate method for
controlling activation.
WM_TOUCH supports only it’s implicit capture
WM_POINTER provides a capture API for controlling
model on a single window
how capture works for contacts and windows
Activation support
WM_TOUCH relies on the mouse messages it
promotes to control activation
WM_POINTER provides an activation API to control
how activation works for a window
Pen and other pointing device input
WM_TOUCH does not include pen input
WM_POINTER can carry any pointing device’s input