コード例 #1
0
ファイル: HCWRemote.cs プロジェクト: ewin66/media
 protected override void Dispose(bool disposeManagedResources)
 {
     if (disposeManagedResources && (components != null))
     {
         components.Dispose();
     }
     HCWNative.IR_Close(this.Handle, 0);
     base.Dispose(disposeManagedResources);
 }
コード例 #2
0
ファイル: HCWRemote.cs プロジェクト: ewin66/media
        private void Form1_Load(object sender, EventArgs e)
        {
            int repeatCount;
            int remoteCode;
            int keyCode;

            HCWNative.IR_Open(this.Handle, 0, false, 0);
            // ignore any initial remote commands
            while (HCWNative.IR_GetSystemKeyCode(out repeatCount, out remoteCode, out keyCode))
            {
            }
        }
コード例 #3
0
ファイル: HCWRemote.cs プロジェクト: ewin66/media
        private void ProcessSystemKeyCode()
        {
            int repeatCount = 0;
            int remoteCode  = 0;
            int keyCode     = 0;
            // Time of button press - Use this for repeat delay calculations
            DateTime sentTime = DateTime.Now;

            if (!HCWNative.IR_GetSystemKeyCode(out repeatCount, out remoteCode, out keyCode))
            {
                return;
            }
            if (_lastKeyCode == keyCode)
            {
                // button release time elapsed since last identical command
                // if so, reset counter & start new session
                if ((sentTime - _lastTime) > _buttonRelease)
                {
                    _sameKeyCodeCount = 0;   // new session with this button
                }
                else
                {
                    _sameKeyCodeCount++;   // button release time not elapsed
                }
            }
            else
            {
                _sameKeyCodeCount = 0;   // we got a new button
            }
            bool executeKey = false;

            // new button / session
            if (_sameKeyCodeCount == 0)
            {
                executeKey = true;
            }
            //// we got the identical button often enough to accept it
            if (_sameKeyCodeCount == _repeatFilter)
            {
                executeKey = true;
            }
            // we got the identical button accepted and still pressed, repeat with repeatSpeed
            if ((_sameKeyCodeCount > _repeatFilter) && (_sameKeyCodeCount > _lastExecutedKeyCodeCount + _repeatSpeed))
            {
                executeKey = true;
            }
            // double click filter
            if (executeKey && _filterDoubleClicks)
            {
                if ((_sameKeyCodeCount > 0) &&
                    (keyCode == 46 || //46 = fullscreen/green button
                     keyCode == 37 || //37 = OK button
                     keyCode == 56 || //56 = yellow button
                     keyCode == 11 || //11 = red button
                     keyCode == 41 || //41 = blue button
                     keyCode == 13 || //13 = menu button
                     keyCode == 15 || //15 = mute button
                     keyCode == 48))  //48 = pause button
                {
                    executeKey = false;
                }
            }
            if (executeKey)
            {
                _lastExecutedKeyCodeCount = _sameKeyCodeCount;
                _lastKeyCode = keyCode;
                NotifyKeyPressed((KeyName)keyCode);
            }
            _lastTime = sentTime;
        }