More device specific information that can be fetched by code

(i had to repost this cuz it was burried in the algorithim or smth)

it sounds scary, but hear me out!

This new feature would add a new service,

game:GetService("DeviceInfoService")

this would add all sorts of “SAFE” device features (by safe i mean, cant be used to hack or doxx users,

All features that have to do with devices will be here! Even existing ones could be put here to make a more generalized and consistent area to appropriately fetch all device info


for example. Checking for battery percentage
could be used for,

  • optimizing games to save battery like, making Graphix lower
  • have special badges and events depending on your battery.
  • making a visible battery counter on a GUI so you can actually see your battery in game on mobile (or you could just add that in)

how you would actually retrieve that info! / events

local deviceBattery = game:GetService("DeviceInfoService"):GetDeviceBatteryPercentage()
game:GetService("DeviceInfoService"):AttachBatteryPercentScript([battery percent], [function name])

another example, checking what device the player is actually on

this is way better then defining device from input method due to computers that have both keyboard input and screen touch input (chrome book :slight_smile: )

it could be fetched with:

local currDevice = game:GetService("DeviceInfoService"):GetDeviceType()

it either could return a string ex:

"phone"
"computer"
"console"

or it could return numbers, it would only use 4 bits MAX so its not expensive at all:

0 --phone
1 -- computer
2 -- console
3 -- another device in the future?

with the phone checks we could check the device’s rotation!

it would be checked with this code:

local phoneRotation = game:GetService("DeviceInfoService"):GetPhoneRotation()
game:GetService("DeviceInfoService"):AttachPhoneRotationScript([vector 3 value], [function name])

this could be used for gravity based on phones orientation,
like if there’s a ball that you want to fall towards the gravity in REAL LIFE it would fall to where the ground is in real life (really cool) and maybe make the client’s gravity or make workspace gravity physics/water physics or whatever


we could also have a native FPS counter!

it could be fetched with:

local deviceFPS = game:GetService("DeviceInfoService"):GetDeviceFPS()

this would be a straight forward way to detect FPS!


we could also add midframe interrupts,

for the roblox engine programmers, you could use the device’s refresh rate to calculate an estimate to which (whatever is a modern version of a scanline called) the device is in!

this could be used to make waving water effect while saving on data by not having to make multiple frames by changing the position of the image midframe!

here’s where you would fetch that info!

game:GetService("DeviceInfoService"):AttachEventToScanlinePositionAsync([scanlineNumb], [event name])

it could also be used for some INSANE and cool effects like:

  • desert heat effects
  • water waves
  • make parts of the screen display different things/locations on the world map without using these pesky 3d Ui frames
  • make a screen shaking effect
  • and aid on games that emulate retro consoles (very cool)

we could also have a way to detect general (none harmful) device information! to make cool “Device inspection” games to see your specs or something like that.
This type of thing would bring more people to roblox by being able to easily watch ur device specs by using specific games.


HERE IS ALL OF THE CODE IN ACTION

local client = game.Players.LocalPlayer
local dIS = game:GetService("DeviceInfoService")
local frame = script.parent.splitImgExample
local fpsTxt = script.parent.fpsLabel
local rotateWarn = script.parent.fpsLabel
local badgeServ = game:GetService("BadgeService")
local optMod = require(game.ReplicatedStorage.OptimizationModule)
local loadDeviceInfEvent = game.ReplicatedStorage.UpdtDeviceForOthers
local devLabel = script.Parent.DeviceLabel
function uiPosShift(scan)
   if scan == 0 then
       frame.Position = uimd2.new(0,0,0,0)
   else
       frame.Position = uimd2.new(0,0,0,100)
   end
end
function rotateWarn ()
   rotateWarn.Visible = true
   wait(3)
   rotateWarn.Visible = false
end
function batterySixSeven ()
   badgeServ:AwardBadgeAsync(client.UserId,2139141313) -- random badge
end

dIS:AttachEventToScanlinePositionAsync(0,uiPosShift(0))
dIS:AttachEventToScanlinePositionAsync(100,uiPosShift(100))
dIS:AttachScriptToPhoneRotation(vector3.new(0,100,0),rotateWarn())
dIS:AttachFunctonToBatteryPercent(67,batterySixSeven())
if dIS:GetDeviceBatteryPercentage() <= 20 then
   optMod.OptimizeForLowPower()
end
local deviceIndx = {
   "Phone",
   "Computer",
   "Console",
}
devLabel.Text = deviceIndx[dIS:GetDeviceType()]
loadDeviceInfEvent:FireServer(dIS:GetDeviceType())

ANY SUGGESTIONS WILL BE ADDED BY REQUEST IN A FEW DAYS IF I FEEL LIKE IT

1 Like

Generally don’t do that, if needed you can edit and bump the original post.


Also most of these features are already reasonably achievable currently.

Checking what device a player is actually on

https://create.roblox.com/docs/reference/engine/classes/UserInputService#PreferredInput

local UserInputService = game:GetService("UserInputService")

local function preferredInputChanged()
	local preferredInput = UserInputService.PreferredInput

	if preferredInput == Enum.PreferredInput.Touch then
		-- Player is on touch-enabled device with no other input types available/connected
		print("Touch")
	elseif preferredInput == Enum.PreferredInput.Gamepad then
		-- Player has connected or most recently interacted with a gamepad
		print("Gamepad")
	elseif preferredInput == Enum.PreferredInput.KeyboardAndMouse then
		-- Player has connected or most recently interacted with a keyboard or mouse
		print("KeyboardAndMouse")
	end
end

preferredInputChanged()

UserInputService:GetPropertyChangedSignal("PreferredInput"):Connect(function()
	preferredInputChanged()
end)
checking device rotation (i.e. phone gyroscope)

How do I move the player's camera using the phone's gyro?

https://create.roblox.com/docs/reference/engine/classes/UserInputService#GetDeviceRotation

local UserInputService = game:GetService("UserInputService")

if UserInputService.GyroscopeEnabled then
	local _, cf = UserInputService:GetDeviceRotation()
	print(cf)
else
	warn("Cannot get device rotation because device does not have an enabled gyroscope!")
end
Native FPS counter
local fps = 0
while true do
    fps = 1 / game:GetService("RunService").RenderStepped:Wait()
end
midframe interrupts / device refresh rate

Once again already possible through Runservice.RenderStepped.

https://create.roblox.com/docs/reference/engine/classes/RunService#RenderStepped


The only real thing not already possible is the battery percentage, which I do think that it could be useful to see your for a battery % in game. But knowing how developers used cpu clock times to determine alt accounts, I don’t see Roblox adding it any time soon for the same reason.

1 Like

dude i dont rlly thing u understand, for the stuff that really exists, im just saying that we should move it to a single service with all of that information inside it so we only have to call one API

also, detecting which device the player’s on using input methods can be useless due to the fact of hybrid devices like chrome books, like if u use the chromebook touch screen, wont the code think ur in mobile?

and if u connect a controller to a computer/phone? wont it think ur in xbox?

my idea is to finally have a decisive service to detect which device type were actually in without having a inconsistent (inp type) device check

You can run your own checks for this, but yes I do agree it would be easier if there was a single function that returned device type and other variables like FPS

1 Like