Beispiel #1
0
        public static void SimulateModifiedKeyStroke(Microsoft.DirectX.DirectInput.Key modifier, Microsoft.DirectX.DirectInput.Key keycode)
        {
            INPUT structure = new INPUT();

            structure.type           = (int)InputType.INPUT_KEYBOARD;
            structure.ki.wScan       = (short)modifier;
            structure.ki.dwFlags     = (int)((int)KEYEVENTF.KEYDOWN | (uint)KEYEVENTF.SCANCODE);
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT input2 = new INPUT();

            input2.type           = (int)InputType.INPUT_KEYBOARD;
            input2.ki.wScan       = (short)keycode;//changed this line,input2 was structure before
            input2.mi.dwFlags     = (int)((int)KEYEVENTF.KEYDOWN | (uint)KEYEVENTF.SCANCODE);
            input2.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT structure2 = new INPUT();

            structure.type           = (int)InputType.INPUT_KEYBOARD;
            structure.ki.wScan       = (short)keycode;
            structure.ki.dwFlags     = (int)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT input3 = new INPUT();

            input2.type           = (int)InputType.INPUT_KEYBOARD;
            structure.ki.wScan    = (short)modifier;
            input2.mi.dwFlags     = (int)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            input2.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT[] pInputs = new INPUT[] { structure, input2, structure2, input3 };

            SendInput(4, pInputs, Marshal.SizeOf(structure));
        }
Beispiel #2
0
 public KeyProperties(Microsoft.DirectX.DirectInput.Key a, bool b)
 {
     modifier    = (Microsoft.DirectX.DirectInput.Key)(0);
     keyCode1    = a;
     holdDown    = b;
     useModifier = false;
 }
Beispiel #3
0
 public KeyProperties(Microsoft.DirectX.DirectInput.Key a, Microsoft.DirectX.DirectInput.Key b, bool c)//used when we have a modifier
 {
     modifier    = a;
     keyCode1    = b;
     holdDown    = c;
     useModifier = true;
 }
Beispiel #4
0
 public void AddButtonKeyMapping(ButtonEnum button, Microsoft.DirectX.DirectInput.Key keyCode, bool holdDown)
 {
     if (ButtonKeys.Contains((int)button))
     {
         ButtonKeys.Remove((int)button);//to save on later garbage collection
     }
     ButtonKeys[(int)button] = new KeyProperties(keyCode, holdDown);
 }
 public static void SimulateModifiedKeyStroke(Microsoft.DirectX.DirectInput.Key modifier, Microsoft.DirectX.DirectInput.Key keycode)
 {
     SimulateKeyDown(modifier);
     SimulateKeyDown(keycode);
     System.Threading.Thread.Sleep(ModifiedKeyStrokeDelay);
     SimulateKeyUp(keycode);
     SimulateKeyUp(modifier);
 }
Beispiel #6
0
        public ControllerIdType GetNewKeyboardInstance(DirectInput.Key KeyUp, DirectInput.Key KeyDown, DirectInput.Key KeyLeft, DirectInput.Key KeyRight, DirectInput.Key KeyAttack)
        {
            System.Collections.Hashtable KeyTable = new System.Collections.Hashtable();
            KeyTable[InputDeviceAccess.GameKeys.Up]     = KeyUp;
            KeyTable[InputDeviceAccess.GameKeys.Down]   = KeyDown;
            KeyTable[InputDeviceAccess.GameKeys.Left]   = KeyLeft;
            KeyTable[InputDeviceAccess.GameKeys.Right]  = KeyRight;
            KeyTable[InputDeviceAccess.GameKeys.Attack] = KeyAttack;

            InputDeviceAccess.TypeOfDevices TypeOfDevice = InputDeviceAccess.TypeOfDevices.Keyboard;

            return(this.InitializeDevice(TypeOfDevice, KeyTable));
        }
Beispiel #7
0
        public static void SimulateKeyUp(Microsoft.DirectX.DirectInput.Key key)
        {
            INPUT structure = new INPUT();

            structure.type           = (int)InputType.INPUT_KEYBOARD;
            structure.ki.wScan       = (short)key;
            structure.ki.dwFlags     = (int)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT[] pInputs = new INPUT[] { structure };

            SendInput(1, pInputs, Marshal.SizeOf(structure));
        }
Beispiel #8
0
 public PauseMenu(Microsoft.DirectX.DirectInput.Key mappedKey)
 {//recibe un key.algo para la key que abre y cierra el menu
     this.mappedKey = mappedKey;
     drawer2D       = new Drawer2D();
     fondo          = new CustomSprite();
     bitmap_fondo   = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\pause_menu.png", D3DDevice.Instance.Device);
     fondo.Bitmap   = bitmap_fondo;
     CalcularFullScreenScalingAndPosition(fondo);
     sound            = new CustomSprite();
     bitmap_sound     = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\sound_icon.png", D3DDevice.Instance.Device);
     bitmap_sound_off = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\sound_off_icon.png", D3DDevice.Instance.Device);
     CalcularChildScalingAndPosition(sound, bitmap_sound                  /*lo uso como base, total el de sound on y off son iguales*/
                                     , .90f, .90f, .05f, .1f, main_rect); //90% de x 90% de y , .5% del tamaño de la pantalla
 }//@ ver si hay alguna forma de no tener q pasar los dos scale, usar aspect_ratio del rect capaz
