Beispiel #1
0
 /// <summary>
 /// Initialize a new instance of <see cref="SystemInfo"/>
 /// </summary>
 /// <param name="displayName">A <see cref="string"/> that specify how the system name is displayed</param>
 /// <param name="system">A <see cref="CoreSystem"/> that specify what core is used</param>
 /// <param name="maxControllers">Maximum controller allowed by this system</param>
 /// <param name="availableButtons">Which buttons are available (i.e. are actually on the controller) for this system</param>
 private SystemInfo(string displayName, CoreSystem system, int maxControllers, JoypadButton availableButtons)
 {
     _DisplayName = displayName;
     _System = system;
     _MaxControllers = maxControllers;
     _AvailableButtons = availableButtons;
 }
Beispiel #2
0
 /// <summary>
 /// Initialize a new instance of <see cref="SystemInfo"/>
 /// </summary>
 /// <param name="displayName">A <see cref="string"/> that specify how the system name is displayed</param>
 /// <param name="system">A <see cref="CoreSystem"/> that specify what core is used</param>
 /// <param name="maxControllers">Maximum controller allowed by this system</param>
 /// <param name="availableButtons">Which buttons are available (i.e. are actually on the controller) for this system</param>
 private SystemInfo(string displayName, CoreSystem system, int maxControllers, JoypadButton availableButtons)
 {
     _DisplayName      = displayName;
     _System           = system;
     _MaxControllers   = maxControllers;
     _AvailableButtons = availableButtons;
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SystemInfo"/> class
        /// </summary>
        /// <param name="displayName">A <see cref="string"/> that specify how the system name is displayed</param>
        /// <param name="system">A <see cref="CoreSystem"/> that specify what core is used</param>
        /// <param name="maxControllers">Maximum controller allowed by this system</param>
        /// <param name="availableButtons">Which buttons are available (i.e. are actually on the controller) for this system</param>
        private SystemInfo(string displayName, CoreSystem system, int maxControllers, JoypadButton availableButtons = 0)
        {
            DisplayName      = displayName;
            System           = system;
            MaxControllers   = maxControllers;
            AvailableButtons = availableButtons;

            _allSystemInfos.Add(this);
        }
        public void JoypadEvent(JoypadButton btn, bool depressed)
        {
            VirtualKeyCode code;

            switch (btn)
            {
            case JoypadButton.DPAD_LEFT:
                code = VirtualKeyCode.LEFT;
                break;

            case JoypadButton.DPAD_TOP:
                code = VirtualKeyCode.UP;
                break;

            case JoypadButton.DPAD_RIGHT:
                code = VirtualKeyCode.RIGHT;
                break;

            case JoypadButton.DPAD_BOTTOM:
                code = VirtualKeyCode.DOWN;
                break;

            case JoypadButton.BUTTON_START:
                code = VirtualKeyCode.RETURN;
                break;

            case JoypadButton.BUTTON_SELECT:
                code = VirtualKeyCode.SPACE;
                break;

            case JoypadButton.BUTTON_A:
                code = VirtualKeyCode.VK_Z;
                break;

            case JoypadButton.BUTTON_B:
                code = VirtualKeyCode.VK_X;
                break;

            default:
                code = VirtualKeyCode.VK_A;
                break;
            }
            if (depressed)
            {
                InputSimulator.SimulateKeyDown(code);
            }
            else
            {
                InputSimulator.SimulateKeyUp(code);
            }
        }
 public void JoypadEvent(JoypadButton btn, bool depressed)
 {
     VirtualKeyCode code;
     switch (btn)
     {
         case JoypadButton.DPAD_LEFT:
             code = VirtualKeyCode.LEFT;
             break;
         case JoypadButton.DPAD_TOP:
             code = VirtualKeyCode.UP;
             break;
         case JoypadButton.DPAD_RIGHT:
             code = VirtualKeyCode.RIGHT;
             break;
         case JoypadButton.DPAD_BOTTOM:
             code = VirtualKeyCode.DOWN;
             break;
         case JoypadButton.BUTTON_START:
             code = VirtualKeyCode.RETURN;
             break;
         case JoypadButton.BUTTON_SELECT:
             code = VirtualKeyCode.SPACE;
             break;
         case JoypadButton.BUTTON_A:
             code = VirtualKeyCode.VK_Z;
             break;
         case JoypadButton.BUTTON_B:
             code = VirtualKeyCode.VK_X;
             break;
         default:
             code = VirtualKeyCode.VK_A;
             break;
     }
     if (depressed)
         InputSimulator.SimulateKeyDown(code);
     else
         InputSimulator.SimulateKeyUp(code);
 }
 /// <summary>
 /// Add specified input to current ones
 /// </summary>
 /// <param name="input">Input to add</param>
 public void AddInput(JoypadButton input)
 {
     input           &= System.AvailableButtons;
     _pressedButtons |= input;
 }
 public void JoypadEvent(JoypadButton btn, bool depressed)
 {
     System.Console.WriteLine("JoypadEvent not yet implemented");
 }
Beispiel #8
0
 /// <summary>
 /// Returns a core assigned description of the specified joypad button, if any is assigned.
 /// </summary>
 /// <param name="port">The port of the joypad.</param>
 /// <param name="button">The button to query.</param>
 /// <returns>If a description is assigned, the description, otherwise "".</returns>
 public string GetJoypadDescription(int port, JoypadButton button)
 {
     string desc = "";
     inputDescriptors.TryGetValue(DeviceType.Joypad + "," + port + "," + ((int)button) + "," + 0, out desc);
     return desc;
 }
 public void JoypadEvent(JoypadButton btn, bool depressed)
 {
     System.Console.WriteLine("JoypadEvent not yet implemented");
 }
Beispiel #10
0
 /// <summary>
 /// Remove specified input to current ones
 /// </summary>
 /// <param name="input">Input to remove</param>
 public void RemoveInput(JoypadButton input)
 {
     _PressedButtons ^= input;
 }
Beispiel #11
0
 /// <summary>
 /// Clear inputs
 /// </summary>
 public void ClearInputs()
 {
     _PressedButtons = 0;
 }
Beispiel #12
0
 /// <summary>
 /// Add specified input to current ones
 /// </summary>
 /// <param name="input">Input to add</param>
 public void AddInput(JoypadButton input)
 {
     input &= _System.AvailableButtons;
     _PressedButtons |= input;
 }
 /// <summary>
 /// Convert a <see cref="JoypadButton"/> value to BizHawk <see cref="string"/>
 /// </summary>
 /// <param name="button"><see cref="JoypadButton"/> you want to convert</param>
 /// <param name="system">Current <see cref="SystemInfo"/></param>
 /// <returns>A <see cref="string"/> that is used by BizHawk</returns>
 /// <exception cref="IndexOutOfRangeException">Thrown when <see cref="JoypadButton"/> hasn't been found</exception>
 public string ConvertBack(JoypadButton button, SystemInfo system)
 {
     return((string)ConvertBack(button, null, system, CultureInfo.CurrentCulture));
 }
Beispiel #14
0
 /// <summary>
 /// Convert a <see cref="JoypadButton"/> value to BizHawk <see cref="string"/>
 /// </summary>
 /// <param name="button"><see cref="JoypadButton"/> you want to convert</param>
 /// <param name="system">Current <see cref="SystemInfo"/></param>
 /// <returns>A <see cref="string"/> that is used by BizHawk</returns>
 /// <exception cref="IndexOutOfRangeException">Thrown when <see cref="JoypadButton"/> hasn't been found</exception>
 public string ConvertBack(JoypadButton button, SystemInfo system)
 {
     return (string)ConvertBack(button, null, system, CultureInfo.CurrentCulture);
 }
 /// <summary>
 /// Clear inputs
 /// </summary>
 public void ClearInputs()
 {
     _pressedButtons = 0;
 }
 /// <summary>
 /// Remove specified input to current ones
 /// </summary>
 /// <param name="input">Input to remove</param>
 public void RemoveInput(JoypadButton input)
 {
     _pressedButtons ^= input;
 }
Beispiel #17
0
 void server_MessageReceived(object sender, OscMessageReceivedEventArgs e)
 {
     log.Log(LogLevel.Info, "Message Recieved");
     log.Log(LogLevel.Info, "  " + e.Message.Address);
     if (e.Message.Address == JOYPAD_BUTTON_EVENT)
     {
         JoypadButton btn       = (JoypadButton)reverseEndianizeOscInt(e.Message.Data[0]);
         bool         depressed = reverseEndianizeOscInt(e.Message.Data[1]) != 0;
         log.Log(LogLevel.Info, string.Format("    {0} - {1}", btn, depressed));
         inputController.JoypadEvent(btn, depressed);
     }
     else if (e.Message.Address == MOUSE_EVENT)
     {
         int btn = reverseEndianizeOscInt(e.Message.Data[0]);
         int dx  = reverseEndianizeOscInt(e.Message.Data[1]);
         int dy  = reverseEndianizeOscInt(e.Message.Data[2]);
         log.Log(LogLevel.Info, string.Format("    btn: {0}, dx: {1}, dy: {2}", btn, dx, dy));
         inputController.MouseEvent(btn, dx, dy);
     }
     else if (e.Message.Address == SCROLL_EVENT)
     {
         int dx = reverseEndianizeOscInt(e.Message.Data[0]);
         int dy = reverseEndianizeOscInt(e.Message.Data[1]);
         log.Log(LogLevel.Info, string.Format("    dx: {0}, dy: {1}", dx, dy));
         inputController.ScrollEvent(dx, dy);
     }
     else if (e.Message.Address == KEYBOARD_EVENT)
     {
         int  code  = reverseEndianizeOscInt(e.Message.Data[0]);
         bool shift = reverseEndianizeOscInt(e.Message.Data[1]) != 0;
         log.Log(LogLevel.Info, string.Format("    code: {0,2:X}, '{1}', shift: {2}", code, (char)code, shift));
         inputController.KeyboardEvent(code, shift);
     }
     else if (e.Message.Address == VOLUME_EVENT)
     {
         int d = reverseEndianizeOscInt(e.Message.Data[0]);
         log.Log(LogLevel.Info, string.Format("    d: {0}", d));
         if (UseVolumeMacros)
         {
             if (d == 1)
             {
                 inputController.PlayKeyMacro(VolumeUpMacro);
             }
             else
             {
                 inputController.PlayKeyMacro(VolumeDownMacro);
             }
         }
         else
         {
             if (d == 1)
             {
                 inputController.VolumeUp();
             }
             else
             {
                 inputController.VolumeDown();
             }
         }
     }
 }