FS#9221 by Christopher Williams fixing a couple of bugs in keybox
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18138 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b2c4a9a0a9
commit
2d337dab7f
5 changed files with 53 additions and 44 deletions
|
@ -33,14 +33,14 @@ pacbox
|
|||
/* For all the color targets */
|
||||
#if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \
|
||||
(LCD_DEPTH == 2) && !defined(ARCHOS_AV300)
|
||||
doom
|
||||
//doom
|
||||
#endif
|
||||
|
||||
/* For all the swcodec targets */
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
midi
|
||||
/* beatbox */
|
||||
mpegplayer
|
||||
//mpegplayer
|
||||
#endif
|
||||
|
||||
#endif /* IRIVER_IFP7XX_SERIES */
|
||||
|
|
|
@ -26,7 +26,7 @@ PLUGIN_HEADER
|
|||
|
||||
#define BATTERY_LOG "/battery_bench.txt"
|
||||
#define BUF_SIZE 16000
|
||||
#define DISK_SPINDOWN_TIMEOUT 3600
|
||||
#define DISK_SPINDOWN_TIMEOUT 1800
|
||||
|
||||
#define EV_EXIT 1337
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id:$
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 Nils Wallménius
|
||||
*
|
||||
|
@ -111,13 +111,13 @@ MENUITEM_RETURNVALUE(context_add_entry, "Add entry", 0,
|
|||
NULL, Icon_NOICON);
|
||||
MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1,
|
||||
&context_item_cb, Icon_NOICON);
|
||||
MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 1,
|
||||
MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 2,
|
||||
&context_item_cb, Icon_NOICON);
|
||||
MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 2,
|
||||
MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 3,
|
||||
&context_item_cb, Icon_NOICON);
|
||||
MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 3,
|
||||
MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 4,
|
||||
&context_item_cb, Icon_NOICON);
|
||||
MENUITEM_RETURNVALUE(context_debug, "debug", 4,
|
||||
MENUITEM_RETURNVALUE(context_debug, "debug", 5,
|
||||
&context_item_cb, Icon_NOICON);
|
||||
|
||||
MAKE_MENU(context_m, "Context menu",
|
||||
|
@ -144,9 +144,12 @@ static char * kb_list_cb(int selected_item, void *data,
|
|||
struct pw_entry *entry = pw_list.first.next;
|
||||
for (i = 0; i < selected_item; i++)
|
||||
{
|
||||
if (entry->next)
|
||||
if (entry)
|
||||
entry = entry->next;
|
||||
}
|
||||
if (!entry)
|
||||
return NULL;
|
||||
|
||||
rb->snprintf(buffer, buffer_len, "%s", entry->title);
|
||||
|
||||
return buffer;
|
||||
|
@ -162,20 +165,19 @@ static void init_ll(void)
|
|||
static void delete_entry(int selected_item)
|
||||
{
|
||||
int i;
|
||||
struct pw_entry *entry = pw_list.first.next;
|
||||
struct pw_entry *entry = &pw_list.first;
|
||||
struct pw_entry *entry2;
|
||||
|
||||
/* find the entry before the one to delete */
|
||||
for (i = 0; i < selected_item - 1; i++)
|
||||
for (i = 0; i < selected_item; i++)
|
||||
{
|
||||
if (entry->next)
|
||||
entry = entry->next;
|
||||
}
|
||||
if (entry->next)
|
||||
entry2 = entry->next;
|
||||
else
|
||||
if (!entry2)
|
||||
return;
|
||||
if (entry2->next)
|
||||
|
||||
entry->next = entry2->next;
|
||||
|
||||
entry2->used = false;
|
||||
|
@ -201,10 +203,13 @@ static void add_entry(int selected_item)
|
|||
}
|
||||
|
||||
rb->splash(HZ, "Enter title");
|
||||
pw_list.entries[i].title[0] = '\0';
|
||||
rb->kbd_input(pw_list.entries[i].title, FIELD_LEN);
|
||||
rb->splash(HZ, "Enter name");
|
||||
pw_list.entries[i].name[0] = '\0';
|
||||
rb->kbd_input(pw_list.entries[i].name, FIELD_LEN);
|
||||
rb->splash(HZ, "Enter password");
|
||||
pw_list.entries[i].password[0] = '\0';
|
||||
rb->kbd_input(pw_list.entries[i].password, FIELD_LEN);
|
||||
|
||||
for (j = 0; j < selected_item; j++)
|
||||
|
@ -392,7 +397,7 @@ static void encrypt_buffer(char *buf, size_t size, uint32_t *key)
|
|||
static int parse_buffer(void)
|
||||
{
|
||||
int i;
|
||||
intptr_t len;
|
||||
int len;
|
||||
struct pw_entry *entry = pw_list.first.next;
|
||||
char *start, *end;
|
||||
start = &buffer[HEADER_LEN];
|
||||
|
@ -411,36 +416,32 @@ static int parse_buffer(void)
|
|||
for (i = 0; i < MAX_ENTRIES; i++)
|
||||
{
|
||||
end = rb->strchr(start, '\0'); /* find eol */
|
||||
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN];
|
||||
if ((len > bytes_read + HEADER_LEN)
|
||||
|| (intptr_t)start == (intptr_t)end)
|
||||
len = end - &buffer[HEADER_LEN];
|
||||
if ((len > bytes_read + HEADER_LEN) || start == end)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
rb->strncpy(entry->title, start,
|
||||
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
|
||||
rb->strncpy(entry->title, start, FIELD_LEN);
|
||||
start = end + 1;
|
||||
|
||||
end = rb->strchr(start, '\0'); /* find eol */
|
||||
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN];
|
||||
len = end - &buffer[HEADER_LEN];
|
||||
if (len > bytes_read + HEADER_LEN)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
rb->strncpy(entry->name, start,
|
||||
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
|
||||
rb->strncpy(entry->name, start, FIELD_LEN);
|
||||
start = end + 1;
|
||||
|
||||
end = rb->strchr(start, '\0'); /* find eol */
|
||||
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN];
|
||||
len = end - &buffer[HEADER_LEN];
|
||||
if (len > bytes_read + HEADER_LEN)
|
||||
{
|
||||
break;
|
||||
}
|
||||
rb->strncpy(entry->password, start,
|
||||
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
|
||||
rb->strncpy(entry->password, start, FIELD_LEN);
|
||||
start = end + 1;
|
||||
entry->used = true;
|
||||
if (i + 1 < MAX_ENTRIES - 1)
|
||||
|
@ -483,9 +484,10 @@ static void write_output(int fd)
|
|||
if (entry->next)
|
||||
entry = entry->next;
|
||||
}
|
||||
*p++ = '\0'; /* mark the end of the list */
|
||||
|
||||
/* round up to a number divisible by BLOCK_SIZE */
|
||||
size = (((intptr_t)p - (intptr_t)&buffer) / BLOCK_SIZE + 1) * BLOCK_SIZE;
|
||||
size = ((p - buffer + BLOCK_SIZE - 1) / BLOCK_SIZE) * BLOCK_SIZE;
|
||||
|
||||
salt = rb->rand();
|
||||
make_key();
|
||||
|
|
|
@ -162,10 +162,12 @@ struct GPatch * gusload(char * filename)
|
|||
|
||||
int file = rb->open(filename, O_RDONLY);
|
||||
|
||||
DEBUGF("filename: %s\n", filename);
|
||||
|
||||
if(file == -1)
|
||||
{
|
||||
char message[50];
|
||||
rb->snprintf(message, 50, "Error opening %s", filename);
|
||||
char message[MAX_PATH];
|
||||
rb->snprintf(message, MAX_PATH, "Error opening %s", filename);
|
||||
rb->splash(HZ*2, message);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -197,12 +199,12 @@ struct GPatch * gusload(char * filename)
|
|||
|
||||
/* printf("\nFILE: %s", filename); */
|
||||
/* printf("\nlayerSamples=%d", gp->numWaves); */
|
||||
|
||||
DEBUGF("hej\n");
|
||||
int a=0;
|
||||
for(a=0; a<gp->numWaves; a++)
|
||||
gp->waveforms[a] = loadWaveform(file);
|
||||
|
||||
|
||||
DEBUGF("hej2\n");
|
||||
/* printf("\nPrecomputing note table"); */
|
||||
|
||||
for(a=0; a<128; a++)
|
||||
|
@ -210,7 +212,7 @@ struct GPatch * gusload(char * filename)
|
|||
gp->noteTable[a] = selectWaveform(gp, a);
|
||||
}
|
||||
rb->close(file);
|
||||
|
||||
DEBUGF("hej3\n");
|
||||
return gp;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,10 +140,11 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
|
|||
return -1;
|
||||
}
|
||||
|
||||
char name[40];
|
||||
char fn[40];
|
||||
char name[MAX_PATH];
|
||||
char fn[MAX_PATH];
|
||||
|
||||
/* Scan our config file and load the right patches as needed */
|
||||
char *p;
|
||||
int c = 0;
|
||||
name[0] = '\0';
|
||||
printf("Loading instruments");
|
||||
|
@ -151,8 +152,12 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
|
|||
{
|
||||
while(readChar(file)!=' ' && !eof(file));
|
||||
readTextBlock(file, name);
|
||||
|
||||
rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name);
|
||||
DEBUGF("name: %s\n", name);
|
||||
p = rb->strrchr(name, '.');
|
||||
if (!p || rb->strncmp(p, ".pat", 4))
|
||||
rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
|
||||
else
|
||||
rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s", name);
|
||||
/* printf("\nLOADING: <%s> ", fn); */
|
||||
|
||||
if(patchUsed[a]==1)
|
||||
|
@ -167,7 +172,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
|
|||
c = readChar(file);
|
||||
}
|
||||
rb->close(file);
|
||||
|
||||
DEBUGF("drums!!\n");
|
||||
file = rb->open(drumConfig, O_RDONLY);
|
||||
if(file < 0)
|
||||
{
|
||||
|
@ -183,7 +188,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
|
|||
{
|
||||
readTextBlock(file, number);
|
||||
readTextBlock(file, name);
|
||||
rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name);
|
||||
rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
|
||||
|
||||
idx = rb->atoi(number);
|
||||
if(idx == 0)
|
||||
|
|
Loading…
Reference in a new issue