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 MAX_BUTTONS				    21
13 
14 #define WII_UP						0x00000001
15 #define WII_RIGHT					0x00000002
16 #define WII_DOWN					0x00000004
17 #define WII_LEFT					0x00000008
18 #define WII_1_A						0x00000010
19 #define WII_2_B						0x00000020
20 #define WII_A_Y_X					0x00000040
21 #define WII_B_X_Y					0x00000080
22 #define WII_MINUS					0x00000100
23 #define WII_PLUS_START				0x00000200
24 #define WII_HOME					0x00000400
25 #define WII_R_TRIGGER				0x00000800
26 #define WII_L_TRIGGER				0x00001000
27 #define WII_ZR						0x00002000
28 #define WII_ZL						0x00004000
29 #define WII_C_R						0x00008000
30 #define WII_Z_L						0x00010000
31 #define WII_SUB_UP					0x00020000
32 #define WII_SUB_RIGHT				0x00040000
33 #define WII_SUB_DOWN				0x00080000
34 #define WII_SUB_LEFT				0x00100000
35 
36 #define	CONTROL_ESC					11
37 
38 #define	CONTROL_DEFAULT1_UP			1
39 #define	CONTROL_DEFAULT1_RIGHT		2
40 #define	CONTROL_DEFAULT1_DOWN		3
41 #define	CONTROL_DEFAULT1_LEFT		4
42 #define CONTROL_DEFAULT1_FIRE1		5
43 #define CONTROL_DEFAULT1_FIRE2		7
44 #define	CONTROL_DEFAULT1_FIRE3		16
45 #define	CONTROL_DEFAULT1_FIRE4		17
46 #define	CONTROL_DEFAULT1_FIRE5		6
47 #define	CONTROL_DEFAULT1_FIRE6		8
48 #define CONTROL_DEFAULT1_START		10
49 #define CONTROL_DEFAULT1_SCREENSHOT 9
50 
51 #define	CONTROL_DEFAULT2_UP			(1+MAX_BUTTONS)
52 #define	CONTROL_DEFAULT2_RIGHT		(2+MAX_BUTTONS)
53 #define	CONTROL_DEFAULT2_DOWN		(3+MAX_BUTTONS)
54 #define	CONTROL_DEFAULT2_LEFT		(4+MAX_BUTTONS)
55 #define CONTROL_DEFAULT2_FIRE1		(5+MAX_BUTTONS)
56 #define CONTROL_DEFAULT2_FIRE2		(7+MAX_BUTTONS)
57 #define	CONTROL_DEFAULT2_FIRE3		(16+MAX_BUTTONS)
58 #define	CONTROL_DEFAULT2_FIRE4		(17+MAX_BUTTONS)
59 #define	CONTROL_DEFAULT2_FIRE5		(6+MAX_BUTTONS)
60 #define	CONTROL_DEFAULT2_FIRE6		(8+MAX_BUTTONS)
61 #define CONTROL_DEFAULT2_START		(10+MAX_BUTTONS)
62 #define CONTROL_DEFAULT2_SCREENSHOT (9+MAX_BUTTONS)
63 
64 #define	CONTROL_DEFAULT3_UP			(1+(MAX_BUTTONS*2))
65 #define	CONTROL_DEFAULT3_RIGHT		(2+(MAX_BUTTONS*2))
66 #define	CONTROL_DEFAULT3_DOWN		(3+(MAX_BUTTONS*2))
67 #define	CONTROL_DEFAULT3_LEFT		(4+(MAX_BUTTONS*2))
68 #define CONTROL_DEFAULT3_FIRE1		(5+(MAX_BUTTONS*2))
69 #define CONTROL_DEFAULT3_FIRE2		(7+(MAX_BUTTONS*2))
70 #define	CONTROL_DEFAULT3_FIRE3		(16+(MAX_BUTTONS*2))
71 #define	CONTROL_DEFAULT3_FIRE4		(17+(MAX_BUTTONS*2))
72 #define	CONTROL_DEFAULT3_FIRE5		(6+(MAX_BUTTONS*2))
73 #define	CONTROL_DEFAULT3_FIRE6		(8+(MAX_BUTTONS*2))
74 #define CONTROL_DEFAULT3_START		(10+(MAX_BUTTONS*2))
75 #define CONTROL_DEFAULT3_SCREENSHOT (9+(MAX_BUTTONS*2))
76 
77 #define	CONTROL_DEFAULT4_UP			(1+(MAX_BUTTONS*3))
78 #define	CONTROL_DEFAULT4_RIGHT		(2+(MAX_BUTTONS*3))
79 #define	CONTROL_DEFAULT4_DOWN		(3+(MAX_BUTTONS*3))
80 #define	CONTROL_DEFAULT4_LEFT		(4+(MAX_BUTTONS*3))
81 #define CONTROL_DEFAULT4_FIRE1		(5+(MAX_BUTTONS*3))
82 #define CONTROL_DEFAULT4_FIRE2		(7+(MAX_BUTTONS*3))
83 #define	CONTROL_DEFAULT4_FIRE3		(16+(MAX_BUTTONS*3))
84 #define	CONTROL_DEFAULT4_FIRE4		(17+(MAX_BUTTONS*3))
85 #define	CONTROL_DEFAULT4_FIRE5		(6+(MAX_BUTTONS*3))
86 #define	CONTROL_DEFAULT4_FIRE6		(8+(MAX_BUTTONS*3))
87 #define CONTROL_DEFAULT4_START		(10+(MAX_BUTTONS*3))
88 #define CONTROL_DEFAULT4_SCREENSHOT (9+(MAX_BUTTONS*3))
89 
90 #define WII_SHUTDOWN                -1
91 #define WII_RESET                   -2
92 
93 typedef struct
94 {
95 	int	settings[32];
96 	unsigned long keyflags, newkeyflags;
97 	int kb_break;
98 }
99 s_playercontrols;
100 
101 void control_exit();
102 void control_init(int joy_enable);
103 int control_usejoy(int enable);
104 int control_getjoyenabled();
105 int keyboard_getlastkey();
106 void control_setkey(s_playercontrols * pcontrols, unsigned int flag, int key);
107 int control_scankey();
108 char* control_getkeyname(unsigned int keycode);
109 void control_update(s_playercontrols ** playercontrols, int numplayers);
110 void control_rumble(int port, int msec);
111 unsigned long getPad(int port);
112 
113 #endif
114 
115