Browse Source

input: Removed previous input system

undefined
Benlitz Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
8a657ea287
21 changed files with 158 additions and 1833 deletions
  1. +0
    -6
      demos/tutorial/07_input.cpp
  2. +1
    -5
      src/core.h
  3. +3
    -2
      src/debug/fps.cpp
  4. +0
    -4
      src/eglapp.cpp
  5. +0
    -4
      src/input/controller.cpp
  6. +0
    -4
      src/input/controller.h
  7. +30
    -445
      src/input/input.cpp
  8. +83
    -425
      src/input/input.h
  9. +0
    -74
      src/input/inputdevice.cpp
  10. +0
    -126
      src/input/inputdevice.h
  11. +0
    -46
      src/input/inputdevice_internal.h
  12. +0
    -71
      src/input/keyboard.cpp
  13. +0
    -47
      src/input/keyboard.h
  14. +0
    -112
      src/input/stick.cpp
  15. +0
    -56
      src/input/stick.h
  16. +1
    -7
      src/lolcore.vcxproj
  17. +32
    -50
      src/lolcore.vcxproj.filters
  18. +1
    -22
      src/platform/d3d9/d3d9input.cpp
  19. +2
    -9
      src/platform/sdl/sdlapp.cpp
  20. +3
    -313
      src/platform/sdl/sdlinput.cpp
  21. +2
    -5
      src/platform/sdl/sdlinput.h

+ 0
- 6
demos/tutorial/07_input.cpp View File

@@ -25,7 +25,6 @@ class InputTutorial : public WorldEntity
public:
InputTutorial()
{
#if LOL_INPUT_V2
m_controller = new Controller(KEY_MAX, AXIS_MAX);

m_keyboard = InputDevice::Get("Keyboard");
@@ -46,7 +45,6 @@ public:
m_controller->GetAxis(AXIS_PITCH).Bind("Joystick1", "Axis2");
m_controller->GetAxis(AXIS_YAW).Bind("Joystick1", "Axis1");
}
#endif

m_pitch_angle = 0;
m_yaw_angle = 0;
@@ -90,7 +88,6 @@ public:
{
WorldEntity::TickGame(seconds);

#if LOL_INPUT_V2
/* Handle keyboard */
if (m_keyboard)
{
@@ -129,7 +126,6 @@ public:
m_mouse->GetCursorPixel(0).x, m_mouse->GetCursorPixel(0).y));
}
else
#endif
{
m_text->SetText("no mouse detected");
}
@@ -217,10 +213,8 @@ private:
AXIS_MAX
};

#if LOL_INPUT_V2
InputDevice *m_keyboard, *m_mouse, *m_joystick;
Controller *m_controller;
#endif

bool m_autorot;
float m_pitch_angle;


+ 1
- 5
src/core.h View File

@@ -124,14 +124,10 @@ static inline int isnan(float f)
#include "video.h"
#include "audio.h"
#include "scene.h"
#include "input/input.h"
#include "input/keyboard.h"
#include "input/stick.h"
#include "profiler.h"

// Input (v2)
// Input
#include "input/input.h"
#include "input/inputdevice.h"
#include "input/controller.h"

// Entities


+ 3
- 2
src/debug/fps.cpp View File

@@ -87,13 +87,14 @@ void DebugFps::TickGame(float seconds)
1e3f * Profiler::GetMax(Profiler::STAT_TICK_FRAME));
data->lines[4]->SetText(buf);
#else
sprintf(buf, "%2.2f/%2.2f/%2.2f/%2.2f %2.2f fps (%i)",
sprintf(buf, "%2.2f/%2.2f/%2.2f/%2.2f %2.2f fps (%i) %2.2f",
1e3f * Profiler::GetAvg(Profiler::STAT_TICK_GAME),
1e3f * Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
1e3f * Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
1e3f * Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
1.0f / Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
Ticker::GetFrameNum());
1e3f * Profiler::GetAvg(Profiler::STAT_USER_00),
Ticker::GetFrameNum());
data->lines[0]->SetText(buf);
#endif
}


+ 0
- 4
src/eglapp.cpp View File

@@ -251,11 +251,7 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
# endif

# if defined USE_SDL
# if defined LOL_INPUT_V2
new SdlInput(res.x, res.y, data->screen_size.x, data->screen_size.y);
# else
new SdlInput();
# endif
# endif

/* Initialise everything */


+ 0
- 4
src/input/controller.cpp View File

@@ -14,8 +14,6 @@

#include "core.h"

#ifdef LOL_INPUT_V2

namespace lol
{

@@ -137,5 +135,3 @@ Array<Controller*> Controller::DeactivateAll()
}

} /* namespace lol */

#endif // LOL_INPUT_V2

+ 0
- 4
src/input/controller.h View File

@@ -13,8 +13,6 @@

#include "core.h"

#if defined LOL_INPUT_V2

namespace lol
{

@@ -98,7 +96,5 @@ private:

} /* namespace lol */

#endif // LOL_INPUT_V2

#endif // __LOL_INPUT_CONTROLLER_H__


+ 30
- 445
src/input/input.cpp View File

@@ -1,484 +1,69 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2013 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//


#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>

#include "core.h"

#ifndef LOL_INPUT_V2
#include "input/input_internal.h"

namespace lol
{

/*
* Input implementation class
*/

InputTracker* Input::m_input_tracker = nullptr;

static class InputData
{
friend class Input;

public:
InputData()
: mouse(-1),
buttons(0),
nentities(0),
lastfocus(0)
{
m_keystate.Resize(Key::Last);
memset(&m_keystate[0], 0, m_keystate.Bytes());
}

private:
ivec2 mouse;
uint32_t buttons;

Array<uint8_t> m_keystate;

static int const MAX_ENTITIES = 100;
WorldEntity *entities[MAX_ENTITIES];
int nentities;
WorldEntity *lastfocus;

Array<Stick *> m_sticks;
}
inputdata;

static InputData * const data = &inputdata;

/*
* ButtonSetting class
*/

int ButtonSetting::GetActionSettingIdx(Action a)
{
for (int i = 0; i < m_associated_action_list.Count(); i++)
if (ACTION_CMP(m_associated_action_list[i].m_action, a))
return i;
return -1;
}

/*
* InputTracker class
*/

InputTracker::InputTracker()
{
m_gamegroup = GAMEGROUP_BEFORE;

for (int i = 0; i < Key::Last * 2; ++i)
m_input_status << 0;

Ticker::Ref(this);
}

//Internal
int InputTracker::GetButtonSettingIdx(Key k)
{
for (int i = 0; i < m_input_assocation_list.Count(); i++)
if (m_input_assocation_list[i].m_raw_button == k)
return i;
return -1;
}

//-----
int InputTracker::GetCurrentButtonStatus(Key k)
{
if (k < m_input_status.Count())
return m_input_status[k];
return 0;
}

//-----
int InputTracker::GetPreviousButtonStatus(Key k)
{
if (k < m_input_status.Count())
return m_input_status[(int)k + (int)Key::Last];
return 0;
}

//Internal : Updates the action status & timers
void InputTracker::UpdateActionStatus(float seconds)
{
Array<uint8_t> &keystate = Input::GetKeyboardState();

//SOOOoooo ugly.
for (int i = 0; i < Key::Last; ++i)
{
m_input_status[i + Key::Last] = m_input_status[i];
m_input_status[i] = keystate[i];
}

for (int i = 0; i < m_input_assocation_list.Count(); i++)
{
ButtonSetting &CurIT = m_input_assocation_list[i];

for (int j = 0; j < CurIT.m_associated_action_list.Count(); j++)
{
ActionSetting &CurAS = CurIT.m_associated_action_list[j];

if (CurAS.m_buffered_since <= CurAS.m_buffering_time)
CurAS.m_buffered_since += seconds;

if (GetCurrentButtonStatus(CurIT.m_raw_button) &&
CurAS.m_buffering_time >= .0f)
CurAS.m_buffered_since = .0f;
}
}
}

//Helps link a software input Action-Id to an hardware input Button-Id.
void InputTracker::LinkActionToKey(Action a, Key k)
{
int ITIdx = GetButtonSettingIdx(k);
if (ITIdx == -1)
{
ITIdx = m_input_assocation_list.Count();
m_input_assocation_list << ButtonSetting(k);
}

ButtonSetting &CurIT = m_input_assocation_list[ITIdx];

int ASIdx = CurIT.GetActionSettingIdx(a);
if (ASIdx == -1)
{
ASIdx = CurIT.m_associated_action_list.Count();
CurIT.m_associated_action_list << ActionSetting(a);
}
}

//Helps unlink a software input Action-Id to an hardware input k-Id.
void InputTracker::UnlinkAction(Action a)
{
for (int i = 0; i < m_input_assocation_list.Count(); i++)
{
ButtonSetting &CurIT = m_input_assocation_list[i];
int ASIdx = CurIT.GetActionSettingIdx(a);
if (ASIdx != -1)
CurIT.m_associated_action_list.Remove(ASIdx);
}
}

//Returns the current status of a given action
int InputTracker::GetStatus(Action a)
{
for (int i = 0; i < m_input_assocation_list.Count(); i++)
{
ButtonSetting &CurIT = m_input_assocation_list[i];
int ASIdx = CurIT.GetActionSettingIdx(a);
if (ASIdx != -1)
{
ActionSetting &CurAS = CurIT.m_associated_action_list[ASIdx];

if (CurAS.m_buffering_time >= .0f && CurAS.m_buffered_since <= CurAS.m_buffering_time)
return 1;
return 0;
}
}
return 0;
}

//Returns TRUE if action status went from Active to Inactive this frame
bool InputTracker::WasReleased(Action a)
{
for (int i = 0; i < m_input_assocation_list.Count(); i++)
{
ButtonSetting &CurIT = m_input_assocation_list[i];
int ASIdx = CurIT.GetActionSettingIdx(a);
if (ASIdx != -1)
{

if (GetPreviousButtonStatus(CurIT.m_raw_button) &&
!GetCurrentButtonStatus(CurIT.m_raw_button))
return true;
return false;
}
}
return false;
}

//Returns TRUE if action status went from Inactive to Active this frame
bool InputTracker::WasPressed(Action a)
{
for (int i = 0; i < m_input_assocation_list.Count(); i++)
{
ButtonSetting &CurIT = m_input_assocation_list[i];
int ASIdx = CurIT.GetActionSettingIdx(a);
if (ASIdx != -1)
{
if (!GetPreviousButtonStatus(CurIT.m_raw_button) &&
GetCurrentButtonStatus(CurIT.m_raw_button))
return true;
return false;
}
}
return false;
}

//Returns the current status of a given action
int InputTracker::GetStatus(Key k)
{
return GetCurrentButtonStatus(k);
}

//Returns TRUE if action status went from Active to Inactive this frame
bool InputTracker::WasReleased(Key k)
{
if (GetPreviousButtonStatus(k) &&
!GetCurrentButtonStatus(k))
return true;
return false;
}

//Returns TRUE if action status went from Inactive to Active this frame
bool InputTracker::WasPressed(Key k)
{
if (!GetPreviousButtonStatus(k) &&
GetCurrentButtonStatus(k))
return true;
return false;
}

/*
* Public Input class
*/

#if 0
vec2 Input::GetAxis(int axis)
{
vec2 ret;

/* Simulate a joystick using the keyboard. */
int left = GetKeyState(Key::D) - (GetKeyState(Key::A) | GetKeyState(Key::Q));
int up = (GetKeyState(Key::W) | GetKeyState(Key::Z)) - GetKeyState(Key::S);
ret.x += left;
ret.y += up;
if (left && up)
ret = ret * sqrtf(0.5f);

return ret;
}
#endif

ivec2 Input::GetMousePos()
{
return data->mouse;
}

uint32_t Input::GetMouseButtons()
{
return data->buttons;
}

Array<uint8_t> &Input::GetKeyboardState()
{
return data->m_keystate;
}

int Input::GetKeyState(int key)
{
return data->m_keystate[key];
}

//Helps link a software input Action-Id to an hardware input Button-Id.
void Input::LinkActionToKey(Action a, Key k)
{
if (CheckInputTrackerInit())
Input::m_input_tracker->LinkActionToKey(a, k);
}

//Helps unlink a software input Action-Id to an hardware input Button-Id.
void Input::UnlinkAction(Action a)
{
if (CheckInputTrackerInit())
Input::m_input_tracker->UnlinkAction(a);
}

//Returns the current status of a given action
int Input::GetStatus(Action a)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->GetStatus(a);
return 0;
}

