DerpDevice - Code your games correctly!

I am so sick and tired of joining a game and getting console controls because I have a controller plugged in.

If you have half a brain, you should be using LastInputTypeChanged() or GetLastInputType().

I made this small module for myself, specifically tackling cross-device development. I implore you to either use this, a module like it, or make it yourself. I do not want controller controls when I join Roblox games anymore.

Module: https://create.roblox.com/store/asset/102979065556374/DerpDevice?viewFromStudio=true&keyword=&searchId=4dca82a7-bb7a-443b-b0f3-cb3d5120e3e2

Example usage:

Obviously, this code snippet is missing some context, but what it does is change keybind on UI. You can see how .DeviceUpdated is used to dynamically update the label every time the user’s device is changed. In addition, we can get the user’s device by simply calling GetUserDevice(), that way we know what to render for each type of device.

local function updateLabel()
	local device = UserDevice.GetUserDevice()
	
	local iconType = "Image"
	
	if device == "Controller" then
		template.ImageLabel.Image = UserInputService:GetImageForKeyCode(keybind.Controller[1])
	elseif device == "PC" then
		
		if keybind.PC[1] == Enum.UserInputType.MouseButton1 then
			template.ImageLabel.Image = "rbxassetid://94107535658418"
		else
			template.ButtonText.Text = utf8.char(keybind.PC[1].Value):upper()
			iconType = "Text"
		end
	end
	
	template.ButtonText.Visible = iconType == "Text"
	template.ImageLabel.Visible = iconType == "Image"
	template.Visible = device ~= "Mobile"		
end
UserDevice.DeviceUpdated:Connect(updateLabel)
updateLabel()
27 Likes

Finally, someone who gets it. I was starting to think I’d have to start every game by unplugging my controller, my mouse, and possibly my fridge just to get the right UI. This DerpDevice module is the hero we didn’t deserve but desperately needed.

My career, and sanity has been saved. Thank you derpmonster83. :pray:

9 Likes

Wow ! Another new module from the one and only, derpmonster83 ? After his recent release of DerpText, derpmonster83 has nothing been but a gift to the ROBLOX Development Community ! Cheers to past, present, and future derpmonster83 modules :slight_smile:

3 Likes

this is probably the greatest, most revolutionary, most influential module of our time. it will be remembered alongside the likes of profilestore, react-lua and rojo. no other module will ever exude as much sheer aura as derpdevice. we are blessed to be living in the timeline where derpdevice is released and open sourced. this is a paradigm shift that will completely change the way we develop on roblox.

3 Likes

DerpDevice will help me Code my games correctly! Thank you!