00001 /********************************************************************************* 00002 * 00003 * Razor! Engine - A modular C++ presentation engine 00004 * 00005 * $Id: HardKeyManager.cpp,v 1.1.1.1 2000/12/09 09:28:39 christ Exp $ 00006 * 00007 * Copyright (c) 2000 Tilo Christ. All Rights Reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 * 00023 **********************************************************************************/ 00024 00025 00026 00027 #include "HardKeyManager.h" 00028 00029 00030 void HardKeyManager::init() 00031 { 00032 // Get the key repeat rate for when we want to restore it after the game. 00033 KeyRates(false, &oldInitDelay, &oldPeriod, &oldDoubleTapDelay, &oldQueueAhead); 00034 00035 setMask(keysAllowedMask); 00036 } 00037 00038 00039 void HardKeyManager::destroy() 00040 { 00041 releaseHardKeys(); 00042 } 00043 00044 00045 void HardKeyManager::captureHardKeys() 00046 { 00047 // Set the keys we poll to not generate events. This saves CPU cycles. 00048 KeySetMask( ~mask ); 00049 } 00050 00051 00052 void HardKeyManager::releaseHardKeys() 00053 { 00054 KeySetMask(keyBitsAll); 00055 KeyRates(true, &oldInitDelay, &oldPeriod, &oldDoubleTapDelay, &oldQueueAhead); 00056 } 00057 00058 00059 UInt32 HardKeyManager::getCurrentState() 00060 { 00061 return KeyCurrentState(); 00062 } 00063 00064 00065 void HardKeyManager::setMask(UInt32 mask) 00066 { 00067 HardKeyManager::mask = mask; 00068 } 00069 00070 00071 UInt32 HardKeyManager::mask; 00072 00073 UInt16 HardKeyManager::oldInitDelay; 00074 UInt16 HardKeyManager::oldPeriod; 00075 UInt16 HardKeyManager::oldDoubleTapDelay; 00076 Boolean HardKeyManager::oldQueueAhead;