Changeset 143

Show
Ignore:
Timestamp:
08/14/07 21:06:03 (1 year ago)
Author:
dsmith
Message:

stifled cwiid_connect errors on wminput reconnect

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r142 r143  
    112007-08-14 L. Donnie Smith <cwiid@abstrakraft.org> 
     2        libcwiid 
     3        * make cwiid_err_default public 
     4 
    25        wminput 
    36        * added {c,py}_wiimote_deinit functions 
  • trunk/libcwiid/cwiid.h

    r116 r143  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2008-08-14 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * make cwiid_err_default public 
     20 * 
    1821 *  2007-05-16 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * changed cwiid_connect, cwiid_disconnect to cwiid_open, cwiid_close 
     
    301304/* Error reporting (library wide) */ 
    302305int cwiid_set_err(cwiid_err_t *err); 
     306void cwiid_err_default(struct wiimote *wiimote, const char *str, va_list ap); 
    303307 
    304308/* Connection */ 
  • trunk/libcwiid/util.c

    r112 r143  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2008-08-14 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * make cwiid_err_default public 
     20 *  * clean up cwiid_err 
     21 * 
    1822 *  2007-04-24 L. Donnie Smith <cwiid@abstrakraft.org> 
    1923 *  * rewrite for API overhaul 
     
    5559#include "cwiid_internal.h" 
    5660 
    57 static cwiid_err_t cwiid_err_default; 
     61cwiid_err_t cwiid_err_default; 
    5862 
    5963static cwiid_err_t *cwiid_err_func = &cwiid_err_default; 
     
    6872} 
    6973 
    70 static void cwiid_err_default(struct wiimote *wiimote, const char *str, 
    71                               va_list ap) 
     74void cwiid_err_default(struct wiimote *wiimote, const char *str, va_list ap) 
    7275{ 
    7376        vfprintf(stderr, str, ap); 
     
    8184        if (cwiid_err_func) { 
    8285                va_start(ap, str); 
    83                 if (wiimote) { 
    84                         (*cwiid_err_func)(wiimote, str, ap); 
    85                 } 
    86                 else { 
    87                         (*cwiid_err_func)(NULL, str, ap); 
    88                 } 
     86                (*cwiid_err_func)(wiimote, str, ap); 
    8987                va_end(ap); 
    9088        } 
  • trunk/wminput/main.c

    r142 r143  
    6565#endif 
    6666 
     67#include <errno.h> 
    6768#include <stdint.h> 
    6869#include <stdio.h> 
     
    114115        printf("\t-d, --daemon\t\tImplies -q, -r, and -w.\n"); 
    115116        printf("\t-q, --quiet\t\tReduce output to errors\n"); 
    116         printf("\t-r, --reconnect [wait]\t\tAutomatically try reconnect after wiimote disconnect.\n"); 
     117        printf("\t-r, --reconnect [wait]\tAutomatically try reconnect after wiimote disconnect.\n"); 
    117118        printf("\t-w, --wait\t\tWait indefinitely for wiimote to connect.\n"); 
     119} 
     120 
     121void cwiid_err_connect(struct wiimote *wiimote, const char *str, va_list ap) 
     122{ 
     123        /* TODO: temporary kludge to stifle error messages from cwiid_open */ 
     124        if (errno != EHOSTDOWN) { 
     125                vfprintf(stderr, str, ap); 
     126                fprintf(stderr, "\n"); 
     127        } 
    118128} 
    119129 
     
    279289                        } 
    280290                        /* TODO: avoid continuously calling cwiid_open */ 
    281                         /* TODO: kill error messages on failed cwiid_open calls */ 
     291                        cwiid_set_err(cwiid_err_connect); 
    282292                        while (!(wiimote = cwiid_open(&current_bdaddr, CWIID_FLAG_MESG_IFC))); 
     293                        cwiid_set_err(cwiid_err_default); 
    283294                } 
    284295                else {