iap: split iap_handlepkt into a function per mode
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29755 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c77b014283
commit
9ea20660ca
1 changed files with 629 additions and 614 deletions
91
apps/iap.c
91
apps/iap.c
|
@ -218,30 +218,16 @@ static void iap_set_remote_volume(void)
|
||||||
iap_send_pkt(data, sizeof(data));
|
iap_send_pkt(data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void iap_handlepkt(void)
|
static void iap_handlepkt_mode0(void)
|
||||||
{
|
{
|
||||||
|
unsigned int cmd = serbuf[2];
|
||||||
|
switch (cmd) {
|
||||||
|
|
||||||
if(!iap_setupflag) return;
|
|
||||||
if(serbuf[0] == 0) return;
|
|
||||||
|
|
||||||
/* if we are waiting for a remote button to go out,
|
|
||||||
delay the handling of the new packet */
|
|
||||||
if(!iap_remotetick)
|
|
||||||
{
|
|
||||||
queue_post(&button_queue, SYS_IAP_HANDLEPKT, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle Mode 0 */
|
|
||||||
if (serbuf[1] == 0x00)
|
|
||||||
{
|
|
||||||
switch (serbuf[2])
|
|
||||||
{
|
|
||||||
case 0x24:
|
case 0x24:
|
||||||
{
|
{
|
||||||
/* ipod video send this */
|
/* ipod video send this */
|
||||||
unsigned char data[] = {0x00, 0x25, 0x00, 0x00, 0x00,
|
unsigned char data[] = {0x00, 0x25, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00,0x01};
|
0x00, 0x00, 0x00, 0x00, 0x01};
|
||||||
iap_send_pkt(data, sizeof(data));
|
iap_send_pkt(data, sizeof(data));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -364,15 +350,15 @@ void iap_handlepkt(void)
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
unsigned char data[] = {0x00, 0x02, 0x00, 0x00};
|
unsigned char data[] = {0x00, 0x02, 0x00, 0x00};
|
||||||
data[3] = serbuf[2]; /* respond with cmd */
|
data[3] = cmd; /* respond with cmd */
|
||||||
iap_send_pkt(data, sizeof(data));
|
iap_send_pkt(data, sizeof(data));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Handle Mode 2 */
|
|
||||||
else if (serbuf[1] == 0x02)
|
static void iap_handlepkt_mode2(void)
|
||||||
{
|
{
|
||||||
if(serbuf[2] != 0) return;
|
if(serbuf[2] != 0) return;
|
||||||
iap_remotebtn = BUTTON_NONE;
|
iap_remotebtn = BUTTON_NONE;
|
||||||
iap_remotetick = false;
|
iap_remotetick = false;
|
||||||
|
@ -463,11 +449,12 @@ void iap_handlepkt(void)
|
||||||
iap_remotebtn |= BUTTON_RC_LEFT;
|
iap_remotebtn |= BUTTON_RC_LEFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Handle Mode 3 */
|
|
||||||
else if (serbuf[1] == 0x03)
|
static void iap_handlepkt_mode3(void)
|
||||||
{
|
{
|
||||||
switch(serbuf[2])
|
unsigned int cmd = serbuf[2];
|
||||||
|
switch (cmd)
|
||||||
{
|
{
|
||||||
/* some kind of status packet? */
|
/* some kind of status packet? */
|
||||||
case 0x01:
|
case 0x01:
|
||||||
|
@ -496,16 +483,19 @@ void iap_handlepkt(void)
|
||||||
}
|
}
|
||||||
/* get volume from accessory */
|
/* get volume from accessory */
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
|
{
|
||||||
if (serbuf[3] == 0x04)
|
if (serbuf[3] == 0x04)
|
||||||
global_settings.volume = (-58)+((int)serbuf[5]+1)/4;
|
global_settings.volume = (-58)+((int)serbuf[5]+1)/4;
|
||||||
sound_set_volume(global_settings.volume);
|
sound_set_volume(global_settings.volume); /* indent BUG? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Handle Mode 4 */
|
}
|
||||||
else if (serbuf[1] == 0x04)
|
|
||||||
{
|
static void iap_handlepkt_mode4(void)
|
||||||
switch (((unsigned long)serbuf[2] << 8) | serbuf[3])
|
{
|
||||||
|
unsigned int cmd = (serbuf[2] << 8) | serbuf[3];
|
||||||
|
switch (cmd)
|
||||||
{
|
{
|
||||||
/* Get data updated??? flag */
|
/* Get data updated??? flag */
|
||||||
case 0x0009:
|
case 0x0009:
|
||||||
|
@ -816,11 +806,12 @@ void iap_handlepkt(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Handle Mode 7 */
|
|
||||||
else if (serbuf[1] == 0x07)
|
static void iap_handlepkt_mode7(void)
|
||||||
{
|
{
|
||||||
switch(serbuf[2])
|
unsigned int cmd = serbuf[2];
|
||||||
|
switch (cmd)
|
||||||
{
|
{
|
||||||
/* tuner capabilities */
|
/* tuner capabilities */
|
||||||
case 0x02:
|
case 0x02:
|
||||||
|
@ -847,7 +838,31 @@ void iap_handlepkt(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void iap_handlepkt(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!iap_setupflag) return;
|
||||||
|
if(serbuf[0] == 0) return;
|
||||||
|
|
||||||
|
/* if we are waiting for a remote button to go out,
|
||||||
|
delay the handling of the new packet */
|
||||||
|
if(!iap_remotetick)
|
||||||
|
{
|
||||||
|
queue_post(&button_queue, SYS_IAP_HANDLEPKT, 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char mode = serbuf[1];
|
||||||
|
switch (mode) {
|
||||||
|
case 0: iap_handlepkt_mode0(); break;
|
||||||
|
case 2: iap_handlepkt_mode2(); break;
|
||||||
|
case 3: iap_handlepkt_mode3(); break;
|
||||||
|
case 4: iap_handlepkt_mode4(); break;
|
||||||
|
case 7: iap_handlepkt_mode7(); break;
|
||||||
|
}
|
||||||
|
|
||||||
serbuf[0] = 0;
|
serbuf[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue