• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Manpreet Singh

[SlimDX 11,C#] No RawInput Documentation/tutorial?

4 posts in this topic

I decided to move from directx 9 to 11 and came across SlimDX with C#. Of course most of the things are new and different but somehow I'm managing. Now I wanted to have some kind of an input system for a FPS-like camera and as most people suggested I turned towards SlimDX.RawInput. And...

I'm lost. Completely.

I can't find any sort of material which might explain what all the RegisterDevice and EventHandler functions are and what exactly am I supposed to do. The only thing I could write so far is
[code]

class Input
{
public delegate void Input(object obj, SlimDX.RawInput.KeyboardInputEventArgs args);
public void Initialize(Input ip)
{

Device1.RegisterDevice(SlimDX.Multimedia.UsagePage.Generic, SlimDX.Multimedia.UsageId.Keyboard, DeviceFlags.None);
Device1.KeyboardInput += new System.EventHandler<KeyboardInputEventArgs>(ip);

}

};
[/code]

And I'm not even sure about the function declaration at the top, I just copied that from here [url="http://digg.pp.fi/3d/src/Main/EntitySystem/SubSystems/InputSystem.cs"]http://digg.pp.fi/3d.../InputSystem.cs[/url].

Am I supposed to be looking at the win32 RawInput documentation and just convert it to C# code? Is the SlimDX RawInput similar to the Win32 one or not?

Thanks!
0

Share this post


Link to post
Share on other sites
SlimDX is just a wrapper for Directx, giving you access through .net. I've never used it but from what I've read you just pull in the namespace for rawinput, call the register function, setup an event handler and trap the keys / mouse input and process.

[CODE]

SlimDX.RawInput.Device.RegisterDevice(UsagePage.Generic, UsageId.Keyboard, DeviceFlags.None);
SlimDX.RawInput.Device.RegisterDevice(UsagePage.Generic, UsageId.Mouse, DeviceFlags.None);

SlimDX.RawInput.Device.KeyboardInput += Device_KeyboardInput;
SlimDX.RawInput.Device.MouseInput += Device_MouseInput;

private void Device_MouseInput(object sender, MouseInputEventArgs e)
{
//process input here
}

private void Device_KeyboardInput(object sender, KeyboardInputEventArgs e)
{
process input here
}

[/CODE]


[url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645543(v=vs.85).aspx"]http://msdn.microsof...3(v=vs.85).aspx[/url] Edited by DJTN
0

Share this post


Link to post
Share on other sites
Thanks for the info!

But my problem is... what exactly to fill out in the input processing function. I've seen the msdn documentation for reading in unbuffered data, they've used WM_INPUT and a function GetRawInputData, which I think I can't use in SlimDX ( I checked the SlimDX RawInput class reference but the function is not there).

Another question: you've made the function to be private, how or what function do I call from outside for updating? Will this keyboard input function be somehow called every time there is a key press or release event?

One more: Does SlimDX contain virtual key enumerations like VK_SPACE or VK_CONTROL to identify the key being pressed?

I'm sorry if all this sounds like spoon feeding, but I'm just not able to understand anything here. :(
0

Share this post


Link to post
Share on other sites
I'm not going to be much help in regards to SlimDX. :( The code I posted is suedo code. You could make the functions public or what ever you wanted. You could use your IDE to print out or step through the code to see what the event args are and trap them accordingly. If I remeber correctly, the events will be triggered on keypress and relese.

Keep in mind, you can just as well get keyboard state from the the appropriate P/Invoke calls to [url="http://pinvoke.net/default.aspx/user32/GetKeyboardState.html"][color="#0f72da"]GetKeyboardState[/color][/url] and mouse button state from [url="http://pinvoke.net/default.aspx/user32/GetAsyncKeyState.html"][color="#0f72da"]GetAsyncKeyState[/color][/url]. And screen position of the mouse from [url="http://pinvoke.net/default.aspx/user32/GetCursorPos.html"][color="#0f72da"]GetCursorPos[/color][/url] So raw input isn't your only alternative to direct input, or tapping into windows messages.
0

Share this post


Link to post
Share on other sites
There isn't a whole lot to the SlimDX RawInput wrapper. If you havent, take a look at the [url="http://slimdx.org/docs/#N_SlimDX_RawInput"]documentation[/url].

The event args that are passed to you uses the System.Windows.Forms.Keys enum. And it doesnt matter if the function is private or not, you only care about responding to events from the input device and won't be calling that function from the message loop. At least when using the SlimDX Wrapper.

How they do it [url="http://code.google.com/p/slimdx/source/browse/trunk/source/rawinput/DeviceRI.cpp"]under the hood[/url] is exactly that, by responding on WM_INPUT and using GetRawInputData, which is then processed to be consumed by your event handlers. So by doing this work for you, they made it fairly easy to use and the pseudo-code DJTN is pretty much all you need to do to get up and running.

Another thing to keep in mind when comparing this to [i]GetAsyncKeyState[/i] is you're going to respond to RawInput as keys are pressed/released, where getting the current keyboardstate is more of a polling process - e.g. in your game loop, when you update your objects, you can poll the input device and respond accordingly. You can of course have a setup where responding to RawInput just keeps track the input state (e.g. keys pressed), which a snapshot of is used everytime your objects are updated. An example: [url="http://code.google.com/p/tesla-engine/source/browse/trunk/Source/Tesla.Windows/Input/RawInputKeyboardWrapper.cs"]RawInputKeyboardWrapper [/url]vs [url="http://code.google.com/p/tesla-engine/source/browse/trunk/Source/Tesla.Windows/Input/WindowsKeyboardWrapper.cs"]WindowsKeyboardWrapper[/url]. Other possible ways would be to buffer the events and handle them in the order they were received.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0