Beispiel #9
0
        public static void SimulateKeyPress(Microsoft.DirectX.DirectInput.Key key)
        {
            INPUT structure = new INPUT();

            structure.type           = (int)InputType.INPUT_KEYBOARD;
            structure.ki.wScan       = (short)key;
            structure.ki.dwFlags     = (int)((int)KEYEVENTF.KEYDOWN | (uint)KEYEVENTF.SCANCODE);
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT input2 = new INPUT();

            input2.type           = (int)InputType.INPUT_KEYBOARD;
            input2.ki.wScan       = (short)key;//changed this line
            input2.mi.dwFlags     = (int)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            input2.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT[] pInputs = new INPUT[] { structure, input2 };

            SendInput(2, pInputs, Marshal.SizeOf(structure));
        }
        public static void SimulateKeyUp(Microsoft.DirectX.DirectInput.Key key)
        {
            INPUT structure = new INPUT();

            structure.type = (int)InputType.INPUT_KEYBOARD;
            //structure.ki.wVk = VkKeyScan((char)key);
            structure.ki.wScan = (ushort)key;
            if (IsExtendedKey(key))
            {
                structure.ki.dwFlags = (uint)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE | (uint)KEYEVENTF.EXTENDEDKEY);
            }
            else
            {
                structure.ki.dwFlags = (uint)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            }
            structure.ki.time        = 0;
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT[] pInputs = new INPUT[] { structure };

            SendInput(1, pInputs, Marshal.SizeOf(structure));
        }
        public static int ModifiedKeyStrokeDelay = 5;//number of milliseconds combination keys will be held down.
        //this number was experimentally found out as the minimum necessary for MW4 to respond to modified
        //keystroke

        /// <summary>
        /// Determines if the <see cref="VirtualKeyCode"/> is an ExtendedKey
        /// </summary>
        /// <param name="keyCode">The key code.</param>
        /// <returns>true if the key code is an extended key; otherwise, false.</returns>
        /// <remarks>
        /// The extended keys consist of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRLPAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad.
        ///
        /// See http://msdn.microsoft.com/en-us/library/ms646267(v=vs.85).aspx Section "Extended-Key Flag"
        /// </remarks>
        public static bool IsExtendedKey(Microsoft.DirectX.DirectInput.Key keyCode)
        {
            if (
                keyCode == Microsoft.DirectX.DirectInput.Key.Insert ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Delete ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Home ||
                keyCode == Microsoft.DirectX.DirectInput.Key.End ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Prior ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Next ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Right ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Up ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Left ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Down ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Numlock ||
                keyCode == Microsoft.DirectX.DirectInput.Key.BackSpace ||
                keyCode == Microsoft.DirectX.DirectInput.Key.Divide)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #12
0
 public void sendKeyPress(Microsoft.DirectX.DirectInput.Key modifier, Microsoft.DirectX.DirectInput.Key keycode)
 {
     InputSimulator.SimulateModifiedKeyStroke(modifier, keycode);
 }
 public static void SimulateModifiedKeyStroke(Microsoft.DirectX.DirectInput.Key[] modifierKeyCodes, Microsoft.DirectX.DirectInput.Key keycode)
 {
     foreach (Microsoft.DirectX.DirectInput.Key k in modifierKeyCodes)
     {
         SimulateKeyDown(k);
     }
     SimulateKeyDown(keycode);
     System.Threading.Thread.Sleep(ModifiedKeyStrokeDelay);
     SimulateKeyUp(keycode);
     foreach (Microsoft.DirectX.DirectInput.Key k in modifierKeyCodes)
     {
         SimulateKeyUp(k);
     }
 }
 public KeyboardEventHandler(DxI.Key key, List<InputEvent> futureEvents)
     : base(futureEvents)
 {
     m_key = key;
 }
 public static void SimulateKeyPress(Microsoft.DirectX.DirectInput.Key key)
 {
     SimulateKeyDown(key);
     SimulateKeyUp(key);
 }
Beispiel #16
0
 public void AddButtonKeyLightMapping(ButtonEnum button, bool lightOnHold, int intensity, Microsoft.DirectX.DirectInput.Key keyCode1, Microsoft.DirectX.DirectInput.Key keyCode2, bool holdDown)
 {
     AddButtonLightMapping(button, lightOnHold, intensity);
     AddButtonKeyMapping(button, keyCode1, keyCode2, holdDown);
 }
Beispiel #17
0
 public void AddButtonKeyMapping(ButtonEnum button, Microsoft.DirectX.DirectInput.Key modifier, Microsoft.DirectX.DirectInput.Key keyCode, bool holdDown)
 {
     ButtonKeys[(int)button] = new KeyProperties(modifier, keyCode, holdDown);
 }
Beispiel #18
0
 public void sendKeyUp(Microsoft.DirectX.DirectInput.Key keycode)
 {
     InputSimulator.SimulateKeyUp(keycode);
 }