Wii. Wii. ., Wii. Bluetooth, , Bluetooth , 1., Wii. ., SANYO eneloop, 2 Bluetooth, PC. , Windows. 1. Wii

Σχετικά έγγραφα
Εργαστήριο 4: Υλοποίηση Αφηρημένου Τύπου Δεδομένων: Ταξινομημένη Λίστα

Προγραμματισμό για ΗΜΥ

Κεφάλαιο : Εισαγωγή στην C: (Διαλέξεις 3-4)

Δομημένος Προγραμματισμός (ΤΛ1006)

ΕΛΛΗΝΙΚΗ ΕΤΑΙΡΕΙΑ ΕΠΙΣΤΗΜΟΝΩΝ ΚΑΙ ΕΠΑΓΓΕΛΜΑΤΙΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΩΝ GREEK COMPUTER SOCIETY

Οντοκεντρικός Προγραμματισμός

Κεφάλαιο : Εισαγωγή στην C. ( ιαλέξεις 3-4) ιδάσκων: ηµήτρης Ζεϊναλιπούρ

Απάντηση. // We write in a header file named my_header.h #ifndef my_header_h #define my_header_h #define divides(x,y) (((y)%(x)==0)?

Ειδικά Θέματα Ι. Σήμερα!

Προγραμματισμός Η/Υ (ΤΛ2007 )

Διάλεξη 13: Δομές Δεδομένων ΙΙ (Ταξινομημένες Λίστες)

Στην ενότητα αυτή θα µελετηθούν τα εξής επιµέρους θέµατα: ΕΠΛ 131 Αρχές Προγραµµατισµού I 3-2

Λειτουργικά Συστήματα

Αρχεία Κεφαλίδων ΑΡΧΕΙΑ ΚΕΦΑΛΙΔΩΝ. Γεώργιος Παπαϊωάννου ( )

Γλώσσα Προγραμματισμού C

ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΣΧΟΛΗ ΘΕΤΙΚΩΝ ΕΠΙΣΤΗΜΩΝ ΤΜΗΜΑ ΜΑΘΗΜΑΤΙΚΩΝ ΙΠΛΩΜΑΤΙΚΗ ΕΡΓΑΣΙΑ

Εισαγωγή στην C. Μορφή Προγράµµατος σε γλώσσα C

ΕΛΛΗΝΙΚΗ ΕΤΑΙΡΕΙΑ ΕΠΙΣΤΗΜΟΝΩΝ ΚΑΙ ΕΠΑΓΓΕΛΜΑΤΙΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΩΝ ΜΕΛΟΣ IFIP, IOI

Π. Σταθοπούλου ή Οµάδα Α (Φοιτητές µε µονό αριθµό Μητρώου ) ιδασκαλία : Παρασκευή 11πµ-13µµ ΗΛ7

Προγραμματισμός Ι (HY120)

Πρόγραμμα αυτόματης ανάγνωσης και βαθμολόγησης απαντήσεων σε εξέταση με την μέθοδο πολλαπλών επιλογών..

Η Γλώσσα C Μία Σφαιρική Ανασκόπηση

Ηλεκτρονικοί Υπολογιστές

ΛΥΣΕΙΣ ΘΕΜΑΤΩΝ ΤΕΛΙΚΗΣ ΦΑΣΗΣ

Διάλεξη 26: Σωροί. Διδάσκων: Παναγιώτης Ανδρέου

ΑΡΧΕΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ

24ος ΠΑΝΕΛΛΗΝΙΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ

ΕΠΛ 032.3: Προγραµµατισµός ΜεθόδωνΕπίλυσηςΠροβληµάτων

Εισαγωγή στον Προγραµµατισµό. Διάλεξη 2 η : Βασικές Έννοιες της γλώσσας προγραµµατισµού C Χειµερινό Εξάµηνο 2011

Εργαστήριο 8: Αναδρομική διεργασία εισαγωγής καινούριου κόμβου σε ΔΔΑ

ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Η/Υ Ακαδημαϊκό έτος ΑΣΚΗΣΗ #5 Προτεινόμενη Λύση

