1、读了导师的四项发明专利书,有了一些了解
2、学习使用了windowsAPI里的函数,可以用leapmotion来检测到swipe的手势,并在鼠标停留的记事本里输入指定的文字。
class SampleListener : public Listener {
public:
virtual void onFrame(const Controller&);
private:
};
void SampleListener::onFrame(const Controller& controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
//HWND wnd;
POINT curpos;
GetCursorPos(&curpos); //获取当前鼠标的位置,位置将储存在curpos里。
HWND hWnd = WindowFromPoint(curpos); //根据curpos所指的坐标点获取窗口句柄
SendMessage(hWnd,WM_CHAR,WPARAM('g'),0); //发送一个字符(按键)消息g给当前鼠标所指向的窗口句柄
break;
}
default:
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
}
int main(int argc, char** argv) {
// Create a sample listener and controller
SampleListener listener;
Controller controller;
// Have the sample listener receive events from the controller
controller.addListener(listener);
if (argc > 1 && strcmp(argv[1], "--bg") == 0)
controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);
// Keep this process running until Enter is pressed
std::cout << "Press Enter to quit..." << std::endl;
std::cin.get();
// Remove the sample listener when done
controller.removeListener(listener);
return 0;
}
以仓央嘉措的两句话结尾:
我问佛:如何才能如你般睿智?
佛曰:佛是过来人,人是未来佛