//Returns TRUE if action status when from Active to Inactive this frame
bool Input::WasPressed(Action a)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->WasPressed(a);
return false;
}

//Returns TRUE if action status when from Active to Inactive this frame
bool Input::WasReleased(Action a)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->WasReleased(a);
return false;
}

//Returns the current status of a given action
int Input::GetStatus(Key k)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->GetStatus(k);
return 0;
}

//Returns TRUE if action status when from Active to Inactive this frame
bool Input::WasPressed(Key k)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->WasPressed(k);
return false;
}

//Returns TRUE if action status when from Active to Inactive this frame
bool Input::WasReleased(Key k)
{
if (CheckInputTrackerInit())
return Input::m_input_tracker->WasReleased(k);
return false;
}

//--
void Input::TrackMouse(WorldEntity *e)
{
if (data->nentities >= InputData::MAX_ENTITIES)
return;
data->entities[data->nentities] = e;
data->nentities++;
}
Array<InputDevice*> InputDevice::devices;
bool InputDevice::m_capturemouse;

void Input::UntrackMouse(WorldEntity *e)
void InputDeviceInternal::AddKey(const char* name)
{
for (int n = 0; n < data->nentities; n++)
{
if (data->entities[n] != e)
continue;

data->entities[n] = data->entities[data->nentities - 1];
data->nentities--;
n--;
}
m_keynames.Push(name);
m_keys.Push(false);
}

void Input::SetMousePos(ivec2 coord)
void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
{
data->mouse = coord;

WorldEntity *top = nullptr;

/* Find the top “widget” amongst all entities that match the
* mouse coordinates */
for (int n = 0; n < data->nentities; n++)
{
if (coord.x < data->entities[n]->m_bbox[0].x
|| coord.x >= data->entities[n]->m_bbox[1].x
|| coord.y < data->entities[n]->m_bbox[0].y
|| coord.y >= data->entities[n]->m_bbox[1].y)
continue;

if (!top || top->m_bbox[1].z < data->entities[n]->m_bbox[1].z)
top = data->entities[n];
}

for (int n = 0; n < data->nentities; n++)
{
if (data->entities[n] == top)
{
data->entities[n]->m_mousepos = coord - (ivec2)top->m_bbox[0].xy;
if (top != data->lastfocus)
data->entities[n]->m_pressed = data->buttons;
else
data->entities[n]->m_clicked = 0;
}
else
{
data->entities[n]->m_mousepos = ivec2(-1);
/* FIXME */
data->entities[n]->m_released = 0;
data->entities[n]->m_pressed = 0;
data->entities[n]->m_clicked = 0;
}
}

data->lastfocus = top;
m_axisnames.Push(name);
m_axis.Push(0.0f, sensitivity);
}

void Input::SetMouseButton(int index)
void InputDeviceInternal::AddCursor(const char* name)
{
uint32_t flag = 1 << index;
data->buttons |= flag;

if (data->lastfocus)
{
if (!(data->lastfocus->m_pressed & flag))
data->lastfocus->m_clicked |= flag;
data->lastfocus->m_pressed |= flag;
data->lastfocus->m_released &= ~flag;
}
m_cursornames.Push(name);
m_cursors.Push(vec2(0.0), ivec2(0));
}

void Input::UnsetMouseButton(int index)
InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
{
uint32_t flag = 1 << index;
data->buttons &= ~flag;

if (data->lastfocus)
{
if (!(data->lastfocus->m_pressed & flag))
data->lastfocus->m_released |= flag;
data->lastfocus->m_pressed &= ~flag;
data->lastfocus->m_clicked &= ~flag;
}
InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
/* "value" is unused, what matters is the index. */
# define KEY_FUNC(key, value) \
keyboard->AddKey(#key);
# undef KEY_FUNC
return keyboard;
}

Stick *Input::CreateStick()
InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
{
Stick *stick = new Stick();
Ticker::Ref(stick);
data->m_sticks.Push(stick);
return stick;
}
InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
mouse->AddKey("ButtonLeft");
mouse->AddKey("ButtonMiddle");
mouse->AddKey("ButtonRight");

void Input::DestroyStick(Stick *stick)
{
for (int i = 0; i < data->m_sticks.Count(); i++)
if (data->m_sticks[i] == stick)
data->m_sticks.Remove(i);
Ticker::Unref(stick);
}
mouse->AddAxis("X");
mouse->AddAxis("Y");

Stick *Input::TrackStick(int desired)
{
/* FIXME: add the possibility to choose amongst sticks */
if (desired >= data->m_sticks.Count())
return nullptr;
Ticker::Ref(data->m_sticks[desired]);
return data->m_sticks[desired];
}
mouse->AddCursor("Cursor");

void Input::UntrackStick(Stick *stick)
{
Ticker::Unref(stick);
// TODO: extended button, and wheel (as axis or as buttons? or both?)
return mouse;
}

} /* namespace lol */

#endif // !LOL_INPUT_V2

+ 83
- 425
src/input/input.h View File

@@ -1,464 +1,122 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2013 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

//
// The Input static class
// ----------------------
//

#if !defined __LOL_INPUT_INPUT_H__
#define __LOL_INPUT_INPUT_H__

#include <cstring>
#include <string.h>
#if !defined __LOL_INPUT_H__
#define __LOL_INPUT_H__

#include "core.h"

#ifndef LOL_INPUT_V2

#include "lol/math/vector.h"
#include "input/keyboard.h"
#include "input/stick.h"