Διάλεξη 17: Έλεγχος Λογισμικού

Προγραμματισμός σε C. Πράξεις με bits (bitwise operators)

Εργαστήριο 2: Πίνακες

Προγραμματισμός Υπολογιστών με C++

ΤΕΧΝΟΛΟΓΙΑ ΚΑΙ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΥΠΟΛΟΓΙΣΤΩΝ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ

Δομές ελέγχου ροής προγράμματος

3 &4. Εισαγωγήστη C Ιωάννης Κατάκης

Βασικά Στοιχεία της Java

Γράφοι. Ορολογία. Ορισµός: G = (V, E) όπου. Ορολογία (συνέχεια) γράφος ή γράφηµα (graph) V:ένα σύνολο E:µια διµελής σχέση στο V

ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Η/Υ Ακαδημαϊκό έτος ΤΕΤΡΑΔΙΟ ΕΡΓΑΣΤΗΡΙΟΥ #5

Δομές Δεδομένων και Αλγόριθμοι (Γ εξάμηνο) Τμήμα Μηχανικών Πληροφορικής ΤΕ, ΤΕΙ Ηπείρου. Άσκηση εργαστηρίου #6 (Υλοποίηση δυαδικού δένδρου αναζήτησης)

ΕΠΛ 034: Εισαγωγή στον Προγραμματισμό για ΗΜΥ

#define, 70, 575 #elif, 580 #else, 580 #endif, 580 #error, 584 #if, 580 #ifdef, 583 #ifndef, 580, 583 #include, 70, 227, 574 #undef, 579

ΒΑΣΙΚΟΙ ΤΥΠΟΙ ΚΑΙ ΠΙΝΑΚΕΣ

Παρακάτω δίνεται o σκελετός προγράμματος σε γλώσσα C. Σχολιάστε κάθε γραμμή του κώδικα.

Εισαγωγή στον Προγραμματισμό

Αναφορά εργασίας. Χατζητζάνος Ευάγγελος

Διάλεξη 3: Προγραμματισμός σε JAVA I. Διδάσκων: Παναγιώτης Ανδρέου

ΠΛΗ111. Ανοιξη Μάθηµα 5 ο. Ουρά. Τµήµα Ηλεκτρονικών Μηχανικών και Μηχανικών Υπολογιστών Πολυτεχνείο Κρήτης

