c# - GetState.IsKeyDown() never returns true (Microsoft.Xna.Framework.Input.Keyboard) -


i trying check if key pressed on keyboard xna.framwork.input, method use doesn't see work.

my code (only important parts):

using system.threading; using microsoft.xna.framework.input; using microsoft.xna.framework;  private static void getinput() {     (int = 0; < 1000; i++) {         update();          if (iskeypressed(keys.w)) {             console.writeline("w pressed");         }         if (iskeypressed(keys.s)) {             console.writeline("s pressed");         }          thread.sleep(10);     } }  public static keyboardstate currentkeyboardstate { get; private set; }  public static void update() {     currentkeyboardstate = keyboard.getstate(); }   public static bool iskeypressed(keys key) {     return currentkeyboardstate.iskeydown(key); } 

no matter press, "iskeypressed" never returns true.

this method executed in new thread, running in main thread didn't change anything.

i using visual studio 2012 ultimate update 1, .net 4.5, win 7 x64, xna game studio 4.0

is code incorrect or problem somewhere else?

input not threadable, maybe due windows message loop in main thread,

if have no other constrain, should use game class xna provides, , invoke input.getstate inside update method... after can use keyboarstate in thread want.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -