Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/include/PR/os_cont.h
7858 views
1
2
/*====================================================================
3
* os_cont.h
4
*
5
* Copyright 1995, Silicon Graphics, Inc.
6
* All Rights Reserved.
7
*
8
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
9
* Inc.; the contents of this file may not be disclosed to third
10
* parties, copied or duplicated in any form, in whole or in part,
11
* without the prior written permission of Silicon Graphics, Inc.
12
*
13
* RESTRICTED RIGHTS LEGEND:
14
* Use, duplication or disclosure by the Government is subject to
15
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
16
* in Technical Data and Computer Software clause at DFARS
17
* 252.227-7013, and/or in similar or successor clauses in the FAR,
18
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
19
* Copyright Laws of the United States.
20
*====================================================================*/
21
22
/*---------------------------------------------------------------------*
23
Copyright (C) 1998 Nintendo. (Originated by SGI)
24
25
$RCSfile: os_cont.h,v $
26
$Revision: 1.1 $
27
$Date: 1998/10/09 08:01:05 $
28
*---------------------------------------------------------------------*/
29
30
#ifndef _OS_CONT_H_
31
#define _OS_CONT_H_
32
33
#ifdef _LANGUAGE_C_PLUS_PLUS
34
extern "C" {
35
#endif
36
37
#include <PR/ultratypes.h>
38
#include "os_message.h"
39
40
41
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
42
43
/**************************************************************************
44
*
45
* Type definitions
46
*
47
*/
48
49
/*
50
* Structure for controllers
51
*/
52
53
typedef struct {
54
u16 type; /* Controller Type */
55
u8 status; /* Controller status */
56
u8 errnum;
57
}OSContStatus;
58
59
typedef struct {
60
u16 button;
61
s8 stick_x; /* -80 <= stick_x <= 80 */
62
s8 stick_y; /* -80 <= stick_y <= 80 */
63
s16 stick2_x;
64
s16 stick2_y;
65
u8 errnum;
66
} OSContPad;
67
68
typedef struct {
69
void *address; /* Ram pad Address: 11 bits */
70
u8 databuffer[32]; /* address of the data buffer */
71
u8 addressCrc; /* CRC code for address */
72
u8 dataCrc; /* CRC code for data */
73
u8 errnum;
74
} OSContRamIo;
75
76
77
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
78
79
/**************************************************************************
80
*
81
* Global definitions
82
*
83
*/
84
85
/*
86
* Controllers number
87
*/
88
89
#ifndef _HW_VERSION_1
90
#define MAXCONTROLLERS 4
91
#else
92
#define MAXCONTROLLERS 6
93
#endif
94
95
/* controller errors */
96
#define CONT_NO_RESPONSE_ERROR 0x8
97
#define CONT_OVERRUN_ERROR 0x4
98
#ifdef _HW_VERSION_1
99
#define CONT_FRAME_ERROR 0x2
100
#define CONT_COLLISION_ERROR 0x1
101
#endif
102
103
/* Controller type */
104
105
#define CONT_ABSOLUTE 0x0001
106
#define CONT_RELATIVE 0x0002
107
#define CONT_JOYPORT 0x0004
108
#define CONT_EEPROM 0x8000
109
#define CONT_EEP16K 0x4000
110
#define CONT_TYPE_MASK 0x1f07
111
#define CONT_TYPE_NORMAL 0x0005
112
#define CONT_TYPE_MOUSE 0x0002
113
#define CONT_TYPE_VOICE 0x0100
114
115
/* Controller status */
116
117
#define CONT_CARD_ON 0x01
118
#define CONT_CARD_PULL 0x02
119
#define CONT_ADDR_CRC_ER 0x04
120
#define CONT_EEPROM_BUSY 0x80
121
122
/* Buttons */
123
124
#define CONT_A 0x8000
125
#define CONT_B 0x4000
126
#define CONT_G 0x2000
127
#define CONT_START 0x1000
128
#define CONT_UP 0x0800
129
#define CONT_DOWN 0x0400
130
#define CONT_LEFT 0x0200
131
#define CONT_RIGHT 0x0100
132
#define CONT_L 0x0020
133
#define CONT_R 0x0010
134
#define CONT_E 0x0008
135
#define CONT_D 0x0004
136
#define CONT_C 0x0002
137
#define CONT_F 0x0001
138
139
/* Nintendo's official button names */
140
141
#define A_BUTTON CONT_A
142
#define B_BUTTON CONT_B
143
#define L_TRIG CONT_L
144
#define R_TRIG CONT_R
145
#define Z_TRIG CONT_G
146
#define START_BUTTON CONT_START
147
#define U_JPAD CONT_UP
148
#define L_JPAD CONT_LEFT
149
#define R_JPAD CONT_RIGHT
150
#define D_JPAD CONT_DOWN
151
#define U_CBUTTONS CONT_E
152
#define L_CBUTTONS CONT_C
153
#define R_CBUTTONS CONT_F
154
#define D_CBUTTONS CONT_D
155
156
/* Controller error number */
157
158
#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
159
#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
160
#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
161
#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */
162
#define CONT_ERR_NOT_READY 12
163
#define CONT_ERR_VOICE_MEMORY 13
164
#define CONT_ERR_VOICE_WORD 14
165
#define CONT_ERR_VOICE_NO_RESPONSE 15
166
167
168
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
169
170
/**************************************************************************
171
*
172
* Macro definitions
173
*
174
*/
175
176
177
/**************************************************************************
178
*
179
* Extern variables
180
*
181
*/
182
183
184
/**************************************************************************
185
*
186
* Function prototypes
187
*
188
*/
189
190
/* Controller interface */
191
192
extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *);
193
extern s32 osContReset(OSMesgQueue *, OSContStatus *);
194
extern s32 osContStartQuery(OSMesgQueue *);
195
extern s32 osContStartReadData(OSMesgQueue *);
196
#ifndef _HW_VERSION_1
197
extern s32 osContSetCh(u8);
198
#endif
199
extern void osContGetQuery(OSContStatus *);
200
extern void osContGetReadData(OSContPad *);
201
202
203
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
204
205
#ifdef _LANGUAGE_C_PLUS_PLUS
206
}
207
#endif
208
209
#endif /* !_OS_CONT_H_ */
210
211