Εργαστήριο Δομημένος Προγραμματισμός (C#) Τμήμα Μηχανολογίας Νικόλαος Ζ. Ζάχαρης Καθηγητής Εφαρμογών

ΚΑΛΟΥΠΩΜΑΤΑ & ΜΕΤΑΤΡΟΠΕΣ

Προγραµµατισµός ΙΙ. Ηγλώσσααντικειµενοστραφούς. ιδάσκων ηµήτριος Κατσαρός, Τµ. Μηχανικών Η/Υ, Τηλεπικοινωνιών & ικτύων Πανεπιστήµιο Θεσσαλίας

Εργαστήριο 5 Αναδρομική διεργασία εισαγωγής καινούριου κόμβου σε ΔΔΑ με αλφαβητική σειρά

Εισαγωγή στην πληροφορική

Διάλεξη 12: Λίστες Υλοποίηση & Εφαρμογές. Διδάσκων: Παναγιώτης Ανδρέου

Αντικειμενοστρεφής Προγραμματισμός

Εισαγωγικό Φροντιστήριο

Εισαγωγή στην πληροφορική

ΑΣΚΗΣΕΙΣ ΓΙΑ ΤΟ ΕΡΓΑΣΤΗΡΙΟ 2

ΕΛΛΗΝΙΚΗ ΕΤΑΙΡΕΙΑ ΕΠΙΣΤΗΜΟΝΩΝ ΚΑΙ ΕΠΑΓΓΕΛΜΑΤΙΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΩΝ ΜΕΛΟΣ IFIP, IOI Org. GREEK COMPUTER SOCIETY MEMBER OF IFIP, IOI Org.

Κλήση Συναρτήσεων ΚΛΗΣΗ ΣΥΝΑΡΤΗΣΕΩΝ. Γεώργιος Παπαϊωάννου ( )

C: Από τη Θεωρία στην Εφαρμογή

Δομές ελέγχου & επανάληψης

Προεπεξεργαστής C. Προγραμματισμός Ι 1

Συναρτήσεις και διαδικασίες

Δομές δεδομένων (2) Αλγόριθμοι

Π. Σταθοπούλου ή Οµάδα Α (Φοιτητές µε µονό αριθµό Μητρώου ) ιδασκαλία : Παρασκευή 11πµ-13µµ ΗΛ7

Προγραμματισμός Ι. Προεπεξεργαστής. Δημήτρης Μιχαήλ. Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο

Προγραμματισμός Ι (ΗΥ120)

ΕΙΣΑΓΩΓΗ ΣΤΟΝ ΔΟΜΗΜΕΝΟ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ

ΕΠΛ232 Προγραμματιστικές Τεχνικές και Εργαλεία Οργάνωση Προγραμμάτων σε Πολλαπλά Αρχεία (Κεφάλαιο , KNK-2ED)

B. Ενσωμάτωση Ιθαγενών Μεθόδων

Οντοκεντρικός Προγραμματισμός

Βασικά Στοιχεία της Java

Εισαγωγή στον Προγραμματισμό

Σι θα δούμε σε αυτό το μάθημα;

ΛΥΣΕΙΣ ΘΕΜΑΤΩΝ ΤΕΛΙΚΗΣ ΦΑΣΗΣ Οι παρακάτω λύσεις είναι απολύτως ενδεικτικές

Δομές Δεδομένων και Αλγόριθμοι

Διδάσκων: Δημήτριος Βαρσάμης

ΕΡΓΑΣΤΗΡΙΟ ΜΕΘΟ ΟΛΟΓΙΕΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ Ι ΕΡΓΑΣΤΗΡΙΟ

Α' Εξάμηνο ΕΙΣΑΓΩΓΗ ΣΤΟ ΔΟΜΗΜΕΝΟ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ. Ασκήσεις Επανάληψης

Γεώργιος Δημητρίου Προσαρμογή Εισαγωγικού Μαθήματος από Prof. Stephen A. Edwards (Columbia University)

Εισαγωγή στη γλώσσα προγραμματισμού C++

ΣΧΕΔΙΑΣΗ ΚΑΙ ΥΛΟΠΟΙΗΣΗ ΛΟΓΙΣΜΙΚΟΥ

Δομημένος Προγραμματισμός

Ασκήσεις σε Επαναληπτικούς Βρόχους και Συναρτήσεις. Επανάληψη για την ενδιάμεση εξέταση. (Διάλεξη 13)

Μεθόδων Επίλυσης Προβλημάτων

Προγραμματισμός Η/Υ. Ενότητα 2α: Εισαγωγή στη C (Μέρος Πρώτο)

Μεταφραστής (Compiler)

Διάλεξη 17: Έλεγχος Λογισµικού

Προγραμματιστικές Τεχνικές

Περιεχόμενα. Πρόλογος... 17

Στόχοι και αντικείμενο ενότητας. Συντακτικό Γλώσσας. Αλφάβητο. #2.. Εισαγωγή στη C (Μέρος Πρώτο)

Διάλεξη 16: Σωροί. Στην ενότητα αυτή θα μελετηθούν τα εξής επιμέρους θέματα: - Ουρές Προτεραιότητας - Ο ΑΤΔ Σωρός, Υλοποίηση και πράξεις

Ενώσεις δεδομένων Απαριθμητές Ψηφιακοί τελεστές Αναδρομικές συναρτήσεις

Προγραμματισμός Ι (ΗΥ120)

Παίρνοντας Αποφάσεις 1

Δομημένος Προγραμματισμός. Τμήμα Επιχειρηματικού Σχεδιασμού και Πληροφοριακών Συστημάτων

ΕΙΣΑΓΩΓΗ ΣΤΟΝ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ Ενδεικτικές Απαντήσεις Εξετάσεων Β' Περιόδου Θέµα 1. (α')

Transcript:

