check "desktop" or "mobile"

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Tricky
Citizen
Posts: 75
Joined: Thu Dec 18, 2014 4:07 pm
Location: Breda, the Netherlands
Contact:

check "desktop" or "mobile"

Post by Tricky »

I was wondering, if there is a way to check if the device used to play a love2d-game is either a desktop(or laptop) or a mobile device (phone or tablet)

Now this question may seem stupid. After all Mac and Linux are desktop and Android and iOS are mobile, but Windows can offer a little problem here, since Windows can run on both desktop and mobiles. (As far as I know Windows 10 can).

The reason I ask is:
The game concept I have in mind can be played for 100% with the mouse or touch screen (so for the game itself it doesn't matter), it's rather that I intend to include the achievement API sites like Game Jolt use to log achievements and stuff and then entering a username + token will be required. On desktop, no prob. Keyboard is used, but on mobile devices, no keyboard present (well, that is, I cannot assume everybody has a bluetooth keyboard 'connected'). Now I already have a setup to "fake" a keyboard, but is it needed to show that "fake-keyboard" on desktops as well?

I've tried to look this up, but all I found so far was a way to detect the OS itself (also handy), but I guess that when you run the game on a mobile Windows device, it will produce the same out put as on a Windows desktop computer or laptop.

Or should I just add a button summoning the fake-keyboard if needed? :P
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: check "desktop" or "mobile"

Post by Sulunia »

Tricky wrote: Sat Jul 29, 2017 9:02 pm ...Or should I just add a button summoning the fake-keyboard if needed? :P
If needed/requested. Otherwise, save yourself the trouble.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: check "desktop" or "mobile"

Post by zorg »

Where did you read that windows mobile was at all supported?

love.system.getOS exactly tells you whether the game's running on a mobile device (cellphone/tablet) or a desktop/laptop/netbook;

Code: Select all

mobile = false
if love.system.getOS() == 'iOS' or love.system.getOS() == 'Android' then
  mobile = true
end
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: check "desktop" or "mobile"

Post by Sulunia »

zorg wrote: Sat Jul 29, 2017 9:10 pm Where did you read that windows mobile was at all supported?
I assumed this is what he was talking about.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: check "desktop" or "mobile"

Post by zorg »

Sulunia wrote: Sat Jul 29, 2017 9:13 pm
zorg wrote: Sat Jul 29, 2017 9:10 pm Where did you read that windows mobile was at all supported?
I assumed this is what he was talking about.
>Intel HD Graphics
> 12 cores
> OpenGL 3.2

Can it even run Löve with a GUI window?

Anyway, i guess (after requiring the ffi) jit.os and/or jit.arch may be of use... though not even that may help.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Tricky
Citizen
Posts: 75
Joined: Thu Dec 18, 2014 4:07 pm
Location: Breda, the Netherlands
Contact:

Re: check "desktop" or "mobile"

Post by Tricky »

When it comes to Love2d being supported on Windows on a mobile device, really I never tried that one out. But I know people whose (work) mobile phone uses Windows 10 (and since those devices are not mine I could never tried that out), and that was what my question was based upon, also Microsoft also made clear they do have plans to expand their work on mobile devices with Windows 10 (not that I am tempted to buy a mobile device based on Windows. Heck I don't even use Windows as my primary system on desktop, but when it comes to distribution I got to take my players in mind and not myself). Even with tablets being seen as "laptop" if it was attached to a keyboard. (My only mobile device is an Android tablet).
Yeah, the code you came up with was also obvious for me since I already know it's safe to assume iOS and Android are only used on mobile devices (although I've heard (not that I could verify that story, though) some people have been successful in installing Android in Virtual Box, but I guess it's goes too far to take THAT possibility in mind) :-p

Well I guess I may just automatically turn that "fake-keyboard" on for Android and iOS by default and turn it off by default for the other platforms and just add a button to manually turn it on/off if the players desire (that way people who were able to get the game onto a Windows phone can at least use the feature requiring a keyboard, I guess).
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: check "desktop" or "mobile"

Post by raidho36 »

I would write volumes about it but all of that can be summarized as "don't make assumptions".
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: check "desktop" or "mobile"

Post by Sulunia »

Tricky wrote: Sat Jul 29, 2017 10:20 pm [...]
Finish your game first. If people request, do your modifications. I'd just assume every windows user is on a desktop and call it a day.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: check "desktop" or "mobile"

Post by slime »

Tricky wrote: Sat Jul 29, 2017 9:02 pmThe reason I ask is:
The game concept I have in mind can be played for 100% with the mouse or touch screen (so for the game itself it doesn't matter), it's rather that I intend to include the achievement API sites like Game Jolt use to log achievements and stuff and then entering a username + token will be required. On desktop, no prob. Keyboard is used, but on mobile devices, no keyboard present (well, that is, I cannot assume everybody has a bluetooth keyboard 'connected'). Now I already have a setup to "fake" a keyboard, but is it needed to show that "fake-keyboard" on desktops as well?
You can use love.keyboard.setTextInput to show the native system virtual keyboard on touch devices. I don't know if SDL's UWP backend supports that, but I assume so.
User avatar
Tricky
Citizen
Posts: 75
Joined: Thu Dec 18, 2014 4:07 pm
Location: Breda, the Netherlands
Contact:

Re: check "desktop" or "mobile"

Post by Tricky »

Finish your game first. If people request, do your modifications. I'd just assume every windows user is on a desktop and call it a day.
The problem for me is, that I’ve always been working from setting a framework up first (or use one I already have, but since I haven’t done much in Love2d yet, and my old-engine (though Lua based) is totally incompatible with Love2D, I’m now preparing this framework). Experience has taught me that errors I make now can be very hard to fix afterward, so I want to do it well in one go. (It’s not exactly a “small” game I got in mind). ;)
(Perhaps after making a game like this (that game was made with Lua but not with Love2D, sorry), you understand I’m used to think “big”. Although my love2d project will not be an RPG like that, but still a genre that requires some thinking before starting on it). :)

You can use love.keyboard.setTextInput to show the native system virtual keyboard on touch devices. I don't know if SDL's UWP backend supports that, but I assume so.
Top
Hey, thanks a lot. I will surely investigate that function. I guess using that system virtual keyboard creates keypress/release events in the same manner a “real” keyboard does (I have not yet read it, but I will after sending this). If so, that will certainly help me ;)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 46 guests