如何在S60 5th中模拟触摸事件
Tested on Nokia 5800 Xpress Music
需要能力:SwEvent
1. 在"e32event.h"中,有对TRawEvent类的定义,其中TType这个枚举类型中包含了各种硬件级的事件,包括触摸和键盘等操作.
EButton1Down
EButton1Up
代表了在触摸屏设备上的开始接触触摸屏和离开触摸屏的事件。
2. 使用下面代码你可以模拟出各种触摸事件:
1 TRawEvent lEventDown;
2 lEventDown.Set(TRawEvent::EButton1Down, X, Y);
3 UserSvr::AddEvent(lEventDown);
2 lEventDown.Set(TRawEvent::EButton1Down, X, Y);
3 UserSvr::AddEvent(lEventDown);
//可能需要添加一些延迟,或者通过程序逻辑来控制
1 TRawEvent lEventUp;
2 lEventUp.Set(TRawEvent::EButton1Up, X, Y);
3 UserSvr::AddEvent(lEventUp);
2 lEventUp.Set(TRawEvent::EButton1Up, X, Y);
3 UserSvr::AddEvent(lEventUp);
3. 请注意在触摸屏手机上,坐标点X,Y的起始点(0,0)默认情况下是针对横屏的,所以某些时候需要必要的坐标转换。