Wii 3T 1,, 1., Wii ( :Wii ) Bluetooth., Bluetooth 2,. 2,,.,. 1. Wii.,. Bluetooth,., SANYO eneloop,. 2. Bluetooth PC,., PC., Bluetooth. 2000., Windows. 3.. Wii Wii,., Wii.,. 1 WiiRemote, 2009 2 Bluetooth, PC.

,. USB, LED, LED.. R1:47Ω R2:47Ω R3:330Ω LED1 4: LED (TL110 ) LED5: 3mmLED (GL3BC402BOP1) 1:.. 3 3.1. http://wiiyourself.gl.tter.org/ WiiYourself!. (2010/07/12), Ver.1.15., Wii 1 2 3. PC Bluetooth 4. PC Bluetooth 5,., WiiYourself! Demo Demo.exe., Connected.,. HOME,. WiiYourself! C++.. Visual Studio 2008 Visual C++ 2008 Express Edition. 3 Wii,. PC. 4. 5.,.

3.2, Microsoft Driver Development Kit(DDK). (2010/07/12) Windows Driver Kit(WDK) 6.. Visual Studio. [ ] [ ] [ ], [ ] [VC++ ] WDK /lib/wxp/i386, WindowsXP. Windows7 win7, Windows7., win7 CPU 7.. 3.3 Visual C++ 2008.,. [ ] [ ] [ ],. 1. [ ] [C/C++] $(VCInstallDir)include ; WDK /inc/api; WDK /inc/ddk WDK. wiimote.h,,.. 1 #include "wiimote.h" 2 #include " mywiimote.h" 3 #include <math.h> 4 1: mywiimote.cpp 6 7600.16385.1 7 32bitCPU i386, 64bitCPU ia64 amd64(x64). ia64 CPU, intel x86 AMD64, Intel64(x86 64)., Core2Duo Core2Quod amd64.