namespace lol
{

typedef std::string Action;
static inline int ACTION_CMP(Action a, Action b) { return a.compare(b) == 0; }

class WorldEntity;

/*
* The key enumeration values match libSDL's so that we can
* easily pass information between Lol and SDL.
*/
struct Key
class InputDevice
{
enum Value
{
/* ASCII mapped keys */
Unknown = 0,
First = 0,
Backspace = 8,
Tab = (int)'\t',
Clear = 12,
Return = 13,
Pause = 19,
Escape = 27,
Space = (int)' ',
Exclaim = (int)'!',
DoubleQuote = (int)'"',
Hash = (int)'#',
Dollar = (int)'$',
Ampersand = (int)'&',
Quote = (int)'\'',
LeftParen = (int)'(',
RightParen = (int)')',
Asterisk = (int)'*',
Plus = (int)'+',
Comma = (int)',',
Minus = (int)'-',
Period = (int)'.',
Slash = (int)'/',
K0 = (int)'0',
K1 = (int)'1',
K2 = (int)'2',
K3 = (int)'3',
K4 = (int)'4',
K5 = (int)'5',
K6 = (int)'6',
K7 = (int)'7',
K8 = (int)'8',
K9 = (int)'9',
Colon = (int)':',
Semicolon = (int)';',
Less = (int)'<',
Equals = (int)'=',
Greater = (int)'>',
Question = (int)'?',
At = (int)'@',
/* XXX: SDL decides to skip uppercase characters */
LeftBracket = (int)'[',
BackSlash = (int)'\\',
RightBracket = (int)']',
Caret = (int)'^',
Underscore = (int)'_',
Backquote = (int)'`',
A = (int)'a',
B = (int)'b',
C = (int)'c',
D = (int)'d',
E = (int)'e',
F = (int)'f',
G = (int)'g',
H = (int)'h',
I = (int)'i',
J = (int)'j',
K = (int)'k',
L = (int)'l',
M = (int)'m',
N = (int)'n',
O = (int)'o',
P = (int)'p',
Q = (int)'q',
R = (int)'r',
S = (int)'s',
T = (int)'t',
U = (int)'u',
V = (int)'v',
W = (int)'w',
X = (int)'x',
Y = (int)'y',
Z = (int)'z',
Delete = 127,

/* International keyboard syms */
World0 = 160, /* 0xA0 */
World1 = 161,
World2 = 162,
World3 = 163,
World4 = 164,
World5 = 165,
World6 = 166,
World7 = 167,
World8 = 168,
World9 = 169,
World10 = 170,
World11 = 171,
World12 = 172,
World13 = 173,
World14 = 174,
World15 = 175,
World16 = 176,
World17 = 177,
World18 = 178,
World19 = 179,
World20 = 180,
World21 = 181,
World22 = 182,
World23 = 183,
World24 = 184,
World25 = 185,
World26 = 186,
World27 = 187,
World28 = 188,
World29 = 189,
World30 = 190,
World31 = 191,
World32 = 192,
World33 = 193,
World34 = 194,
World35 = 195,
World36 = 196,
World37 = 197,
World38 = 198,
World39 = 199,
World40 = 200,
World41 = 201,
World42 = 202,
World43 = 203,
World44 = 204,
World45 = 205,
World46 = 206,
World47 = 207,
World48 = 208,
World49 = 209,
World50 = 210,
World51 = 211,
World52 = 212,
World53 = 213,
World54 = 214,
World55 = 215,
World56 = 216,
World57 = 217,
World58 = 218,
World59 = 219,
World60 = 220,
World61 = 221,
World62 = 222,
World63 = 223,
World64 = 224,
World65 = 225,
World66 = 226,
World67 = 227,
World68 = 228,
World69 = 229,
World70 = 230,
World71 = 231,
World72 = 232,
World73 = 233,
World74 = 234,
World75 = 235,
World76 = 236,
World77 = 237,
World78 = 238,
World79 = 239,
World80 = 240,
World81 = 241,
World82 = 242,
World83 = 243,
World84 = 244,
World85 = 245,
World86 = 246,
World87 = 247,
World88 = 248,
World89 = 249,
World90 = 250,
World91 = 251,
World92 = 252,
World93 = 253,
World94 = 254,
World95 = 255, /* 0xFF */

/* Numeric keypad */
KP0 = 256,
KP1 = 257,
KP2 = 258,
KP3 = 259,
KP4 = 260,
KP5 = 261,
KP6 = 262,
KP7 = 263,
KP8 = 264,
KP9 = 265,
KPPeriod = 266,
KPDivide = 267,
KPMultiply = 268,
KPMinus = 269,
KPPlus = 270,
KPEnter = 271,
KPEquals = 272,
public:
/** Get the name of this input device */
const String& GetName();

/** Get the index of the corresponding key, needed to call GetKey */
int GetKeyIndex(const char* name) const { return GetItemIndex(name, m_keynames); }
/** Get the index of the corresponding axis, needed to call GetAxis */
int GetAxisIndex(const char* name) const { return GetItemIndex(name, m_axisnames); }
/** Get the index of the corresponding cursor, needed to call GetCursor */
int GetCursorIndex(const char* name) const { return GetItemIndex(name, m_cursornames); }

/** Get the current state of the given key, true being pressed and false being released */
bool GetKey(int index) const { return m_keys[index]; }
/** Get the current value of the given axis. Devices should cap this value between -1 and 1 as much as possible, through it is not guaranteed */
float GetAxis(int index) const { return m_axis[index].m1 * m_axis[index].m2; }
/** Get the current value of the given cursor, 0,0 being the bottom-left corner and 1,1 being the top-right corner */
vec2 GetCursor(int index) const { return m_cursors[index].m1; }
/** Get the coordinate of the pixel the cursor is currently over, 0,0 being the bottom-left corner. */
ivec2 GetCursorPixel(int index) const { return m_cursors[index].m2; }


/** Set a per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
void SetAxisSensitivity(int index, float sensitivity) { m_axis[index].m2 = sensitivity; }
/** Get the per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
float GetAxisSensitivity(int index) const { return m_axis[index].m2; }

/** Get a list of the name of all available keys in this device */
const Array<String>& GetAllKeys() const { return m_keynames; }
/** Get a list of the name of all available axis in this device */
const Array<String>& GetAllAxis() const { return m_axisnames; }
/** Get a list of the name of all available cursors in this device */
const Array<String>& GetAllCursors() const { return m_cursornames; }

/** Get an input device by its name */
static InputDevice* Get(const char* name) { return GetDevice(name); }
/** Set whether the mouse cursor should be captured. */
static void CaptureMouse(bool activated) { m_capturemouse = activated; }

/* Arrows + Home/End pad */
Up = 273,
Down = 274,
Right = 275,
Left = 276,
Insert = 277,
Home = 278,
End = 279,
PageUp = 280,
PageDown = 281,
protected:
// TODO: hide all of this in a InputDeviceData?

/* Function keys */
F1 = 282,
F2 = 283,
F3 = 284,
F4 = 285,
F5 = 286,
F6 = 287,
F7 = 288,
F8 = 289,
F9 = 290,
F10 = 291,
F11 = 292,
F12 = 293,
F13 = 294,
F14 = 295,
F15 = 296,
String m_name;

/* Modifier keys */
NumLock = 300,
CapsLock = 301,
ScrollLock= 302,
RightShift = 303,
LeftShift = 304,
RightCtrl = 305,
LeftCtrl = 306,
RightAlt = 307,
LeftAlt = 308,
RightMeta = 309,
LeftMeta = 310,
LeftSuper = 311, /* Left "Windows" key */
RightSuper = 312, /* Right "Windows" key */
Mode = 313, /* "Alt Gr" key */
Compose = 314, /* Multi-key compose key */
Array<String> m_keynames;
Array<String> m_axisnames;
Array<String> m_cursornames;

/* Miscellaneous function keys */
Help = 315,
Print = 316,
SysReq = 317,
Break = 318,
Menu = 319,
Power = 320, /* Power Macintosh power key */
Euro = 321, /* Some european keyboards */
Undo = 322, /* Atari keyboard has Undo */
/** key states (pressed/released) */
Array<bool> m_keys;
/** axis states (value and sensitivity) */
Array<float, float> m_axis;
/** cursor position */
Array<vec2, ivec2> m_cursors;

/* Add any other keys here */
Last
static bool m_capturemouse;

InputDevice(const char* name) : m_name(name)
{
devices.Push(this);
}
m_value;

//BH : Removed KMod from main enum, because I don't have any idea about handling them correctly for now.
/*
//Enumeration of valid key mods (possibly OR'd together)
KM_NONE = 0x0000,
KM_LSHIFT = 0x0001,
KM_RSHIFT = 0x0002,
KM_LCTRL = 0x0040,
KM_RCTRL = 0x0080,
KM_LALT = 0x0100,
KM_RALT = 0x0200,
KM_LMETA = 0x0400,
KM_RMETA = 0x0800,
KM_NUM = 0x1000,
KM_CAPS = 0x2000,
KM_MODE = 0x4000,

KM_RESERVED = 0x8000,

//Left/Right independent key mods definition
KM_CTRL = (KM_LCTRL|KM_RCTRL),
KM_SHIFT = (KM_LSHIFT|KM_RSHIFT),
KM_ALT = (KM_LALT|KM_RALT),
KM_META = (KM_LMETA|KM_RMETA),
*/

inline Key(Value v) { m_value = v; }
inline operator Value() { return m_value; }
inline bool operator==(const Key& val)
~InputDevice()
{
return m_value == val.m_value;
for (int i = 0; i < devices.Count(); ++i)
{
if (devices[i] == this)
{
devices.Remove(i);
return;
}
}
}
};

struct ActionSetting
{
Action m_action;
float m_buffering_time;
float m_buffered_since;

ActionSetting(Action NewAction)
: m_action(NewAction),
m_buffering_time(.0f),
m_buffered_since(.0f)
{ }
};

struct ButtonSetting
{
Key m_raw_button;
Array<ActionSetting> m_associated_action_list;

ButtonSetting(Key NewRawButton)
: m_raw_button(NewRawButton)
{ }

int GetActionSettingIdx(Action SearchAction);
};

class InputTracker : public Entity
{
friend class Input;

public:
InputTracker();

private:
Array<uint8_t> m_input_status;
Array<ButtonSetting> m_input_assocation_list;

int GetButtonSettingIdx(struct Key k);
int GetCurrentButtonStatus(struct Key k);
int GetPreviousButtonStatus(struct Key k);
void UpdateActionStatus(float seconds);
static Array<InputDevice*> devices;

protected:
virtual char const * GetName()
{
return "<InputTracker>";
}
virtual void TickGame(float seconds)
template <typename T>
int GetItemIndex(const char* name, const Array<String, T>& Array) const
{
Entity::TickGame(seconds);

UpdateActionStatus(seconds);
for (int i = 0; i < Array.Count(); ++i)
{
if (Array[i] == name)
return i;
}
return -1;
}

void LinkActionToKey(Action a, struct Key k);
void UnlinkAction(Action a);
int GetStatus(Action a);
bool WasPressed(Action a);
bool WasReleased(Action a);

//You should probably use the Action System
int GetStatus(Key k);
bool WasPressed(Key k);
bool WasReleased(Key k);
};

class Input
{
private:
static InputTracker* m_input_tracker;

static bool CheckInputTrackerInit()
static InputDevice* GetDevice(const char* name)
{
if (Input::m_input_tracker)
return true;

Input::m_input_tracker = new InputTracker();
return true;
for (int i = 0; i < devices.Count(); ++i)
{
if (devices[i]->m_name == name)
return devices[i];
}
return nullptr;
}

public:

/* These methods are general queries */
static ivec2 GetMousePos();
static uint32_t GetMouseButtons();

/* Action management */
static void LinkActionToKey(Action a, struct Key k);
static void UnlinkAction(Action a);
static int GetStatus(Action a);
static bool WasPressed(Action a);
static bool WasReleased(Action a);

/* Raw Button management. You should use actions. */
static int GetStatus(Key k);
static bool WasPressed(Key k);
static bool WasReleased(Key k);

/* Entities can subscribe to events */
static void TrackMouse(WorldEntity *e);
static void UntrackMouse(WorldEntity *e);

/* These methods are called by the underlying input listeners */
/* FIXME: this should disappear and be replaced by an input
* system that abstracts mice */
static void SetMousePos(ivec2 coord);
static void SetMouseButton(int index);
static void UnsetMouseButton(int index);

/* Keyboard handling */
static Array<uint8_t> &GetKeyboardState();
static int GetKeyState(int key);

static Keyboard *CreateKeyboard();
static void DestroyKeyboard(Keyboard *keyboard);

static Keyboard *TrackKeyboard(int desired);
static void UntrackKeyboard(Keyboard *keyboard);

/* Joystick handling */
static Stick *CreateStick();
static void DestroyStick(Stick *stick);

static Stick *TrackStick(int desired);
static void UntrackStick(Stick *stick);
};

} /* namespace lol */

#endif // !LOL_INPUT_V2

#endif // __LOL_INPUT_INPUT_H__
#endif // __LOL_INPUT_H__


+ 0
- 74
src/input/inputdevice.cpp View File

@@ -1,74 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include "core.h"

#ifdef LOL_INPUT_V2

#include "input/inputdevice_internal.h"

namespace lol
{

Array<InputDevice*> InputDevice::devices;
bool InputDevice::m_capturemouse;

void InputDeviceInternal::AddKey(const char* name)
{
m_keynames.Push(name);
m_keys.Push(false);
}

void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
{
m_axisnames.Push(name);
m_axis.Push(0.0f, sensitivity);
}

void InputDeviceInternal::AddCursor(const char* name)
{
m_cursornames.Push(name);
m_cursors.Push(vec2(0.0), ivec2(0));
}

InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
{
InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
/* "value" is unused, what matters is the index. */
# define KEY_FUNC(key, value) \
keyboard->AddKey(#key);
# include "input/keys.h"
# undef KEY_FUNC
return keyboard;
}

InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
{
InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
mouse->AddKey("ButtonLeft");
mouse->AddKey("ButtonMiddle");
mouse->AddKey("ButtonRight");

mouse->AddAxis("X");
mouse->AddAxis("Y");

mouse->AddCursor("Cursor");

// TODO: extended button, and wheel (as axis or as buttons? or both?)
return mouse;
}

} /* namespace lol */

#endif // LOL_INPUT_V2

+ 0
- 126
src/input/inputdevice.h View File

@@ -1,126 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if !defined __LOL_INPUT_DEVICE_H__
#define __LOL_INPUT_DEVICE_H__

#include "core.h"

#if defined LOL_INPUT_V2

namespace lol
{

class InputDevice
{
public:
/** Get the name of this input device */
const String& GetName();

/** Get the index of the corresponding key, needed to call GetKey */
int GetKeyIndex(const char* name) const { return GetItemIndex(name, m_keynames); }
/** Get the index of the corresponding axis, needed to call GetAxis */
int GetAxisIndex(const char* name) const { return GetItemIndex(name, m_axisnames); }
/** Get the index of the corresponding cursor, needed to call GetCursor */
int GetCursorIndex(const char* name) const { return GetItemIndex(name, m_cursornames); }

/** Get the current state of the given key, true being pressed and false being released */
bool GetKey(int index) const { return m_keys[index]; }
/** Get the current value of the given axis. Devices should cap this value between -1 and 1 as much as possible, through it is not guaranteed */
float GetAxis(int index) const { return m_axis[index].m1 * m_axis[index].m2; }
/** Get the current value of the given cursor, 0,0 being the bottom-left corner and 1,1 being the top-right corner */
vec2 GetCursor(int index) const { return m_cursors[index].m1; }
/** Get the coordinate of the pixel the cursor is currently over, 0,0 being the bottom-left corner. */
ivec2 GetCursorPixel(int index) const { return m_cursors[index].m2; }


/** Set a per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
void SetAxisSensitivity(int index, float sensitivity) { m_axis[index].m2 = sensitivity; }
/** Get the per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
float GetAxisSensitivity(int index) const { return m_axis[index].m2; }

/** Get a list of the name of all available keys in this device */
const Array<String>& GetAllKeys() const { return m_keynames; }
/** Get a list of the name of all available axis in this device */
const Array<String>& GetAllAxis() const { return m_axisnames; }
/** Get a list of the name of all available cursors in this device */
const Array<String>& GetAllCursors() const { return m_cursornames; }

/** Get an input device by its name */
static InputDevice* Get(const char* name) { return GetDevice(name); }
/** Set whether the mouse cursor should be captured. */
static void CaptureMouse(bool activated) { m_capturemouse = activated; }

protected:
// TODO: hide all of this in a InputDeviceData?

String m_name;

Array<String> m_keynames;
Array<String> m_axisnames;
Array<String> m_cursornames;

/** key states (pressed/released) */
Array<bool> m_keys;
/** axis states (value and sensitivity) */
Array<float, float> m_axis;
/** cursor position */
Array<vec2, ivec2> m_cursors;

static bool m_capturemouse;

InputDevice(const char* name) : m_name(name)
{
devices.Push(this);
}

~InputDevice()
{
for (int i = 0; i < devices.Count(); ++i)
{
if (devices[i] == this)
{
devices.Remove(i);
return;
}
}
}

private:
static Array<InputDevice*> devices;

template <typename T>
int GetItemIndex(const char* name, const Array<String, T>& Array) const
{
for (int i = 0; i < Array.Count(); ++i)
{
if (Array[i] == name)
return i;
}
return -1;
}

static InputDevice* GetDevice(const char* name)
{
for (int i = 0; i < devices.Count(); ++i)
{
if (devices[i]->m_name == name)
return devices[i];
}
return nullptr;
}
};

} /* namespace lol */

#endif // LOL_INPUT_V2

#endif // __LOL_INPUT_DEVICE_H__


+ 0
- 46
src/input/inputdevice_internal.h View File

@@ -1,46 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if !defined __LOL_INPUT_DEVICE_INTERNAL_H__
#define __LOL_INPUT_DEVICE_H__

#include "core.h"

#if defined LOL_INPUT_V2

namespace lol
{

/** Internal class (not public) that allows to construct an InputDevice dynamically, when the keys, axis and cursors are not known at compile time */
class InputDeviceInternal : InputDevice
{
public:
InputDeviceInternal(const char* name) : InputDevice(name) { }

void AddKey(const char* name);
void AddAxis(const char* name, float sensitivity = 1.0f);
void AddCursor(const char* name);

void SetKey(int index, bool state) { m_keys[index] = state; }
void SetAxis(int index, float value) { m_axis[index].m1 = value; }
void SetCursor(int index, const vec2& position, const ivec2& pixel) { m_cursors[index].m1 = position; m_cursors[index].m2 = pixel; }

static bool GetMouseCapture() { return m_capturemouse; }

static InputDeviceInternal* CreateStandardKeyboard();
static InputDeviceInternal* CreateStandardMouse();
};

} /* namespace lol */

#endif // LOL_INPUT_V2

#endif // __LOL_INPUT_DEVICE_INTERNAL_H__


+ 0
- 71
src/input/keyboard.cpp View File

@@ -1,71 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>

#include "core.h"

#ifndef LOL_INPUT_V2

namespace lol
{

/*
* Keyboard implementation class
*/

static class KeyboardData
{
friend class Keyboard;

public:
KeyboardData() { }

private:
Array<uint32_t> m_chars;
}
keyboarddata;

/*
* Public Keyboard class
*/

Keyboard::Keyboard()
: m_data(new KeyboardData())
{
}

Keyboard::~Keyboard()
{
delete m_data;
}

void Keyboard::PushChar(uint32_t ch)
{
m_data->m_chars.Push(ch);
}

uint32_t Keyboard::PopChar()
{
if (!m_data->m_chars.Count())
return 0;

uint32_t ret = m_data->m_chars[0];
m_data->m_chars.Remove(0);
return ret;
}

} /* namespace lol */

#endif // !LOL_INPUT_V2

+ 0
- 47
src/input/keyboard.h View File

@@ -1,47 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

//
// The Keyboard class
// ------------------
//

#if !defined __LOL_INPUT_KEYBOARD_H__
#define __LOL_INPUT_KEYBOARD_H__

#include "entity.h"

#ifndef LOL_INPUT_V2

namespace lol
{

class KeyboardData;

class Keyboard : public Entity
{
friend class Input;

public:
void PushChar(uint32_t ch);
uint32_t PopChar();

private:
Keyboard();
~Keyboard();
KeyboardData *m_data;
};

} /* namespace lol */

#endif // !LOL_INPUT_V2

#endif // __LOL_INPUT_KEYBOARD_H__


+ 0
- 112
src/input/stick.cpp View File

@@ -1,112 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>

#include "core.h"

#ifndef LOL_INPUT_V2

namespace lol
{

/*
* Stick implementation class
*/

static class StickData
{
friend class Stick;

public:
StickData() { }

private:
/* First element is the remap target */
Array<int, float> m_axes;
Array<int, int> m_buttons;
}
stickdata;

/*
* Public Stick class
*/

Stick::Stick()
: m_data(new StickData())
{
}

Stick::~Stick()
{
delete m_data;
}

void Stick::SetAxisCount(int n)
{
m_data->m_axes.Empty();
for (int i = 0; i < n; i++)
m_data->m_axes.Push(i, 0.f);
}

void Stick::SetButtonCount(int n)
{
m_data->m_buttons.Empty();
for (int i = 0; i < n; i++)
m_data->m_buttons.Push(i, 0);
}

void Stick::SetAxis(int n, float val)
{
m_data->m_axes[m_data->m_axes[n].m1].m2 = val;
}

void Stick::SetButton(int n, int val)
{
m_data->m_buttons[m_data->m_buttons[n].m1].m2 = val;
}

void Stick::RemapAxis(int src, int dst)
{
m_data->m_axes[src].m1 = dst;
}

void Stick::RemapButton(int src, int dst)
{
m_data->m_buttons[src].m1 = dst;
}

int Stick::GetAxisCount()
{
return m_data->m_axes.Count();
}

int Stick::GetButtonCount()
{
return m_data->m_buttons.Count();
}

float Stick::GetAxis(int n)
{
return m_data->m_axes[n].m2;
}

int Stick::GetButton(int n)
{
return m_data->m_buttons[n].m2;
}

} /* namespace lol */

#endif // !LOL_INPUT_V2

+ 0
- 56
src/input/stick.h View File

@@ -1,56 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

//
// The Stick class
// ---------------
//

#if !defined __LOL_INPUT_STICK_H__
#define __LOL_INPUT_STICK_H__

#include "entity.h"

#ifndef LOL_INPUT_V2

namespace lol
{

class StickData;

class Stick : public Entity
{
friend class Input;

public:
void SetAxisCount(int n);
void SetButtonCount(int n);
void SetAxis(int n, float val);
void SetButton(int n, int val);
void RemapAxis(int src, int dst);
void RemapButton(int src, int dst);

int GetAxisCount();
int GetButtonCount();
float GetAxis(int n);
int GetButton(int n);

private:
Stick();
~Stick();
StickData *m_data;
};

} /* namespace lol */

#endif // !LOL_INPUT_V2

#endif // __LOL_INPUT_STICK_H__


+ 1
- 7
src/lolcore.vcxproj View File

@@ -146,9 +146,6 @@
<ClCompile Include="image\image.cpp" />
<ClCompile Include="input\controller.cpp" />
<ClCompile Include="input\input.cpp" />
<ClCompile Include="input\inputdevice.cpp" />
<ClCompile Include="input\keyboard.cpp" />
<ClCompile Include="input\stick.cpp" />
<ClCompile Include="layer.cpp" />
<ClCompile Include="light.cpp" />
<ClCompile Include="map.cpp" />
@@ -209,11 +206,8 @@
<ClInclude Include="image\image-private.h" />
<ClInclude Include="input\controller.h" />
<ClInclude Include="input\input.h" />
<ClInclude Include="input\inputdevice.h" />
<ClInclude Include="input\inputdevice_internal.h" />
<ClInclude Include="input\keyboard.h" />
<ClInclude Include="input\input_internal.h" />
<ClInclude Include="input\keys.h" />
<ClInclude Include="input\stick.h" />
<ClInclude Include="layer.h" />
<ClInclude Include="light.h" />
<ClInclude Include="loldebug.h" />


+ 32
- 50
src/lolcore.vcxproj.filters View File

@@ -43,21 +43,6 @@
<Filter Include="mesh">
<UniqueIdentifier>{1eaa8df5-7a31-4358-a1e9-0e265de6ed49}</UniqueIdentifier>
</Filter>
<Filter Include="platform">
<UniqueIdentifier>{a11c55f8-8e10-4270-be24-38e8d4fcf589}</UniqueIdentifier>
</Filter>
<Filter Include="platform\sdl">
<UniqueIdentifier>{4089421f-2cc2-4036-a6b2-9df8a2f4efc8}</UniqueIdentifier>
</Filter>
<Filter Include="platform\xbox">
<UniqueIdentifier>{317cb5cc-5dcc-4e14-be90-40a125a2e2ec}</UniqueIdentifier>
</Filter>
<Filter Include="platform\d3d9">
<UniqueIdentifier>{a914e15d-3201-467a-a9c9-d7c5244b13ee}</UniqueIdentifier>
</Filter>
<Filter Include="platform\ps3">
<UniqueIdentifier>{c6c6b597-ed6c-4d82-a166-964beeeeb525}</UniqueIdentifier>
</Filter>
<Filter Include="lol\base">
<UniqueIdentifier>{e17b998c-d494-480b-ae29-5d1564f73327}</UniqueIdentifier>
</Filter>
@@ -79,6 +64,21 @@
<Filter Include="lol\debug">
<UniqueIdentifier>{01285b11-c6c7-4a9e-8dee-daa2c63901e4}</UniqueIdentifier>
</Filter>
<Filter Include="mesh\platform">
<UniqueIdentifier>{a11c55f8-8e10-4270-be24-38e8d4fcf589}</UniqueIdentifier>
</Filter>
<Filter Include="mesh\platform\sdl">
<UniqueIdentifier>{4089421f-2cc2-4036-a6b2-9df8a2f4efc8}</UniqueIdentifier>
</Filter>
<Filter Include="mesh\platform\xbox">
<UniqueIdentifier>{317cb5cc-5dcc-4e14-be90-40a125a2e2ec}</UniqueIdentifier>
</Filter>
<Filter Include="mesh\platform\d3d9">
<UniqueIdentifier>{a914e15d-3201-467a-a9c9-d7c5244b13ee}</UniqueIdentifier>
</Filter>
<Filter Include="mesh\platform\ps3">
<UniqueIdentifier>{c6c6b597-ed6c-4d82-a166-964beeeeb525}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="image\image.cpp">
@@ -94,10 +94,10 @@
<Filter>debug</Filter>
</ClCompile>
<ClCompile Include="platform\sdl\sdlapp.cpp">
<Filter>platform\sdl</Filter>
<Filter>mesh\platform\sdl</Filter>
</ClCompile>
<ClCompile Include="platform\sdl\sdlinput.cpp">
<Filter>platform\sdl</Filter>
<Filter>mesh\platform\sdl</Filter>
</ClCompile>
<ClCompile Include="math\half.cpp">
<Filter>math</Filter>
@@ -151,10 +151,10 @@
<Filter>image\codec</Filter>
</ClCompile>
<ClCompile Include="platform\xbox\xboxapp.cpp">
<Filter>platform\xbox</Filter>
<Filter>mesh\platform\xbox</Filter>
</ClCompile>
<ClCompile Include="platform\xbox\xboxinput.cpp">
<Filter>platform\xbox</Filter>
<Filter>mesh\platform\xbox</Filter>
</ClCompile>
<ClCompile Include="gpu\indexbuffer.cpp">
<Filter>gpu</Filter>
@@ -162,14 +162,8 @@
<ClCompile Include="input\input.cpp">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="input\keyboard.cpp">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="input\stick.cpp">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="platform\d3d9\d3d9input.cpp">
<Filter>platform\d3d9</Filter>
<Filter>mesh\platform\d3d9</Filter>
</ClCompile>
<ClCompile Include="audio.cpp">
<Filter>...</Filter>
@@ -268,10 +262,10 @@
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="platform\ps3\ps3app.cpp">
<Filter>platform\ps3</Filter>
<Filter>mesh\platform\ps3</Filter>
</ClCompile>
<ClCompile Include="platform\ps3\ps3input.cpp">
<Filter>platform\ps3</Filter>
<Filter>mesh\platform\ps3</Filter>
</ClCompile>
<ClCompile Include="gpu\lolfx-compiler.cpp">
<Filter>gpu</Filter>
@@ -315,9 +309,6 @@
<ClCompile Include="input\controller.cpp">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="input\inputdevice.cpp">
<Filter>input</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="debug\fps.h">
@@ -330,10 +321,10 @@
<Filter>debug</Filter>
</ClInclude>
<ClInclude Include="platform\sdl\sdlinput.h">
<Filter>platform\sdl</Filter>
<Filter>mesh\platform\sdl</Filter>
</ClInclude>
<ClInclude Include="platform\sdl\sdlapp.h">
<Filter>platform\sdl</Filter>
<Filter>mesh\platform\sdl</Filter>
</ClInclude>
<ClInclude Include="lol\image\color.h">
<Filter>lol\image</Filter>
@@ -369,22 +360,16 @@
<Filter>image</Filter>
</ClInclude>
<ClInclude Include="platform\xbox\xboxapp.h">
<Filter>platform\xbox</Filter>
<Filter>mesh\platform\xbox</Filter>
</ClInclude>
<ClInclude Include="platform\xbox\xboxinput.h">
<Filter>platform\xbox</Filter>
<Filter>mesh\platform\xbox</Filter>
</ClInclude>
<ClInclude Include="input\input.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="input\keyboard.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="input\stick.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="platform\d3d9\d3d9input.h">
<Filter>platform\d3d9</Filter>
<Filter>mesh\platform\d3d9</Filter>
</ClInclude>
<ClInclude Include="audio.h">
<Filter>...</Filter>
@@ -501,13 +486,13 @@
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="platform\ps3\ps3app.h">
<Filter>platform\ps3</Filter>
<Filter>mesh\platform\ps3</Filter>
</ClInclude>
<ClInclude Include="platform\ps3\ps3input.h">
<Filter>platform\ps3</Filter>
<Filter>mesh\platform\ps3</Filter>
</ClInclude>
<ClInclude Include="platform\ps3\threadbase.h">
<Filter>platform\ps3</Filter>
<Filter>mesh\platform\ps3</Filter>
</ClInclude>
<ClInclude Include="map.h">
<Filter>src\...</Filter>
@@ -614,16 +599,13 @@
<ClInclude Include="lol\image\image.h">
<Filter>lol\image</Filter>
</ClInclude>
<ClInclude Include="input\inputdevice.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="input\keys.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="input\inputdevice_internal.h">
<ClInclude Include="input\controller.h">
<Filter>input</Filter>
</ClInclude>
<ClInclude Include="input\controller.h">
<ClInclude Include="input\input_internal.h">
<Filter>input</Filter>
</ClInclude>
</ItemGroup>


+ 1
- 22
src/platform/d3d9/d3d9input.cpp View File

@@ -20,9 +20,7 @@
#include "core.h"
#include "d3d9input.h"

#ifdef LOL_INPUT_V2
#include "input/inputdevice_internal.h"
#endif // LOL_INPUT_V2
#include "input/input_internal.h"

namespace lol
{
@@ -37,11 +35,7 @@ class D3d9InputData

private:
#if defined USE_XINPUT
#if defined LOL_INPUT_V2
Array<int, InputDeviceInternal*> m_joysticks;
#else
Array<int, Stick *> m_joysticks;
#endif // LOL_INPUT_V2
#endif // USE_XINPUT
};

@@ -58,7 +52,6 @@ D3d9Input::D3d9Input()
XINPUT_STATE state;
if (XInputGetState(i, &state) != ERROR_SUCCESS)
continue;
#if defined LOL_INPUT_V2
// TODO: we can put more friendly name here, such as LeftAxisX, ButtonX...
InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
for (int j = 0; j < 4; ++j)
@@ -67,12 +60,6 @@ D3d9Input::D3d9Input()
stick->AddKey(String::Printf("Button%d", j+1).C());

m_data->m_joysticks.Push(i, stick);
#else
Stick *stick = Input::CreateStick();
stick->SetAxisCount(4);
stick->SetButtonCount(16);
m_data->m_joysticks.Push(i, stick);
#endif // LOL_INPUT_V2
}
#endif

@@ -85,11 +72,7 @@ D3d9Input::~D3d9Input()
/* Unregister all the joysticks we added */
while (m_data->m_joysticks.Count())
{
#if defined LOL_INPUT_V2
delete m_data->m_joysticks[0].m2;
#else
Input::DestroyStick(m_data->m_joysticks[0].m2);
#endif // LOL_INPUT_V2
m_data->m_joysticks.Remove(0);
}
#endif
@@ -118,11 +101,7 @@ void D3d9Input::TickDraw(float seconds)
m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f);

