Control menu with Xbox controller

Control menu with Xbox controller

Anonymous
Not applicable
728 Views
3 Replies
Message 1 of 4

Control menu with Xbox controller

Anonymous
Not applicable

I know I've done this before, but I am completely drawing a blank now.  How do I allow for an Xbox controller to conrol the menu to start and exit a game?  I feel like it should be in the main_menu.lua file, but I can't figure it out.

Reply
Reply
0 Likes
Accepted solutions (1)
729 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Similarly, is there a resource like this one: http://wiki.unity3d.com/index.php/Xbox360Controller that shows how the Xbox Controller buttons map for the lua player file in Stingray?

Reply
Reply
0 Likes
Message 3 of 4

santd
Autodesk
Autodesk

Hello @Anonymous,

 

I found the following post of yours that was answered by Dan Matlack:

 

http://forums.autodesk.com/t5/stingray/lua-script-for-xbox-control/m-p/5907611#M2224

 

Does that cover what you are attempting to do?

 

If not, could you provide more information in regards to what you are looking for.

 

Cheers,




David Santos

Reply
Reply
0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

You can do it by editing the mainmenu.lua file. Scroll to the bottom and add the following:

 

 

elseif Pad1 and Pad1.active() then
	if Pad1.pressed(stingray.Pad1.button_id(Appkit.Util.plat(nil, "a", nil, "cross"))) then MainMenu.action = "start"
	elseif Pad1.pressed(stingray.Pad1.button_id(Appkit.Util.plat(nil, "y", nil, "triangle"))) then MainMenu.action = "exit"
	end
end

 

Here it is in context:

 

if MainMenu.action == nil  then
	local time = stingray.World.time(SimpleProject.world)
	local p = stingray.Application.platform()
	if time - start_time > 1 then
		if Appkit.Util.is_pc() then
			if stingray.Keyboard.pressed(stingray.Keyboard.button_id("1")) then MainMenu.action = "start"
			elseif stingray.Keyboard.pressed(stingray.Keyboard.button_id("esc")) then MainMenu.action = "exit"
			elseif Pad1 and Pad1.active() then
				if Pad1.pressed(stingray.Pad1.button_id(Appkit.Util.plat(nil, "a", nil, "cross"))) then MainMenu.action = "start"
				elseif Pad1.pressed(stingray.Pad1.button_id(Appkit.Util.plat(nil, "y", nil, "triangle"))) then MainMenu.action = "exit"
				end
    			end
    		end
	end
end

 

Reply
Reply