5 struct wiimote * cwiiremote; 6 7 int wiiinit() 8 { 9 int t=0; 10 cwiiremote = new wiimote(); 11 // 12 for(t=0; t<4; t++){ 13 if(cwiiremote ->Connect(wiimote:: FIRST_AVAILABLE)) break; 14 Sleep (1000); 15 } 16 //,, 17 cwiiremote ->SetReportType(wiimote:: IN_BUTTONS_ACCEL_IR); 18 if(t==4) return 0; 19 return 1; 20 } 21 22 int wiidel() 23 { 24 // 25 if( cwiiremote){ 26 cwiiremote ->Disconnect (); 27 delete cwiiremote; 28 } 29 return 1; 30 } 31 32 33 void wiirumble(bool sw) 34 { 35 cwiiremote ->SetRumble(sw); 36 } 37 void wiibutton(wiistate &Wiistate) 38 { 39 if(cwiiremote ->Button.One()) Wiistate.Button[ WiiKeyNum:: KEY1]++; 40 else Wiistate.Button[ WiiKeyNum:: KEY1] = -(Wiistate.Button[ WiiKeyNum:: KEY1] >0); 41 if(cwiiremote ->Button.Two()) Wiistate.Button[ WiiKeyNum:: KEY2]++; 42 else Wiistate.Button[ WiiKeyNum:: KEY2] = -(Wiistate.Button[ WiiKeyNum:: KEY2] >0); 43 44 if(cwiiremote ->Button.A()) Wiistate.Button[ WiiKeyNum::A]++; 45 else Wiistate.Button[ WiiKeyNum::A] = -(Wiistate.Button[ WiiKeyNum::A] >0); 46 if(cwiiremote ->Button.B()) Wiistate.Button[ WiiKeyNum::B]++; 47 else Wiistate.Button[ WiiKeyNum::B] = -(Wiistate.Button[ WiiKeyNum::B] >0); 48 49 if(cwiiremote ->Button.Minus()) Wiistate.Button[ WiiKeyNum:: MINUS]++; 50 else Wiistate.Button[ WiiKeyNum:: MINUS] = -(Wiistate.Button[ WiiKeyNum:: MINUS] >0); 51 if(cwiiremote ->Button.Plus()) Wiistate.Button[ WiiKeyNum:: PLUS]++; 52 else Wiistate.Button[ WiiKeyNum:: PLUS] = -(Wiistate.Button[ WiiKeyNum:: PLUS] >0); 53 if(cwiiremote ->Button.Home()) Wiistate.Button[ WiiKeyNum:: HOME]++; 54 else Wiistate.Button[ WiiKeyNum:: HOME] = -(Wiistate.Button[ WiiKeyNum:: HOME] >0); 55 56 if(cwiiremote ->Button.Up()) Wiistate.Button[ WiiKeyNum::UP]++; 57 else Wiistate.Button[ WiiKeyNum::UP] = -(Wiistate.Button[ WiiKeyNum::UP] >0); 58 if(cwiiremote ->Button.Down()) Wiistate.Button[ WiiKeyNum:: DOWN]++; 59 else Wiistate.Button[ WiiKeyNum:: DOWN] = -(Wiistate.Button[ WiiKeyNum:: DOWN] >0); 60 if(cwiiremote ->Button.Right()) Wiistate.Button[ WiiKeyNum:: RIGHT]++; 61 else Wiistate.Button[ WiiKeyNum:: RIGHT] = -(Wiistate.Button[ WiiKeyNum:: RIGHT] >0); 62 if(cwiiremote ->Button.Left()) Wiistate.Button[ WiiKeyNum:: LEFT]++; 63 else Wiistate.Button[ WiiKeyNum:: LEFT] = -(Wiistate.Button[ WiiKeyNum:: LEFT] >0); 64 } 65 void getwiistate(wiistate &Wiistate) 66 { 67 if(cwiiremote ->RefreshState()!= NO_CHANGE) wiibutton(wiistate); // 68 Wiistate.BatteryPercent = (char)cwiiremote ->BatteryPercent; // 69 // 70 Wiistate.Acceleration.X = cwiiremote ->Acceleration.X; // x 71 Wiistate.Acceleration.Y = cwiiremote ->Acceleration.Y; // y 72 Wiistate.Acceleration.Z = cwiiremote ->Acceleration.Z; // z 73 Wiistate. Acceleration.ABS = sqrt(wiistate. Acceleration.X*Wiistate. Acceleration.X

74 + Wiistate. Acceleration.Y*Wiistate. Acceleration.Y 75 + Wiistate. Acceleration.Z*Wiistate. Acceleration.Z); 76 // 77 for(int t=0; t<4; t++){ 78 if(wiistate.ir[t]. bvisible = cwiiremote ->IR.Dot[t]. bvisible){ 79 // L E D 80 Wiistate.Ir[t].Size = cwiiremote ->IR.Dot[t].Size; // L E D 81 Wiistate.Ir[t].X = cwiiremote ->IR.Dot[t].X; // x 82 Wiistate.Ir[t].Y = cwiiremote ->IR.Dot[t].Y; // y 83 84 Wiistate.Ir[t].RawX = cwiiremote ->IR.Dot[t].RawX; // X 85 Wiistate.Ir[t].RawY = cwiiremote ->IR.Dot[t].RawY; // Y 86 } 87 } 88 wiirumble(wiistate.rumbleswitch); // 89 cwiiremote ->SetLEDs((BYTE)Wiistate.LEDSwitch); // L E D 90 } 1 #pragma once 2 3 // 4 enum WiiKeyNum{ 5 KEY1 = 0, 6 KEY2, 7 A, 8 B, 9 MINUS, 10 PLUS, 11 HOME, 12 UP, 13 DOWN, 14 RIGHT, 15 LEFT, 16 KEYMAX 17 }; 18 19 // W i i 20 struct WIISTATE{ 21 int Button[ WiiKeyNum:: KEYMAX]; 22 struct accel{ 23 float X; 24 float Y; 25 float Z; 26 float ABS; 27 } Acceleration; 28 struct ir{ 29 bool bvisible; 30 int Size; 31 float X; 32 float Y; 33 int RawX; 34 int RawY; 35 }Ir[4]; 36 char BatteryPercent; 37 bool RumbleSwitch; 38 char LEDSwitch; 39 }; 40 41 // 42 extern int wiiinit(); 43 extern int wiidel(); 44 extern void getwiistate(wiistate & wiistate); 2: mywiimote.h, cwiiremote, WIISTATE Wiistate.,