for (int b = 0; b < 16; b++)
#if defined LOL_INPUT_V2
m_data->m_joysticks[i].m2->SetKey(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
#else
m_data->m_joysticks[i].m2->SetButton(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
#endif // LOL_INPUT_V2
}
#endif
}


+ 2
- 9
src/platform/sdl/sdlapp.cpp View File

@@ -66,11 +66,9 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) :
exit(EXIT_FAILURE);
}

# ifdef LOL_INPUT_V2
const SDL_VideoInfo* vidinfo = SDL_GetVideoInfo();
int screen_w = vidinfo->current_w;
int screen_h = vidinfo->current_h;
# endif

# if defined USE_D3D9
SDL_Surface *video = SDL_SetVideoMode(res.x, res.y, 16, 0);
@@ -83,9 +81,8 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) :
# else
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
# ifdef LOL_INPUT_V2
// TODO: when implementing fullscreen, be sure to overwrite screen_w and screen_h with the value of vidinfo after the call to SDL_SetVideoMode
# endif

// TODO: when implementing fullscreen, be sure to overwrite screen_w and screen_h with the value of vidinfo after the call to SDL_SetVideoMode
SDL_Surface *video = SDL_SetVideoMode(res.x, res.y, 0, SDL_OPENGL);
# endif
if (!video)
@@ -109,11 +106,7 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) :
new D3d9Input();
# endif

