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 "KeyboardSenderAgent.h" 00025 00026 #include "ReachinMicoleApplication.h" 00027 #include "MicoleStringStream.h" 00028 00029 KeyboardSenderAgent::KeyboardSenderAgent() 00030 :MicoleAgent("KeyboardSenderAgent","SenderAgent"), _keyboardListener(new KeyboardListener), _keyb(new Keyboard) 00031 { 00032 _keyboardListener->_kbssa = this; 00033 ReachinMicoleApplication *rma = ReachinMicoleApplication::getInstance(); 00034 //rma->getDisplay()->children->add(_keyb.get()); 00035 _keyb->strokes->route(_keyboardListener); 00036 rma->sendBusMessage("KEYBOARD INPUT CREATED"); 00037 } 00038 00039 //must not be used 00040 KeyboardSenderAgent::KeyboardSenderAgent(const KeyboardSenderAgent &) 00041 :MicoleAgent("KeyboardSenderAgent","SenderAgent"), _keyboardListener(NULL) 00042 { 00043 _keyboardListener->_kbssa = this; 00044 } 00045 00046 KeyboardSenderAgent::~KeyboardSenderAgent() 00047 { 00048 } 00049 00050 void KeyboardSenderAgent::KeyboardListener::evaluate(MFInt32*character) 00051 { 00052 MicoleStringStream s; 00053 //for (MField< int >::const_iterator it = character->get().begin() ; it != character->get().end() ; it++) 00054 //{ 00055 // s << "IN KBD : key=" << *it; 00056 s << "IN KBD : key=" << character->get()[0]<<";"; 00057 00058 _kbssa->sendMessage(s.str().c_str()); 00059 00060 s.flush(); 00061 //ReachinMicoleApplication::getInstance()->sendBusMessage("TEST KBD"); 00062 //ReachinMicoleApplication::getInstance()->sendBusMessage(s.str().c_str()); 00063 //} 00064 } 00065