source: trunk/src/input/inputdevice.cpp @ 2816

Last change on this file since 2816 was 2816, checked in by lolbot, 8 years ago

fixed 542 files out of 2754:

  • removed 0 CR characters
  • removed 0 trailing whitespaces
  • replaced 0 tabs with spaces
  • fixed 542 svn:eol-style properties
  • Property svn:eol-style set to LF
File size: 1.6 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Benjamin Litzelmann
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11#ifdef LOL_INPUT_V2
12
13#if defined HAVE_CONFIG_H
14#   include "config.h"
15#endif
16
17#include "core.h"
18
19#include "input/inputdevice_internal.h"
20
21namespace lol
22{
23
24Array<InputDevice*> InputDevice::devices;
25bool InputDevice::m_capturemouse;
26
27void InputDeviceInternal::AddKey(const char* name)
28{
29    m_keynames.Push(name);
30    m_keys.Push(false);
31}
32
33void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
34{
35    m_axisnames.Push(name);
36    m_axis.Push(0.0f, sensitivity);
37}
38
39void InputDeviceInternal::AddCursor(const char* name)
40{
41    m_cursornames.Push(name);
42    m_cursors.Push(vec2(0.0), ivec2(0));
43}
44
45InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
46{
47    InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
48#   define KEY_FUNC(key, value) keyboard->AddKey(#key);
49#   include "input/keys.h"
50#   undef KEY_FUNC
51    return keyboard;
52}
53
54InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
55{
56    InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
57    mouse->AddKey("ButtonLeft");
58    mouse->AddKey("ButtonMiddle");
59    mouse->AddKey("ButtonRight");
60
61    mouse->AddAxis("X");
62    mouse->AddAxis("Y");
63
64    mouse->AddCursor("Cursor");
65
66    // TODO: extended button, and wheel (as axis or as buttons? or both?)
67    return mouse;
68}
69
70} /* namespace lol */
71
72#endif // LOL_INPUT_V2
Note: See TracBrowser for help on using the repository browser.