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