# ifdef LOL_INPUT_V2
new SdlInput(video->w, video->h, screen_w, screen_h);
# else
new SdlInput();
# endif
#endif
}



+ 3
- 313
src/platform/sdl/sdlinput.cpp View File

@@ -23,9 +23,7 @@
#include "core.h"
#include "sdlinput.h"

#ifdef LOL_INPUT_V2
#include "input/inputdevice_internal.h"
#endif // LOL_INPUT_V2
#include "input/input_internal.h"

/* We force joystick polling because no events are received when
* there is no SDL display (eg. on the Raspberry Pi). */
@@ -49,7 +47,6 @@ private:
static void SetMousePos(ivec2 position);

#if USE_SDL
# ifdef LOL_INPUT_V2
SdlInputData(int app_w, int app_h, int screen_w, int screen_h) :
m_prevmouse(ivec2(0)),
m_app_w((float)app_w),
@@ -68,9 +65,6 @@ private:
float m_screen_w;
float m_screen_h;
bool m_mousecapture;
# else
Array<SDL_Joystick *, Stick *> m_joysticks;
# endif // LOL_INPUT_V2
#endif // USE_SDL
};

@@ -78,13 +72,8 @@ private:
* Public SdlInput class
*/

#ifdef LOL_INPUT_V2
SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)
: m_data(new SdlInputData(app_w, app_h, screen_w, screen_h))
#else
SdlInput::SdlInput()
: m_data(new SdlInputData())
#endif
{
#if USE_SDL
/* Enable Unicode translation of keyboard events */
@@ -99,10 +88,8 @@ SdlInput::SdlInput()
SDL_JoystickEventState(SDL_ENABLE);
# endif

#ifdef LOL_INPUT_V2
m_data->m_keyboard = InputDeviceInternal::CreateStandardKeyboard();
m_data->m_mouse = InputDeviceInternal::CreateStandardMouse();
#endif

/* Register all the joysticks we can find, and let the input
* system decide what it wants to track. */
@@ -125,7 +112,6 @@ SdlInput::SdlInput()
continue;
}

