⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyboardappmodel.cpp

📁 On screen keyboard source code in Linux
💻 CPP
字号:
/* $Id: KeyboardAppModel.cpp,v 1.15 2003/11/11 21:24:44 chrisf Exp $ *//* Copyright (c) 2003 Chris Faherty  and others *//*This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/#include <eikgted.h>#include "Keyboard.pan"#include "KeyboardAppView.h"#include "KeyboardAppModel.h"_LIT(LDD_NAME,"ECOMM");#if defined (__WINS__)_LIT(PDD_NAME,"ECDRV");#else_LIT(PDD_NAME,"EUART1");#endifCKeyboardAppModel *CKeyboardAppModel::NewL(){    CKeyboardAppModel *self = CKeyboardAppModel::NewLC();    CleanupStack::Pop(self);    return self;}CKeyboardAppModel *CKeyboardAppModel::NewLC(){    CKeyboardAppModel *self = new (ELeave)CKeyboardAppModel();    CleanupStack::PushL(self);    self->ConstructL();    return self;}CKeyboardAppModel::CKeyboardAppModel() :    CActive(EPriorityStandard),    connected(false){}CKeyboardAppModel::~CKeyboardAppModel(){    Cancel();    Stop();}void CKeyboardAppModel::ConstructL(){    CActiveScheduler::Add(this);}void CKeyboardAppModel::SetView(CKeyboardAppView *aView){    iView = aView;}void CKeyboardAppModel::Start(){    _LIT(KColons,"::");    TInt r;    TBuf16<6> csyName;    csyName.Copy(_L("ECUART"));#if defined (__WINS__)    RFs fileServer;    User::LeaveIfError(fileServer.Connect());    fileServer.Close();#endif    r = User::LoadPhysicalDevice(PDD_NAME);    if (r != KErrNone && r != KErrAlreadyExists)        User::Leave(r);    r = User::LoadLogicalDevice(LDD_NAME);    if (r != KErrNone && r != KErrAlreadyExists)        User::Leave(r);#if !defined (__WINS__)    r = StartC32();    if (r != KErrNone && r != KErrAlreadyExists)        User::Leave(r);#endif    User::LeaveIfError(server.Connect());    User::LeaveIfError(server.LoadCommModule(csyName));    TInt numPorts;    r = server.NumPorts(numPorts);    User::LeaveIfError(r);    TSerialInfo portInfo;    r = server.GetPortInfo(_L("COMM"), portInfo);    User::LeaveIfError(r);    TBuf16<KMaxPortName+4> portName; // declare an empty descriptor buffer    portName.Num(5);	 // put in the port number in ASCII    portName.Insert(0, KColons);	  // stick in a couple of colons    portName.Insert(0, portInfo.iName); // and lead off with the iName    r = commPort.Open(server, portName, ECommExclusive);    User::LeaveIfError(r);    connected = true;    TCommConfig portSettings;    commPort.Config(portSettings);    portSettings().iRate = EBps9600;    portSettings().iParity = EParityNone;    portSettings().iDataBits = EData8;    portSettings().iStopBits = EStop1;#if !defined (__WINS__)    portSettings().iSIREnable = ESIREnable;#endif    r = commPort.SetConfig(portSettings);    commPort.Read(iStatus, localInputBuffer, 0);    User::WaitForRequest(iStatus);    r = iStatus.Int();    User::LeaveIfError (r);    connected = true;    IssueRead();}void CKeyboardAppModel::Stop(){    if (connected) {        commPort.Close();        server.Close();        connected = false;    }}void CKeyboardAppModel::IssueRead(){    commPort.Read(iStatus, 10*1000*1000, localInputBuffer, 1);    SetActive();}TBool CKeyboardAppModel::Connected(){    return connected;}/* CActive */void CKeyboardAppModel::DoCancel(){    commPort.ReadCancel();}/* CActive */void CKeyboardAppModel::RunL(){    switch (iStatus.Int()) {    case KErrTimedOut:        /* null read to keep it powered up */        commPort.Read(iStatus, localInputBuffer, 0);        User::WaitForRequest(iStatus);        break;    case KErrNone:        iView->Incoming(localInputBuffer);        break;    }    IssueRead();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -