00001 /* 00002 * This file is part of Micole Architecture 00003 * 00004 * Copyright (C) 2007 Micole partners 00005 * 00006 * Micole Architecture is free software: you can redistribute it 00007 * and/or modify it under the terms of the GNU Lesser General 00008 * Public License as published by the Free Software Foundation, 00009 * either version 3 of the License, or (at your option) any 00010 * later version. 00011 * 00012 * Micole Architecture is distributed in the hope that it will be 00013 * useful, * but WITHOUT ANY WARRANTY; without even the implied 00014 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 * PURPOSE. See the GNU Lesser General Public License for more 00016 * details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with Micole Architecture. If not, see 00020 * <http://www.gnu.org/licenses/>. 00021 */ 00022 00023 #include "stdafx.h" 00024 #include "MouseInputAgent.h" 00025 #include "ReachinMicoleApplication.h" 00026 #include <MicoleStringStream.h> 00027 00028 MouseInputAgent::MouseInputAgent() 00029 { 00030 bindMessage( "^IN MSE : pos=\\((.*), (.*)\\); evt=\\((.*)\\);$", BUS_CALLBACK_OF(MouseInputAgent, handleMouseMove)); 00031 bindMessage( "^IN MSE : pos=\\((.*), (.*)\\);$", BUS_CALLBACK_OF(MouseInputAgent, handleMouseMove)); 00032 } 00033 00034 MouseInputAgent::~MouseInputAgent() 00035 { 00036 } 00037 00038 void MouseInputAgent::handleMouseMove(MicoleBus *app, int argc, const char **argv) 00039 { 00040 if(argc>=2) 00041 { 00042 _pos.x = atof(argv[0]); 00043 _pos.y = atof(argv[1]); 00044 onMove(_pos.x,_pos.y); 00045 } 00046 00047 if(argc==3) 00048 { 00049 string btn_stat = string(argv[2]); 00050 if(btn_stat.compare("BT1_PRESSED")==0) 00051 onButtonDown(1); 00052 else if(btn_stat.compare("BT1_RELEASED")==0) 00053 onButtonDown(1); 00054 00055 if(btn_stat.compare("BT2_PRESSED")==0) 00056 onButtonDown(2); 00057 else if(btn_stat.compare("BT2_RELEASED")==0) 00058 onButtonDown(2); 00059 } 00060 }