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