example.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * wiiuse
  3. *
  4. * Written By:
  5. * Michael Laforest < para >
  6. * Email: < thepara (--AT--) g m a i l [--DOT--] com >
  7. *
  8. * Copyright 2006-2007
  9. *
  10. * This file is part of wiiuse.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. * $Header$
  26. *
  27. */
  28. /**
  29. * @file
  30. *
  31. * @brief Example using the wiiuse API.
  32. *
  33. * This file is an example of how to use the wiiuse library.
  34. */
  35. #include <stdio.h> /* for printf */
  36. #include "wiiuse.h" /* for wiimote_t, classic_ctrl_t, etc */
  37. #ifndef WIIUSE_WIN32
  38. #include <unistd.h> /* for usleep */
  39. #endif
  40. #define MAX_WIIMOTES 4
  41. /**
  42. * @brief Callback that handles an event.
  43. *
  44. * @param wm Pointer to a wiimote_t structure.
  45. *
  46. * This function is called automatically by the wiiuse library when an
  47. * event occurs on the specified wiimote.
  48. */
  49. void handle_event(struct wiimote_t* wm) {
  50. printf("\n\n--- EVENT [id %i] ---\n", wm->unid);
  51. /* if a button is pressed, report it */
  52. if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) {
  53. printf("A pressed\n");
  54. }
  55. if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) {
  56. printf("B pressed\n");
  57. }
  58. if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) {
  59. printf("UP pressed\n");
  60. }
  61. if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) {
  62. printf("DOWN pressed\n");
  63. }
  64. if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) {
  65. printf("LEFT pressed\n");
  66. }
  67. if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) {
  68. printf("RIGHT pressed\n");
  69. }
  70. if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) {
  71. printf("MINUS pressed\n");
  72. }
  73. if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) {
  74. printf("PLUS pressed\n");
  75. }
  76. if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
  77. printf("ONE pressed\n");
  78. }
  79. if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) {
  80. printf("TWO pressed\n");
  81. }
  82. if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) {
  83. printf("HOME pressed\n");
  84. }
  85. /*
  86. * Pressing minus will tell the wiimote we are no longer interested in movement.
  87. * This is useful because it saves battery power.
  88. */
  89. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) {
  90. wiiuse_motion_sensing(wm, 0);
  91. }
  92. /*
  93. * Pressing plus will tell the wiimote we are interested in movement.
  94. */
  95. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) {
  96. wiiuse_motion_sensing(wm, 1);
  97. }
  98. /*
  99. * Pressing B will toggle the rumble
  100. *
  101. * if B is pressed but is not held, toggle the rumble
  102. */
  103. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B)) {
  104. wiiuse_toggle_rumble(wm);
  105. }
  106. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_UP)) {
  107. wiiuse_set_ir(wm, 1);
  108. }
  109. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) {
  110. wiiuse_set_ir(wm, 0);
  111. }
  112. /*
  113. * Motion+ support
  114. */
  115. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
  116. if (WIIUSE_USING_EXP(wm)) {
  117. wiiuse_set_motion_plus(wm, 2); // nunchuck pass-through
  118. } else {
  119. wiiuse_set_motion_plus(wm, 1); // standalone
  120. }
  121. }
  122. if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO)) {
  123. wiiuse_set_motion_plus(wm, 0); // off
  124. }
  125. /* if the accelerometer is turned on then print angles */
  126. if (WIIUSE_USING_ACC(wm)) {
  127. printf("wiimote roll = %f [%f]\n", wm->orient.roll, wm->orient.a_roll);
  128. printf("wiimote pitch = %f [%f]\n", wm->orient.pitch, wm->orient.a_pitch);
  129. printf("wiimote yaw = %f\n", wm->orient.yaw);
  130. }
  131. /*
  132. * If IR tracking is enabled then print the coordinates
  133. * on the virtual screen that the wiimote is pointing to.
  134. *
  135. * Also make sure that we see at least 1 dot.
  136. */
  137. if (WIIUSE_USING_IR(wm)) {
  138. int i = 0;
  139. /* go through each of the 4 possible IR sources */
  140. for (; i < 4; ++i) {
  141. /* check if the source is visible */
  142. if (wm->ir.dot[i].visible) {
  143. printf("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
  144. }
  145. }
  146. printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
  147. printf("IR z distance: %f\n", wm->ir.z);
  148. }
  149. /* show events specific to supported expansions */
  150. if (wm->exp.type == EXP_NUNCHUK || wm->exp.type == EXP_MOTION_PLUS_NUNCHUK) {
  151. /* nunchuk */
  152. struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk;
  153. if (IS_PRESSED(nc, NUNCHUK_BUTTON_C)) {
  154. printf("Nunchuk: C pressed\n");
  155. }
  156. if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z)) {
  157. printf("Nunchuk: Z pressed\n");
  158. }
  159. printf("nunchuk roll = %f\n", nc->orient.roll);
  160. printf("nunchuk pitch = %f\n", nc->orient.pitch);
  161. printf("nunchuk yaw = %f\n", nc->orient.yaw);
  162. printf("nunchuk joystick angle: %f\n", nc->js.ang);
  163. printf("nunchuk joystick magnitude: %f\n", nc->js.mag);
  164. printf("nunchuk joystick vals: %f, %f\n", nc->js.x, nc->js.y);
  165. printf("nunchuk joystick calibration (min, center, max): x: %i, %i, %i y: %i, %i, %i\n",
  166. nc->js.min.x,
  167. nc->js.center.x,
  168. nc->js.max.x,
  169. nc->js.min.y,
  170. nc->js.center.y,
  171. nc->js.max.y);
  172. } else if (wm->exp.type == EXP_CLASSIC) {
  173. /* classic controller */
  174. struct classic_ctrl_t* cc = (classic_ctrl_t*)&wm->exp.classic;
  175. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZL)) {
  176. printf("Classic: ZL pressed\n");
  177. }
  178. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_B)) {
  179. printf("Classic: B pressed\n");
  180. }
  181. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_Y)) {
  182. printf("Classic: Y pressed\n");
  183. }
  184. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_A)) {
  185. printf("Classic: A pressed\n");
  186. }
  187. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_X)) {
  188. printf("Classic: X pressed\n");
  189. }
  190. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZR)) {
  191. printf("Classic: ZR pressed\n");
  192. }
  193. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_LEFT)) {
  194. printf("Classic: LEFT pressed\n");
  195. }
  196. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_UP)) {
  197. printf("Classic: UP pressed\n");
  198. }
  199. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_RIGHT)) {
  200. printf("Classic: RIGHT pressed\n");
  201. }
  202. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_DOWN)) {
  203. printf("Classic: DOWN pressed\n");
  204. }
  205. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_L)) {
  206. printf("Classic: FULL L pressed\n");
  207. }
  208. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_MINUS)) {
  209. printf("Classic: MINUS pressed\n");
  210. }
  211. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_HOME)) {
  212. printf("Classic: HOME pressed\n");
  213. }
  214. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_PLUS)) {
  215. printf("Classic: PLUS pressed\n");
  216. }
  217. if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_R)) {
  218. printf("Classic: FULL R pressed\n");
  219. }
  220. printf("classic L button pressed: %f\n", cc->l_shoulder);
  221. printf("classic R button pressed: %f\n", cc->r_shoulder);
  222. printf("classic left joystick angle: %f\n", cc->ljs.ang);
  223. printf("classic left joystick magnitude: %f\n", cc->ljs.mag);
  224. printf("classic right joystick angle: %f\n", cc->rjs.ang);
  225. printf("classic right joystick magnitude: %f\n", cc->rjs.mag);
  226. } else if (wm->exp.type == EXP_GUITAR_HERO_3) {
  227. /* guitar hero 3 guitar */
  228. struct guitar_hero_3_t* gh3 = (guitar_hero_3_t*)&wm->exp.gh3;
  229. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_UP)) {
  230. printf("Guitar: Strum Up pressed\n");
  231. }
  232. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_DOWN)) {
  233. printf("Guitar: Strum Down pressed\n");
  234. }
  235. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_YELLOW)) {
  236. printf("Guitar: Yellow pressed\n");
  237. }
  238. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_GREEN)) {
  239. printf("Guitar: Green pressed\n");
  240. }
  241. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_BLUE)) {
  242. printf("Guitar: Blue pressed\n");
  243. }
  244. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_RED)) {
  245. printf("Guitar: Red pressed\n");
  246. }
  247. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_ORANGE)) {
  248. printf("Guitar: Orange pressed\n");
  249. }
  250. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_PLUS)) {
  251. printf("Guitar: Plus pressed\n");
  252. }
  253. if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_MINUS)) {
  254. printf("Guitar: Minus pressed\n");
  255. }
  256. printf("Guitar whammy bar: %f\n", gh3->whammy_bar);
  257. printf("Guitar joystick angle: %f\n", gh3->js.ang);
  258. printf("Guitar joystick magnitude: %f\n", gh3->js.mag);
  259. } else if (wm->exp.type == EXP_WII_BOARD) {
  260. /* wii balance board */
  261. struct wii_board_t* wb = (wii_board_t*)&wm->exp.wb;
  262. float total = wb->tl + wb->tr + wb->bl + wb->br;
  263. float x = ((wb->tr + wb->br) / total) * 2 - 1;
  264. float y = ((wb->tl + wb->tr) / total) * 2 - 1;
  265. printf("Weight: %f kg @ (%f, %f)\n", total, x, y);
  266. printf("Interpolated weight: TL:%f TR:%f BL:%f BR:%f\n", wb->tl, wb->tr, wb->bl, wb->br);
  267. printf("Raw: TL:%d TR:%d BL:%d BR:%d\n", wb->rtl, wb->rtr, wb->rbl, wb->rbr);
  268. }
  269. if (wm->exp.type == EXP_MOTION_PLUS ||
  270. wm->exp.type == EXP_MOTION_PLUS_NUNCHUK) {
  271. printf("Motion+ angular rates (deg/sec): pitch:%03.2f roll:%03.2f yaw:%03.2f\n",
  272. wm->exp.mp.angle_rate_gyro.pitch,
  273. wm->exp.mp.angle_rate_gyro.roll,
  274. wm->exp.mp.angle_rate_gyro.yaw);
  275. }
  276. }
  277. /**
  278. * @brief Callback that handles a read event.
  279. *
  280. * @param wm Pointer to a wiimote_t structure.
  281. * @param data Pointer to the filled data block.
  282. * @param len Length in bytes of the data block.
  283. *
  284. * This function is called automatically by the wiiuse library when
  285. * the wiimote has returned the full data requested by a previous
  286. * call to wiiuse_read_data().
  287. *
  288. * You can read data on the wiimote, such as Mii data, if
  289. * you know the offset address and the length.
  290. *
  291. * The \a data pointer was specified on the call to wiiuse_read_data().
  292. * At the time of this function being called, it is not safe to deallocate
  293. * this buffer.
  294. */
  295. void handle_read(struct wiimote_t* wm, byte* data, unsigned short len) {
  296. int i = 0;
  297. printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
  298. printf("finished read of size %i\n", len);
  299. for (; i < len; ++i) {
  300. if (!(i % 16)) {
  301. printf("\n");
  302. }
  303. printf("%x ", data[i]);
  304. }
  305. printf("\n\n");
  306. }
  307. /**
  308. * @brief Callback that handles a controller status event.
  309. *
  310. * @param wm Pointer to a wiimote_t structure.
  311. * @param attachment Is there an attachment? (1 for yes, 0 for no)
  312. * @param speaker Is the speaker enabled? (1 for yes, 0 for no)
  313. * @param ir Is the IR support enabled? (1 for yes, 0 for no)
  314. * @param led What LEDs are lit.
  315. * @param battery_level Battery level, between 0.0 (0%) and 1.0 (100%).
  316. *
  317. * This occurs when either the controller status changed
  318. * or the controller status was requested explicitly by
  319. * wiiuse_status().
  320. *
  321. * One reason the status can change is if the nunchuk was
  322. * inserted or removed from the expansion port.
  323. */
  324. void handle_ctrl_status(struct wiimote_t* wm) {
  325. printf("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", wm->unid);
  326. printf("attachment: %i\n", wm->exp.type);
  327. printf("speaker: %i\n", WIIUSE_USING_SPEAKER(wm));
  328. printf("ir: %i\n", WIIUSE_USING_IR(wm));
  329. printf("leds: %i %i %i %i\n", WIIUSE_IS_LED_SET(wm, 1), WIIUSE_IS_LED_SET(wm, 2), WIIUSE_IS_LED_SET(wm, 3), WIIUSE_IS_LED_SET(wm, 4));
  330. printf("battery: %f %%\n", wm->battery_level);
  331. }
  332. /**
  333. * @brief Callback that handles a disconnection event.
  334. *
  335. * @param wm Pointer to a wiimote_t structure.
  336. *
  337. * This can happen if the POWER button is pressed, or
  338. * if the connection is interrupted.
  339. */
  340. void handle_disconnect(wiimote* wm) {
  341. printf("\n\n--- DISCONNECTED [wiimote id %i] ---\n", wm->unid);
  342. }
  343. void test(struct wiimote_t* wm, byte* data, unsigned short len) {
  344. printf("test: %i [%x %x %x %x]\n", len, data[0], data[1], data[2], data[3]);
  345. }
  346. short any_wiimote_connected(wiimote** wm, int wiimotes) {
  347. int i;
  348. if (!wm) {
  349. return 0;
  350. }
  351. for (i = 0; i < wiimotes; i++) {
  352. if (wm[i] && WIIMOTE_IS_CONNECTED(wm[i])) {
  353. return 1;
  354. }
  355. }
  356. return 0;
  357. }
  358. /**
  359. * @brief main()
  360. *
  361. * Connect to up to two wiimotes and print any events
  362. * that occur on either device.
  363. */
  364. int main(int argc, char** argv) {
  365. wiimote** wiimotes;
  366. int found, connected;
  367. /*
  368. * Initialize an array of wiimote objects.
  369. *
  370. * The parameter is the number of wiimotes I want to create.
  371. */
  372. wiimotes = wiiuse_init(MAX_WIIMOTES);
  373. /*
  374. * Find wiimote devices
  375. *
  376. * Now we need to find some wiimotes.
  377. * Give the function the wiimote array we created, and tell it there
  378. * are MAX_WIIMOTES wiimotes we are interested in.
  379. *
  380. * Set the timeout to be 5 seconds.
  381. *
  382. * This will return the number of actual wiimotes that are in discovery mode.
  383. */
  384. found = wiiuse_find(wiimotes, MAX_WIIMOTES, 5);
  385. if (!found) {
  386. printf("No wiimotes found.\n");
  387. return 0;
  388. }
  389. /*
  390. * Connect to the wiimotes
  391. *
  392. * Now that we found some wiimotes, connect to them.
  393. * Give the function the wiimote array and the number
  394. * of wiimote devices we found.
  395. *
  396. * This will return the number of established connections to the found wiimotes.
  397. */
  398. connected = wiiuse_connect(wiimotes, MAX_WIIMOTES);
  399. if (connected) {
  400. printf("Connected to %i wiimotes (of %i found).\n", connected, found);
  401. } else {
  402. printf("Failed to connect to any wiimote.\n");
  403. return 0;
  404. }
  405. /*
  406. * Now set the LEDs and rumble for a second so it's easy
  407. * to tell which wiimotes are connected (just like the wii does).
  408. */
  409. wiiuse_set_leds(wiimotes[0], WIIMOTE_LED_1);
  410. wiiuse_set_leds(wiimotes[1], WIIMOTE_LED_2);
  411. wiiuse_set_leds(wiimotes[2], WIIMOTE_LED_3);
  412. wiiuse_set_leds(wiimotes[3], WIIMOTE_LED_4);
  413. wiiuse_rumble(wiimotes[0], 1);
  414. wiiuse_rumble(wiimotes[1], 1);
  415. #ifndef WIIUSE_WIN32
  416. usleep(200000);
  417. #else
  418. Sleep(200);
  419. #endif
  420. wiiuse_rumble(wiimotes[0], 0);
  421. wiiuse_rumble(wiimotes[1], 0);
  422. printf("\nControls:\n");
  423. printf("\tB toggles rumble.\n");
  424. printf("\t+ to start Wiimote accelerometer reporting, - to stop\n");
  425. printf("\tUP to start IR camera (sensor bar mode), DOWN to stop.\n");
  426. printf("\t1 to start Motion+ reporting, 2 to stop.\n");
  427. printf("\n\n");
  428. /*
  429. * Maybe I'm interested in the battery power of the 0th
  430. * wiimote. This should be WIIMOTE_ID_1 but to be sure
  431. * you can get the wiimote associated with WIIMOTE_ID_1
  432. * using the wiiuse_get_by_id() function.
  433. *
  434. * A status request will return other things too, like
  435. * if any expansions are plugged into the wiimote or
  436. * what LEDs are lit.
  437. */
  438. /* wiiuse_status(wiimotes[0]); */
  439. /*
  440. * This is the main loop
  441. *
  442. * wiiuse_poll() needs to be called with the wiimote array
  443. * and the number of wiimote structures in that array
  444. * (it doesn't matter if some of those wiimotes are not used
  445. * or are not connected).
  446. *
  447. * This function will set the event flag for each wiimote
  448. * when the wiimote has things to report.
  449. */
  450. while (any_wiimote_connected(wiimotes, MAX_WIIMOTES)) {
  451. if (wiiuse_poll(wiimotes, MAX_WIIMOTES)) {
  452. /*
  453. * This happens if something happened on any wiimote.
  454. * So go through each one and check if anything happened.
  455. */
  456. int i = 0;
  457. for (; i < MAX_WIIMOTES; ++i) {
  458. switch (wiimotes[i]->event) {
  459. case WIIUSE_EVENT:
  460. /* a generic event occurred */
  461. handle_event(wiimotes[i]);
  462. break;
  463. case WIIUSE_STATUS:
  464. /* a status event occurred */
  465. handle_ctrl_status(wiimotes[i]);
  466. break;
  467. case WIIUSE_DISCONNECT:
  468. case WIIUSE_UNEXPECTED_DISCONNECT:
  469. /* the wiimote disconnected */
  470. handle_disconnect(wiimotes[i]);
  471. break;
  472. case WIIUSE_READ_DATA:
  473. /*
  474. * Data we requested to read was returned.
  475. * Take a look at wiimotes[i]->read_req
  476. * for the data.
  477. */
  478. break;
  479. case WIIUSE_NUNCHUK_INSERTED:
  480. /*
  481. * a nunchuk was inserted
  482. * This is a good place to set any nunchuk specific
  483. * threshold values. By default they are the same
  484. * as the wiimote.
  485. */
  486. /* wiiuse_set_nunchuk_orient_threshold((struct nunchuk_t*)&wiimotes[i]->exp.nunchuk, 90.0f); */
  487. /* wiiuse_set_nunchuk_accel_threshold((struct nunchuk_t*)&wiimotes[i]->exp.nunchuk, 100); */
  488. printf("Nunchuk inserted.\n");
  489. break;
  490. case WIIUSE_CLASSIC_CTRL_INSERTED:
  491. printf("Classic controller inserted.\n");
  492. break;
  493. case WIIUSE_WII_BOARD_CTRL_INSERTED:
  494. printf("Balance board controller inserted.\n");
  495. break;
  496. case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED:
  497. /* some expansion was inserted */
  498. handle_ctrl_status(wiimotes[i]);
  499. printf("Guitar Hero 3 controller inserted.\n");
  500. break;
  501. case WIIUSE_MOTION_PLUS_ACTIVATED:
  502. printf("Motion+ was activated\n");
  503. break;
  504. case WIIUSE_NUNCHUK_REMOVED:
  505. case WIIUSE_CLASSIC_CTRL_REMOVED:
  506. case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED:
  507. case WIIUSE_WII_BOARD_CTRL_REMOVED:
  508. case WIIUSE_MOTION_PLUS_REMOVED:
  509. /* some expansion was removed */
  510. handle_ctrl_status(wiimotes[i]);
  511. printf("An expansion was removed.\n");
  512. break;
  513. default:
  514. break;
  515. }
  516. }
  517. }
  518. }
  519. /*
  520. * Disconnect the wiimotes
  521. */
  522. wiiuse_cleanup(wiimotes, MAX_WIIMOTES);
  523. return 0;
  524. }