1 /*---------------------------------------------------------------------------* 2 Project: WPAD library 3 File: wpad.h 4 Programmers: TOKUNAGA, Yasuhiro 5 HIRATSU Daisuke 6 FUKUDA Takahiro 7 TOJO Haruki 8 9 Copyright (C) 2005-2006 Nintendo. All rights reserved. 10 11 These coded instructions, statements, and computer programs contain 12 proprietary information of Nintendo of America Inc. and/or Nintendo 13 Company Ltd., and are protected by Federal copyright law. They may 14 not be disclosed to third parties or copied or duplicated in any form, 15 in whole or in part, without the prior written consent of Nintendo. 16 17 $Log: wpad.h,v $ 18 Revision 1.70.2.1 2007/12/10 07:25:08 tojo 19 Made the following functions privated. 20 - WPADSaveConfig 21 - WPADEnableMotor 22 - WPADSetSpeakerVolume 23 24 Revision 1.70 2007/07/10 08:10:28 tojo 25 Removed WPAD_SYNC_EVT_BUSY. 26 27 Revision 1.69 2007/05/03 08:22:24 tojo 28 (none) 29 30 Revision 1.68 2007/04/12 07:59:42 tojo 31 (none) 32 33 Revision 1.67 2007/04/11 00:59:29 tojo 34 (none) 35 36 Revision 1.66 2007/04/10 10:14:08 tojo 37 (none) 38 39 Revision 1.65 2007/04/02 09:54:56 tojo 40 Added attaching/detaching dummy extension only for debug use. 41 42 Revision 1.64 2007/03/19 12:48:10 tojo 43 (none) 44 45 Revision 1.63 2006/11/29 10:27:29 tojo 46 Implemented WPADControlExtGimmick. 47 48 Revision 1.62 2006/11/29 10:14:14 tojo 49 (none) 50 51 Revision 1.60 2006/10/20 01:56:44 tojo 52 Added WPADGetDpdFormat(). 53 54 Revision 1.59 2006/10/18 09:55:07 tojo 55 (none) 56 57 Revision 1.58 2006/10/11 17:08:04 tojo 58 Added busy state. 59 60 Revision 1.57 2006/09/27 01:09:15 tojo 61 Changed api. 62 63 Revision 1.56 2006/09/23 06:01:23 tojo 64 Changed API names. 65 66 Revision 1.55 2006/09/22 02:49:22 tojo 67 Added WPAD_ERR_CORRUPTED. 68 69 Revision 1.54 2006/09/21 05:47:50 tojo 70 Added WPAD_ERR_NOPERM and WPAD_ERR_BROKEN 71 72 Revision 1.53 2006/09/15 13:52:03 tojo 73 Added fast sync apis and check audio streaming can 74 75 Revision 1.52 2006/09/06 03:12:34 tojo 76 Added some macros. 77 78 Revision 1.51 2006/09/06 02:40:45 tojo 79 Implemented to control connectability. 80 81 Revision 1.50 2006/09/04 01:54:20 tojo 82 Added WPADSetDpdSensitivity. 83 84 Revision 1.49 2006/09/02 02:06:50 tojo 85 (none) 86 87 Revision 1.48 2006/08/29 01:42:05 tojo 88 Added WPAD_DEV_FUTURE 89 90 Revision 1.47 2006/08/28 14:32:18 tojo 91 Added WPAD_DEV_NOT_SUPPORTED 92 93 Revision 1.46 2006/08/28 13:07:25 tojo 94 Made WPADGetDpdSensitivity public. 95 96 Revision 1.45 2006/08/16 10:55:28 mitu 97 deleted WPAD_MEM_FACEDATA_LEN. 98 99 Revision 1.44 2006/08/16 09:37:36 tojo 100 (none) 101 102 Revision 1.43 2006/08/15 01:00:08 tojo 103 (none) 104 105 Revision 1.42 2006/08/14 17:45:02 tojo 106 (none) 107 108 Revision 1.41 2006/08/14 16:58:05 tojo 109 Modified WPADMEM API. 110 111 Revision 1.40 2006/08/14 07:49:11 tojo 112 (none) 113 114 Revision 1.39 2006/08/11 10:19:23 yasumoto_yoshitaka 115 surpress padding warning 116 117 Revision 1.38 2006/08/11 07:53:55 tojo 118 Added embedded memory apis. 119 120 Revision 1.37 2006/08/10 01:18:42 tojo 121 Added dpd full mode. 122 Changed system config apis. 123 124 Revision 1.36 2006/08/07 00:18:16 tojo 125 (none) 126 127 Revision 1.35 2006/08/03 13:09:34 tojo 128 Moved some config api to privete apis. 129 130 Revision 1.34 2006/08/03 11:54:45 tojo 131 Changed clamp apis. 132 133 Revision 1.33 2006/08/01 06:03:18 tojo 134 (none) 135 136 Revision 1.32 2006/07/20 01:18:12 tojo 137 Added WPADIsMotorEnabled. 138 139 Revision 1.31 2006/07/19 08:14:43 tojo 140 Changed argument type u8 to u16 at WPADSetDisableChannel 141 142 Revision 1.30 2006/07/18 10:04:49 tojo 143 Added WPAD_STRM_INTERVAL 144 Changed WPAD_DISABLED_WIFI_* 145 146 Revision 1.29 2006/07/04 08:16:52 tojo 147 Added speaker/config/motor functions 148 149 Revision 1.28 2006/06/30 08:59:19 tojo 150 Added WPADGetWorkMemorySize(). 151 152 Revision 1.27 2006/06/17 07:00:55 tojo 153 (none) 154 155 Revision 1.26 2006/06/17 05:19:13 tojo 156 Added WPAD_ADD_LEN 157 Removed WPAD_ACC_1G_VALUE, WPAD_FS_ACC_1G_VALUE 158 159 Revision 1.25 2006/06/16 04:30:50 tojo 160 Added WPAD_CLEAR_EVT_BUSY. 161 Changed WPAD_CL_STICK_RESO. 162 163 Revision 1.24 2006/06/15 07:04:03 tojo 164 Changed API of WPADGetAccGravityUnit. 165 166 Revision 1.22 2006/06/15 05:46:05 tojo 167 (none) 168 169 Revision 1.21 2006/06/15 05:20:33 tojo 170 Added WPADGetAccGravityUnit. 171 Removed WPADGetOrigin. 172 Resumed WPADRecalibrate for backward compatibility. 173 174 Revision 1.20 2006/06/14 11:31:14 tojo 175 Added WPADGetRegisteredDevNum(). 176 177 Revision 1.19 2006/06/14 10:49:05 tojo 178 Fixed typo : Extention -> Extension. 179 Removed WPADIsEmulator, WPADRecalibrate. 180 Added WPADIsSpeakerEnabled. 181 182 Revision 1.18 2006/06/13 14:21:54 tojo 183 Added some macros. 184 185 Revision 1.17 2006/06/13 11:45:14 tojo 186 Added delete all link keys handler. 187 188 Revision 1.16 2006/06/13 06:29:55 tojo 189 (none) 190 191 Revision 1.15 2006/06/13 06:05:34 tojo 192 Added 193 WPADSetExtentionCallback 194 WPADSetConnectCallback 195 WPADIsEmulator 196 197 Revision 1.14 2006/06/12 11:42:18 ekwon 198 New API to query enable/disable state of DPD. 199 200 Revision 1.13 2006/06/12 06:05:44 tojo 201 (none) 202 203 Revision 1.12 2006/06/12 00:07:39 tojo 204 Changed some API 205 Defined classic controller button mappings 206 207 Revision 1.11 2006/06/05 11:47:43 tojo 208 Defined WPADOrigin. 209 Added WPADGetOrigin. 210 211 Revision 1.10 2006/06/03 10:00:50 tojo 212 Switched WPAD_BUTTON_C and WPAD_BUTTON_Z 213 214 Revision 1.9 2006/06/01 08:53:36 tojo 215 Changed the declaration of WPADSyncCallback 216 217 Revision 1.8 2006/05/25 13:00:33 tojo 218 wrapped wud api 219 220 Revision 1.7 2006/05/25 12:21:04 tojo 221 added WPADRegisterAllocator(), 222 223 Revision 1.6 2006/05/23 05:48:26 tojo 224 added WPAD_DPD_* and WPAD_SPEAKER_* 225 226 Revision 1.5 2006/05/17 12:37:30 ekwon 227 Added NearEmpty field to WPADInfo. 228 229 Revision 1.4 2006/05/17 04:59:33 kawaset 230 Added definitions for production version controllers. Use preprocessor macro WPADEMU for backwards compatibility. 231 232 Revision 1.3 2006/02/07 11:44:09 yasuh-to 233 Deleted structure for Classic Contoroller. CL is not release at SDK1.0. 234 235 *---------------------------------------------------------------------------*/ 236 237 #ifndef __WPAD_H__ 238 #define __WPAD_H__ 239 240 #include <revolution/types.h> 241 #include <revolution/os.h> 242 243 #ifdef __cplusplus 244 extern "C" { 245 #endif 246 247 #define WPAD_CHAN0 0 248 #define WPAD_CHAN1 1 249 #define WPAD_CHAN2 2 250 #define WPAD_CHAN3 3 251 252 #define WPAD_MAX_CONTROLLERS 4 253 254 #define WPAD_MOTOR_STOP 0 255 #define WPAD_MOTOR_RUMBLE 1 256 257 #ifndef WPADEMU 258 // Under construction. These definitions are subject to change. 259 260 #define WPAD_BUTTON_LEFT 0x0001 261 #define WPAD_BUTTON_RIGHT 0x0002 262 #define WPAD_BUTTON_DOWN 0x0004 263 #define WPAD_BUTTON_UP 0x0008 264 #define WPAD_BUTTON_PLUS 0x0010 265 #define WPAD_BUTTON_2 0x0100 266 #define WPAD_BUTTON_1 0x0200 267 #define WPAD_BUTTON_B 0x0400 268 #define WPAD_BUTTON_A 0x0800 269 #define WPAD_BUTTON_MINUS 0x1000 270 #define WPAD_BUTTON_HOME 0x8000 271 272 #define WPAD_BUTTON_Z 0x2000 273 #define WPAD_BUTTON_C 0x4000 274 275 // backwards compatibility 276 #define WPAD_BUTTON_START WPAD_BUTTON_PLUS 277 #define WPAD_BUTTON_SELECT WPAD_BUTTON_MINUS 278 #define WPAD_BUTTON_SMALL_A WPAD_BUTTON_1 279 #define WPAD_BUTTON_SMALL_B WPAD_BUTTON_2 280 281 // for classic controller extension 282 #define WPAD_CL_BUTTON_UP 0x0001 283 #define WPAD_CL_BUTTON_LEFT 0x0002 284 #define WPAD_CL_TRIGGER_ZR 0x0004 285 #define WPAD_CL_BUTTON_X 0x0008 286 #define WPAD_CL_BUTTON_A 0x0010 287 #define WPAD_CL_BUTTON_Y 0x0020 288 #define WPAD_CL_BUTTON_B 0x0040 289 #define WPAD_CL_TRIGGER_ZL 0x0080 290 #define WPAD_CL_RESERVED 0x0100 291 #define WPAD_CL_TRIGGER_R 0x0200 292 #define WPAD_CL_BUTTON_PLUS 0x0400 293 #define WPAD_CL_BUTTON_HOME 0x0800 294 #define WPAD_CL_BUTTON_MINUS 0x1000 295 #define WPAD_CL_TRIGGER_L 0x2000 296 #define WPAD_CL_BUTTON_DOWN 0x4000 297 #define WPAD_CL_BUTTON_RIGHT 0x8000 298 299 300 #define WPAD_DPD_OFF 0 301 #define WPAD_DPD_STD 1 302 #define WPAD_DPD_EXP 3 303 #define WPAD_DPD_FULL 5 304 305 #define WPAD_DPD_MAX_OBJECTS 4 306 #define WPAD_DPD_ANGLE 42.0f // viewing angle 307 #define WPAD_DPD_IMG_RESO_WX 1024 // DPD image resolution 308 #define WPAD_DPD_IMG_RESO_WY 768 309 310 #define WPAD_SPEAKER_OFF 0 311 #define WPAD_SPEAKER_ON 1 312 #define WPAD_SPEAKER_MUTE 2 313 #define WPAD_SPEAKER_MUTE_OFF 3 314 #define WPAD_SPEAKER_PLAY 4 315 #define WPAD_SPEAKER_RESET 5 316 317 #define WPAD_EXTGMK_OFF 0 318 #define WPAD_EXTGMK_ON 1 319 320 #define WPAD_ACC_RESO 1024 // accelerometer resolution 321 #define WPAD_ACC_MAX 3.4f // valid gravity = 3.4G 322 323 #define WPAD_FS_STICK_RESO 256 // stick resolution of FreeStyle unit 324 #define WPAD_FS_ACC_RESO 1024 // accelerometer resolution of FreeStyle unit 325 #define WPAD_FS_ACC_MAX 2.1f // valid gravity = 2.1G 326 327 #define WPAD_CL_STICK_RESO 1024 328 #define WPAD_CL_TRIGGER_RESO 256 329 330 // device type 331 #define WPAD_DEV_CORE 0 332 #define WPAD_DEV_FREESTYLE 1 333 #define WPAD_DEV_CLASSIC 2 334 #define WPAD_DEV_FUTURE 251 335 #define WPAD_DEV_NOT_SUPPORTED 252 336 #define WPAD_DEV_NOT_FOUND 253 337 #define WPAD_DEV_UNKNOWN 255 338 339 // data format of Core 340 #define WPAD_FMT_CORE 0 // only buttons 341 #define WPAD_FMT_CORE_ACC 1 // buttons, motion sensor 342 #define WPAD_FMT_CORE_ACC_DPD 2 // buttons, motion sensor, pointing 343 // data format of Core + Nunchaku 344 #define WPAD_FMT_FREESTYLE 3 // buttons, nunchaku 345 #define WPAD_FMT_FREESTYLE_ACC 4 // buttons, motion sensor, nunchaku 346 #define WPAD_FMT_FREESTYLE_ACC_DPD 5 // buttons, motion sensor, pointing, nunchaku 347 // data format of Core + Classic Controller 348 #define WPAD_FMT_CLASSIC 6 // buttons, classic 349 #define WPAD_FMT_CLASSIC_ACC 7 // buttons, motion sensor, classic 350 #define WPAD_FMT_CLASSIC_ACC_DPD 8 // buttons, motion sensor, pointing, classic 351 // data format of Core + DPD full mode 352 #define WPAD_FMT_CORE_ACC_DPD_FULL 9 // buttons, motion sensor, pointing 353 354 #define WPAD_STATE_DISABLED 0 355 #define WPAD_STATE_ENABLING 1 356 #define WPAD_STATE_ENABLED 2 357 #define WPAD_STATE_SETUP 3 358 #define WPAD_STATE_DISABLING 4 359 360 // disable channel to avoid WiFi interference. 361 #define WPAD_DISABLE_CLEAR 0x0000 // enable all range 362 #define WPAD_DISABLE_WIFI_CHAN_1 0x0001 363 #define WPAD_DISABLE_WIFI_CHAN_2 0x0002 364 #define WPAD_DISABLE_WIFI_CHAN_3 0x0004 365 #define WPAD_DISABLE_WIFI_CHAN_4 0x0008 366 #define WPAD_DISABLE_WIFI_CHAN_5 0x0010 367 #define WPAD_DISABLE_WIFI_CHAN_6 0x0020 368 #define WPAD_DISABLE_WIFI_CHAN_7 0x0040 369 #define WPAD_DISABLE_WIFI_CHAN_8 0x0080 370 #define WPAD_DISABLE_WIFI_CHAN_9 0x0100 371 #define WPAD_DISABLE_WIFI_CHAN_10 0x0200 372 #define WPAD_DISABLE_WIFI_CHAN_11 0x0400 373 #define WPAD_DISABLE_WIFI_CHAN_12 0x0800 374 #define WPAD_DISABLE_WIFI_CHAN_13 0x1000 375 #define WPAD_DISABLE_WIFI_CHAN_14 0x2000 376 377 // battery level 378 #define WPAD_BATTERY_LEVEL_CRITICAL 0 379 #define WPAD_BATTERY_LEVEL_LOW 1 380 #define WPAD_BATTERY_LEVEL_MEDIUM 2 381 #define WPAD_BATTERY_LEVEL_HIGH 3 382 #define WPAD_BATTERY_LEVEL_MAX 4 383 384 #define WPAD_LED_CHAN_1 0x1 385 #define WPAD_LED_CHAN_2 0x2 386 #define WPAD_LED_CHAN_3 0x4 387 #define WPAD_LED_CHAN_4 0x8 388 389 #define WPAD_SYNC_EVT_START 0 390 #define WPAD_SYNC_EVT_DONE 1 391 392 #define WPAD_CLEAR_EVT_BUSY -1 393 #define WPAD_CLEAR_EVT_START 0 394 #define WPAD_CLEAR_EVT_DONE 1 395 396 #define WPAD_ADDR_LEN 6 397 398 #define WPAD_STRM_INTERVAL OSNanosecondsToTicks(6666667) 399 400 // clamp algorithm for stick 401 #define WPAD_STICK_CLAMP_OCTA_WITH_PLAY 0 402 #define WPAD_STICK_CLAMP_OCTA_WITHOUT_PLAY 1 403 #define WPAD_STICK_CLAMP_CIRCLE_WITH_PLAY 2 404 #define WPAD_STICK_CLAMP_CIRCLE_WITHOUT_PLAY 3 405 // clamp algorithm for trigger 406 #define WPAD_TRIGGER_FIXED_BASE 0 407 #define WPAD_TRIGGER_INDIVIDUAL_BASE 1 408 // clamp algorithm for accelerometer 409 #define WPAD_ACC_CLAMP_CUBE 0 410 #define WPAD_ACC_CLAMP_SPHERE 1 411 412 #define WPAD_SENSOR_BAR_POS_BOTTOM 0 413 #define WPAD_SENSOR_BAR_POS_TOP 1 414 415 #define WPAD_MEM_GAMEDATA_LEN 3888 416 417 #define WPAD_SYNC_TYPE_STD 0 418 #define WPAD_SYNC_TYPE_SMP 1 419 420 #else 421 // SI-based WPAD 422 423 #define WPAD_BUTTON_HOME 0x0001 424 #define WPAD_BUTTON_SELECT 0x0002 425 #define WPAD_BUTTON_A 0x0004 426 #define WPAD_BUTTON_B 0x0008 427 #define WPAD_BUTTON_SMALL_A 0x0010 428 #define WPAD_BUTTON_SMALL_B 0x0020 429 #define WPAD_BUTTON_START 0x0100 430 #define WPAD_BUTTON_UP 0x0200 431 #define WPAD_BUTTON_DOWN 0x0400 432 #define WPAD_BUTTON_RIGHT 0x0800 433 #define WPAD_BUTTON_LEFT 0x1000 434 #define WPAD_BUTTON_Z1 0x2000 435 #define WPAD_BUTTON_Z2 0x4000 436 #define WPAD_BUTTON_X WPAD_BUTTON_SMALL_A 437 #define WPAD_BUTTON_Y WPAD_BUTTON_SMALL_B 438 #define WPAD_TRIGGER_Z WPAD_BUTTON_Z1 439 #define WPAD_TRIGGER_R WPAD_BUTTON_Z2 440 #define WPAD_TRIGGER_L 0x8000 441 442 #define WPAD_DPD_MAX_OBJECTS 4 443 #define WPAD_DPD_ANGLE 42.0f // viewing angle 444 #define WPAD_DPD_IMG_RESO_WX 1024 // DPD image resolution 445 #define WPAD_DPD_IMG_RESO_WY 768 446 447 #define WPAD_ACC_RESO 1024 // accelerometer resolution 448 #define WPAD_ACC_1G_VALUE 205 // gravity value 449 450 #define WPAD_FS_STICK_RESO 256 // stick resolution of FreeStyle unit 451 #define WPAD_FS_ACC_RESO 1024 // accelerometer resolution of FreeStyle unit 452 #define WPAD_FS_ACC_1G_VALUE 205 // gravity value of FreeStyle unit 453 454 #define WPAD_DEV_CORE 0 455 #define WPAD_DEV_FREESTYLE 1 456 #define WPAD_DEV_DOLPHIN 254 457 #define WPAD_DEV_UNKNOWN 255 458 #define WPAD_DEV_NOT_FOUND 253 // For backwards compatibility. Don't use. 459 460 #define WPAD_FMT_CORE 0 // data format of Core controller 461 #define WPAD_FMT_FREESTYLE 1 // data format of FreeStyle controller 462 #define WPAD_FMT_DOLPHIN 255 // data format of Dolphin controller(for debug) 463 464 #endif 465 466 #define WPAD_ERR_NONE 0 467 #define WPAD_ERR_NO_CONTROLLER -1 468 #define WPAD_ERR_BUSY -2 469 #define WPAD_ERR_TRANSFER -3 470 #define WPAD_ERR_INVALID -4 471 #define WPAD_ERR_NOPERM -5 472 #define WPAD_ERR_BROKEN -6 473 #define WPAD_ERR_CORRUPTED -7 474 475 #ifdef __MWERKS__ 476 #pragma warn_padding off 477 #endif 478 typedef struct DPDObject 479 { 480 s16 x; // 0 <= x < WPAD_DPD_IMG_RESO_WX 481 s16 y; // 0 <= y < WPAD_DPD_IMG_RESO_WY 482 u16 size; 483 u8 traceId; 484 // 1 byte padding 485 } DPDObject; 486 #ifdef __MWERKS__ 487 #pragma warn_padding reset 488 #endif 489 490 #ifdef __MWERKS__ 491 #pragma warn_padding off 492 #endif 493 typedef struct DPDObjEx 494 { 495 s16 range_x1; 496 s16 range_y1; 497 s16 range_x2; 498 s16 range_y2; 499 u16 pixel; 500 s8 radius; 501 // 1 byte padding 502 } DPDObjEx; 503 #ifdef __MWERKS__ 504 #pragma warn_padding reset 505 #endif 506 507 typedef struct WPADStatus 508 { 509 u16 button; // Or-ed WPAD_BUTTON_* bits 510 s16 accX; // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2 511 s16 accY; // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2 512 s16 accZ; // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2 513 DPDObject obj[WPAD_DPD_MAX_OBJECTS]; 514 515 u8 dev; // one of WPAD_DEV_* number 516 s8 err; // one of WPAD_ERR_* number 517 } WPADStatus; 518 519 typedef struct WPADFSStatus 520 { 521 u16 button; // Or-ed WPAD_BUTTON_* bits 522 s16 accX; // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2 523 s16 accY; // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2 524 s16 accZ; // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2 525 DPDObject obj[WPAD_DPD_MAX_OBJECTS]; 526 527 u8 dev; // one of WPAD_DEV_* number 528 s8 err; // one of WPAD_ERR_* number 529 530 s16 fsAccX; // -WPAD_FS_ACC_RESO/2 <= fsAccX < WPAD_ACC_RESO/2 531 s16 fsAccY; // -WPAD_FS_ACC_RESO/2 <= fsAccY < WPAD_ACC_RESO/2 532 s16 fsAccZ; // -WPAD_FS_ACC_RESO/2 <= fsAccZ < WPAD_ACC_RESO/2 533 s8 fsStickX; // -WPAD_FS_STICK_RESO/2 <= fsStickX < WPAD_FS_STICK_RESO/2 534 s8 fsStickY; // -WPAD_FS_STICK_RESO/2 <= fsStickY < WPAD_FS_STICK_RESO/2 535 } WPADFSStatus; 536 537 typedef struct WPADCLStatus 538 { 539 u16 button; // Or-ed WPAD_BUTTON_* bits 540 s16 accX; // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2 541 s16 accY; // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2 542 s16 accZ; // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2 543 DPDObject obj[WPAD_DPD_MAX_OBJECTS]; 544 545 u8 dev; // one of WPAD_DEV_* number 546 s8 err; // one of WPAD_ERR_* number 547 548 u16 clButton; // Or-ed WPAD_CL_BUTTON * bits 549 s16 clLStickX; // -WPAD_CL_STICK_RESO/2 <= clLStickX < WPAD_CL_STICK_RESO/2 550 s16 clLStickY; // -WPAD_CL_STICK_RESO/2 <= clLStickY < WPAD_CL_STICK_RESO/2 551 s16 clRStickX; // -WPAD_CL_STICK_RESO/2 <= clRStickX < WPAD_CL_STICK_RESO/2 552 s16 clRStickY; // -WPAD_CL_STICK_RESO/2 <= clRStickY < WPAD_CL_STICK_RESO/2 553 u8 clTriggerL; // 0 <= clTriggerL < WPAD_CL_TRIGGER_RESO 554 u8 clTriggerR; // 0 <= clTriggerR < WPAD_CL_TRIGGER_RESO 555 } WPADCLStatus; 556 557 typedef struct WPADStatusEx 558 { 559 u16 button; // Or-ed WPAD_BUTTON_* bits 560 s16 accX; // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2 561 s16 accY; // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2 562 s16 accZ; // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2 563 DPDObject obj[WPAD_DPD_MAX_OBJECTS]; 564 565 u8 dev; // one of WPAD_DEV_* number 566 s8 err; // one of WPAD_ERR_* number 567 568 DPDObjEx exp[WPAD_DPD_MAX_OBJECTS]; 569 570 } WPADStatusEx; 571 572 typedef struct WPADInfo 573 { 574 BOOL dpd; // the active status of pointer unit 575 BOOL speaker; // the active status of speaker unit 576 BOOL attach; // whether an attachment is installed (=1) or not (=0) 577 BOOL lowBat; // whether the current battery level is lower than a threshold (0x20) 578 BOOL nearempty; // sound buffer is nearly empty 579 u8 battery; // the current battery level (WPAD_BATTERY_LEVEL_*) 580 u8 led; // the current pattern of 4 LEDs 581 u8 protocol; // not used 582 u8 firmware; // not used 583 } WPADInfo; 584 585 typedef struct WPADAcc 586 { 587 s16 x; 588 s16 y; 589 s16 z; 590 } WPADAcc; 591 592 593 typedef void ( *WPADExtensionCallback )( s32 chan, s32 result ); 594 typedef void ( *WPADSamplingCallback )( s32 chan ); 595 typedef void ( *WPADConnectCallback )( s32 chan, s32 reason ); 596 typedef void ( *WPADCallback )( s32 chan, s32 result ); 597 typedef void * ( *WPADAlloc )( u32 size ); 598 typedef u8 ( *WPADFree )( void *ptr ); 599 typedef void ( *WPADSyncDeviceCallback )( s32 result, s32 num ); 600 typedef void ( *WPADClearDeviceCallback )( s32 result ); 601 typedef void ( *WPADFlushCallback )( u32 result ); 602 603 #define WPADButtonDown( buttonLast, button ) \ 604 ( (u16) (((buttonLast) ^ (button)) & (button)) ) 605 606 #define WPADButtonUp( buttonLast, button ) \ 607 ( (u16) (((buttonLast) ^ (button)) & (buttonLast)) ) 608 609 #define WPADStartMotor( chan ) WPADControlMotor( ( chan ), WPAD_MOTOR_RUMBLE ) 610 #define WPADStopMotor( chan ) WPADControlMotor( ( chan ), WPAD_MOTOR_STOP ) 611 612 613 #ifdef WPADEMU 614 // only for WPADEmu 615 BOOL WPADAttach ( s32 chan ); 616 BOOL WPADRecalibrate ( s32 chan ); 617 618 #endif 619 620 621 void WPADInit ( void ); 622 void WPADShutdown ( void ); 623 void WPADReconnect ( void ); 624 void WPADRegisterAllocator ( WPADAlloc alloc, WPADFree free ); 625 u32 WPADGetWorkMemorySize ( void ); 626 s32 WPADProbe ( s32 chan, u32 *type ); 627 s32 WPADGetStatus ( void ); 628 u32 WPADGetDataFormat ( s32 chan ); 629 s32 WPADSetDataFormat ( s32 chan, u32 fmt ); 630 void WPADRead ( s32 chan, void *status ); 631 void WPADSetAutoSamplingBuf ( s32 chan, void *buf, u32 length); 632 u32 WPADGetLatestIndexInBuf ( s32 chan ); 633 void WPADGetAccGravityUnit ( s32 chan, u32 type, WPADAcc *acc ); 634 void WPADGetCLTriggerThreshold ( s32 chan, u8 *left, u8 *right ); 635 636 #ifdef WPADEMU 637 void WPADClampStick ( u32 fmt, void *status ); 638 #else 639 void WPADClampStick ( s32 chan, void *status, u32 type ); 640 void WPADClampTrigger ( s32 chan, void *status, u32 type ); 641 void WPADClampAcc ( s32 chan, void *status, u32 type ); 642 #endif 643 644 BOOL WPADIsDpdEnabled ( s32 chan ); 645 u8 WPADGetDpdFormat ( s32 chan ); 646 s32 WPADControlDpd ( s32 chan, u32 command, WPADCallback callback ); 647 u8 WPADGetDpdSensitivity ( void ); 648 void WPADSetDpdSensitivity ( u8 level ); 649 650 s32 WPADControlExtGimmick ( s32 chan, u32 command, WPADCallback callback ); 651 652 void WPADDisconnect ( s32 chan ); 653 s32 WPADGetInfo ( s32 chan, WPADInfo *info ); 654 s32 WPADGetInfoAsync ( s32 chan, WPADInfo *info, WPADCallback callback ); 655 void WPADGetAddress ( s32 chan, u8 *addr ); 656 u8 WPADGetRegisteredDevNum ( void ); 657 u8 WPADGetTemporaryDevNum ( void ); 658 u8 WPADGetRadioSensitivity ( s32 chan ); 659 660 BOOL WPADIsSpeakerEnabled ( s32 chan ); 661 s32 WPADControlSpeaker ( s32 chan, u32 command, WPADCallback callback ); 662 u8 WPADGetSpeakerVolume ( void ); 663 s32 WPADSendStreamData ( s32 chan, void *buf, u16 len ); 664 BOOL WPADCanSendStreamData ( s32 chan ); 665 666 void WPADControlMotor ( s32 chan, u32 command ); 667 BOOL WPADIsMotorEnabled ( void ); 668 669 void WPADSetAutoSleepTime ( u8 minute ); 670 u8 WPADGetSensorBarPosition ( void ); 671 void WPADClearPortMapTable ( void ); 672 673 s32 WPADReadGameData ( s32 chan, void *p_buf, u16 len, u16 offset, WPADCallback callback ); 674 s32 WPADWriteGameData ( s32 chan, void *p_buf, u16 len, u16 offset, WPADCallback callback ); 675 void WPADSetGameTitleUtf16 ( const u16 *title ); 676 s32 WPADGetGameTitleUtf16 ( s32 chan, const u16 **title ); 677 s32 WPADGetGameDataTimeStamp ( s32 chan, OSTime *time ); 678 679 BOOL WPADSetAcceptConnection ( BOOL accept ); 680 BOOL WPADGetAcceptConnection ( void ); 681 682 BOOL WPADSetDisableChannel ( u16 disable ); 683 BOOL WPADStartSyncDevice ( void ); 684 BOOL WPADStartClearDevice ( void ); 685 BOOL WPADStartSimpleSync ( void ); 686 BOOL WPADStopSimpleSync ( void ); 687 BOOL WPADStartFastSyncDevice ( void ); 688 BOOL WPADStartFastSimpleSync ( void ); 689 690 s32 WPADGetSyncType ( s32 chan, u8 *type ); 691 692 WPADSamplingCallback WPADSetSamplingCallback ( s32 chan, WPADSamplingCallback callback ); 693 WPADExtensionCallback WPADSetExtensionCallback ( s32 chan, WPADExtensionCallback callback ); 694 WPADConnectCallback WPADSetConnectCallback ( s32 chan, WPADConnectCallback callback ); 695 WPADSyncDeviceCallback WPADSetSyncDeviceCallback ( WPADSyncDeviceCallback callback ); 696 WPADSyncDeviceCallback WPADSetSimpleSyncCallback ( WPADSyncDeviceCallback callback ); 697 WPADClearDeviceCallback WPADSetClearDeviceCallback ( WPADClearDeviceCallback callback ); 698 699 // These can be used in only debug build so that application can debug extension handling 700 BOOL WPADAttachDummyExtension( s32 chan, u32 type ); 701 BOOL WPADDetachDummyExtension( s32 chan ); 702 703 #ifdef __cplusplus 704 } 705 #endif 706 707 708 #endif // __WPAD_H__ 709