Page 1 of 2

check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 9:02 pm
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

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 9:08 pm
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.

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 9:10 pm
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

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 9:13 pm
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.

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 9:23 pm
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.

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 10:20 pm
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).

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 10:34 pm
by raidho36
I would write volumes about it but all of that can be summarized as "don't make assumptions".

Re: check "desktop" or "mobile"

Posted: Sat Jul 29, 2017 10:41 pm
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.

Re: check "desktop" or "mobile"

Posted: Sun Jul 30, 2017 12:15 am
by slime
Tricky wrote:
Sat Jul 29, 2017 9:02 pm
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?
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.

Re: check "desktop" or "mobile"

Posted: Sun Jul 30, 2017 9:29 am
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 ;)