I've got real device Nokia Lumia 730 (windows phone 8.1) for testing my game cocos2d-x. And I've discovered multitouch doesn't work.
First of all sample code:
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = [&](std::vector touches, Event* event){
log("onTouchesBegan: %d", touches.size());
}
listener->onTouchesMoved = [&](std::vector touches, Event* event){
log("onTouchesMoved: %d", touches.size());
}
listener->onTouchesEnded = [&](std::vector touches, Event* event){
log("onTouchesEnded: %d", touches.size());
}
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
No matter how many fingers I'm touching it always says 1.
I ran the same app on Android (samsung galaxy s3) and it's working well.
As I found out there's no need/no way to enable multitouch on windows phone and it's already enabled by default.
Second, I made simple test inside my win8.1-xaml project (didn't test win8.1-universal, can't use it anyway, because of lacking 3rd party libs support like admob):
Touch.FrameReported += Touch_FrameReported;
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
if (Visibility == Visibility.Collapsed)
return;
TouchPointCollection pointCollection = e.GetTouchPoints(this);
Debug.WriteLine("points touched: " + pointCollection.Count);
}
And this actually works and prints correct values.
So running these 2 pieces of code at the same time produces for example this:
onTouchesBegan: 1 <-- cocos2d-x part
points touched: 2 <-- c# project part
Cocos thinks there's only one touch, however wp knows there's more (2).
Help!
Related
I have Lumia 830 and i've tried to create flashlight app in UWP C#. my device Flashlight works great but i don't know why i can't create my own app turn on / off Torch of my phone.
I use Lamp class :
var lamp = await Lamp.GetDefaultAsync();
if (lamp == null)
{
ShowErrorMessage("No Lamp device found");
return;
}
lamp.IsEnabled = true;
when run this code on my phone "lamp" is null and it couldn't find my FlashLED. I've got this code from MSDN.Microsoft.com and thay said
If the returned object is null, the Lamp API is unsupported on the
device. Some devices may not support the Lamp API even if there is a
lamp physically present on the device.
This class doesn't work on my Lumia 830 i don't kno why? :(
also i use this code :
var mediaDev = new MediaCapture();
await mediaDev.InitializeAsync();
var videoDev = mediaDev.VideoDeviceController;
var tc = videoDev.TorchControl;
if (tc.Supported)
{
// But wait, for this to work with Blue camera drivers, we have to Start a recording session
// Create video encoding profile as MP4
var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
// Start Video Recording
var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName);
await mediaDev.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile);
// Turn on Torch
mediaDev.VideoDeviceController.TorchControl.Enabled = true;
}
this code works and my FlashLED turn on but it record video and it take's user SD Card memory.
please help me if you know there is best way to turn on/off Torch or FlashLED.
thanks in advance
Hussein Habibi Juybari
The Lamp API is designed for Windows 10 devices only and you can only use it on devices which support the API. Currently supported devices are 950/950XL, 650, and 550. Older devices will not be updated to support this API. You should fall back to the Windows 8.1 method of turning on flash when you detect that the lamp device is not available on older devices.
From: https://wpdev.uservoice.com/forums/110705/suggestions/15846967
Please test default sample named LampDevice (cf. https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/LampDevice). Do you have the same behavior ? I just tested on Lumia 930 it works fine. No Lumia 830 to test it.
I am new to windows phone app development.
I am trying to use the powerStatus class in a windows phone 7 app. I have searched quite a bit regarding that and learnt that it is necessary to add reference of System.Windows.Forms
But in the add reference of the project 'System.Windows.Forms' is not present.
How can I use the powerStatus class?
Please help.
Thank you.
Please Refer this msdn link that will clearly shows that how can you get the status of the Battery. i.e. The remaining Percentage of charge in phone;s battery.
Know the battery status in windows phone
In this link, use the RemainingChargePercent() Method this will return the value that indicates the percentage of the charge remaining on the phone's battery.
This things will used in windows phone 8 only.
But, you are with windows phone 7. so, currently there is no API available for windows phone 7 to know the remaining charge in phone's battery.
You will get the information like the if your phone is connected to power source or running in battery.
I will show here some important msdn question links that shows that there is no method or the class is available to get the charge level in windows phone 7.
The MSDN Question link: how to get the battery status in windows phone 7.
if you have the need to show the battery charge percentage, then i suggest you to proceed with windows phone 8.
It work for wp8. but I am not sure about wp7.
_battery = Battery.GetDefault();
var remainingCharge = string.Format("{0} %", _battery.RemainingChargePercent);
var remainingTime = _battery.RemainingDischargeTime.TotalMinutes;
_battery.RemainingChargePercentChanged += OnRemainingChargePercentChanged;
private void OnRemainingChargePercentChanged(object sender, object e)
{
var remainingCharge = string.Format("{0} %", _battery.RemainingChargePercent);
var remainingTime = _battery.RemainingDischargeTime.TotalMinutes;
if(Microsoft.Phone.Info.DeviceStatus.PowerSource == Microsoft.Phone.Info.PowerSource.External)
var text = "Charger Connected";
else
var text = "Charger Not Connected";
}
I'm trying to get touch positions in a MonoGame I'm running on a windows Phone 8 device and debugging through Visual Studio 2012.
This is my update method:
public override void Update(Microsoft.Xna.Framework.GameTime time)
{
if (_StateIsActive) // for pausing game
{
base.Update(time);
TouchCollection touchCollection = TouchPanel.GetState();
foreach (TouchLocation tl in touchCollection)
{
if ((tl.State == TouchLocationState.Pressed)
|| (tl.State == TouchLocationState.Moved))
{
Debug.WriteLine(tl.Position.ToString());
}
}
}
}
When I touch the screen all I get in the output is:
{X:INF Y:INF}
What am I doing wrong?
EDIT: I tried to do what has been done in this thread, but it wont work as I only get the INF value. MonoGame reading touch gestures
The answer seems to be that there is a bug in this version of Mono Game (3.0.1.0) related to this and that it will be fixed with a new release within the next few days.
Source: #MonoGame channel on IRC and their forums.
I know this question as been beaten to death, but I don't want anything super complicated here.
We have a companion app with our site that is only compatible with 7 and 10-inch tablets. We need to only alert users on those devices about our app. Problem is, I can't go by resolution. My Galaxy S3 has a 1280 x 720 screen, but is obviously not a tablet. I also can't for the life of me find out a way to get the physical size of the screen. The only solution I have come up with is detecting whether the device can make calls with MobileCapabilities.CanInitiateVoiceCall. Unfortuantely, by boss isn't happy with that solution.
So... How can I distinguish between a phone and a tablet in my web app (Server or client side)?
UPDATE: So far it seems that the best approach for Android is something from a blog post by the Android team: All Android phones use "Mobile" in the UserAgent string, so checking for "Mobile" *and "Android" will tell you if it's a phone, while just "Android" should be a tablet. iOS devices should be just as simple--checking for "iPhone" vs "iPad" seems to have worked so far.
I know this is a little late, but I was looking for the same thing.
Wurfl has wat you want. You can implement it easily and and even have an api you can query.
For ASP.NET application first you must place the one-off initialization.
public class Global : HttpApplication
{
public const String WurflDataFilePath = "~/App_Data/wurfl.zip";
private void Application_Start(Object sender, EventArgs e)
{
var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath);
var configurer = new InMemoryConfigurer().MainFile(wurflDataFile);
var manager = WURFLManagerBuilder.Build(configurer);
HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
}
}
And then use it like this.
var device = WURFLManagerBuilder.Instance.GetDeviceForRequest(userAgent);
var isTablet = device.GetCapability("is_tablet");
var isSmartphone = device.GetCapability("is_smartphone");
For more info check ASP.NET implementation
Hope this helps anyone else looking for this.
You can try to do a user agent detection and search for the keywrords, for example, all Non tablet devices have a "Mobile Safari" key words on their user agent.
Is there a way to simulate touch events in Windows 8 (and preferably in windows 7).
I know there is a project called Multi touch vista but I feel its a bit overkill and I never got it working correctly with multiple screens.
What I want to do is very simple, I want to start an app that can send touch events to Windows no need for multiple mice or any thing like that.
Can it be done or do I need a (MMV) driver to do that?
Thanks
/Jimmy
I was looking for something similar and found this article Simulating Touch Input in Windows Developer preview using Touch Injection API and sample code (C++) may answer your question. However, this seems to work only on Windows 8 (not Windows 7).
It simulates Tap, Hold, Drag, Pinch/Pan, Rotate and Cross-Slide.
Here is the touch (Tap) code:
POINTER_TOUCH_INFO contact;
InitializeTouchInjection(1, TOUCH_FEEDBACK_DEFAULT); // Here number of contact point is declared as 1.
memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
contact.pointerInfo.pointerType = PT_TOUCH;
contact.pointerInfo.pointerId = 0; //contact 0
contact.pointerInfo.ptPixelLocation.y = 200; // Y co-ordinate of touch on screen
contact.pointerInfo.ptPixelLocation.x = 300; // X co-ordinate of touch on screen
contact.touchFlags = TOUCH_FLAG_NONE;
contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
contact.orientation = 90; // Orientation of 90 means touching perpendicular to screen.
contact.pressure = 32000;
// defining contact area (I have taken area of 4 x 4 pixel)
contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
InjectTouchInput(1, &contact); // Injecting the touch down on screen
contact.pointerInfo.pointerFlags = POINTER_FLAG_UP;
InjectTouchInput(1, &contact); // Injecting the touch Up from screen
Another article: Getting Started with Windows Touch Gestures
I haven't had a chance to try it myself, but according to this article, the simulator included with the Windows 8 Dev Preview allows for simulating multi-touch zoom and rotation gestures using a mouse.
You can see a demonstration of this at approximately 35:40 of this BUILD conference session: Tools for building Metro style apps
Further to the solution which points to the C++ Sample code for InjectTouchInput which comes packaged in the User32.dll of Windows 8, the C# solution can be found here:
InjectTouchInput Windows 8 C# not working (returns false)
Creating a virtual Hid driver appears to be the only way.