direct input for irrlicht?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

direct input for irrlicht?

Post by Mel »

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! :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Sorry I have no other solution for you but I just want to mention that I believe that as long as OpenGL doesn't have this DirectX's input system won't be used.

P.S
And because it has nothing to do with rendering.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, Irrlicht does support input handling, so we might also include Direct Input. But onyl via some proper abstraction, which would also be implementable by other systems (and actually is).
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Yeah, I personally think it would be pretty cool to implement some abstractions, and then implement the input handling specifics under that. One reason being that I would like to use XInput just for some fun purposes.
TheQuestion = 2B || !2B
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

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
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

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
kburkhart84
Posts: 277
Joined: Thu Dec 15, 2005 6:11 pm

Post by kburkhart84 »

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.
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Post by d3jake »

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
Post Reply