Jump to content

Lua Jostick Module.


Andy Gilbert
 Share

Recommended Posts

Hi, just wondering if anyone has managed to get the lua joystick module to work?

 

Ive downloaded but just receive the Joystick 0 Not found => EXITnotification despite having a PC gamepad plugged in a working.

 

I find it so fustrating theres no way of having a joystick working with lua??

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

HI Diedir. yes its your demo, so this will only work with a Xbox gamepad?

 

Any chace it could be modified to see any gamepad/joystick?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Ahh thanks Rick, ok ill have a look. I dont quite understand how to "port" to lua else i would do it, ive tried looking into it but struggled to find out good info about doing so or even how i go about making extensions for lua?

 

Any good resources on this?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

The way I started was by looking at how to call DLL's made in C from Lua. Did some google searches on that and it showed me what was required. Then you can carry that over to mostly any library. I only currently know how to do it with C functions and not C++ classes. It gets more confusing when trying to port classes over. I've done a RakNet port (not complete) and this joystick port so far.

 

The basic idea is to write a DLL that exposes the functionality you require. Then Lua can load that DLL and make calls to it.

Link to comment
Share on other sites

I can give it a try if you like Andy. If it's pretty short it should be fairly easy.

 

 

So basically after I create the basic open/close/poll I can make methods to get each of the data elements in the structure. Shouldn't be to bad. Also am I right in assuming you can only have 4 controllers? That's what the last library did, and I notice gamecreator's example has an array of Joysticks that is set to 4 also. It'll just be easier if that's a known hardware limitation. I can actually structure this much like diedir's gamepad lib he was using.

 

http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.dijoystate2(v=vs.85).aspx

Link to comment
Share on other sites

Hi rick, that would really appreciated. I dont mind a limit, I'm happy with just 1 working. :) if there is anything I can do to help then let me know.

Thanks rick, keep me updated on how u get on.

 

And thanks gamecreator for making your code available.

 

Andy.

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Thanks rick, keep me updated on how u get on.[

 

Will do. Probably get to it tonight or tomorrow. I'll just hardcode it for 4 controllers as I just seem to remember that being a limitation of Windows anyway. I'm going to make it look similar to the other port I did, but I'll have functions to get groups of data since Lua can return more than 1 parameter from functions.

 

Below is the result of polling the joystick. So I'll do something like GetXYZ() which will return the first 3 variables, then GetRXYZ() which will return the others, etc. For the arrays I'll say like GetButton(index) and you can pass in 1-128 for button numbers that you want to check.

 

typedef struct DIJOYSTATE2 {
   LONG lX;
   LONG lY;
   LONG lZ;
   LONG lRx;
   LONG lRy;
   LONG lRz;
   LONG rglSlider[2];
   DWORD rgdwPOV[4];
   BYTE rgbButtons[128];
   LONG lVX;
   LONG lVY;
   LONG lVZ;
   LONG lVRx;
   LONG lVRy;
   LONG lVRz;
   LONG rglVSlider[2];
   LONG lAX;
   LONG lAY;
   LONG lAZ;
   LONG lARx;
   LONG lARy;
   LONG lARz;
   LONG rglASlider[2];
   LONG lFX;
   LONG lFY;
   LONG lFZ;
   LONG lFRx;
   LONG lFRy;
   LONG lFRz;
   LONG rglFSlider[2];
} DIJOYSTATE2, *LPDIJOYSTATE2;

Link to comment
Share on other sites

  • 2 years later...

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...