Hi there!
This was originaly posted in the anouncements forum, but it only had about 34 views and no replies...I'm also posting this here because I wasn't exactly sure where this should reall go sense this is a program announcement, but this is geared towards VB6 Users, so if a moderator could delete this post or the last post in the announcements, I would appreciate it, because I'm just not sure where to put this.
I'm still working on the examples...
I am so excited to show off, well, sort of, my first release of a Visual Basic 6.0 Type Library for XInput to be used with Microsoft's (or Mad Catz') XBox 360 Controller, written in the free Visual C++ 2008 Express Edition!
It's a little crude, and rough around the edges, but it at least has its basic functionality at it's core, and yes, the source code is provided in a WinRAR archive along with the GPadLib.dll!
I do not have a working VB6 example quite yet, because with these "little" projects for games that I start get out of hand and I turn a mole hill into a mountain! But from what I've been messing around with, the commands really do work.
All you have to do to use GPadLib.dll is to paste it into your VB98 directory after copying the GPadLib.dll file from wherever you extracted the .rar file to, go to GPad Lib\Release\GPadLib.dll.
Then it's as simple as the following,
1.) Start VB6 and create a Standard Project.
2.) On the Menu Bar at the top, click Projects>References.
3.) On the right hand side of the dialog, click browse.
4.) Locate the dll file in your VB98 directory, or wherever you put it, and double click it.
5.) If all is well, it was for me, it should be automatically imported to the list of VB6 Type Libraries, and enabled for the project...if it's not enabled then just click on the box to the left of GPad XInput Type Library for VB6, and close out the window.
To use it in your code, there's no need to use it as an object for you variables, because the way I coded it, I'm a noob in C++, so all you have to do is call the functions according to the documentation in the root folder of GPad Lib as if it was native to VB6.
Some files in the GPad Lib folders are for Visual C++ 6, because I started it in Visual C++ 6, forgetting that DirectX9 is only supported in the Visual Studio .NET editions, so I spent hours debugging it in MFC++ 6.0 and then eventually came to my senses and ported it to MFC++ 2008 Express Edition, Rebuild it, and it worked!
I'm sorry for not putting any comments in the C++ code, I was in a hurry to get this working, not that it was important. I just needed to add a little more to my self pride! It's been a little low lately with being $12,000.00 in dept to my parents for my $10,700.00 Car Note and $2,300.00 dept for the last 2 car insurance payments.
Anyway, inside the text document in the root folder is a list and a set of explanations of the commands and their usage in VB6.
If I could have a little help, or if someone could point me in the right direction at least of how I can get this to work like the DirectX8 Type Library, I would much appreciate it, and will update this post with each new release of the dll and eventually, hopefully, a VB6 example for testing XInput in GPad Lib and a small working example Game written in VB6...WITH COMMENTS!!!
So that those who do not want or feel like downloading the code, or just don't want to download right now and just want to see the C++ Code right away, here it is...
GPadLib.cpp:
Code:
#include <windows.h>
#include <XInput.h>
#define MAX_CONTROLLERS 4
struct GPAD_INFO
{
bool IsConnected;
XINPUT_STATE CurState;
XINPUT_VIBRATION CurVibration;
};
GPAD_INFO GPad[MAX_CONTROLLERS];
bool __stdcall GPad_Poll(int player)
{
DWORD dwResult = XInputGetState(player, &GPad[player].CurState);
GPad[player].IsConnected = (dwResult == ERROR_SUCCESS);
return GPad[player].IsConnected;
}
bool __stdcall GPad_ButtonA(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_A)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonB(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_B)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonX(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_X)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonY(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonBack(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_BACK)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonStart(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_START)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonLBumper(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonRBumper(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonLThumb(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonRThumb(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonDPadUp(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonDPadDown(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonDPadLeft(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
{
return true;
}
return false;
}
bool __stdcall GPad_ButtonDPadRight(int player)
{
if (GPad[player].CurState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
{
return true;
}
return false;
}
int __stdcall GPad_ButtonLeftTrigger(int player)
{
return GPad[player].CurState.Gamepad.bLeftTrigger;
}
int __stdcall GPad_ButtonRightTrigger(int player)
{
return GPad[player].CurState.Gamepad.bRightTrigger;
}
short __stdcall GPad_LStickX(int player)
{
return GPad[player].CurState.Gamepad.sThumbLX;
}
short __stdcall GPad_LStickY(int player)
{
return GPad[player].CurState.Gamepad.sThumbLY;
}
short __stdcall GPad_RStickX(int player)
{
return GPad[player].CurState.Gamepad.sThumbRX;
}
short __stdcall GPad_RStickY(int player)
{
return GPad[player].CurState.Gamepad.sThumbRY;
}
void __stdcall GPad_Rumble(int player, int left_speed, int right_speed)
{
GPad[player].CurVibration.wLeftMotorSpeed = left_speed;
GPad[player].CurVibration.wRightMotorSpeed = right_speed;
XInputSetState(player, &GPad[player].CurVibration);
}
GPadLib.def:
Code:
LIBRARY GPadLib
DESCRIPTION "GPad XInput Library for Visual Basic 6.0."
EXPORTS
GPad_ButtonA
GPad_ButtonB
GPad_ButtonX
GPad_ButtonY
GPad_ButtonBack
GPad_ButtonStart
GPad_ButtonLBumper
GPad_ButtonRBumper
GPad_ButtonDPadUp
GPad_ButtonDPadDown
GPad_ButtonDPadLeft
GPad_ButtonDPadRight
GPad_ButtonLThumb
GPad_ButtonRThumb
GPad_ButtonLeftTrigger
GPad_ButtonRightTrigger
GPad_LStickX
GPad_LStickY
GPad_RStickX
GPad_RStickY
GPad_Poll
GPad_Rumble
GPadLib.odl:
Code:
[
uuid(183580CF-DFC4-4537-BAF4-00FBC97B6642),
helpstring("GPad XInput Library for VB 6.0."),
lcid(0x0409),
version(1.0)
]
library GPadLib
{
[
helpstring("GPad XInput for VB 6.0 functions exported by GPadLib.dll"),
version(1.0),
dllname("GPadLib.dll")
]
module GPadLibFunctions
{
[
helpstring("Returns the A Button State."),
entry("GPad_ButtonA")
]
bool __stdcall GPad_ButtonA([in] int player);
[
helpstring("Returns the B Button State."),
entry("GPad_ButtonB")
]
bool __stdcall GPad_ButtonB([in] int player);
[
helpstring("Returns the X Button State."),
entry("GPad_ButtonX")
]
bool __stdcall GPad_ButtonX([in] int player);
[
helpstring("Returns the Y Button State."),
entry("GPad_ButtonY")
]
bool __stdcall GPad_ButtonY([in] int player);
[
helpstring("Returns the Back Button State."),
entry("GPad_ButtonBack")
]
bool __stdcall GPad_ButtonBack([in] int player);
[
helpstring("Returns the Start Button State."),
entry("GPad_ButtonStart")
]
bool __stdcall GPad_ButtonStart([in] int player);
[
helpstring("Returns the Left Shoulder Button State."),
entry("GPad_ButtonLBumper")
]
bool __stdcall GPad_ButtonLBumper([in] int player);
[
helpstring("Returns the Right Shoulder Button State."),
entry("GPad_ButtonRBumper")
]
bool __stdcall GPad_ButtonRBumper([in] int player);
[
helpstring("Returns the Left Thumb Button State."),
entry("GPad_ButtonLThumb")
]
bool __stdcall GPad_ButtonLThumb([in] int player);
[
helpstring("Returns the Right Thumb Button State."),
entry("GPad_ButtonRThumb")
]
bool __stdcall GPad_ButtonRThumb([in] int player);
[
helpstring("Returns the DPad Up Button State."),
entry("GPad_ButtonDPadUp")
]
bool __stdcall GPad_ButtonDPadUp([in] int player);
[
helpstring("Returns the DPad Down Button State."),
entry("GPad_ButtonDPadDown")
]
bool __stdcall GPad_ButtonDPadDown([in] int player);
[
helpstring("Returns the DPad Left Button State."),
entry("GPad_ButtonDPadLeft")
]
bool __stdcall GPad_ButtonDPadLeft([in] int player);
[
helpstring("Returns the DPad Right Button State."),
entry("GPad_ButtonDPadRight")
]
bool __stdcall GPad_ButtonDPadRight([in] int player);
[
helpstring("Gets the state of the current controller and returns 1 for SUCCESS and 0 for FAIL."),
entry("GPad_Poll")
]
bool __stdcall GPad_Poll([in] int player);
[
helpstring("Returns the Left Trigger Value."),
entry("GPad_ButtonLeftTrigger")
]
int __stdcall GPad_ButtonLeftTrigger([in] int player);
[
helpstring("Returns the Right Trigger Value."),
entry("GPad_ButtonRightTrigger")
]
int __stdcall GPad_ButtonRightTrigger([in] int player);
[
helpstring("Returns the Left Stick X Value."),
entry("GPad_LStickX")
]
short __stdcall GPad_LStickX([in] int player);
[
helpstring("Returns the Left Stick Y Value."),
entry("GPad_LStickY")
]
short __stdcall GPad_LStickY([in] int player);
[
helpstring("Returns the Right Stick X Value."),
entry("GPad_RStickX")
]
short __stdcall GPad_RStickX([in] int player);
[
helpstring("Returns the Right Stick Y Value."),
entry("GPad_RStickY")
]
short __stdcall GPad_RStickY([in] int player);
[
helpstring("Sets the left and right rumble speeds."),
entry("GPad_Rumble")
]
short __stdcall GPad_Rumble([in] int player, [in] int left_speed, [in] int right_speed);
}
};
GPadLib.rc:
Code:
1 typelib GPadLib.tlb
Again, any help would be greatly appreciated...
...and here are the commands that will also be in the VB6 GPad Lib Command List.txt in the root folder of the
archive:
Code:
GPad Lib Commands and Explanations:
GPad_ButtonA
syntax: GPad_ButtonA(player as long) as long
Breaking it down:
player as long; player 0 to 3.
returns; 1 if pressed, 0 if not
GPad_ButtonB*
GPad_ButtonX*
GPad_BUttonY*
GPad_BUttonLBumper*
GPad_ButtonRBumper*
GPad_ButtonLThumb*
GPad_ButtonRThumb*
GPad_ButtonBack*
GPad_ButtonStart*
GPad_ButtonDPadUp*
GPad_ButtonDPadDown*
GPad_ButtonDPadLeft*
GPad_ButtonDPadRight*
* = Similar usage as the previous command.
GPad_ButtonLeftTrigger
syntax: GPad_ButtonLeftTrigger(player as long) as long
Breaking it down:
player as long; player 0 to 3
returns; 0 if not being held to 255 if held all the way
Gpad_ButtonRightTrigger*
* = Similar usage as the previous command.
GPad_LStickX
syntax: Gpad_LStickX(player as long) as integer
Breaking it down:
player as long; player 0 to 3
returns; 0 if stationary, -32768 to 32767 if not
GPad_LStickY*
GPad_RStickX*
GPad_RStickY*
* = Similar usage as the previous command.
GPad_Poll
Syntax: Gpad_Poll(player as long) as long
Breaking it down:
player as long; player 0 to 3
returns; 0 if fail, 1 if success
Note: Call this at the begining of you main game loop to check for device loss and
input from that controller.
GPad_Rumble
Syntax: GPad_Rumble(player as long, left_speed as long, right_speed as long) as integer
Breaking it down:
player as long; player 0 to 3
left_speed as long; range 0 to 65535, 0 = 0%, 65535 = 100%
right_speed as long; range 0 to 65535, 0 = 0%, 65535 = 100%
returns; none
and here is the link to the file:
http://www.filefactory.com/file/b3b2g3e/n/GPad_Lib.rar
Enjoy!
Edit: I thought some more about where I had just posted this...
Should this technically be in the Anouncements forum? I wasn't sure because it wasn't just VB6 in that forum, but this is geared mostly towards those who enjoy learning with/using VB6 and who want access to XInput, so maybe I should post this in the announcements forum as well???
Somebody let me know, and yes I've read this Forum's Posting Policies, I'm just not sure sense this could be in either one...at least to me it could be either one.
Thanks.