Mercurial > audlegacy-plugins
comparison src/lirc/lirc.c @ 2305:738914331374
Add ability to enter track number using remote. (Bugzilla #115)
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Sat, 12 Jan 2008 13:09:10 -0600 |
parents | 5e54ffc4f46f |
children | 8d4db9a04cd2 |
comparison
equal
deleted
inserted
replaced
2304:ccca9906abd0 | 2305:738914331374 |
---|---|
67 gint mute=0; /* mute flag */ | 67 gint mute=0; /* mute flag */ |
68 gint mute_vol=0; /* holds volume before mute */ | 68 gint mute_vol=0; /* holds volume before mute */ |
69 | 69 |
70 gint input_tag; | 70 gint input_tag; |
71 | 71 |
72 char track_no[64]; | |
73 int track_no_pos; | |
74 | |
75 gint tid; | |
76 | |
72 void init_lirc(void) | 77 void init_lirc(void) |
73 { | 78 { |
74 int flags; | 79 int flags; |
75 | 80 |
76 if((lirc_fd=lirc_init("audacious",1))==-1) | 81 if((lirc_fd=lirc_init("audacious",1))==-1) |
102 | 107 |
103 void init(void) | 108 void init(void) |
104 { | 109 { |
105 load_cfg(); | 110 load_cfg(); |
106 init_lirc(); | 111 init_lirc(); |
112 track_no_pos=0; | |
113 tid=0; | |
107 } | 114 } |
108 | 115 |
109 gboolean reconnect_lirc(gpointer data) | 116 gboolean reconnect_lirc(gpointer data) |
110 { | 117 { |
111 fprintf(stderr,_("%s: trying to reconnect...\n"),plugin_name); | 118 fprintf(stderr,_("%s: trying to reconnect...\n"),plugin_name); |
112 init(); | 119 init(); |
113 return (lirc_fd==-1); | 120 return (lirc_fd==-1); |
121 } | |
122 | |
123 gboolean jump_to(gpointer data) | |
124 { | |
125 audacious_drct_pl_set_pos(atoi(track_no)-1); | |
126 track_no_pos=0; | |
127 return FALSE; | |
114 } | 128 } |
115 | 129 |
116 void lirc_input_callback(gpointer data,gint source, | 130 void lirc_input_callback(gpointer data,gint source, |
117 GdkInputCondition condition) | 131 GdkInputCondition condition) |
118 { | 132 { |
122 int ret; | 136 int ret; |
123 char *ptr; | 137 char *ptr; |
124 gint balance; | 138 gint balance; |
125 gboolean show_pl; | 139 gboolean show_pl; |
126 int n; | 140 int n; |
141 gchar *utf8_title_markup; | |
127 | 142 |
128 while((ret=lirc_nextcode(&code))==0 && code!=NULL) | 143 while((ret=lirc_nextcode(&code))==0 && code!=NULL) |
129 { | 144 { |
130 while((ret=lirc_code2char(config,code,&c))==0 && c!=NULL) | 145 while((ret=lirc_code2char(config,code,&c))==0 && c!=NULL) |
131 { | 146 { |
303 list.data=c+13; | 318 list.data=c+13; |
304 audacious_drct_pl_add(&list); | 319 audacious_drct_pl_add(&list); |
305 /* This is to refresh window content */ | 320 /* This is to refresh window content */ |
306 audacious_drct_pl_win_toggle(pl_visible); | 321 audacious_drct_pl_win_toggle(pl_visible); |
307 } | 322 } |
323 else if((strlen(c)==1) && ((*c>='0') || (*c<='9'))) | |
324 { | |
325 if (track_no_pos<63) | |
326 { | |
327 if (tid) g_source_remove(tid); | |
328 track_no[track_no_pos++]=*c; | |
329 track_no[track_no_pos]=0; | |
330 tid=g_timeout_add(1500, jump_to, NULL); | |
331 utf8_title_markup = g_markup_printf_escaped( | |
332 "<span font_desc='%s'>%s</span>", aosd_font, track_no); | |
333 aud_hook_call("aosd toggle", utf8_title_markup); | |
334 } | |
335 } | |
308 else | 336 else |
309 { | 337 { |
310 fprintf(stderr,_("%s: unknown command \"%s\"\n"), | 338 fprintf(stderr,_("%s: unknown command \"%s\"\n"), |
311 plugin_name,c); | 339 plugin_name,c); |
312 } | 340 } |
339 if(lirc_fd!=-1) | 367 if(lirc_fd!=-1) |
340 { | 368 { |
341 lirc_deinit(); | 369 lirc_deinit(); |
342 lirc_fd=-1; | 370 lirc_fd=-1; |
343 } | 371 } |
344 } | 372 g_free(aosd_font); |
373 } |