I hope this is the right place to ask... Well considering that direct input is a Direct X feature, i don't hope to see support for future irrlicht releases but i0m wondering if there is already out there any extension to support direct input (to use a controller) as the controls i'm thinking to add into my project would be a bit difficult to use if the only input device is the keyboard.
thanks in advance!
direct input for irrlicht?
direct input for irrlicht?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
DirectX Input isn't that hard to handle, instead it's quite easy. Implementing it into your own Eventhandler/Inputhandler shouldn't be much of a Problem. I also once used it for an OpenGL app without problems, cause the GLFW InputHandling had some very nasty bugs in C#
Code: Select all
private Microsoft.DirectX.DirectInput.Device mKeyboard;
private Microsoft.DirectX.DirectInput.Device mMouse;
...
mKeyboard = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard);
mMouse = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Mouse);
mKeyboard.Acquire();
mMouse.Acquire();
...
public void update()
{
Microsoft.DirectX.DirectInput.MouseState state = mMouse.CurrentMouseState; // this is important cause everytime you call CurrentMouseState the distance the mouse travelled will be queried again and i don't think you will move your mouse very far during two function calls ;) so save the whole state in a variable and get the values from that one
int mousex = state.X;
int mousey = state.Y;
if (mousex != 0)
{
float turny = (float)mousex / 5.0f;
mMouseX = mousex;
mOr.Z -= turny;
}
if (mousey != 0)
{
float turnx = (float)mousey / 5.0f;
mMouseY = mousey;
mOr.X += turnx;
}
if (mKeyboard.GetPressedKeys().Length > 0)
{
Microsoft.DirectX.DirectInput.Key[] Keys = mKeyboard.GetPressedKeys();
for (int i = 0; i < Keys.Length; i++)
{
if (Keys[i] == Microsoft.DirectX.DirectInput.Key.W)
{
// there is an error here somwhere, this is mathematically not completely right, but i have been too lazy to iron it out ;)
mPos.X += (float)System.Math.Sin(((mOr.Z % 360) / 180.0f) * System.Math.PI) * 0.4f;
mPos.Y += (float)System.Math.Cos(((mOr.Z % 360) / 180.0f) * System.Math.PI) * 0.4f;
mPos.Z += (float)System.Math.Cos(((mOr.X % 360) / 180.0f) * System.Math.PI) * 0.4f;
}
R2D2's Irrlicht Mods
Messed up with my database so the page is not working at the moment -.-
CPU: Core 2 Quad Q6700RAM: 4096 mb Graphics: Radeon 4850 512mb Sound: on board InternetConnection: DSL
Messed up with my database so the page is not working at the moment -.-
CPU: Core 2 Quad Q6700RAM: 4096 mb Graphics: Radeon 4850 512mb Sound: on board InternetConnection: DSL
Of course, You can use Direct Input with OpenGL renderer, but only on Windows... but Linux, MacOSX? If You need more advanced input system than currently from Irrlicht You should use: Object Oriented Input System: http://sourceforge.net/projects/wgois Project is cross-platform and it's on the zlib style license:)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 277
- Joined: Thu Dec 15, 2005 6:11 pm
I currently use DInput8 for my projects instead of the Irrlicht's event manager, though I aquire all devices in nonexclusive mode so that Irrlichtr will still recieve input as well. I can freely give out the classes I use if anybody were to want them, though they aren't anything special, they do work.
I'm using SDL to handle joystick input. I got the main code from a member here named "CuteAlien" and it works like a champ. Alien also told me that the code extends to keyboard and mouse (I think so anyway..). The best part is that it is cross platform.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
"I'll find out if what I deleted was vital here shortly..." -d3jake