Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# MouseState.cpp

Go to the documentation of this file.

    00001 //------------------------------------------------------------------------------
    00002 // Lamp : Open source game middleware
    00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
    00004 //
    00005 // This library is free software; you can redistribute it and/or
    00006 // modify it under the terms of the GNU Lesser General Public
    00007 // License as published by the Free Software Foundation; either
    00008 // version 2.1 of the License, or (at your option) any later version.
    00009 //
    00010 // This library is distributed in the hope that it will be useful,
    00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013 // Lesser General Public License for more details.
    00014 //
    00015 // You should have received a copy of the GNU Lesser General Public
    00016 // License along with this library; if not, write to the Free Software
    00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 //------------------------------------------------------------------------------
    00019
    00020 /** @file
    00021  * マウスステート実装
    00022  * @author Junpee
    00023  */
    00024
    00025 #include "LampBasic.h"
    00026 #include "Input/Mouse/MouseState.h"
    00027 #include "Core/InputOutput/BinaryWriter.h"
    00028 #include "Core/InputOutput/BinaryReader.h"
    00029
    00030 namespace Lamp{
    00031
    00032 //------------------------------------------------------------------------------
    00033 // バイナリ書き出し
    00034 void MouseState::writeBinary(BinaryWriter* binaryWriter) const{
    00035     Assert(Limit::inShortRange(getXAxis()));
    00036     Assert(Limit::inShortRange(getYAxis()));
    00037     Assert(Limit::inShortRange(getZAxis()));
    00038     binaryWriter->writeShort(getXAxis());
    00039     binaryWriter->writeShort(getYAxis());
    00040     binaryWriter->writeShort(getZAxis());
    00041     BitSet<u_char> buttonBit(0);
    00042     for(int i = 0; i < maxButtonCount; i++){
    00043         buttonBit.setIndexedBit(i, buttonPressed(i));
    00044     }
    00045     binaryWriter->writeUChar(buttonBit.getBits());
    00046 }
    00047 //------------------------------------------------------------------------------
    00048 // バイナリ読み込み
    00049 void MouseState::readBinary(BinaryReader* binaryReader){
    00050     setXAxis(binaryReader->readShort());
    00051     setYAxis(binaryReader->readShort());
    00052     setZAxis(binaryReader->readShort());
    00053     BitSet<u_char> buttonBit(binaryReader->readUChar());
    00054     for(int i = 0; i < maxButtonCount; i++){
    00055         setButtonPressed(i, buttonBit.getIndexedBit(i));
    00056     }
    00057 }
    00058 //------------------------------------------------------------------------------
    00059 } // End of namespace Lamp
    00060 //------------------------------------------------------------------------------