Wacom tablet with SDL2 - windows

I would like to read pen events and touch events from a Wacom tablet, from which I need at least the position and pressure. I saw that there are touch events in SDL2, but no events are triggered in my application with the code below. I tested with a Bamboo Touch using both the pen and my fingers.
Does SDL2 not support pens? What is the easiest alternative for me to use on Windows if not?
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
running = false;
break;
case SDL_FINGERUP:
printf("finger up: \n");
break;
case SDL_FINGERDOWN:
printf("finger down: \n");
break;
case SDL_FINGERMOTION:
printf("finger motion: \n");
break;
}
}

Related

Is there any way to implement long press gesture with SkiaSharp?

I am using Skiasharp on Xamarin Forms app. With SKTouchAction I was trying to capture the time duration of SKTouchAction.Pressed and SKTouchAction.Released and find if the gesture is Long pressed or not. But the issue is SKTouchAction.Released is not triggered on Android.
protected override void OnTouch(SKTouchEventArgs e)
{
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
There is a similar issue on the github. It seems you need to let the OS know that you wanted to continue receiving touch events. Such as:
protected override void OnTouch(SKTouchEventArgs e)
{
e.Handled = true;
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
In addition, you can also refer to this case.

Hide Lanscape mode in Android phone in NativeScript Angular

Hide Lanscape mode in Android phone in NativeScript Angular
1.Allow both orientations in Android tablet
2.Restrict Landscape and allow only portriat version in phone
lockOrientation(orientation) {
const activity = app.android.startActivity;
switch (orientation) {
case 'unlocked':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
break;
case 'portrait-primary':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case 'portrait-secondary':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
break;
case 'landscape-primary':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case 'landscape-secondary':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
break;
case 'portrait':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
break;
case 'landscape':
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
break;
default:
activity.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
break;
}
just checking and calling the below method is working for me
if (app.android && device.deviceType === 'Phone') {
this.lockOrientation('portrait');
}
Use deviceType from platforms to know which device type the app is running. If it's Tablet then use nativescript orientation plugin to lock the orientation to portrait.

Phonegap network status in windows mobile

I have used below function for check network status in windows mobile simulator. It returns "unknown" either ethertnet present or not.
function checkConnection() {
var networkState = navigator.network.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
checkConnection();
On Windows Phone, For get The current interface you can use the class 'NetworkInterfaceList' :
NetworkInterfaceInfo CurrentInterface;
var interfacesList = new NetworkInterfaceList();
foreach (NetworkInterfaceInfo specificInterface in interfacesList)
{
CurrentInterface = specificInterface;
break;
}
You can Subscribe to an event for the network changement :
DeviceNetworkInformation.NetworkAvailabilityChanged += NetworkChanged;
private void NetworkChanged(object sender, NetworkNotificationEventArgs e)
{
CurrentInterface = e.NetworkInterface;
}
After get the current interface, you can get the true type of network :
switch (CurrentInterface.InterfaceType)
{
case NetworkInterfaceType.Ethernet:
// ETHERNET (USB connected)
break;
case NetworkInterfaceType.MobileBroadbandCdma:
switch (pNetworkInterfaceInfo.InterfaceSubtype)
{
case NetworkInterfaceSubType.Cellular_GPRS:
// 2G
break;
case NetworkInterfaceSubType.Cellular_EDGE:
// 2GP
break;
case NetworkInterfaceSubType.Cellular_EVDO:
case NetworkInterfaceSubType.Cellular_EVDV:
// ?
break;
case NetworkInterfaceSubType.Cellular_1XRTT:
// ?
break;
case NetworkInterfaceSubType.Cellular_3G:
// 3G
break;
case NetworkInterfaceSubType.Cellular_HSPA:
// 3GP
break;
case NetworkInterfaceSubType.Unknown:
// Unknonwn ? 4G is Unknown.
break;
}
break;
case NetworkInterfaceType.MobileBroadbandGsm:
switch (pNetworkInterfaceInfo.InterfaceSubtype)
{
case NetworkInterfaceSubType.Cellular_GPRS:
// 2G
break;
case NetworkInterfaceSubType.Cellular_EDGE:
// 2GP
break;
case NetworkInterfaceSubType.Cellular_EVDO:
case NetworkInterfaceSubType.Cellular_EVDV:
// ??
break;
case NetworkInterfaceSubType.Cellular_1XRTT:
// ??
break;
case NetworkInterfaceSubType.Cellular_3G:
// 3G
break;
case NetworkInterfaceSubType.Cellular_HSPA:
// 3GP
break;
case NetworkInterfaceSubType.Unknown:
// Unknown? 4G is Unknown
break;
}
break;
case NetworkInterfaceType.Wireless80211:
// WIFI
break;
}
Note that with a Windows Phone 7 project, We haven't a "4G type", When I test the 4G with a device, The NetworkInterfaceType is unknown... but, if we have a network problems in 32G or 3G, is Unknown too..
I've not test with a Windows Phone 8 project, but, in theory, that works in 4G.
Also, you can have more details on the Networks type here.
PS: For test the network, there is nothing better than testing with a real device, and therefore, a real network.

What will be the best practice to re-start GeoCoordinateWatcher when it fails to get current LatLon

Declare a GeoCoordinateWatcher tracker. This tracker will start on PageOnload event as below.
I dont know how to create a condition such that it will show this :case GeoPositionStatus.NoData, So I need some advise. My objective is it will re-start until it gets the current Latitude and longitude.
Q1) for case GeoPositionStatus.NoData, what will be the best practice to re-start the GeoCoordinateWatcher?
Do this in case GeoPositionStatus.NoData
tracker.Stop();
tracker.Start();
void tracker_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
switch (e.Status)
{
case GeoPositionStatus.Disabled:
if (tracker.Permission == GeoPositionPermission.Denied)
{
MessageBox.Show("The location Service on this device is off.Please read privacy.");
}
else
{
MessageBox.Show("Location service is working but it can not get location data.");
}
break;
case GeoPositionStatus.Initializing:
// Code which needs to be initialized goes here
break;
case GeoPositionStatus.NoData:
//MessageBox.Show("Location data is not available.");
break;
case GeoPositionStatus.Ready:
// Code which needs to be executed when location data is available goes here
break;
}
}

Window focus issue

I am currently programming a graphics application with OpenGL and the Windows API in C++. Unfortunately the image freezes under certain conditions, such as when I'm resizing the window, and/or when my mouse isn't moving. Is there some sort of mechanism I can use in Win32 to ensure that the frames are constantly being processed?
Here's some pseudocode describing the basic flow of my program
Main Loop
while(running)
{
if (PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
{
if (Msg.message==WM_QUIT)
{
SetRunning(false);
}
else
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
else
{
SwapBuffers(deviceContext);
}
}
WndProc
switch(msg)
{
case WM_CLOSE:
{
PostQuitMessage(0);
break;
}
case WM_SIZE:
{
ResizeScreen(LOWORD(lParam),HIWORD(lParam));
break;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
EDIT: I read the tutorial Kol linked to and made some edits, and now the frame rate is consistent even when the mouse is not moving. However the image still freezes when I'm moving or resizing the window, so I'd appreciate help on that.
Read the NeHe site to learn the basics of OpenGL with Win32. There are detailed explanations about how the message loop should look like, what the WM_SIZE handler should do etc.
EDIT
The code which draws the scene and the buffer swapping should be put into the message loop, in an else branch after the if (PeekMessage(...)) branch. See where the DrawGLScene() call is in the above mentioned NeHe example.
EDIT2
The problems were the followings:
The scene renderer function was not called in the WM_SIZE and WM_MOVE handlers.
The scene was drawn only once a second.

Resources