commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
19
include/platform/input/input_keyboard.cpp
Normal file
19
include/platform/input/input_keyboard.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "input/input_keyboard.h"
|
||||
#include "memory/memory.h"
|
||||
|
||||
using namespace GS::Input;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Keyboard::Keyboard()
|
||||
{
|
||||
GS::Memory::Set(is_down, 0, sizeof(bool) * (uint)Key_Last);
|
||||
GS::Memory::Set(was_down, 0, sizeof(bool) * (uint)Key_Last);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
102
include/platform/input/input_mouse.cpp
Normal file
102
include/platform/input/input_mouse.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
96
include/platform/input/input_touch.cpp
Normal file
96
include/platform/input/input_touch.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "input/input_touch.h"
|
||||
#include "nstring/nstring.h"
|
||||
|
||||
using namespace GS::Input;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void TouchDevice::RegisterTouchEvent(float x, float y, float weight)
|
||||
{
|
||||
pending_state.button = asbool(weight > 0);
|
||||
pending_state.x = x;
|
||||
pending_state.y = y;
|
||||
}
|
||||
void TouchDevice::Update()
|
||||
{
|
||||
last_state = state;
|
||||
state = pending_state;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool TouchDevice::IsDown(KeyCode key) const
|
||||
{ return key == Key_Button0 ? state.button : false; }
|
||||
bool TouchDevice::WasDown(KeyCode key) const
|
||||
{ return key == Key_Button0 ? last_state.button : false; }
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool TouchDevice::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 TouchDevice::GetValue(InputCode i) const
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case Input_AxisX: return state.x;
|
||||
case Input_AxisY: return state.y;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
float TouchDevice::GetLastValue(InputCode i) const
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case Input_AxisX: return last_state.x;
|
||||
case Input_AxisY: return last_state.y;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void TouchDevice::SetIndex(int _index)
|
||||
{ index = _index; }
|
||||
Device::Type TouchDevice::GetType() const
|
||||
{ return index == -1 ? Type_Mouse : Type_Touch; }
|
||||
const char *TouchDevice::GetName() const
|
||||
{ return index == -1 ? "mouse" : GS::String::Format("touch%d", index).c_str(); }
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
TouchDevice::TouchDevice(int i) : index(i)
|
||||
{
|
||||
state.x = 0; state.y = 0;
|
||||
state.button = false;
|
||||
pending_state = last_state = state;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user