Lua Script for Xbox Control

Lua Script for Xbox Control

Anonymous
Not applicable
1,807 Views
1 Reply
Message 1 of 2

Lua Script for Xbox Control

Anonymous
Not applicable

I can't seem to figure out how to add more controls from an xbox controller.

How do I activate the MainMenu "Start" by pressing A?  The default script appears to be trying to use an Xbox One or PS4 controller.  What do I need to change or add to make it read a 360 controller?

Similar question to change it from free cam mode to walk mode.  The default just has F2 as the button.  What do I add to allow an Xbox controller to toggle that?

Reply
Reply
0 Likes
Accepted solutions (1)
1,808 Views
1 Reply
Reply (1)
Message 2 of 2

dan.matlack
Alumni
Alumni
Accepted solution

Hello,

 

You can use flow to call xbox buttons: 

 

xboxbuttons.jpg

 

Or you can use lua:

 

In core/appkit/lua/input_mapper.lua there are the key assignments for controllers.

 

local Pad1 = stingray.Pad1

You can check the file out for other mappings and syntax if you want to map in lua in your project.

 

Here is an example of setting the right shoulder button to do the same thing as F2 in the player.lua file --

 

At the top of the file, add the pad local, then in the function that calls the F2 functionality, add that button press you want to map -- see below:

 

DO THIS IN PLAYER.LUA

local Pad1 = stingray.Pad1

local function check_camera_mode(self)
	-- freecam toggle input
	local index = Keyboard.button_id("f2") 
	if (index and Keyboard.pressed(index)) or PlayerHud:check_toggle_camera() or Pad1.pressed(Pad1.button_id(Appkit.Util.plat(nil, "right_shoulder", nil, "cross"))) then
		if self.is_freecam_mode then
			enable_walk_mode(self)
		else
			enable_free_mode(self)
		end
	end
end

 

 

______________________________________
Dan Matlack
Senior Content Manager || Games Solutions
Autodesk, Inc.
Reply
Reply