Changeset d087284c9fe3be67c74edd495b443683ce4ce6af

Show
Ignore:
Timestamp:
07/29/07 18:08:00 (5 years ago)
Author:
dsmith <dsmith@…>
git-author:
L. Donnie Smith <donnie.smith@gatech.edu> / 2007-07-29T18:08:00Z+0000
Parents:
8dfafdd3df12e09ce36b9d0018fbf3718b14c9a5
Children:
f74d95ef1b141f63caaf55d5f29bd5df1ff9cdb0
git-committer:
dsmith <dsmith@918edb2d-ff29-0410-9de2-eb38e7f22bc7> / 2007-07-29T18:08:00Z+0000
Message:

fixed wait forever logic

git-svn-id: http://abstrakraft.org/cwiid/svn/trunk@138 918edb2d-ff29-0410-9de2-eb38e7f22bc7

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r8dfafdd rd087284  
     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 
  • wminput/main.c

    r8dfafdd rd087284  
    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;