How to determine if a TADS 3 game is running on a smartphone

Can anyone offer any thoughts on the best way to determine whether a TADS 3 game is being played on a smartphone vs. a tablet device vs. a desktop/laptop? For my project, the most important distinction is whether it’s a smartphone, since a smartphone screen is so small that I would have to implement a feature to allow the user to flip back and forth between the main text output and the interactive maps that they also have to see.

Here are the thoughts I’ve come up with:

  1. Call systemInfo(SysInfoOsName) to retrieve the operating system. Not at all perfect, as iOS and Android are both used for both tablet devices and for smartphones.
  2. Prompt the user to indicate this manually at the start of the game.

#2 seems like it might be necessary. Anyone disagree?

Looks like the only way to me. You can use something like this at every startup:

display_size = inputManager.getInputDialog(
    InDlgIconQuestion,
    'What kind of display are you using?',
    ['Phone', 'Tablet', 'TV'],
    nil, nil
);

(Some mobile devices can output to a TV.)

1 Like

Thanks, much appreciated.

FWIW, I think you’re thinking about this in the wrong terms. What you actually seem to want to know is “how big is the screen?” There ought to be inquiry functions someplace to find that out (though I know zip about TADS, so I can’t point you to someplace specific).

1 Like

That makes sense, but in a world where my smartphone has ~500 pixels per inch, while on a different device 500 pixels takes up a full 5 inches, it’s hard to know what “how big is the screen” means.

Maybe the most useful data point would be “how many inches wide is the screen?” but I don’t think I’ll get that info by asking the interpreter.

Interpreters should ideally give device independent pixels rather than raw pixels. They could offer a setting to change the pixel density too.

Systems I’m used to typically can report number of pixels and pixel density (pixels per inch or mm). So you can figure the physical dimensions from that. But usually you want to know how many lines of text will fit, and that might be less clear if you don;t know the font in use.

…and, two weeks later, I just happened across something that is of some borderline relevance to the discussion here…

If you use the function bannerGetInfo(), you can get

  1. the banner’s width and height in terms of pixels
  2. the banner’s width and height in terms of character units (the width and height of the character ‘0’)

I guess #2 might allow me to make a better ballpark guess than I thought as to pixel density and how wide the screen is in inches.

I do have a question about this, though… Is there something like this for the screen as a whole, not just a banner? The statuslineBanner can capture the width of the screen, but to capture the height, am I truly forced to set up a vertical banner and measure that?