Changeset 138

Show
Ignore:
Timestamp:
07/29/07 11:08:00 (1 year ago)
Author:
dsmith
Message:

fixed wait forever logic

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r137 r138  
     12007-07-29 L. Donnie Smith <cwiid@abstrakraft.org> 
     2        wminput 
     3        * fixed wait forever logic 
     4 
    152007-07-28 L. Donnie Smith <cwiid@abstrakraft.org> 
    26        configure.ac 
  • trunk/wminput/main.c

    r137 r138  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-07-29 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * fixed wait forever logic 
     20 * 
    1821 *  2007-07-28 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * added config.h include 
     
    232235        printf("Put Wiimote in discoverable mode now (press 1+2)...\n"); 
    233236        if (wait_forever) { 
    234                 if (cwiid_find_wiimote(&bdaddr, -1)) { 
    235                         wminput_err("error finding wiimote"); 
     237                if (!bacmp(&bdaddr, BDADDR_ANY)) { 
     238                        if (cwiid_find_wiimote(&bdaddr, -1)) { 
     239                                wminput_err("error finding wiimote"); 
     240                                conf_unload(&conf); 
     241                                return -1; 
     242                        } 
     243                } 
     244                /* TODO: avoid continuously calling cwiid_open */ 
     245                /* TODO: kill error messages on failed cwiid_open calls */ 
     246                while (!(wiimote = cwiid_open(&bdaddr, CWIID_FLAG_MESG_IFC))); 
     247        } 
     248        else { 
     249                if ((wiimote = cwiid_open(&bdaddr, CWIID_FLAG_MESG_IFC)) == NULL) { 
     250                        wminput_err("unable to connect"); 
    236251                        conf_unload(&conf); 
    237252                        return -1; 
    238253                } 
    239         } 
    240         if ((wiimote = cwiid_open(&bdaddr, CWIID_FLAG_MESG_IFC)) == NULL) { 
    241                 wminput_err("unable to connect"); 
    242                 conf_unload(&conf); 
    243                 return -1; 
    244254        } 
    245255        if (cwiid_set_mesg_callback(wiimote, &cwiid_callback)) { 
     
    310320        sigaddset(&sigset, SIGTERM); 
    311321        sigaddset(&sigset, SIGINT); 
     322        sigaddset(&sigset, SIGUSR1); 
    312323        sigprocmask(SIG_BLOCK, &sigset, NULL); 
    313324        sigwait(&sigset, &signum); 
     
    388399                        break; 
    389400                case CWIID_MESG_ERROR: 
    390                         if (kill(getpid(),SIGINT)) { 
    391                                 wminput_err("Error sending SIGINT"); 
     401                        if (kill(getpid(),SIGUSR1)) { 
     402                                wminput_err("Error sending SIGUSR1"); 
    392403                        } 
    393404                        break;