Ticket #38 (closed enhancement: fixed)

Opened 2 years ago

Last modified 6 months ago

standby mode or wiimote sleeping

Reported by: snaker@sindominio.net Assigned to: dsmith
Priority: major Milestone: Version 0.6.00
Component: wminput Version: 0.5.02
Keywords: standby daemon Cc:

Description

hi

A very nice feature will be the posibility of the wiimote turn off if timeout idle limit and wminput standby waiting for connection then when the user push button A or 1+2 restore the communication.

Thanks for your work, sorry my poor english

Attachments

main.c (19.2 kB) - added by xkill on 07/26/07 03:10:32.
wminput main.c

Change History

05/20/07 14:53:46 changed by nickishappy

This would be easy once ticket:15 was implemented. There could be a command line option to specify the timeout, and when it sees the wiimote wants to connect again wminput makes sure it uses the same config file. I don't think the wiimote has an actual "sleep" mode, so this sounds more like a request for an idle timeout feature.

05/20/07 15:35:49 changed by dsmith

ditto. Basically, this can be implemented identically to #15, or by detecting the power button, which has not yet been reverse engineered.

05/24/07 12:04:49 changed by snaker@sindominio.net

ok

if you run wminput in daemon mode using a script you can disconnect wiimote by hand but wminput could turn off wiimote when pass idle time, i dont know if this feature is implemented but i havent found this.

06/01/07 00:05:38 changed by dsmith

  • component changed from build system to wminput.

Nope, not implemented, but shouldn't be too hard. We'll add it to the queue.

07/18/07 09:59:55 changed by xkill

  • milestone set to Version 0.6.00.

A posible solution patch. When lost wiimote connectivity it trys again.

Added always trying. -a option.

Apply the patch:

69a70
> 
82a84
> char always = 0;
96a99
>       printf("\t-a, --always\t\tWait always. Don't kill when wiimote disconnect.\n");
98a102,110
> void handle_ctrlc(int sig){
>       signal (SIGINT,SIG_IGN);
>       printf ("Exiting. CTRL+C \n");
>       always=0;
>       signal (SIGINT,SIG_DFL);
>       return;
> }
> 
> 
129c141
<               c = getopt_long (argc, argv, "hwc:v", long_options, &option_index);
---
>               c = getopt_long (argc, argv, "hwac:v", long_options, &option_index);
139a152,154
>               case 'a':
>                       always=1;
>                       break;
159a175
> 
214a231,233
>       signal (SIGINT,handle_ctrlc);
>       do {
> 
295a315,317
> 
>       } while (always==1);
> 

So now you can do: wminput -a -w -c in_ptr [your wii mac]

and you can connect alleays ;)

07/19/07 08:15:05 changed by xkill

Now there is another problem, the wiimote always connect to the computer, but sometimes I need to connect to the wii, but it's imposible. So there is another patch to implement wait time between turn off and rediscover:

