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