. 2 WiiYourself! 4 wiimote.cpp, wiimote.h, wiimote common.h, wiimote state.h., DX. DX, http: //dixq.net/g/00.html. 1 #include "DxLib.h" 2 #include " mywiimote.h" 3 3: test.cpp 4 // 5 enum{ 6 FULLSCREEN = 0, // 7 FRAMEPER = 60, // FPS 8 }; 9 10 // 11 int dxlib_clearscreen (); // 12 void disp_fps(); // F P S 13 14 // 15 int count = 0; // 16 struct WIISTATE Wiistate; // W i i 17 18 int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, 19 LPSTR lpcmdline, int ncmdshow) 20 { 21 if(fullscreen ==0) ChangeWindowMode(TRUE); // 22 if(dxlib_init ()==-1) return -1; // D X 23 wiiinit(); // 24 SetDrawScreen(DX_SCREEN_BACK); // 25 26 // E S C H O M E 27 while(( dxlib_clearscreen() == 0)&& 28 ( CheckHitKey( KEY_INPUT_ESCAPE) == 0)&&( Wiistate.Button[ WiiKeyNum:: HOME] == 0)){ 29 // LED 30 if(wiistate. BatteryPercent > 80) Wiistate. LEDSwitch = 0x0f; 31 else if(wiistate. BatteryPercent > 60) Wiistate. LEDSwitch = 0x07; 32 else if(wiistate. BatteryPercent > 40) Wiistate. LEDSwitch = 0x03; 33 else if(wiistate. BatteryPercent > 20) Wiistate. LEDSwitch = 0x01; 34 else Wiistate. LEDSwitch = 0x00; 35 // 36 DrawFormatString( 0, 0, GetColor(0, 255, 255), "% d ", Wiistate.BatteryPercent); 37 // A 38 if(wiistate.button[ WiiKeyNum::A] <= 0) Wiistate. RumbleSwitch = false; 39 else Wiistate. RumbleSwitch = true; 40 } 41 wiidel(); 42 return 0; // 43 } 44 void disp_fps() 45 { 46 int i; 47 static int t=0, ave=0, fps[frameper]; 48 // 49 fps[count%frameper] = GetNowCount()-t; 50 t = GetNowCount (); 51 if(count%frameper == FRAMEPER -1){ 52 // 53 ave = 0; 54 for(i=0; i<frameper; i++) ave += fps[i]; 55 ave /= FRAMEPER; 56 if(ave!= 0){

57 // FPS 58 char buf[128]; 59 sprintf_s(buf, 128, "fs %.1fFPS", 1000.0/( double)ave); 60 SetMainWindowText(buf); 61 } 62 } 63 } 64 int dxlib_clearscreen() 65 { 66 count++; 67 getwiistate(wiistate); // W i i 68 ScreenFlip(); // 69 ClearDrawScreen (); // 70 #ifdef _DEBUG 71 disp_fps(); // FPS 72 #endif 73 return ProcessMessage (); // 74 },, LED,.,. Wii,., mywiimote.cpp mywiimote.h.,,., HTML. 4 4.1 (IR ) Wii, IR. PixArt CMOS 200, 4. Wii LED,,. mywiimote.cpp mywiimote.h Wiistate.Ir, Size X Y RawX RawY. 0 1 8 X Y,.,.,. 8 X 0 1, Y 0 1.

