source: trunk/src/input/inputdevice_internal.h @ 2810

Last change on this file since 2810 was 2810, checked in by benlitz, 8 years ago

Completely reworked input system. Unified device interface, button, axis and cursor support, controller and binding system, mouse capture. Tutorial 07_input provided. Require to compile lolcore with LOL_INPUT_V2 to be activated (also needed app-side before including core.h)

File size: 1.4 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 __LOL_INPUT_DEVICE_INTERNAL_H__
12#define __LOL_INPUT_DEVICE_H__
13
14#if defined LOL_INPUT_V2
15
16#include "core.h"
17
18namespace lol
19{
20
21/** Internal class (not public) that allows to construct an InputDevice dynamically, when the keys, axis and cursors are not known at compile time */
22class InputDeviceInternal : InputDevice
23{
24public:
25    InputDeviceInternal(const char* name) : InputDevice(name) { }
26
27    void AddKey(const char* name);
28    void AddAxis(const char* name, float sensitivity = 1.0f);
29    void AddCursor(const char* name);
30
31    void SetKey(int index, bool state) { m_keys[index] = state; }
32        void SetAxis(int index, float value) { m_axis[index].m1 = value; }
33        void SetCursor(int index, const vec2& position, const ivec2& pixel) { m_cursors[index].m1 = position; m_cursors[index].m2 = pixel; }
34
35        static bool GetMouseCapture() { return m_capturemouse; }
36
37        static InputDeviceInternal* CreateStandardKeyboard();
38    static InputDeviceInternal* CreateStandardMouse();
39};
40
41} /* namespace lol */
42
43#endif // LOL_INPUT_V2
44
45#endif // __LOL_INPUT_DEVICE_INTERNAL_H__
46
Note: See TracBrowser for help on using the repository browser.