Jump to content

XBOX 360 controller LUA template


Daniel0213
 Share

Recommended Posts

Platform: Windows.

 

Downloads:

 

FPS Player scenario (Preconfigured scenario ready to play Updated 08/may/2015)

https://dl.dropboxusercontent.com/u/107114506/Leadwerks/LUA%20XBOX%20360%20controller%20FPS%20Template.rar

 

Marble game ball (Preconfigured scenario ready to play Updated 03/may/2015)

https://dl.dropboxusercontent.com/u/107114506/Leadwerks/Marblegame%20XBOX360%20controller%20template.rar

 

Only DLL: (Updated 08/may/2015)

https://dl.dropboxusercontent.com/u/107114506/Leadwerks/SDL2.dll%20and%20LuaGamePad.dll.zip

 

 

Note:

- You must have connected the XBOX 360 controller to work.

- If you want put the code in you proyect, copy and paste the "LuaGamePad.dll" and "SDL2.dll" in your project folder.

 

-----------------------------------------------------------------------------------------------------------------------------------

New update!!

Data: 08/May2015

 

Working hard on my free time, I developed the LUA FPS XBOX 360 controller.

 

What's new:

 

- The movement is now analog (Left stick).

- The view is now analog (Right stick).

- The sprint is now analog (Right Trigger).

- The sound of the steps are automatically adjusted to the speed of the player, also considers the sprint.

 

It is fully preconfigured and is 100% functional, I've tested with the FPS Weapons Pack and works fine.

 

If you find a bug please send me a report.

 

 

Open the project and open the "07-AI and Events.map"

 

The "FPSPlayer XBOX360 controller adapted.lua" is in the same folder that "FPSPlayer.lua"

The empty template XBOX 360 controller is in the "Scrips / objects / XBOX 360 controller" folder.

 

 

Controller mapping:

 

LUA%20FPS%20XBOX%20360%20Controller%20.JPG

 

-----------------------------------------------------------------------------------------------------------------------------------

Data: 03/May2015

 

Hello everyone!

 

I work hard to create a Lua XBOX 360 controller template.

 

(Based on the work of Skrakle).

http://www.leadwerks.com/werkspace/topic/12476-lua-lib-game-controller-support/

 

 

Upgrade Author: Daniel0213

 

What's new:

 

DRIVER:

I have expanded the functions and recompile the driver. I added:

 

- The right analog stick is now functional.

- The left and right trigger just happen to be digital to be analog + digital.

 

 

SCRIPT:

 

- The script is not oriented to App.lua, now is oriented to the object you want to control, the player. (You must insert the script on the object that you want to control).

- I created a template fully explained with comments.

- I've written and adapted the formulas needed to converter from analog value to Leadwerks. Not any knowledge of analog sensors are required to write your own program. The code gives you automatically a converted analog value.

- To change analog values you do not need to enter the code can be changed quickly from outside.

- Reduced the death zone of analogue sensors, but can be changed easily. The instruction have a comment.

- I separate all the buttons to make it easier to interpret the code.

- You can choose externally the number of controller you want to use.

 

------------------------------------------------------------------------------------------------------------------------------------

 

I inserted the code in the template marble game, for a practical example of the operation display. Within the project it is the empty template XBOX controller and inserted into the ballplayer template for a practical example.

 

(I have asked permission to Josh to do this)

 

 

 

The empty template XBOX 360 controller is in the "Scrips / objects / XBOX 360 controller" folder.

 

The "ballplayer" script has been modified to insert the sample code. Changed the name to "ballplayer Adapted to XBOX 360 controller."

 

I'm using the Leadwerks version 3.5 Beta.

 

 

 

-------------------------------------------------------------------------------------------------------------------------

 

HOW INSTALL:

 

Very simple.

 

1. Unzip the .rar file.

2. Copy the "XBOX360controllertemplate" folder in your Leadwerks project folder.

3. Open leadwerks, go to "project manager" Push "import" enter to "XBOX360controllertemplate" folder and select the "XBOX 360 controller template.werk" file.

4. Select the project and press "OK".

 

You must disable the sandbox lua libraries to work xbox 360 controller.

 

LUA%20Sandbox.png

 

 

-----------------------------------------------------------------------------------------------------------------------------------

 

How analog sensors work:

 

Put the desired maximum values.

 

Analog%20sensor%201.png

 

 

 

In this case, when the left stick reaches its peak (up direction), the analog value which will be 15. Decreasing this value progressively until it reaches 0, when you reach the death zone.

Don't touch the formula.

 

Analog%20sensor%202.png

 

------------------------------------------------------------------------------------------------------------------

 

A bit of theory: The Analog converted formula. (Don't worry, you don't have to create, it is already written in the template code.)

 

 

Analog%20converted%20formula.jpg

 

 

 

ENJOY!!!

 

 

Future upgrades:

 

- Add left and right vibration.

- Linux support.

 

 

Note:

If you want put the code in you proyect, copy and paste the "LuaGamePad.dll" and "SDL2.dll" in your project folder.

Edited by Daniel0213
  • Upvote 5

CPU: Intel Quad core Q8400 / GPU: Nvidia GTX 660 / RAM: 6GB DDR3 1333MHz / Windows 8.1 (x64)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...