Mario Kart 64
Loading...
Searching...
No Matches
os_cont.h
Go to the documentation of this file.
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
34extern "C" {
35#endif
36
37#include <PR/ultratypes.h>
38#include "os_message.h"
39
40#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
41
42/**************************************************************************
43 *
44 * Type definitions
45 *
46 */
47
48/*
49 * Structure for controllers
50 */
51
52typedef struct {
53 u16 type; /* Controller Type */
54 u8 status; /* Controller status */
55 u8 errnum;
56} OSContStatus;
57
58typedef struct {
59 u16 button;
60 s8 stick_x; /* -80 <= stick_x <= 80 */
61 s8 stick_y; /* -80 <= stick_y <= 80 */
62 u8 errno;
63} OSContPad;
64
65typedef struct {
66 void* address; /* Ram pad Address: 11 bits */
67 u8 databuffer[32]; /* address of the data buffer */
68 u8 addressCrc; /* CRC code for address */
69 u8 dataCrc; /* CRC code for data */
70 u8 errno;
71} OSContRamIo;
72
73#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
74
75/**************************************************************************
76 *
77 * Global definitions
78 *
79 */
80
81/*
82 * Controllers number
83 */
84
85#ifndef _HW_VERSION_1
86#define MAXCONTROLLERS 4
87#else
88#define MAXCONTROLLERS 6
89#endif
90
91/* controller errors */
92#define CONT_NO_RESPONSE_ERROR 0x8
93#define CONT_OVERRUN_ERROR 0x4
94#ifdef _HW_VERSION_1
95#define CONT_FRAME_ERROR 0x2
96#define CONT_COLLISION_ERROR 0x1
97#endif
98
99/* Controller type */
100
101#define CONT_ABSOLUTE 0x0001
102#define CONT_RELATIVE 0x0002
103#define CONT_JOYPORT 0x0004
104#define CONT_EEPROM 0x8000
105#define CONT_EEP16K 0x4000
106#define CONT_TYPE_MASK 0x1f07
107#define CONT_TYPE_NORMAL 0x0005
108#define CONT_TYPE_MOUSE 0x0002
109#define CONT_TYPE_VOICE 0x0100
110
111/* Controller status */
112
113#define CONT_CARD_ON 0x01
114#define CONT_CARD_PULL 0x02
115#define CONT_ADDR_CRC_ER 0x04
116#define CONT_EEPROM_BUSY 0x80
117
118/* Buttons */
119
120#define CONT_A 0x8000
121#define CONT_B 0x4000
122#define CONT_G 0x2000
123#define CONT_START 0x1000
124#define CONT_UP 0x0800
125#define CONT_DOWN 0x0400
126#define CONT_LEFT 0x0200
127#define CONT_RIGHT 0x0100
128#define CONT_L 0x0020
129#define CONT_R 0x0010
130#define CONT_E 0x0008
131#define CONT_D 0x0004
132#define CONT_C 0x0002
133#define CONT_F 0x0001
134
135/* Nintendo's official button names */
136
137#define A_BUTTON CONT_A
138#define B_BUTTON CONT_B
139#define L_TRIG CONT_L
140#define R_TRIG CONT_R
141#define Z_TRIG CONT_G
142#define START_BUTTON CONT_START
143#define U_JPAD CONT_UP
144#define L_JPAD CONT_LEFT
145#define R_JPAD CONT_RIGHT
146#define D_JPAD CONT_DOWN
147#define U_CBUTTONS CONT_E
148#define L_CBUTTONS CONT_C
149#define R_CBUTTONS CONT_F
150#define D_CBUTTONS CONT_D
151
152/* Controller error number */
153
154#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
155#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
156#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
157#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */
158#define CONT_ERR_NOT_READY 12
159#define CONT_ERR_VOICE_MEMORY 13
160#define CONT_ERR_VOICE_WORD 14
161#define CONT_ERR_VOICE_NO_RESPONSE 15
162
163#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
164
165/**************************************************************************
166 *
167 * Macro definitions
168 *
169 */
170
171/**************************************************************************
172 *
173 * Extern variables
174 *
175 */
176
177/**************************************************************************
178 *
179 * Function prototypes
180 *
181 */
182
183/* Controller interface */
184
185extern s32 osContInit(OSMesgQueue*, u8*, OSContStatus*);
186extern s32 osContReset(OSMesgQueue*, OSContStatus*);
187extern s32 osContStartQuery(OSMesgQueue*);
188extern s32 osContStartReadData(OSMesgQueue*);
189#ifndef _HW_VERSION_1
190extern s32 osContSetCh(u8);
191#endif
192extern void osContGetQuery(OSContStatus*);
193extern void osContGetReadData(OSContPad*);
194
195#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
196
197#ifdef _LANGUAGE_C_PLUS_PLUS
198}
199#endif
200
201#endif /* !_OS_CONT_H_ */
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status)
Definition osContInit.c:18
void osContGetReadData(OSContPad *pad)
Definition osContStartReadData.c:33
s32 osContStartReadData(OSMesgQueue *mesg)
Definition osContStartReadData.c:9
signed int s32
Definition ultratypes.h:15
signed char s8
Definition ultratypes.h:11
unsigned short int u16
Definition ultratypes.h:14
unsigned char u8
Definition ultratypes.h:12