MV Detect through if player is from a PC or a mobile device?

Is there any way to detect through a script if the player is from a PC or a mobile device?

This would help a lot to activate or deactivate switches, functions, objects, mechanics, options for one platform or another and not have to generate a different project for each platform.

for instance:

If player is from android:

- activate on-screen controls
- activate switch 1

If it is from pc:

- Disable on-screen controls
- Deactivate switch 1

any ideas? Thank you.
Hi there!

Take a look at this:
JavaScript:
/**
 * Checks whether the platform is NW.js.
 *
 * @returns {boolean} True if the platform is NW.js.
 */
Utils.isNwjs = function() {
    return typeof require === "function" && typeof process === "object";
};

/**
 * Checks whether the platform is a mobile device.
 *
 * @returns {boolean} True if the platform is a mobile device.
 */
Utils.isMobileDevice = function() {
    const r = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/i;
    return !!navigator.userAgent.match(r);
};

/**
 * Checks whether the browser is Mobile Safari.
 *
 * @returns {boolean} True if the browser is Mobile Safari.
 */
Utils.isMobileSafari = function() {
    const agent = navigator.userAgent;
    return !!(
        agent.match(/iPhone|iPad|iPod/) &&
        agent.match(/AppleWebKit/) &&
        !agent.match("CriOS")
    );
};

/**
 * Checks whether the browser is Android Chrome.
 *
 * @returns {boolean} True if the browser is Android Chrome.
 */
Utils.isAndroidChrome = function() {
    const agent = navigator.userAgent;
    return !!(agent.match(/Android/) && agent.match(/Chrome/));
};
Hi there!

Take a look at this:
JavaScript:
/**
 * Checks whether the platform is NW.js.
 *
 * @returns {boolean} True if the platform is NW.js.
 */
Utils.isNwjs = function() {
    return typeof require === "function" && typeof process === "object";
};

/**
 * Checks whether the platform is a mobile device.
 *
 * @returns {boolean} True if the platform is a mobile device.
 */
Utils.isMobileDevice = function() {
    const r = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/i;
    return !!navigator.userAgent.match(r);
};

/**
 * Checks whether the browser is Mobile Safari.
 *
 * @returns {boolean} True if the browser is Mobile Safari.
 */
Utils.isMobileSafari = function() {
    const agent = navigator.userAgent;
    return !!(
        agent.match(/iPhone|iPad|iPod/) &&
        agent.match(/AppleWebKit/) &&
        !agent.match("CriOS")
    );
};

/**
 * Checks whether the browser is Android Chrome.
 *
 * @returns {boolean} True if the browser is Android Chrome.
 */
Utils.isAndroidChrome = function() {
    const agent = navigator.userAgent;
    return !!(agent.match(/Android/) && agent.match(/Chrome/));
};
Oh wow, Eli…

You are so talented…

Anyway, how to enable mobile controls (button common events (?)) using the above snippet of code? Thanks!
Oh wow, Eli…

You are so talented…

Anyway, how to enable mobile controls (button common events (?)) using the above snippet of code? Thanks!
Eli didn't write that, it's part of the default codebase.

For enabling/disabling controls, you'd use

Utils.isMobileDevice()

as a condition.
Eli didn't write that, it's part of the default codebase.

For enabling/disabling controls, you'd use

Utils.isMobileDevice()

as a condition.
For a button common event / picture-based controls, how can I use that command within those buttons?
Depends on what button common event plugin you're using.
Depends on what button common event plugin you're using.
For a (clickable (?; not sure pictures can support click / touch input)) picture based (not button common events one), how can I use the above command, Trihan?
For a (clickable (?; not sure pictures can support click / touch input)) picture based (not button common events one), how can I use the above command, Trihan?
Presumably you'll have an event that either shows or hides the pictures that are being used as buttons. You'd have a "conditional branch" in that event and set the command I said as the condition; in the true branch, show the pictures. Then they'll only be displayed if the user is on a mobile device.
Presumably you'll have an event that either shows or hides the pictures that are being used as buttons. You'd have a "conditional branch" in that event and set the command I said as the condition; in the true branch, show the pictures. Then they'll only be displayed if the user is on a mobile device.
Well that’s good but…

Does it even work in detecting whether a user is running an .exe via a PC / via an emulator / interoperability layer like WINE?
It would also help me if he could identify the model of the phone. Don't ask why, I just want to do a little social experiment in the game.

Original thread: https://forums.rpgmakerweb.com/threads/detect-through-if-player-is-from-a-pc-or-a-mobile-device.149391/