This repository has been archived by the owner on Jul 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.h
193 lines (181 loc) · 5.13 KB
/
host.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef HOSTS_HOST_H_INCLUDED
#define HOSTS_HOST_H_INCLUDED
#include "host_defines.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Initiates the host.
*
* This can be implemented if the host needs
* initialization.
*/
int init(int playerCount);
/**
* @brief Gets the state of the specified button.
*
* States are integers between 0 and 100000, while 0 means
* completely off and 100000 means completely on.
*
* This function gets called every frame of the input loop, so there must
* not be any delays. The best way to accomodate this is to use an internal
* caching mechanism.
*/
int getButtonState(int playerID, int button);
#ifdef __cplusplus
namespace piga {
class GameInput;
}
void setGameInput(piga::GameInput *gameInput);
#endif
/**
* @brief A shortcut to leave out the implementation of the output functions.
*
* @return HOST_RETURNCODE_FALSE if the host doesn't implement outputs, HOST_RETURNCODE_TRUE if it does.
*/
int implementsOutputs();
/**
* @brief Returns the number of outputs (all types and positions) this host is capable of.
*
* @return The number of outputs. Numbers can be used to iterate over the possible outputs in the getOutputType() and getOutputPos() functions.
*/
int getOutputCount();
/**
* @brief Returns the type of the specified output.
*
* @param outputID The ID of the output.
*
* @return The HOST_OUTPUT_TYPE of the output.
*/
int getOutputType(int outputID);
/**
* @brief Returns the position of the specified output.
*
* @param outputID The ID of the output.
*
* @return The HOST_OUTPUT_POS of the specified output.
*/
int getOutputPos(int outputID);
/**
* @brief Returns the name of the specified output.
*
* @param outputID The ID of the output to get the name from.
*
* @return The name of the output.
*/
const char* getOutputName(int outputID);
/**
* @brief Returns the description of the specified output.
*
* @param outputID The ID of the output to get the description from.
*
* @return The description of the output.
*/
const char* getOutputDescription(int outputID);
int getIntOutputRangeMin(int outputID);
int getIntOutputRangeMax(int outputID);
float getFloatOutputRangeMin(int outputID);
float getFloatOutputRangeMax(int outputID);
double getDoubleOutputRangeMin(int outputID);
double getDoubleOutputRangeMax(int outputID);
/**
* @brief Sets a color output.
*
* @param outputID The ID of the output.
* @param r Red
* @param g Green
* @param b Blue
* @param a Alpha (if used)
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setColorOutput(int outputID, float r, float g, float b, float a);
/**
* @brief Sets a true/false output.
*
* @param outputID The ID of the output.
* @param value 1 means true, 0 means false.
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setBoolOutput(int outputID, int value);
/**
* @brief Sets a string output.
*
* @param outputID The ID of the output.
* @param outString The string to be sent to the output.
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setStringOutput(int outputID, const char* outString);
/**
* @brief Sets an integer output.
*
* @param outputID The ID of the output.
* @param value The value to be sent to the output.
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setIntOutput(int outputID, int value);
/**
* @brief Sets a float output.
*
* @param outputID The ID of the output.
* @param value The value to be sent to the output.
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setFloatOutput(int outputID, float value);
/**
* @brief Sets a double output.
*
* @param outputID The ID of the output.
* @param value The value to be set to the output.
*
* @return HOST_RETURNCODE_SUCCESS if successful, HOST_RETURNCODE_FAIL or HOST_RETURNCODE_FAIL_INVALID_TYPE otherwise.
*/
int setDoubleOutput(int outputID, double value);
/**
* @brief Sets a callback function to be called when an input happens.
*
* This function will only be called when @ref HOST_RETURNCODE_USECALLBACK
* is set.
*
* Parameters for the input callback function: ControlCode/ButtonID, PlayerID, state
*/
void setCallbackFunc(host_input_callback_func callback);
/**
* @brief Gets called before the host will be destroyed.
*
* This can be implemented if the host needs a destruction handling.
*/
int destroy();
int getPigaMajorVersion()
{
return HOST_VERSION_MAJOR;
}
int getPigaMinorVersion()
{
return HOST_VERSION_MINOR;
}
int getPigaMiniVersion()
{
return HOST_VERSION_MINI;
}
/**
* Returns the name of the host. (Set by the host programmer.)
*/
const char* getName();
/**
* Returns the description of the host. (Set by the host programmer.)
*/
const char* getDescription();
/**
* @brief Returns the author of the host. (Set by the host programmer.)
*/
const char* getAuthor();
#ifdef __cplusplus
}
#endif
#endif