minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation

Home Page:https://www.minetest.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add API to get user input mechanisms (ie: touchscreen? gamepad? keyboard?)

rubenwardy opened this issue · comments

Problem

Currently, mods need to create user interfaces for all devices without being able to customise for an input method. Knowing whether the client has a touchscreen for controls/gui is useful for scaling up GUIs.

This will also be required by #8679

Solutions

In the future, it's likely to be possible for a laptop to use touchscreen controls, and a phone to use a bluetooth keyboard.

I'd like to design the API well. I suggest something like the following information:

{
    has_touchscreen_controls = false, -- whether the touchscreen joystick / in-game controls are enabled
    has_touchscreen_gui = true, -- whether formspecs should be optimised for touchscreen use
    has_keyboard = true, -- whether they have a physical keyboard
    has_mouse = true, -- whether they have a physical mouse / touchpad
    has_gamepad = false, -- whether they have a gamepad / controller
}

This could be a new API

The only unambiguous value here is has_touchscreen_controls: the touchscreen controls are either enabled or not. The rest could be problematic - it's possible to have both a keyboard/mouse and gamepad connected, but only the former used.

Alternatives

...

Additional context

Related: #10632

Suggestion: Split the input methods into two to introduce priorities.

primary = {
	-- Example 1: Laptop
	mouse = true,
	keyboard = true,

	-- Example 2: Mobile
	touchscreen_gui = true,
},
secondary = {
	-- Example 1: Laptop
	touchscreen = true, -- might have a touchscreen?
	joystick = true, -- connected but yet unused

	-- Example 2: Mobile
	keyboard = true, -- connected but yet unused
}

I was thinking about having active_controls_method = "keyboard_mouse" | "touchscreen" | "gamepad",. We don't really have a way of tracking this currently

The addition of expanded keyboard and touch information would be a relevant addition to a PR to fix this

(Like full keyboard, and touch location)