source: trunk/src/input/input.cpp @ 2845

Last change on this file since 2845 was 2845, checked in by benlitz, 6 years ago

copy-paste failure corrected.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
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#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16
17#include "input/input_internal.h"
18
19namespace lol
20{
21
22Array<InputDevice*> InputDevice::devices;
23bool InputDevice::m_capturemouse;
24
25void InputDeviceInternal::AddKey(const char* name)
26{
27    m_keynames.Push(name);
28    m_keys.Push(false);
29}
30
31void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
32{
33    m_axisnames.Push(name);
34    m_axis.Push(0.0f, sensitivity);
35}
36
37void InputDeviceInternal::AddCursor(const char* name)
38{
39    m_cursornames.Push(name);
40    m_cursors.Push(vec2(0.0), ivec2(0));
41}
42
43InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
44{
45    InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
46    /* "value" is unused, what matters is the index. */
47#   define KEY_FUNC(key, value) \
48        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 */
Note: See TracBrowser for help on using the repository browser.