/* SliMP3 emulator - an emulator for the SliMP3 network MP3 player. Copyright (C) 2001 Jacob Potter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include int ir_count=0; int server_sock; struct sockaddr_in server_address; struct _ir_codeent { char desc[15]; char num; } ir_codes[] = { { "1", 0x86 }, { "2", 0x46 }, { "3", 0xc6 }, { "4", 0x26 }, { "5", 0xa6 }, { "6", 0x66 }, { "7", 0xe6 }, { "8", 0x16 }, { "9", 0x96 }, { "0", 0x76 }, { "pip", 0xf6 }, { "back", 0x0e }, { "play", 0x32 }, { "fwd", 0x6e }, { "rec", 0x43 }, { "stop", 0xc2 }, { "pause", 0xb2 }, { "disp", 0x03 }, { "sleep", 0xb3 }, { "guide", 0xb6 }, { "up", 0x0b }, { "left", 0x4b }, { "right", 0xcb }, { "down", 0x8b }, { "menu", 0x83 }, { "ok", 0x2b }, { "chup", 0x0d }, { "chdown", 0x8d }, { "recall", 0xab }, { "power", 0x02 }, { "", 0 } }; char findcode(char *cname) { int i=-1; char rv = 0; while ((ir_codes[++i].num != 0) && (rv == 0)) { if (!strcmp(ir_codes[i].desc, cname)) { rv = ir_codes[i].num; } } return rv; } void send_ir_code(unsigned short code) { char message[]="i\0____\377\20\0\0\367_......"; message[2] = (ir_count & (255 << 24)) >> 24; message[3] = (ir_count & (255 << 16)) >> 16; message[4] = (ir_count & (255 << 8)) >> 8; message[5] = ir_count & 255; message[11] = code; if (sendto(server_sock, message, sizeof(message), 0, (struct sockaddr*)&server_address, sizeof(server_address))<0) { perror("sendto()"); return; } ir_count += 60001; } void do_ir_loop(int s_sock, struct sockaddr_in *s_addr) { char s[80]; int f; server_sock = s_sock; server_address = *s_addr; while (!0) { s[0] = '\0'; scanf("%s", s); f = findcode(s); if (f == 2) return; printf("Sending IR code %x\n", f); send_ir_code(f); } }