# ifdef LOL_INPUT_V2
InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j)
stick->AddAxis(String::Printf("Axis%d", j + 1).C());
@@ -133,17 +119,6 @@ SdlInput::SdlInput()
stick->AddKey(String::Printf("Button%d", j + 1).C());

m_data->m_joysticks.Push(sdlstick, stick);
# else // !LOL_INPUT_V2
Stick *stick = Input::CreateStick();
stick->SetAxisCount(SDL_JoystickNumAxes(sdlstick));
stick->SetButtonCount(SDL_JoystickNumButtons(sdlstick));

/* It's possible to remap axes */
//stick->RemapAxis(4, 2);
//stick->RemapAxis(2, 4);

m_data->m_joysticks.Push(sdlstick, stick);
# endif
}
# endif
#endif
@@ -158,11 +133,7 @@ SdlInput::~SdlInput()
while (m_data->m_joysticks.Count())
{
SDL_JoystickClose(m_data->m_joysticks[0].m1);
# ifdef LOL_INPUT_V2
delete m_data->m_joysticks[0].m2;
# else
Input::DestroyStick(m_data->m_joysticks[0].m2);
# endif
m_data->m_joysticks.Remove(0);
}
#endif
@@ -195,18 +166,10 @@ void SdlInputData::Tick(float seconds)
SDL_JoystickUpdate();
for (int j = 0; j < m_joysticks.Count(); j++)
{
# ifdef LOL_INPUT_V2
for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++)
m_joysticks[j].m2->SetKey(i, SDL_JoystickGetButton(m_joysticks[j].m1, i) != 0);
for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++)
m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f);
# else // !LOL_INPUT_V2
for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++)
m_joysticks[j].m2->SetButton(i, SDL_JoystickGetButton(m_joysticks[j].m1, i));
for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++)
m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f);

# endif
}
# endif

@@ -228,19 +191,11 @@ void SdlInputData::Tick(float seconds)
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
#ifdef LOL_INPUT_V2
m_mouse->SetKey(event.button.button - 1, event.type == SDL_MOUSEBUTTONDOWN);
#else // !LOL_INPUT_V2
if (event.type == SDL_MOUSEBUTTONDOWN)
Input::SetMouseButton(event.button.button - 1);
else
Input::UnsetMouseButton(event.button.button - 1);
#endif // LOL_INPUT_V2
break;
}

# if !SDL_FORCE_POLL_JOYSTICK
# ifdef LOL_INPUT_V2
case SDL_JOYAXISMOTION:
m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f);
break;
@@ -249,23 +204,12 @@ void SdlInputData::Tick(float seconds)
case SDL_JOYBUTTONDOWN:
m_joysticks[event.jbutton.which].m2->SetKey(event.jbutton.button, event.jbutton.state);
break;
# else // !LOL_INPUT_V2
case SDL_JOYAXISMOTION:
m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f);
break;

case SDL_JOYBUTTONUP:
case SDL_JOYBUTTONDOWN:
m_joysticks[event.jbutton.which].m2->SetButton(event.jbutton.button, event.jbutton.state);
break;
# endif // LOL_INPUT_V2
# endif
}
}

