Files
Webcam/include/platform/input/input_mouse.cpp

103 lines
2.4 KiB
C++

/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "input/input_mouse.h"
using namespace GS::Input;
//------------------------------------------------------------------------------
bool Mouse::IsDown(KeyCode key) const
{
switch (key)
{
case Key_Button0: return state.left_button;
case Key_Button1: return state.right_button;
case Key_Button2: return state.middle_button;
default: break;
}
return false;
}
bool Mouse::WasDown(KeyCode key) const
{
switch (key)
{
case Key_Button0: return last_state.left_button;
case Key_Button1: return last_state.right_button;
case Key_Button2: return last_state.middle_button;
default: break;
}
return false;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool Mouse::GetInputRange(InputCode i, float &mn, float &mx) const
{
switch (i)
{
case Input_AxisX:
case Input_AxisY:
mn = 0; mx = 1;
return true;
case Input_RotX: // Horizontal wheel.
case Input_RotY: // Vertical wheel.
mn = 0; mx = 1024;
return true;
default: break;
}
return false;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
float Mouse::GetValue(InputCode i) const
{
switch (i)
{
case Input_AxisX: return state.x;
case Input_AxisY: return state.y;
case Input_RotX: return state.hwheel;
case Input_RotY: return state.wheel;
default: break;
}
return 0;
}
float Mouse::GetLastValue(InputCode i) const
{
switch (i)
{
case Input_AxisX: return last_state.x;
case Input_AxisY: return last_state.y;
case Input_RotX: return last_state.hwheel;
case Input_RotY: return last_state.wheel;
default: break;
}
return 0;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
Mouse::Mouse()
{
state.x = 0; state.y = 0;
state.left_button = false;
state.right_button = false;
state.middle_button = false;
state.wheel = 0;
state.hwheel = 0;
last_state = state;
}
//------------------------------------------------------------------------------