Can you turn NumLock on in XNA?
(I'm looking for a solution to XNA Number lock affects input.)
Can you turn NumLock on in XNA?
(I'm looking for a solution to XNA Number lock affects input.)
I don't know if this is that you are looking for, but I found this article.
In order to know whether or not Caps Lock, Num Lock or Scroll Lock keys are on, we need to make use of the Win32 API through a call to an unmanaged function.
Since we'll make a call to an unmanaged function, the following using statement is in order:
using System.Runtime.InteropServices;
The following is the definition for the unmanaged function we'll be using, GetKeyState():
// An unmanaged function that retrieves the states of each key
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
// Get they key state and store it as bool
bool NumLock = (((ushort)GetKeyState(0x90)) & 0xffff) != 0;
You'll have to P/Invoke SendInput. This is somewhat involved:
Here are the relevant definitions: