   [MDX] DirectInput.Key and int/long?
  Hello, is there any way to get a DirectInput.Key from an int/long/dword? The GetBufferedData() gives me an int identifying which key was pressed/released, and the GetCurrentKeyboardState() function uses DirectInput.Key to identify keys.. It would make my life easier if I could use them both..Any ideas?Also, am I the only one having problems with viewing the help of the MDX functions? When I press F1, I get online help, from the summer 03 update? It barely says anything about how to use these functions, or what the arguments mean.. Is this because I haven't uninstalled the previous SDKs? Any tips on how to fix?[edit]Probably doesn't matter, but just to follow the posting guidelines.. I'm using VS2005 and DX9 SDK April 06.. I've had several previous SDKs installed, without removing them when updating (although, the vc search paths have been updated to only contain the latest), the last one was June 05..[Edited by - DvDmanDT on May 25, 2006 11:31:38 PM]
  Hi DvDmanDT,I'm familiar with DirectInput, though I'm not very familiar with MDX, so you might have to forgive my ignorance, but here goes...DirectInput.Key is listed in the documentation as an Enum object, which has values in the range of 1 to about 240.What happens when you cast the value you get back from GetCurrentKeyboardState() to an int?  Does it match the value you get from GetBufferedData?As for pressing F1...I dislike having my DirectX documentation as part of my Visual Studio interface.  I just drag/drop a link to the documentation onto my Quick Launch bar so I can access it any time, within Visual Studio, or while just surfing the web, just with the click of a mouse.  You get a separate "Help" window, but I prefer it.  You might try the same?Cheers!   ;  Well, for me it brings up an external documentationviewer program (dexplore.exe or something like that). That one is usually great imho, it can use local help, and it can use remote help, and it's alot faster when trying to find some function.The GetCurrentKeyboardState() returns an array or something. So you can do Keys = InDev.GetCurrentKeyboardState(); if(Keys[Key.Escape])return 0; However, if(Keys[MyIntHere])return MyIntHere; Does not work, I get error about converting from int to DirectInput.Key..I do have some unmanaged input code, which works great, but I thought I'd try this as well. Too bad about the documentation, it seems really easy...Does anyone know about how to use GetDeviceState()? I have to pass it a Type (Type CustomFormat is the only param). Again, there seems to be no documentation apart from the param list, which doesn't explain anything (this is the online help on msdn, latest version of it).Perhaps I should just write my input code unmanaged..   ;  DvDmanDT,GetCurrentKeyboardState() doesnt return an array, it returns a KeyboardState reference which acts like a Hashtable.  It has a single member "item," which takes a Key and returns a bool, indicating whether or not the key is pressed at the exact moment that GetCurretKeyboardState() is called.GetBufferedData on the other hand returns a collection of BufferedData.  BufferedData contains, among other things, which keys were pressed since the last time you called GetBufferedData.Why is it exactly you need to use both?  The first allows a polling system where you ask the device which keys are currently pressed.  The second allows you to collect the key press history over a duriation (including currently).In the example you gave:if(Keys[MyIntHere])return MyIntHere;Where did you get 'MyIntHere' from?  If Keys contains the state of all current keys, you can just use the enum as you did in the previous example...if(Keys[Key.Escape])return 0;But what the altered line says is: "What is the state of the key, which is identified by MyIntHere?"  But if you got MyIntHere by calling GetBufferedData, you already know it was pressed...that's how you got the id in the first place.  But as for casting from int->Enum or Enum->int, as of .NET 2005 you can no longer do an implicit cast between Enum and int, or vice-versa.  Try doing an explicit cast. ie..if( Keys[ (Key)MyIntHere ] )return 0;Cheers!   ;  I 'need' both, because devices might get reset and/or buffers overflowed, and then I need to check the current state and compare it against the state I think it is in, and I want to use buffered input to be sure I don't miss keypresses (and it's the way I'm used to after using SDL).You know, I must've tried everything except a cast. Key.FromInt(MyInt), Key(MyInt), new Key(MyInt) and some more similar things, but I never thought of casting. Thanks alot, it seems to be working. Rating++ :)