69a70
> 
82a84,85
> char always = 0;
> int wait_time = 0;
96a100,108
>       printf("\t-a, --always <s>\tWait always but wait N seconds before discover.\n\t\t\t\tDon't kill when wiimote disconnect.\n");
> }
> 
> void handle_ctrlc(int sig){
>       signal (SIGINT,SIG_IGN);
>       printf ("Exiting. CTRL+C \n");
>       always=0;
>       signal (SIGINT,SIG_DFL);
>       return;
98a111
> 
129c142
<               c = getopt_long (argc, argv, "hwc:v", long_options, &option_index);
---
>               c = getopt_long (argc, argv, "hwa:c:v", long_options, &option_index);
139a153,158
>               case 'a':
>                       always=1;
>                       if (optarg) {
>                               wait_time = atoi(optarg);
>                       }
>                       break;
159a179
> 
214a235,237
>       signal (SIGINT,handle_ctrlc);
>       do {
> 
295a319,325
>               if ( wait_time ) {
>                       printf ("wait_time=%d\n",wait_time);
>                       sleep ( wait_time );
>               }
> 
>       } while (always==1);
> 

07/20/07 06:22:47 changed by dsmith

Thanks for your patches - I should have time to take a look at them this weekend.

07/21/07 19:46:42 changed by dsmith

I'm not sure how this is supposed to work...from the looks of your patch, SIGINT always kills wminput, but SIGTERM does not. I think SIGTERM and SIGINT should always kill the app, and another signal (SIGUSR1, maybe) should be sent on wiimote error, causing main to loop.

07/24/07 04:21:09 changed by xkill

  • keywords changed from standby to standby daemon.

OK, now I capture SIGINT (ctrl+c), SIGTERM (kill) and SIGUSR1 to exit.

This is the complete patch:

17a18,24
>  *
>  *  2007-07-24 Pablo Catalina <xkill@ciberhell.ath.cx>
>  *  * Signaling support to trap SIGINT, SIGTERM and SIGUSR1 that exit the program.
>  *
>  *  2007-07-19 Pablo Catalina <xkill@ciberhell.ath.cx>
>  *  * always listen in wiimote standby mode, with wait time support
>  *
69a77
> 
82a91,92
> char always = 0;
> int wait_time = 0;
96a107
>       printf("\t-a, --always <s>\tWait always but wait N seconds before discover.\n\t\t\t\tDon't kill when wiimote disconnect.\n");
98a110,116
> void handle_exit(int sig){
>         signal (sig,handle_exit);
>       printf ("User exit. CTRL+C or KILL \n");
>         always=0;
> }
> 
> 
129c147
<               c = getopt_long (argc, argv, "hwc:v", long_options, &option_index);
---
>               c = getopt_long (argc, argv, "hwa:c:v", long_options, &option_index);
139a158,163
>               case 'a':
>                       always=1;
>                       if (optarg) {
>                               wait_time = atoi(optarg);
>                       }
>                       break;
159a184
> 
189d213
< 
214a239,243
>       signal (SIGINT,handle_exit);
>       signal (SIGTERM,handle_exit);
>       signal (SIGUSR1,handle_exit);
>       do {
> 
295a325,331
>               if ( wait_time ) {
>                       printf ("wait_time=%d\n",wait_time);
>                       sleep ( wait_time );
>               }
> 
>       } while (always==1);
> 

07/24/07 04:52:13 changed by xkill

Sorry, the before post is OK, but with spaggueti code ;) I think that is better to remove the lines added to ignore this signals.

I prefer to catch the signals but without ignore it.

So I remove the lines

[...]
sigset_t sigset;
int signum, ret=0;
[...]
                /* wait */
                sigemptyset(&sigset);
                sigaddset(&sigset, SIGTERM);
                sigaddset(&sigset, SIGINT);
                sigprocmask(SIG_BLOCK, &sigset, NULL);
                sigwait(&sigset, &signum);
[...]

07/24/07 18:04:27 changed by dsmith

Ticket attachments have been enabled for authenticated users, but patches are sufficient - please don't post another full code listing, as it just makes this page impossible to read. I may remove the full listings from your posts.

Add your username or email address to the CC field to receive change notification.

Have you tested this code? Reread my previous post: SIGINT and SIGTERM should exit. Send a SIGUSR1 should not (directly) exit - send SIGUSR1 from cwiid_callback to cause main to loop if always == true. And put semwait back in - polling is bad form, and as you have it implemented, the main loop will continuously reinitialize itself.

07/26/07 03:10:32 changed by xkill

  • attachment main.c added.

wminput main.c

07/29/07 13:08:49 changed by dsmith

I implemented a daemon patch that (I think) takes care of what you're going for here. It doesn't implement standby, so it seemed to fit in #15 more than here.

05/29/08 19:58:01 changed by nickishappy

  • status changed from new to closed.
  • resolution set to fixed.

This functionality now exists with various options added to wminput.