1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
/*
$Id: input.cpp,v 1.5 2001/05/06 19:02:03 sphair Exp $
------------------------------------------------------------------------
ClanLib, the platform independent game SDK.
This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
version 2. See COPYING for details.
For a total list of contributers see CREDITS.
------------------------------------------------------------------------
*/
#include "Core/precomp.h"
#include <API/Display/Input/input.h>
#include <API/Display/Input/inputdevice.h>
#include <API/Display/Input/inputbutton.h>
#include <API/Display/Input/inputcursor.h>
#include <API/Display/Input/keyboard.h>
#include <API/Display/Input/mouse.h>
std::vector<CL_Keyboard*> CL_Input::keyboards;
std::vector<CL_InputDevice*> CL_Input::joysticks;
std::vector<CL_InputDevice*> CL_Input::pointers;
CL_Signal_v2<CL_InputDevice *, const CL_Key&> CL_Input::sig_button_press;
CL_Signal_v2<CL_InputDevice *, const CL_Key&> CL_Input::sig_button_release;
CL_Signal_v3<CL_InputDevice *, int, int> CL_Input::sig_mouse_move;
CL_Signal_v2<int, int> CL_Mouse::sig_move;
bool CL_Keyboard::get_keycode(int button_no)
{
return CL_Input::keyboards[0]->get_button(button_no)->is_pressed();
}
int CL_Mouse::get_x()
{
return (int) CL_Input::pointers[0]->get_cursor(0)->get_x();
}
int CL_Mouse::get_y()
{
return (int) CL_Input::pointers[0]->get_cursor(0)->get_y();
}
bool CL_Mouse::left_pressed()
{
return CL_Input::pointers[0]->get_button(0)->is_pressed();
}
bool CL_Mouse::middle_pressed()
{
return CL_Input::pointers[0]->get_button(1)->is_pressed();
}
bool CL_Mouse::right_pressed()
{
return CL_Input::pointers[0]->get_button(2)->is_pressed();
}
|