Esempio n. 1
0
 public bool StartScan(InputScanSetting setting, InputScanHandler handler,
                       float timeout  = InputScanService.TIME_OUT_DURATION,
                       KeyCode cancel = InputScanService.CANCEL_KEY_CODE,
                       KeyCode clear  = InputScanService.CLEAR_KEY_CODE)
 {
     return(scanService.Start(setting, handler, timeout, cancel, clear));
 }
Esempio n. 2
0
    bool ScanMouseAxis()
    {
        for (int i = 0; i < m_rawMouseAxes.Length; i++)
        {
            if (IsAxisChange(m_rawMouseAxes[i]) && m_scanHandler != null)
            {
                var result = new InputScanResult(m_curScaningSetting, InputResultType.Success);
                result.Axis = i;

                if (m_scanHandler(result))
                {
                    m_scanHandler = null;
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 3
0
    bool ScanJoystickAxis()
    {
        for (int i = 0; i < m_rawJoystickAxes.Length; i++)
        {
            if (IsAxisChange(m_rawJoystickAxes[i]) && m_scanHandler != null)
            {
                var result = new InputScanResult(m_curScaningSetting, InputResultType.Success);
                result.JoystickIndex = i / InputManager.JOYSTICK_AXIS_COUNT;
                result.Axis          = i % InputManager.JOYSTICK_AXIS_COUNT;

                if (m_scanHandler(result))
                {
                    m_scanHandler = null;
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 4
0
    public bool Start(InputScanSetting setting, InputScanHandler handler, float timeout, KeyCode cancel, KeyCode clear)
    {
        if (IsScanning)
        {
            ForceStop();
        }

        m_curScaningSetting = setting;
        m_scanningType      = setting.ScanType;

        m_leftTime      = timeout;
        m_cancelScanKey = cancel;
        m_clearScanKey  = clear;
        m_scanHandler   = handler;

        IsScanning = true;

        axesToValueMap.Clear();

        return(true);
    }
Esempio n. 5
0
    bool ScanJoystickButton()
    {
        int start = (int)KeyCode.Joystick1Button0;
        int end   = (int)KeyCode.Joystick8Button19;

        for (int i = start; i <= end; i++)
        {
            var curKey = (KeyCode)i;
            if (Input.GetKeyDown(curKey) && m_scanHandler != null)
            {
                var result = new InputScanResult(m_curScaningSetting, InputResultType.Success);
                result.JoystickIndex  = (i - start) / InputManager.JOYSTICK_BUTTON_COUNT;
                result.JoystickButton = ((JoystickButton)((i - start) % InputManager.JOYSTICK_BUTTON_COUNT));

                if (m_scanHandler(result))
                {
                    m_scanHandler = null;
                    return(true);
                }
            }
        }

        return(false);
    }
Esempio n. 6
0
    /// <summary>
    /// 监测键盘输入
    /// </summary>
    /// <returns></returns>
    bool ScanKeyboardButton()
    {
        for (int i = 0, length = m_keys.Length; i < length; i++)
        {
            if ((int)m_keys[i] >= (int)KeyCode.JoystickButton0)
            {
                break;
            }

            if (Input.GetKeyDown(m_keys[i]) && m_scanHandler != null)
            {
                var result = new InputScanResult(m_curScaningSetting, InputResultType.Success);
                result.KeyCode = m_keys[i];

                if (m_scanHandler(result))
                {
                    m_scanHandler = null;
                    return(true);
                }
            }
        }

        return(false);
    }