/*
 * Key.cpp
 *
 *  Created on: 2009-07-07
 *      Author: wasyl
 */

#include <allegro5/allegro.h>
#include "Primaries.h"
#include "../app/AppState.h"

/*************************************************/

Key::Key(int key)
	: Switch(true), mKey(key), mState(false)
{}

/*************************************************/

void Key::update()
{
	ALLEGRO_KEYBOARD_STATE *state = AppStateBase::current()->keyState();
	mState = al_key_down(state, mKey);
	updateDependent();
}

/*************************************************/

MouseKey::MouseKey(MouseKeyType which)
	: Switch(true), mWhich(which), mState(false)
{}

/*************************************************/

void MouseKey::update()
{
	ALLEGRO_MOUSE_STATE *state = AppStateBase::current()->mouseState();
	mState = al_mouse_button_down(state, mWhich);
	updateDependent();
}
