Detecting touch properties of the screen - c++

Is there a way in QML or Qt or C++ to know if the screen (or the platform) support tactile, and more specifically, if the screen support multitouch
Is this even possible ?
EDIT :
On windows it seems we could try to enumerate the device to find one that match
https://support.microsoft.com/en-us/kb/259695
This should also be possible on linux
RELATED :
What's the best way to detect a 'touch screen' device using JavaScript?
Is there a way to determine if the current screen supports touch?

You can use the static QTouchDevice::devices() function to enumerate the available touch devices, and the capabilities() function to check the capabilities of individual devices. To check for multitouch support, you would probably call maximumTouchPoints().
The QTouchDevice class describes the device from which touch events originate.
Each QTouchEvent contains a QTouchDevice pointer to allow accessing device-specific properties like type and capabilities. It is the responsibility of the platform or generic plug-ins to register the available touch devices via QWindowSystemInterface before generating any touch events. Applications do not need to instantiate this class, they should just access the global instances pointed to by QTouchEvent::device().

Related

Trouble understanding OpenVR driver API

My end goal is to make a VRidge lightweight clone to understand the OpenVR API, but I'm struggling to understand how to get my code to display something. As a starting point, instead of my phone, I want to create a window as the HMD (SFML, SDL, you name it...) and having SteamVR rendering the VR view in it.
I understand that an object implementing IServerTrackedDeviceProvider is the handler of my driver's devices, ITrackedDeviceServerDriver is the interface of the device itself, and I suspect that my "HMD" device will have to implement IVRDisplayComponent.
Aside from setting some properties and having callbacks to activate and deactivate my device, I have no clue where to get an actual frame to display on the screen. What am I missing ?
You are almost right.
A class inheriting vr::IServerTrackedDeviceProvider(I'll call it the device parent later on) is responsible for registering and maintaining the lifetime of your devices(creating them, registering them, etc.)
Classes inheriting vr::ITrackedDeviceServerDriver after they have been registered by a device parent are considered a tracked device, device type is set by the device parent on register, also in case of the HMD device GetComponent() method needs to return display components if requested, for other devices it can just return NULL
GetComponent() receives a c string with a component name and version, for example "IVRDisplayComponent_002" stored in vr::IVRDisplayComponent_Version, and if the device has a component with a matching name version pair you need to return a pointer to it, if no match is found return NULL
Also about components, in the driver example that Valve provides its done in a very lazy and bad way, DO NOT INHERIT COMPONENTS TO YOUR DEVICE CLASSES
Segment your components into separate objects that you initialize in your device and return them in GetComponent() accordingly
Now, the only thing left for your devices to be properly identified and used by SteamVR is registering them, but there is a catch, you need to specify the device type when you register it by passing one of the values from vr::ETrackedDeviceClass enum(these should be pretty self explanatory when you look at the enum)
This is not all there is to openvr driver of course, for it all to work and for SteamVR to even acknowledge your driver's existence you need to implement an HmdDriverFactory() function, its similarly to GetComponent() except you compare the input c string to a provider name version pair and in case of a device parent its vr::IServerTrackedDeviceProvider_Version, if you get a match return a pointer to the instance of your device parent or any other provider you implemented
A few notes:
HMD needs at least one display component
HMD device is very sensitive to how you submit poses to it(dont ask why, it just is)
Be prepared for the lack of documentation, the best docs that you're gonna get are code comments in openvr_driver.h, ValveSoftware/openvr issue tracker and other people working with openvr drivers (even though there are only few...)
This is not the best explanation of how openvr drivers work, so you're always welcomed to ask for more details in the comments

Is there a way to distinguish a track pad from a mouse on Windows?

I'm looking for a way to determine if the computer my game is running on has a mouse or a trackpad connected so I can set the default controls accordingly. I'm trying to distinguish a typical keyboard + mouse setup you'd find on a desktop versus a laptop which may or may not have an external mouse but will have a built in trackpad.
In pseudo code this is what I'm trying to achieve:
if (hasMouse())
{
setUpMouseControls();
}
else if (hasTrackPad())
{
setUpTrackPadControls();
}
Is there an API that makes this doable? My targets for support are Windows 7+. I'm writing the game in C++.
Some trackpads have special functions that can be used together with a special driver (like scroll bars at the border of the trackpad). In this case it might be possible to detect the presence of a certain device driver (e.g. Acme Trackpad driver).
Howerver this would only work for some track pad models!
You could always detect an USB trackpad by the VID/PID.
However both methods would only work for trackpad models known by your program.
Other trackpads (especially PS/2 ones - maybe built in into laptops) do not identify themselfes as trackpads - they "tell" the computer that they are an ordinary mouse.
There is no chance to detect such a trackpad!
Follow this link: http://msdn.microsoft.com/en-us/library/ms645600%28VS.85%29.aspx
You can use RegisterRawInputDevices function to recieve WM_INPUT messages. Using this message you can determine type of input device and then set your default controls.

Global hotkeys in a cross-platform Qt application

I'm creating a cross platform utility, in C++ using Qt, for which I need to have shortcut keys (or hotkeys, not really sure about the difference). Essentially the application will run and only be visible as an icon in the system tray, and do stuff when you press certain shortcut keys (eg, Ctrl-Shift-f4 or something).
I am under the impression that Qt doesn't provide a way to handle shortcut keys unless the application is in focus, which, in my case it won't be. So, that's out (if however that is a viable option, please clue me in).
I've found plenty of examples/documentation explaining how to do this using Xlib/Xcb for linux, win32 api for windows, and carbon for osx, but I'm having a hard time finding a way to do this that would be applicable within the scope of a Qt application.
What would be a way to accomplish what I need?
I'm digging up this old non-answered question because, using QML, I encountered the same issue. The Shortcut QML type allow you to specify a context property but you still need a focused application or window.
However, I found a library resolving this issue : QHotkey. Describing itself on Github as :
A global shortcut/hotkey for Desktop Qt-Applications.
The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka shortcuts that work everywhere, independent of the application state. This means your application can be active, inactive, minimized or not visible at all and still receive the shortcuts.
QHockey is available as a package through qpm and can be used directly from C++.

Windows Mobile 6.5 Change the camera focus

I have a project to scan some QR-code or bar-code with camera on windows mobile. (phone x01t)
Programing in C++ and using DirectShow.
Tired to change focus with IAMCameraControl interface, but return the error like "...request is not supported".
Are there any way else?
Thanks
Most (if not all) Windows Mobile phones I've used so far used custom camera drivers, which means OEMs decide which functionalities to implement/support. IAMCameraControl is most likely not one of them.
However, you might want to look for OEM-specific SDKs. For instance, Samsung provides custom APIs enabling to change such parameters as camera focus or ISO. Maybe such APIs exist for your device.

Determining HID interface to be POS or Keyboard in C++

I've got some bar code scanner devices that can handle a variety of USB interfaces (COMM Emulation, HID Keyboard, HID POS, etc.) The problem is that, while I can tell if the device is in a HID mode, I need to be able to determine if it's HID Keyboard or HID POS.
Is there a way to determine this using Win32 C++, preferably with the built in windows HID library (hidsdi.h)?
You can use HidD_GetHidGuid to get the unique GUID for the device. Device interface guids are defined by each device/application software vendor, Microsoft or third party as they see fit. In some cases the guids are published and public knowledge and are standard interfaces, in some cases they are not.
You can also use the USBView utility from Microsoft which will let you browse the USB tree or you can look in the registry and see if you can find the GUID for your device. You may still have to query your device to determine device type if the config data is not present or it does not reveal itself other than a generic device, if your device supports this.
There are two types of GUIDs: Device Class and Device Interface. A device can only be a part of one class. Unfortunately, the Device Class and Device Interface GUIDs are sometimes the same, thus confusing developers. In the WinXP DDK, standards were created to try and make the definition of GUIDs less confusing.
See also this previous SO question: Use RegisterDeviceNotification() for ALL USB devices.
Here is a list of possible HID Guids: http://msdn.microsoft.com/en-us/library/ms791134.aspx and use HidD_GetHidGuid as Roboto suggested
You'll need to use the HidP_ functions to check the hid report capabilities. Find out what capabilities (usages) are presented by the HIDPOS device, and check if those usages are present using HidD_GetPreparsedData(), HidP_GetCaps() and then HidP_GetValueCaps(and/or ..ButtonCaps, etc). A good place to look for examples is Jan Axelson's page. If the usages are present, then you've got the POS device. If not, then it must be the keyboard (assuming you've confirmed the device is attached.)