wavelength 1.0.0
Loading...
Searching...
No Matches
inputmap.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "os/binstream.h"
6#include "script/dataarray.h"
7
15class InputMap {
16public:
18 static constexpr int kButtonCount = 24;
19
21 static constexpr int kStickCount = 2;
22
30
38 InputMap(const InputMap &other);
39
45
54 InputMap &operator=(const InputMap &other);
55
64 int GetButtonAction(int nButton);
65
74 void SetButtonAction(int nButton, int nAction);
75
84 void SetStickAction(int nStick, int nAction);
85
94 int GetStickAction(int nStick);
95
104 int FindStick(int nAction);
105
116 void Load(const DataArray *pConfig);
117
125
134 void Save(BinStream &stream) const;
135
146 void Load(BinStream &stream);
147
148private:
149 std::vector<int> mButtons; // The action of each button, indexed by button.
150 std::vector<int> mSticks; // The action of each stick, indexed by stick.
151};
152
163
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Reference-counted array of script data nodes.
Definition dataarray.h:20
The actions a player's controller buttons and analogue sticks are bound to.
Definition inputmap.h:15
void Load(BinStream &stream)
Read the bindings Save() wrote.
static constexpr int kStickCount
The number of analogue sticks the map binds.
Definition inputmap.h:21
InputMap(const InputMap &other)
Construct a copy of another map.
static constexpr int kButtonCount
The number of controller buttons the map binds.
Definition inputmap.h:18
int GetButtonAction(int nButton)
Report the action a controller button is bound to.
void SetButtonAction(int nButton, int nAction)
Bind a controller button to an action.
void Save(BinStream &stream) const
Write the number of buttons, the button bindings, the number of sticks, and the stick bindings.
InputMap & operator=(const InputMap &other)
Copy the button and stick bindings of another map.
void SetStickAction(int nStick, int nAction)
Bind an analogue stick to an action.
void Load(const DataArray *pConfig)
Load the bindings a configuration array lists.
int GetStickAction(int nStick)
Report the action an analogue stick is bound to.
InputMap()
Build a map with every button and stick binding cleared.
int FindStick(int nAction)
Find the analogue stick bound to an action.
void LoadDefaults()
Load the bindings the "input_map" entry of the "db" configuration section lists.
BinStream & operator>>(BinStream &stream, InputMap &map)
Read a map as InputMap::Load() does.
BinStream & operator<<(BinStream &stream, const InputMap &map)
Write a map as InputMap::Save() does.