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 "FF3DDeviceInputAgent.h" 00025 #include <stdlib.h> 00026 /*#define _WINSOCKAPI_ 00027 #define WIN32_LEAN_AND_MEAN 00028 #include <windows.h>*/ 00029 00030 FF3DDeviceInputAgent::FF3DDeviceInputAgent() 00031 : MicoleAgent("FF3DDeviceInputAgent","INPUT"), _buttonPressed(true) 00032 { 00033 bindMessage("^IN FF3D : pos=\\((.*), (.*), (.*)\\);( evt=(.*);)?$", BUS_CALLBACK_OF(FF3DDeviceInputAgent, handleInput)); 00034 } 00035 00036 FF3DDeviceInputAgent::~FF3DDeviceInputAgent() 00037 { 00038 } 00039 00040 void FF3DDeviceInputAgent::handleInput (MicoleBus *app, int argc, const char **argv) 00041 { 00042 if (argc < 3) 00043 return; 00044 _position.x = atof(argv[0]); 00045 _position.y = atof(argv[1]); 00046 _position.z = atof(argv[2]); 00047 00048 if (argc > 3) 00049 { 00050 if(!strcmp(argv[4],"PRESSED")) 00051 { 00052 if (_buttonPressed == false) //if we not press it 00053 { 00054 _buttonPressed = true; 00055 onButtonDown(); 00056 } 00057 } 00058 else 00059 { 00060 if (_buttonPressed == true) //if we press it 00061 { 00062 _buttonPressed = false; 00063 onButtonUp(); 00064 } 00065 } 00066 } 00067 else 00068 { 00069 if (_buttonPressed == true) //if we not press it 00070 { 00071 _buttonPressed = false; 00072 onButtonUp(); 00073 } 00074 } 00075 00076 onInput(); 00077 }