* Fixed the size of device_state_update_flags.
* Fixed device_state_update_flags clear bug.
@@ -31,7 +31,7 @@ | ||
31 | 31 | int functions[WRMT_NUMBER_OF_FUNCTIONS]; |
32 | 32 | int device_state[WRMT_NUMBER_OF_DATA_TYPE]; |
33 | 33 | unsigned char function_updated_flags[WRMT_NUMBER_OF_FUNCTIONS]; |
34 | - unsigned char device_state_updated_flags[WRMT_NUMBER_OF_FUNCTIONS]; | |
34 | + unsigned char device_state_updated_flags[WRMT_NUMBER_OF_DATA_TYPE]; | |
35 | 35 | }; |
36 | 36 | |
37 | 37 | #define WRMT_WiiRemote_Invaliant(self) \ |
@@ -186,6 +186,7 @@ | ||
186 | 186 | input_buffer[7] == 0xff && |
187 | 187 | input_buffer[8] == 0xff) |
188 | 188 | { |
189 | + DebugLog("IR1 not found\n"); | |
189 | 190 | device_state[WRMT_DATA_IR1_FOUND] = 0; |
190 | 191 | device_state[WRMT_DATA_IR1_SIZE] = 0; |
191 | 192 | device_state[WRMT_DATA_IR1_X] = 0; |
@@ -193,6 +194,7 @@ | ||
193 | 194 | } |
194 | 195 | else |
195 | 196 | { |
197 | + DebugLog("IR1 found\n"); | |
196 | 198 | device_state[WRMT_DATA_IR1_FOUND] = 1; |
197 | 199 | device_state[WRMT_DATA_IR1_SIZE] = input_buffer[ 8] & 0x0f; |
198 | 200 | device_state[WRMT_DATA_IR1_X] = input_buffer[ 6]; |
@@ -205,6 +207,7 @@ | ||
205 | 207 | input_buffer[10] == 0xff && |
206 | 208 | input_buffer[11] == 0xff) |
207 | 209 | { |
210 | + DebugLog("IR2 not found\n"); | |
208 | 211 | device_state[WRMT_DATA_IR2_FOUND] = 0; |
209 | 212 | device_state[WRMT_DATA_IR2_SIZE] = 0; |
210 | 213 | device_state[WRMT_DATA_IR2_X] = 0; |
@@ -212,6 +215,7 @@ | ||
212 | 215 | } |
213 | 216 | else |
214 | 217 | { |
218 | + DebugLog("IR2 found\n"); | |
215 | 219 | device_state[WRMT_DATA_IR2_FOUND] = 1; |
216 | 220 | device_state[WRMT_DATA_IR2_SIZE] = input_buffer[11] & 0x0f; |
217 | 221 | device_state[WRMT_DATA_IR2_X] = input_buffer[ 9]; |
@@ -256,6 +260,7 @@ | ||
256 | 260 | #ifdef DUMP_INPUT_BUFFER |
257 | 261 | { |
258 | 262 | int i; |
263 | + fprintf(stderr, "input_buffer : "); | |
259 | 264 | for (i = 0;i < WRMT_BUFFER_SIZE;i++) |
260 | 265 | fprintf(stderr, "%02x ", self->input_buffer[i]); |
261 | 266 | fprintf(stderr, "\n"); |
@@ -313,12 +318,15 @@ | ||
313 | 318 | WRMT_WiiRemote_ValidateOutputReport(self); |
314 | 319 | DebugLog("Hello\n"); |
315 | 320 | |
316 | - int i; | |
317 | - for (i = 0;i < WRMT_BUFFER_SIZE;i++) | |
321 | +#ifdef DUMP_OUTPUT_BUFFER | |
318 | 322 | { |
319 | - fprintf(stderr, "%02x ", self->output_buffer[i]); | |
323 | + int i; | |
324 | + fprintf(stderr, "output_buffer : "); | |
325 | + for (i = 0;i < WRMT_BUFFER_SIZE;i++) | |
326 | + fprintf(stderr, "%02x ", self->output_buffer[i]); | |
327 | + fprintf(stderr, "\n"); | |
320 | 328 | } |
321 | - fprintf(stderr, "\n"); | |
329 | +#endif | |
322 | 330 | |
323 | 331 | for (retry_count = OUTPUT_RETRY_COUNT;retry_count > 0;retry_count--) |
324 | 332 | { |
@@ -717,7 +725,7 @@ | ||
717 | 725 | WRMT_WiiRemote *result = NULL; |
718 | 726 | assert(device_index >= 0 && |
719 | 727 | device_index < WRMT_Impl_GetNumWiiRemote()); |
720 | - DebugLog("Hello\n"); | |
728 | + DebugLog("Hello device_index = %d\n", device_index); | |
721 | 729 | |
722 | 730 | result = &(wiiRemoteList[device_index]); |
723 | 731 |
@@ -731,7 +739,7 @@ | ||
731 | 739 | { |
732 | 740 | WRMT_IOReturn result; |
733 | 741 | WRMT_WiiRemote_Invaliant(self); |
734 | - DebugLog("Hello\n"); | |
742 | + DebugLog("Hello self = %p\n", self); | |
735 | 743 | |
736 | 744 | result = WRMT_WiiRemoteImpl_Open(self->impl); |
737 | 745 | if (result == WRMT_IO_SUCCESS) |
@@ -853,19 +861,17 @@ | ||
853 | 861 | result = WRMT_WiiRemote_SendReportTypeRequest(self); |
854 | 862 | if (result != WRMT_IO_SUCCESS) return result; |
855 | 863 | |
864 | + if (self->function_updated_flags[WRMT_FUNCTION_IR]) | |
865 | + { | |
866 | + result = WRMT_WiiRemote_SendIRParameters(self); | |
867 | + if (result != WRMT_IO_SUCCESS) return result; | |
868 | + } | |
869 | + | |
856 | 870 | self->function_updated_flags[WRMT_FUNCTION_CONTINUOUS] = 0; |
857 | 871 | self->function_updated_flags[WRMT_FUNCTION_MOTION] = 0; |
858 | 872 | self->function_updated_flags[WRMT_FUNCTION_IR] = 0; |
859 | 873 | } |
860 | 874 | |
861 | - if (self->function_updated_flags[WRMT_FUNCTION_IR]) | |
862 | - { | |
863 | - result = WRMT_WiiRemote_SendIRParameters(self); | |
864 | - if (result != WRMT_IO_SUCCESS) return result; | |
865 | - | |
866 | - self->function_updated_flags[WRMT_FUNCTION_IR] = 0; | |
867 | - } | |
868 | - | |
869 | 875 | if (self->function_updated_flags[WRMT_FUNCTION_SPEAKER]) |
870 | 876 | { |
871 | 877 | result = WRMT_WiiRemote_SetUpSpeaker(self); |