Rockbox Development > Starting Development and Compiling

Error making a menu?

(1/4) > >>

motionman95:
I'm a rockbox noob, and, thanks to the helpful people on this forum, I've got my development platform all set up (thanks!). I'm playing with making a plugin, and so far all want to do is make a menu, but it's not working:


--- Code: ---/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id: helloworld.c 17847 2008-06-28 18:10:04Z bagder $
 *
 * Copyright (C) 2002 Björn Stenberg
 *
 * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#include "plugin.h"
#include "menu.h"

/* welcome to the example rockbox plugin */

/* This macros must always be included. Should be placed at the top by
   convention, although the actual position doesn't matter */
PLUGIN_HEADER

/* here is a global api struct pointer. while not strictly necessary,
   it's nice not to have to pass the api pointer in all function calls
   in the plugin */
static const struct plugin_api* rb;

/* this is the plugin entry point */
enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
{
    /* if you don't use the parameter, you can do like
       this to avoid the compiler warning about it */
    (void)parameter;

    /* if you are using a global api pointer, don't forget to copy it!
       otherwise you will get lovely "I04: IllInstr" errors... :-) */
    rb = api;

    /* now go ahead and have fun! */
    MAKE_MENU(menu, "RockLock", NULL, "Input Password", "Set Password")
switch (rb->do_menu(&menu, NULL))
{
    case 0: /* "Input Password" */
        rb->splash(HZ*2, "Hello world!");
    break;
    case 1: /* "Set Password" */
        rb->splash(HZ*2, "Hello world!");
    break;
    default: rb->splash(HZ*2, "Hello world!");
}

    return 0;
}

--- End code ---

But the compiler reports errors, and they make no sense to me:


--- Quote ---CC apps/plugins/helloworld.c
/home/user/rockbox/apps/plugins/helloworld.c: In function 'plugin_start':
/home/user/rockbox/apps/plugins/helloworld.c:47: warning: initialization from incompatible pointer type
/home/user/rockbox/apps/plugins/helloworld.c:47: warning: initialization makes integer from pointer without a cast
/home/user/rockbox/apps/plugins/helloworld.c:48: error: too few arguments to function 'rb->do_menu'
make: *** [/home/user/rockbox/build_c200/apps/plugins/helloworld.o] Error 1
--- End quote ---

Help me please!

nls:
When starting out with plugins like this it is a good idea to look at what other plugins do.
First you are using an old version of helloworld.c plugins should no longer be passed the api poiter as a parameter.

"error: too few arguments to function 'rb->do_menu'" This error is pretty clear, you are not passing enough arguments to do_menu, it wants 4 arguments and you pass it 2.
You can find prototypes for all functions in the api in plugin.h, for do_menu it looks like this:
    int (*do_menu)(const struct menu_item_ex *menu, int *start_selected,
                   struct viewport parent[NB_SCREENS], bool hide_bars);

Hope this helps you a bit, google knows a lot of useful c resources so a bit of reading might be a good idea ;)

motionman95:

--- Quote ---First you are using an old version of helloworld.c plugins should no longer be passed the api poiter as a parameter.
--- End quote ---

I don't understand?

nls:
The code you posted is from a modified helloworld.c but not from the most recent version. If you are using a recent version of the rockbox source, your "plugin_start" function should only take one argument, and that is "const void* parameter".

motionman95:
Where should I look to find out how to detect when the left, right, up, or down keys are pressed?

Navigation

[0] Message Index

[#] Next page

Go to full version