-
Notifications
You must be signed in to change notification settings - Fork 1
/
control.h
73 lines (62 loc) · 1.79 KB
/
control.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
/*
* PROPRIETARY INFORMATION. This software is proprietary to POWDER
* Development, and is not to be reproduced, transmitted, or disclosed
* in any way without written permission.
*
* Produced by: Jeff Lait
*
* POWDER Development
*
* NAME: control.h ( POWDER Library, C++ )
*
* COMMENTS:
* Platform independent control interface
*/
#ifndef __control__
#define __control__
// This allows the standard Game Boy Advance controls or their equivalents,
// namely:
// Direction, any or all of up/down/left/right
// Buttons A & B
// Buttons R & L
// Buttons Start & Select.
// Gameboy DS: X & Y, TOUCH and LID.
// Button definitions
enum BUTTONS
{
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
BUTTON_A,
BUTTON_B,
BUTTON_START,
BUTTON_SELECT,
BUTTON_R,
BUTTON_L,
BUTTON_X,
BUTTON_Y,
BUTTON_TOUCH,
BUTTON_LID,
NUM_BUTTONS
};
// Initialize the control library.
void ctrl_init();
// Set the repeat rate for keypresses.
void ctrl_setrepeat(int timedelay);
// Determine if any button is pressed.
int ctrl_anyrawpressed();
// Check to see if a button is currently pressed.
int ctrl_rawpressed(int button);
// Check to see if a button has been pressed. This triggers on button
// down. It will not retrigger until the button is released, or a timer
// is exceeded. Each call will reset this status, so a second call will
// always report unpressed.
bool ctrl_hit(int button);
// This convience function will build your dx/dy. Raw determines if
// it uses ctrl_hit or rawpressed.
void ctrl_getdir(int &dx, int &dy, int raw = 0, bool allowdiag=false);
// This convience function will build your dx/dy from a keypress.
// Handles those nifty hjkl crap.
void ctrl_getdirfromkey(int keypress, int &dx, int &dy, bool allowdiag=false);
#endif