1 /*
2  * OpenBOR - http://www.LavaLit.com
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
5  *
6  * Copyright (c) 2004 - 2011 OpenBOR Team
7  */
8 
9 #ifndef	CONTROL_H
10 #define	CONTROL_H
11 
12 #define DC_DPAD_UP       0x00000001
13 #define DC_DPAD_RIGHT    0x00000002
14 #define DC_DPAD_DOWN     0x00000004
15 #define DC_DPAD_LEFT     0x00000008
16 #define DC_A             0x00000010
17 #define DC_B             0x00000020
18 #define DC_X             0x00000040
19 #define DC_Y             0x00000080
20 #define DC_LEFT_TRIGGER	 0x00000100
21 #define DC_RIGHT_TRIGGER 0x00000200
22 #define DC_START         0x00000400
23 #define DC_C             0x00000800
24 #define DC_DPAD2_UP		 0x00001000
25 #define DC_DPAD2_DOWN	 0x00002000
26 #define DC_DPAD2_LEFT	 0x00004000
27 #define DC_DPAD2_RIGHT	 0x00008000
28 #define DC_D             0x00010000
29 #define DC_Z             0x00020000
30 
31 #define	CONTROL_ESC					73
32 
33 #define	CONTROL_DEFAULT1_UP			1
34 #define	CONTROL_DEFAULT1_RIGHT		2
35 #define	CONTROL_DEFAULT1_DOWN		3
36 #define	CONTROL_DEFAULT1_LEFT		4
37 #define CONTROL_DEFAULT1_FIRE1		5
38 #define CONTROL_DEFAULT1_FIRE2		7
39 #define	CONTROL_DEFAULT1_FIRE3		9
40 #define	CONTROL_DEFAULT1_FIRE4		10
41 #define	CONTROL_DEFAULT1_FIRE5		6
42 #define	CONTROL_DEFAULT1_FIRE6		8
43 #define CONTROL_DEFAULT1_START		11
44 #define CONTROL_DEFAULT1_SCREENSHOT 73
45 
46 #define	CONTROL_DEFAULT2_UP			(1+18)
47 #define	CONTROL_DEFAULT2_RIGHT		(2+18)
48 #define	CONTROL_DEFAULT2_DOWN		(3+18)
49 #define	CONTROL_DEFAULT2_LEFT		(4+18)
50 #define CONTROL_DEFAULT2_FIRE1		(5+18)
51 #define CONTROL_DEFAULT2_FIRE2		(7+18)
52 #define	CONTROL_DEFAULT2_FIRE3		(9+18)
53 #define	CONTROL_DEFAULT2_FIRE4		(10+18)
54 #define	CONTROL_DEFAULT2_FIRE5		(6+18)
55 #define	CONTROL_DEFAULT2_FIRE6		(8+18)
56 #define CONTROL_DEFAULT2_START		(11+18)
57 #define CONTROL_DEFAULT2_SCREENSHOT 73
58 
59 #define	CONTROL_DEFAULT3_UP			(1+(18*2))
60 #define	CONTROL_DEFAULT3_RIGHT		(2+(18*2))
61 #define	CONTROL_DEFAULT3_DOWN		(3+(18*2))
62 #define	CONTROL_DEFAULT3_LEFT		(4+(18*2))
63 #define CONTROL_DEFAULT3_FIRE1		(5+(18*2))
64 #define CONTROL_DEFAULT3_FIRE2		(7+(18*2))
65 #define	CONTROL_DEFAULT3_FIRE3		(9+(18*2))
66 #define	CONTROL_DEFAULT3_FIRE4		(10+(18*2))
67 #define	CONTROL_DEFAULT3_FIRE5		(6+(18*2))
68 #define	CONTROL_DEFAULT3_FIRE6		(8+(18*2))
69 #define CONTROL_DEFAULT3_START		(11+(18*2))
70 #define CONTROL_DEFAULT3_SCREENSHOT 73
71 
72 #define	CONTROL_DEFAULT4_UP			(1+(18*3))
73 #define	CONTROL_DEFAULT4_RIGHT		(2+(18*3))
74 #define	CONTROL_DEFAULT4_DOWN		(3+(18*3))
75 #define	CONTROL_DEFAULT4_LEFT		(4+(18*3))
76 #define CONTROL_DEFAULT4_FIRE1		(5+(18*3))
77 #define CONTROL_DEFAULT4_FIRE2		(7+(18*3))
78 #define	CONTROL_DEFAULT4_FIRE3		(9+(18*3))
79 #define	CONTROL_DEFAULT4_FIRE4		(10+(18*3))
80 #define	CONTROL_DEFAULT4_FIRE5		(6+(18*3))
81 #define	CONTROL_DEFAULT4_FIRE6		(8+(18*3))
82 #define CONTROL_DEFAULT4_START		(11+(18*3))
83 #define CONTROL_DEFAULT4_SCREENSHOT 73
84 
85 typedef struct
86 {
87 	int	settings[32];
88 	unsigned long keyflags, newkeyflags;
89 	int kb_break;
90 }
91 s_playercontrols;
92 
93 void control_exit();
94 void control_init(int joy_enable);
95 int control_usejoy(int enable);
96 int control_getjoyenabled();
97 int keyboard_getlastkey();
98 void control_setkey(s_playercontrols * pcontrols, unsigned int flag, int key);
99 int control_scankey();
100 char* control_getkeyname(unsigned int keycode);
101 void control_update(s_playercontrols ** playercontrols, int numplayers);
102 void control_rumble(int port, int ratio, int msec);
103 unsigned long getPad(int port);
104 
105 int dcpad_rumblepower[4];
106 
107 #endif
108 
109