/* Handle mouse input */
ivec2 mouse = SdlInputData::GetMousePos();
# ifdef LOL_INPUT_V2
if (InputDeviceInternal::GetMouseCapture() != m_mousecapture)
{
m_mousecapture = InputDeviceInternal::GetMouseCapture();
@@ -289,10 +233,6 @@ void SdlInputData::Tick(float seconds)

m_prevmouse = mouse;

# else // !LOL_INPUT_V2
Input::SetMousePos(mouse);
# endif // LOL_INPUT_V2

# if SDL_VERSION_ATLEAST(1,3,0)
Uint8 *sdlstate = SDL_GetKeyboardState(nullptr);
# else
@@ -300,262 +240,12 @@ void SdlInputData::Tick(float seconds)
# endif

int keyindex = 0;
# ifdef LOL_INPUT_V2
# define KEY_FUNC(name, index) \
m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
/* FIXME: we ignore SDLK_WORLD_0, which means our list of
* keys and SDL's list of keys could be out of sync. */
# include "input/keys.h"
# undef KEY_FUNC
# else // !LOL_INPUT_V2

/* Send the whole keyboard state to the input system */
Array<uint8_t> &lolstate = Input::GetKeyboardState();

lolstate[Key::Unknown] = sdlstate[SDLK_UNKNOWN];
lolstate[Key::Backspace] = sdlstate[SDLK_BACKSPACE];
lolstate[Key::Tab] = sdlstate[SDLK_TAB];
lolstate[Key::Clear] = sdlstate[SDLK_CLEAR];
lolstate[Key::Return] = sdlstate[SDLK_RETURN];
lolstate[Key::Pause] = sdlstate[SDLK_PAUSE];
lolstate[Key::Escape] = sdlstate[SDLK_ESCAPE];
lolstate[Key::Space] = sdlstate[SDLK_SPACE];
lolstate[Key::Exclaim] = sdlstate[SDLK_EXCLAIM];
lolstate[Key::DoubleQuote] = sdlstate[SDLK_QUOTEDBL];
lolstate[Key::Hash] = sdlstate[SDLK_HASH];
lolstate[Key::Dollar] = sdlstate[SDLK_DOLLAR];
lolstate[Key::Ampersand] = sdlstate[SDLK_AMPERSAND];
lolstate[Key::Quote] = sdlstate[SDLK_QUOTE];
lolstate[Key::LeftParen] = sdlstate[SDLK_LEFTPAREN];
lolstate[Key::RightParen] = sdlstate[SDLK_RIGHTPAREN];
lolstate[Key::Asterisk] = sdlstate[SDLK_ASTERISK];
lolstate[Key::Plus] = sdlstate[SDLK_PLUS];
lolstate[Key::Comma] = sdlstate[SDLK_COMMA];
lolstate[Key::Minus] = sdlstate[SDLK_MINUS];
lolstate[Key::Period] = sdlstate[SDLK_PERIOD];
lolstate[Key::Slash] = sdlstate[SDLK_SLASH];
lolstate[Key::K0] = sdlstate[SDLK_0];
lolstate[Key::K1] = sdlstate[SDLK_1];
lolstate[Key::K2] = sdlstate[SDLK_2];
lolstate[Key::K3] = sdlstate[SDLK_3];
lolstate[Key::K4] = sdlstate[SDLK_4];
lolstate[Key::K5] = sdlstate[SDLK_5];
lolstate[Key::K6] = sdlstate[SDLK_6];
lolstate[Key::K7] = sdlstate[SDLK_7];
lolstate[Key::K8] = sdlstate[SDLK_8];
lolstate[Key::K9] = sdlstate[SDLK_9];
lolstate[Key::Colon] = sdlstate[SDLK_COLON];
lolstate[Key::Semicolon] = sdlstate[SDLK_SEMICOLON];
lolstate[Key::Less] = sdlstate[SDLK_LESS];
lolstate[Key::Equals] = sdlstate[SDLK_EQUALS];
lolstate[Key::Greater] = sdlstate[SDLK_GREATER];
lolstate[Key::Question] = sdlstate[SDLK_QUESTION];
lolstate[Key::At] = sdlstate[SDLK_AT];

lolstate[Key::LeftBracket] = sdlstate[SDLK_LEFTBRACKET];
lolstate[Key::BackSlash] = sdlstate[SDLK_BACKSLASH];
lolstate[Key::RightBracket] = sdlstate[SDLK_RIGHTBRACKET];
lolstate[Key::Caret] = sdlstate[SDLK_CARET];
lolstate[Key::Underscore] = sdlstate[SDLK_UNDERSCORE];
lolstate[Key::Backquote] = sdlstate[SDLK_BACKQUOTE];
lolstate[Key::A] = sdlstate[SDLK_a];
lolstate[Key::B] = sdlstate[SDLK_b];
lolstate[Key::C] = sdlstate[SDLK_c];
lolstate[Key::D] = sdlstate[SDLK_d];
lolstate[Key::E] = sdlstate[SDLK_e];
lolstate[Key::F] = sdlstate[SDLK_f];
lolstate[Key::G] = sdlstate[SDLK_g];
lolstate[Key::H] = sdlstate[SDLK_h];
lolstate[Key::I] = sdlstate[SDLK_i];
lolstate[Key::J] = sdlstate[SDLK_j];
lolstate[Key::K] = sdlstate[SDLK_k];
lolstate[Key::L] = sdlstate[SDLK_l];
lolstate[Key::M] = sdlstate[SDLK_m];
lolstate[Key::N] = sdlstate[SDLK_n];
lolstate[Key::O] = sdlstate[SDLK_o];
lolstate[Key::P] = sdlstate[SDLK_p];
lolstate[Key::Q] = sdlstate[SDLK_q];
lolstate[Key::R] = sdlstate[SDLK_r];
lolstate[Key::S] = sdlstate[SDLK_s];
lolstate[Key::T] = sdlstate[SDLK_t];
lolstate[Key::U] = sdlstate[SDLK_u];
lolstate[Key::V] = sdlstate[SDLK_v];
lolstate[Key::W] = sdlstate[SDLK_w];
lolstate[Key::X] = sdlstate[SDLK_x];
lolstate[Key::Y] = sdlstate[SDLK_y];
lolstate[Key::Z] = sdlstate[SDLK_z];
lolstate[Key::Delete] = sdlstate[SDLK_DELETE];

#if SDLK_WORLD_0
lolstate[Key::World0] = sdlstate[SDLK_WORLD_0];
lolstate[Key::World1] = sdlstate[SDLK_WORLD_1];
lolstate[Key::World2] = sdlstate[SDLK_WORLD_2];
lolstate[Key::World3] = sdlstate[SDLK_WORLD_3];
lolstate[Key::World4] = sdlstate[SDLK_WORLD_4];
lolstate[Key::World5] = sdlstate[SDLK_WORLD_5];
lolstate[Key::World6] = sdlstate[SDLK_WORLD_6];
lolstate[Key::World7] = sdlstate[SDLK_WORLD_7];
lolstate[Key::World8] = sdlstate[SDLK_WORLD_8];
lolstate[Key::World9] = sdlstate[SDLK_WORLD_9];
lolstate[Key::World10] = sdlstate[SDLK_WORLD_10];
lolstate[Key::World11] = sdlstate[SDLK_WORLD_11];
lolstate[Key::World12] = sdlstate[SDLK_WORLD_12];
lolstate[Key::World13] = sdlstate[SDLK_WORLD_13];
lolstate[Key::World14] = sdlstate[SDLK_WORLD_14];
lolstate[Key::World15] = sdlstate[SDLK_WORLD_15];
lolstate[Key::World16] = sdlstate[SDLK_WORLD_16];
lolstate[Key::World17] = sdlstate[SDLK_WORLD_17];
lolstate[Key::World18] = sdlstate[SDLK_WORLD_18];
lolstate[Key::World19] = sdlstate[SDLK_WORLD_19];
lolstate[Key::World20] = sdlstate[SDLK_WORLD_20];
lolstate[Key::World21] = sdlstate[SDLK_WORLD_21];
lolstate[Key::World22] = sdlstate[SDLK_WORLD_22];
lolstate[Key::World23] = sdlstate[SDLK_WORLD_23];
lolstate[Key::World24] = sdlstate[SDLK_WORLD_24];
lolstate[Key::World25] = sdlstate[SDLK_WORLD_25];
lolstate[Key::World26] = sdlstate[SDLK_WORLD_26];
lolstate[Key::World27] = sdlstate[SDLK_WORLD_27];
lolstate[Key::World28] = sdlstate[SDLK_WORLD_28];
lolstate[Key::World29] = sdlstate[SDLK_WORLD_29];
lolstate[Key::World30] = sdlstate[SDLK_WORLD_30];
lolstate[Key::World31] = sdlstate[SDLK_WORLD_31];
lolstate[Key::World32] = sdlstate[SDLK_WORLD_32];
lolstate[Key::World33] = sdlstate[SDLK_WORLD_33];
lolstate[Key::World34] = sdlstate[SDLK_WORLD_34];
lolstate[Key::World35] = sdlstate[SDLK_WORLD_35];
lolstate[Key::World36] = sdlstate[SDLK_WORLD_36];
lolstate[Key::World37] = sdlstate[SDLK_WORLD_37];
lolstate[Key::World38] = sdlstate[SDLK_WORLD_38];
lolstate[Key::World39] = sdlstate[SDLK_WORLD_39];
lolstate[Key::World40] = sdlstate[SDLK_WORLD_40];
lolstate[Key::World41] = sdlstate[SDLK_WORLD_41];
lolstate[Key::World42] = sdlstate[SDLK_WORLD_42];
lolstate[Key::World43] = sdlstate[SDLK_WORLD_43];
lolstate[Key::World44] = sdlstate[SDLK_WORLD_44];
lolstate[Key::World45] = sdlstate[SDLK_WORLD_45];
lolstate[Key::World46] = sdlstate[SDLK_WORLD_46];
lolstate[Key::World47] = sdlstate[SDLK_WORLD_47];
lolstate[Key::World48] = sdlstate[SDLK_WORLD_48];
lolstate[Key::World49] = sdlstate[SDLK_WORLD_49];
lolstate[Key::World50] = sdlstate[SDLK_WORLD_50];
lolstate[Key::World51] = sdlstate[SDLK_WORLD_51];
lolstate[Key::World52] = sdlstate[SDLK_WORLD_52];
lolstate[Key::World53] = sdlstate[SDLK_WORLD_53];
lolstate[Key::World54] = sdlstate[SDLK_WORLD_54];
lolstate[Key::World55] = sdlstate[SDLK_WORLD_55];
lolstate[Key::World56] = sdlstate[SDLK_WORLD_56];
lolstate[Key::World57] = sdlstate[SDLK_WORLD_57];
lolstate[Key::World58] = sdlstate[SDLK_WORLD_58];
lolstate[Key::World59] = sdlstate[SDLK_WORLD_59];
lolstate[Key::World60] = sdlstate[SDLK_WORLD_60];
lolstate[Key::World61] = sdlstate[SDLK_WORLD_61];
lolstate[Key::World62] = sdlstate[SDLK_WORLD_62];
lolstate[Key::World63] = sdlstate[SDLK_WORLD_63];
lolstate[Key::World64] = sdlstate[SDLK_WORLD_64];
lolstate[Key::World65] = sdlstate[SDLK_WORLD_65];
lolstate[Key::World66] = sdlstate[SDLK_WORLD_66];
lolstate[Key::World67] = sdlstate[SDLK_WORLD_67];
lolstate[Key::World68] = sdlstate[SDLK_WORLD_68];
lolstate[Key::World69] = sdlstate[SDLK_WORLD_69];
lolstate[Key::World70] = sdlstate[SDLK_WORLD_70];
lolstate[Key::World71] = sdlstate[SDLK_WORLD_71];
lolstate[Key::World72] = sdlstate[SDLK_WORLD_72];
lolstate[Key::World73] = sdlstate[SDLK_WORLD_73];
lolstate[Key::World74] = sdlstate[SDLK_WORLD_74];
lolstate[Key::World75] = sdlstate[SDLK_WORLD_75];
lolstate[Key::World76] = sdlstate[SDLK_WORLD_76];
lolstate[Key::World77] = sdlstate[SDLK_WORLD_77];
lolstate[Key::World78] = sdlstate[SDLK_WORLD_78];
lolstate[Key::World79] = sdlstate[SDLK_WORLD_79];
lolstate[Key::World80] = sdlstate[SDLK_WORLD_80];
lolstate[Key::World81] = sdlstate[SDLK_WORLD_81];
lolstate[Key::World82] = sdlstate[SDLK_WORLD_82];
lolstate[Key::World83] = sdlstate[SDLK_WORLD_83];
lolstate[Key::World84] = sdlstate[SDLK_WORLD_84];
lolstate[Key::World85] = sdlstate[SDLK_WORLD_85];
lolstate[Key::World86] = sdlstate[SDLK_WORLD_86];
lolstate[Key::World87] = sdlstate[SDLK_WORLD_87];
lolstate[Key::World88] = sdlstate[SDLK_WORLD_88];
lolstate[Key::World89] = sdlstate[SDLK_WORLD_89];
lolstate[Key::World90] = sdlstate[SDLK_WORLD_90];
lolstate[Key::World91] = sdlstate[SDLK_WORLD_91];
lolstate[Key::World92] = sdlstate[SDLK_WORLD_92];
lolstate[Key::World93] = sdlstate[SDLK_WORLD_93];
lolstate[Key::World94] = sdlstate[SDLK_WORLD_94];
lolstate[Key::World95] = sdlstate[SDLK_WORLD_95];
#endif // SDLK_WORLD_0

lolstate[Key::KP0] = sdlstate[SDLK_KP0];
lolstate[Key::KP1] = sdlstate[SDLK_KP1];
lolstate[Key::KP2] = sdlstate[SDLK_KP2];
lolstate[Key::KP3] = sdlstate[SDLK_KP3];
lolstate[Key::KP4] = sdlstate[SDLK_KP4];
lolstate[Key::KP5] = sdlstate[SDLK_KP5];
lolstate[Key::KP6] = sdlstate[SDLK_KP6];
lolstate[Key::KP7] = sdlstate[SDLK_KP7];
lolstate[Key::KP8] = sdlstate[SDLK_KP8];
lolstate[Key::KP9] = sdlstate[SDLK_KP9];
lolstate[Key::KPPeriod] = sdlstate[SDLK_KP_PERIOD];
lolstate[Key::KPDivide] = sdlstate[SDLK_KP_DIVIDE];
lolstate[Key::KPMultiply] = sdlstate[SDLK_KP_MULTIPLY];
lolstate[Key::KPMinus] = sdlstate[SDLK_KP_MINUS];
lolstate[Key::KPPlus] = sdlstate[SDLK_KP_PLUS];
lolstate[Key::KPEnter] = sdlstate[SDLK_KP_ENTER];
lolstate[Key::KPEquals] = sdlstate[SDLK_KP_EQUALS];

lolstate[Key::Up] = sdlstate[SDLK_UP];
lolstate[Key::Down] = sdlstate[SDLK_DOWN];
lolstate[Key::Right] = sdlstate[SDLK_RIGHT];
lolstate[Key::Left] = sdlstate[SDLK_LEFT];
lolstate[Key::Insert] = sdlstate[SDLK_INSERT];
lolstate[Key::Home] = sdlstate[SDLK_HOME];
lolstate[Key::End] = sdlstate[SDLK_END];
lolstate[Key::PageUp] = sdlstate[SDLK_PAGEUP];
lolstate[Key::PageDown] = sdlstate[SDLK_PAGEDOWN];

lolstate[Key::F1] = sdlstate[SDLK_F1];
lolstate[Key::F2] = sdlstate[SDLK_F2];
lolstate[Key::F3] = sdlstate[SDLK_F3];
lolstate[Key::F4] = sdlstate[SDLK_F4];
lolstate[Key::F5] = sdlstate[SDLK_F5];
lolstate[Key::F6] = sdlstate[SDLK_F6];
lolstate[Key::F7] = sdlstate[SDLK_F7];
lolstate[Key::F8] = sdlstate[SDLK_F8];
lolstate[Key::F9] = sdlstate[SDLK_F9];
lolstate[Key::F10] = sdlstate[SDLK_F10];
lolstate[Key::F11] = sdlstate[SDLK_F11];
lolstate[Key::F12] = sdlstate[SDLK_F12];
lolstate[Key::F13] = sdlstate[SDLK_F13];
lolstate[Key::F14] = sdlstate[SDLK_F14];
lolstate[Key::F15] = sdlstate[SDLK_F15];

lolstate[Key::NumLock] = sdlstate[SDLK_NUMLOCK];
lolstate[Key::CapsLock] = sdlstate[SDLK_CAPSLOCK];
lolstate[Key::ScrollLock] = sdlstate[SDLK_SCROLLOCK];
lolstate[Key::RightShift] = sdlstate[SDLK_RSHIFT];
lolstate[Key::LeftShift] = sdlstate[SDLK_LSHIFT];
lolstate[Key::RightCtrl] = sdlstate[SDLK_RCTRL];
lolstate[Key::LeftCtrl] = sdlstate[SDLK_LCTRL];
lolstate[Key::RightAlt] = sdlstate[SDLK_RALT];
lolstate[Key::LeftAlt] = sdlstate[SDLK_LALT];
lolstate[Key::RightMeta] = sdlstate[SDLK_RMETA];
lolstate[Key::LeftMeta] = sdlstate[SDLK_LMETA];
lolstate[Key::LeftSuper] = sdlstate[SDLK_LSUPER];
lolstate[Key::RightSuper] = sdlstate[SDLK_RSUPER];
lolstate[Key::Mode] = sdlstate[SDLK_MODE];
lolstate[Key::Compose] = sdlstate[SDLK_COMPOSE];

lolstate[Key::Help] = sdlstate[SDLK_HELP];
lolstate[Key::Print] = sdlstate[SDLK_PRINT];
lolstate[Key::SysReq] = sdlstate[SDLK_SYSREQ];
lolstate[Key::Break] = sdlstate[SDLK_BREAK];
lolstate[Key::Menu] = sdlstate[SDLK_MENU];
lolstate[Key::Power] = sdlstate[SDLK_POWER];
lolstate[Key::Euro] = sdlstate[SDLK_EURO];
lolstate[Key::Undo] = sdlstate[SDLK_UNDO];

UNUSED(seconds);
# endif // LOL_INPUT_V2
# include "input/keys.h"
# undef KEY_FUNC

#endif // USE_SDL
}


+ 2
- 5
src/platform/sdl/sdlinput.h View File

@@ -26,13 +26,10 @@ class SdlInputData;
class SdlInput : public Entity
{
public:
#ifdef LOL_INPUT_V2
/** passing the screen resolution (note: not the windowed app resolution!) allows to make the mouse axis resolution-independent */
SdlInput(int app_w, int app_h, int screen_w, int screen_h);
#else
SdlInput();
#endif
virtual ~SdlInput();

virtual ~SdlInput();
void SetScreenResolution();

protected:


Loading…
Cancel
Save