Results 1 to 4 of 4

Thread: DInput in 0.9

  1. #1
    Lesser Knight
    Join Date
    Aug 2008
    Location
    Folsom, California USA
    Posts
    37

    Default DInput in 0.9

    I'm curious about the status of DirectInput on 0.9. I noticed that it is included in various Win32-related modules, which is a bummer because it makes clanDisplay depend on the dX SDK. Not a big deal --- well, actually, a 400mb deal but annoying for people who think they're not going to need anything from DirectX because they're using message input and OpenGL.

    So, I was wondering if there's any plans in the works to either remove it altogether, or to split it into the DX target modules as a variant input context provider.

    If not, I might look at doing so.

    --- Kevin

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    I'm not entirely sure what to do about DirectX in clanDisplay. I consider the DirectX dependency as fairly low priority because downloading the SDK isn't that big a deal (Windows game developers are used to needing DX). Its only during deployment that it can be a bit annoying to needing to bundle the redistributable.

    My bigger worry with DirectInput is that it seems unclear what Microsoft's long term plans are in this area. For some reason they didn't use DirectInput for their XBOX, and the library they wrote for it only targets their own console controller.

    I suspect that perhaps you do not need a library like DirectInput anymore, since HID devices probably follow some standard that means you can use the WM_INPUT and RAWINPUT stuff added in Windows XP. I haven't researched this much though, just noticed these messages one of the days I was MSDN surfing.

    I actually think that if I was to improve this part of ClanLib, I would probably try research WM_INPUT to see if I can drop this dependency. DirectInput smells badly of something Microsoft is about to deprecate, and I'm so dead tired of having all my code bases constantly deprecated by Microsoft that I'd rather use a low level API than risk having to read up on yet another API that only lasts a couple of years.

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    A while ago, during porting the ClanLib 0.8 Joystick example to 0.9 (Now deleted) - I added support code to 0.9 Win32 target.

    This was required for win32 to automatically poll the directinput device.

    This is how it worked:
    In "CL_Win32Window::create_new_window()"
    Code:
    		RAWINPUTDEVICE Rid[1];
    		Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC; 
    		Rid[0].usUsage = HID_USAGE_GENERIC_JOYSTICK; 
    		Rid[0].dwFlags = RIDEV_INPUTSINK;   
    		Rid[0].hwndTarget = hwnd;
    		RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));
    Was added, so that window events are thrown
    (Note: I was not sure if HID_USAGE_GENERIC_GAMEPAD was also required.)

    In "CL_Win32Window::window_proc()"
    Code:
    	case WM_INPUT:
    		received_joystick_input();
    		return true;
    Which is called when input occurs.
    In "CL_Win32Window::received_joystick_input()", this function only calls ic.poll()
    which polls all the input context devices.. Note - the mouse and keyboard poll() functions are empty

    And "CL_InputDeviceProvider_DirectInput:oll()" calls directinput_device->Poll();

    Reading the MSDN documentation, you should be able to obtain the joystick information (without using DirectInput) by directly using the WM_INPUT message. (See http://msdn.microsoft.com/en-us/library/ms645543.aspx )
    Last edited by rombust; 09-23-2008 at 07:09 AM. Reason: Spelling

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    OK, so there is not really a reason to use DirectInput anymore. It is safer and better to interface the HID standards than any MS library, I think. Hardware people don't change their standards as often as MS does.

Similar Threads

  1. dinput.lib on Windows
    By Chambers in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 04-16-2008, 06:49 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •