下面是一种消抖算法,(常用于ucgui,xvworks图形控制等领域)只是思想,下面分析一下

if(msg.type == MSG_POINTER )
{
/*when the buttonState is not 0,it state the mouse has pressed*/
if(msg.data.pointer.buttonState !=0)
{
buttonState_tmp =(int)msg.data.pointer.buttonState;
/* handle the mouse shake*/
while(msg.data.pointer.buttonState)
uglInputMsgGet (pDisplayControl->inputServiceId, &msg, 140 /* mSec */);
mouseEcho(pDisplayControl,buttonState_tmp);
}
}

 

if(msg.data.pointer.buttonState !=0)
这一句说明有鼠标按下,因为只要按下一定不为0
buttonState_tmp =(int)msg.data.pointer.buttonState;
把当前值保存下来。
while(msg.data.pointer.buttonState)
如果鼠标不抬起的话,这个msg.data.pointer.buttonState一直不为0,就起到了消抖的作用
uglInputMsgGet (pDisplayControl->inputServiceId, &msg, 140 /* mSec */);
在while里面重新或得坐标值
mouseEcho(pDisplayControl,buttonState_tmp);
退出while后,就是消抖完成了。执行用户程序了
 

相关文章:

  • 2021-09-04
  • 2021-09-03
  • 2021-07-11
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-04-20
猜你喜欢
  • 2021-12-12
  • 2021-08-10
  • 2021-07-21
  • 2021-04-28
  • 2021-09-08
相关资源
相似解决方案