,. LED, Wii. RawX 0 1023, RawY 0 767., RawX,, RawY,., Wii. IRXmax = Wiistate.Ir[maxsize].RawX (1) IRYmin = Wiistate.Ir[maxsize].RawY (2), Wii. IRXmin = Wiistate.Ir[maxsize].RawX (3) IRYmax = Wiistate.Ir[maxsize].RawY (4), maxsize,. 1 for(int t=0; t<4; t++){ 2 if(wiistate.ir[t]. bvisible){ 3 if(tempsize > Wiistate.Ir[t]. Size){ 4 tempsize = Wiistate.Ir[t]. Size; 5 maxsize = t; 6 } 7 } 8 } 4: lightsencer.cpp (1) (4). IRPOINTX = 640 IRPOINTY = 480 ( ) Wiistate.Ir[maxsize].RawX IRXmin 1 IRXmax IRXmin Wiistate.Ir[maxsize].RawY IRYmin IRYmax IRYmin (5) (6) IRPOINTX IRPOINTY, 640 480. IRXmin, IRXmax, IRYmin, IRYmax,., (5) 640 X, (6) 480 Y.

4.2 WiiYourself!., 1.. 5: add1.cpp 1 void wiinunbutton(wiistate &Wiistate) 2 { 3 if(cwiiremote ->Nunchuk.C) Wiistate. NunchukButton[ WiiNunchukKeyNum::C]++; 4 else Wiistate. NunchukButton[ WiiNunchukKeyNum::C] = 5 -(Wiistate. NunchukButton[ WiiNunchukKeyNum::C] >0); 6 if(cwiiremote ->Nunchuk.Z) Wiistate. NunchukButton[ WiiNunchukKeyNum::Z]++; 7 else Wiistate. NunchukButton[ WiiNunchukKeyNum::Z] = 8 -(Wiistate. NunchukButton[ WiiNunchukKeyNum::Z] >0); 9 }, 1 wiiinit.. 6: change1.cpp 1 int wiiinit() 2 { 3 int t=0; 4 cwiiremote = new wiimote(); 5 // 6 for(t=0; t<4; t++){ 7 if(cwiiremote ->Connect(wiimote:: FIRST_AVAILABLE)) break; 8 Sleep (1000); 9 } 10 //,,, 11 if(cwiiremote ->NunchukConnected ()){ 12 cwiiremote ->SetReportType(wiimote:: IN_BUTTONS_ACCEL_IR_EXT); 13 }else{ 14 cwiiremote ->SetReportType(wiimote:: IN_BUTTONS_ACCEL_IR); 15 } 16 if(t==4) return 0; 17 return 1; 18 }, 1 getwiistate.. 7: add2.cpp 1 // 2 Wiistate. NunchukCon = cwiiremote ->NunchukConnected (); 3 if(wiistate. NunchukCon){ 4 // 5 wiinunbutton(wiistate); 6 // 7 Wiistate.NunchukAccel.X = cwiiremote ->Nunchuk.Acceleration.X; // x 8 Wiistate.NunchukAccel.Y = cwiiremote ->Nunchuk.Acceleration.Y; // y 9 Wiistate.NunchukAccel.Z = cwiiremote ->Nunchuk.Acceleration.Z; // z 10 Wiistate. NunchukAccel.ABS = sqrt(wiistate. NunchukAccel.X*Wiistate. NunchukAccel.X 11 + Wiistate. NunchukAccel.Y*Wiistate. NunchukAccel.Y 12 + Wiistate. NunchukAccel.Z*Wiistate. NunchukAccel.Z); 13 // 14 Wiistate. NunchukJoy.X = cwiiremote ->Nunchuk.Joystick.X; 15 Wiistate. NunchukJoy.Y = cwiiremote ->Nunchuk.Joystick.Y; 16 }

., 2. 1 enum WiiNunchukKeyNum{ 2 C, 3 Z, 4 NUNMAX 5 }; 8: add1.h, 2 WIISTATE.,. 1 bool NunchukCon; 2 int NunchukButton[ WiiNunchukKeyNum:: NUNMAX]; 3 struct nunchukaccel{ 4 float X; 5 float Y; 6 float Z; 7 float ABS; 8 } NunchukAccel; 9 struct nunchukjoystick{ 10 float X; 11 float Y; 12 } NunchukJoy; 9: add2.h. X Y -1 1., HTML. mywiimote nun.cpp mywiimote nun.h. 5,,. Wii,.,.,,,., HOSPITAL. 6,., Wii. Wii 4, Wii 2., Wii. Wii, 4.,.,.