Tutorial 6: Button detection

In this Wii programming tutorial we will cover displaying an image as the mouse cursor and how to detect button clicking. You can grab the PDF of this tutorial here: codemii-tutorial-6.

Firstly download this tutorial6-image which will contain the required files to get us started. This zip file also contains the JPEG code required to display images which you should have learnt about in the last tutorial. Extract this zip file in C:\devkitPro\examples\gamecube and open up tutorial6.pnproj.

As you should recall, we displayed a cursor which we could control on the gamecube by using the following code:

[sourcecode language=’c’]int cursor_x = 300;
int cursor_y = 250;

while(1) {

PAD_ScanPads();

if (PAD_StickY(0) > 18) {
cursor_y–;
}
if (PAD_StickY(0) < -18) { cursor_y++; } if (PAD_StickX(0) > 18) {
cursor_x++;
}
if (PAD_StickX(0) < -18) { cursor_x--; } VIDEO_ClearFrameBuffer (rmode, xfb, COLOR_BLACK); DrawBox (cursor_x, cursor_y, cursor_x + 1, cursor_y + 1, COLOR_WHITE); VIDEO_WaitVSync(); }[/sourcecode] So all that’s required for us to do is change DrawBox to use display_jpeg instead. [sourcecode language='c']display_jpeg(about, cursor_x, cursor_y); [/sourcecode] Compile your source and there we have it; your cursor is now showing up as an image. Detecting button clicking

In order to detect button clicking we have to know our button’s four co-ordinates; x1, x2, y1 and y2. The simplest way to figure this out is to just print the location of your cursor to the screen when you press A so you can see the x and y co-ordinates as when you are displaying an image it’s not the same as the x and y of the cursor. I know that there has to be a better way for doing this, but I’m just showing you what worked for me.

Put change display_jpeg back to DrawBox as we’ll need to find the x and y co-ordinates.

You can then add the following code to print out the x and y co-ordinates of the cursor:

[sourcecode language=’c’]u16 buttonsDown = PAD_ButtonsDown(0);

if( buttonsDown & PAD_BUTTON_A ) {
printf(“x = %i. y = %i\n”, cursor_x, cursor_y);
usleep(500000);
}[/sourcecode]

We have used printf before, which prints something to the screen but in this case we are using printf to print out two integers; x and y. The way the statement works is we say to printf that we will be passing an integer in the first argument which is denoted by %i. After we have finished the text to print (“ “), we pass the first argument; cursor_x which is an integer. Printf grabs this integer and displays it when it prints “x = 100”. You can print a double (%d), long (%l), characters (%c) and so on.

Usleep as the name suggests, makes the whole application pause for a specified amount of time. The argument usleep takes is a integer and is in microseconds. 500000 would be 500 milliseconds which is ½ of a second.

Before using usleep you need to include [sourcecode language=’c’]#include [/sourcecode] in your headers. Unistd includes miscellaneous functions. If you didn’t include unistd, it would still compile but throw an error saying it can’t find the usleep function, but lucky for us it would still work.

So now if we compile and run our code (tutorial6-mouse-image), we can move the cursor around the about image. What we need to do is find the x, y co-ordinates of the top left and bottom right of the image. So if you were to go ahead and do this yourself you would find that they would roughly be 202, 120 (top left) and 254, 141 (bottom right).

We have our image’s co-ordinates and now all that’s left to do is produce code that will identify if our cursor is in our images co-ordinates. Something as found below works nicely:

[sourcecode language=’c’]if (cursor_x >= 202 && cursor_x <= 254 && cursor_y >= 120 && cursor_y <= 141) { printf("Button pressed\n"); }[/sourcecode] Place the above code in the if (buttonsDown & PAD_BUTTON_A) { statement and recompile your code (tutorial6-button-detection). Once you’ve run it with gcube, try pressing the A button (Q key) around the button and inside the button. You’ll see it works quite well and correctly detects when the button is pressed.

25 Responses to “Tutorial 6: Button detection”

  1. slash_trax says:

    I found your tutorials last Sunday and I have to say they are great. I haven’t been following them verbatim instead choosing to use them as sort of a guild to figure things out for myself. I started a new project, adding all of the elements from the different tutorials to it successfully.

    Is there a way to stack or layer elements so that you can have text on top of a JPEG image? Also can the JPEG tutorial be reworked for PNG files or is there a completely different way of adding them?

  2. teknecal says:

    I think you should just be able to display the text over the image by adding it after the display_jpeg function (or which ever function you use to show the jpeg).

    For PNG images it’s a little different and I have a not so pretty example here: http://www.codemii.com/display_png.zip

  3. harry says:

    thanks very much, again! 🙂
    I hope I’ll have a good idea for some homebrew software soon…

    I wonder if anyone is planning on releasing a “Wii Channel installer”. Something that can turn a Homebrew Channel Icon into a real Channel in the menu. Would be cool (for Sega, NES & SNES) but I guess it would need someone like bushing to create something like that.

  4. Ethan says:

    When I try to compile your file in display_png.zip it cannot find the include png/pngogc.h. Where can I find this include file?

    thanks for your tutorials,
    they are great,
    Ethan

  5. teknecal says:

    You can grab the png files here: http://www.codemii.com/libogc_png.zip. Extract it to C:\devkitPro\devkitPPC\powerpc-gekko

    I haven’t really looked into PNGs as I’m now just using GRRLib and I don’t have to think about it.

  6. DCelso says:

    How I can use the wii-mote ir instead of analog joystic in this example?
    And How I can use the nunchuck analog joystic in this example?
    Thanks.

  7. teknecal says:

    To use the Wiimote you can follow http://www.codemii.com/2008/08/31/tutorial-4-cursors/

    To use the nunchuck you can have a read of this http://forum.wiibrew.org/read.php?11,1334

  8. durdadan says:

    he he, sorry, you must hate seeing my post in all the topics

    i am getting this error

    > “make”
    main.c
    linking … tutorial6.elf
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(dynamics.o): In function `calc_joystick_state’:
    dynamics.c:(.text.calc_joystick_state+0xa0): undefined reference to `atanf’
    dynamics.c:(.text.calc_joystick_state+0xf0): undefined reference to `sqrt’
    dynamics.c:(.text.calc_joystick_state+0x154): undefined reference to `atanf’
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(dynamics.o): In function `calculate_orientation’:
    dynamics.c:(.text.calculate_orientation+0x230): undefined reference to `atan2f’
    dynamics.c:(.text.calculate_orientation+0x25c): undefined reference to `atan2f’
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(ir.o): In function `calc_yaw’:
    ir.c:(.text.calc_yaw+0x28): undefined reference to `atanf’
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(ir.o): In function `apply_ir_smoothing’:
    ir.c:(.text.apply_ir_smoothing+0x3c): undefined reference to `sqrtf’
    ir.c:(.text.apply_ir_smoothing+0xa4): undefined reference to `atan2f’
    ir.c:(.text.apply_ir_smoothing+0xac): undefined reference to `cosf’
    ir.c:(.text.apply_ir_smoothing+0xc8): undefined reference to `sinf’
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(ir.o): In function `rotate_dots’:
    ir.c:(.text.rotate_dots+0xa0): undefined reference to `cos’
    ir.c:(.text.rotate_dots+0xb4): undefined reference to `sin’
    c:/devkitPro/libogc/lib/wiilibwiiuse.a(ir.o): In function `find_sensorbar’:
    ir.c:(.text.find_sensorbar+0x5d4): undefined reference to `atan2′
    ir.c:(.text.find_sensorbar+0x624): undefined reference to `atan2′
    ir.c:(.text.find_sensorbar+0x8d4): undefined reference to `atan2′
    c:/devkitPro/libogc/lib/wiilibbte.a(physbusif.o): In function `physbusif_output’:
    physbusif.c:(.text.physbusif_output+0x148): undefined reference to `USB_WriteBlkMsgAsync’
    physbusif.c:(.text.physbusif_output+0x184): undefined reference to `USB_WriteCtrlMsgAsync’
    c:/devkitPro/libogc/lib/wiilibbte.a(physbusif.o): In function `physbusif_shutdown’:
    physbusif.c:(.text.physbusif_shutdown+0x3c): undefined reference to `USB_CloseDeviceAsync’
    c:/devkitPro/libogc/lib/wiilibbte.a(physbusif.o): In function `__issue_intrread’:
    physbusif.c:(.text.__issue_intrread+0x9c): undefined reference to `USB_ReadIntrMsgAsync’
    c:/devkitPro/libogc/lib/wiilibbte.a(physbusif.o): In function `__issue_bulkread’:
    physbusif.c:(.text.__issue_bulkread+0x9c): undefined reference to `USB_ReadBlkMsgAsync’
    c:/devkitPro/libogc/lib/wiilibbte.a(physbusif.o): In function `physbusif_init’:
    physbusif.c:(.text.physbusif_init+0x58): undefined reference to `USB_Initialize’
    physbusif.c:(.text.physbusif_init+0x1a0): undefined reference to `USB_OpenDevice’
    physbusif.c:(.text.physbusif_init+0x1c8): undefined reference to `USB_OpenDevice’
    collect2: ld returned 1 exit status
    make[1]: *** [/c/devkitpro/examples/gamecube/tutorial6/tutorial6.elf] Error 1
    “make”: *** [build] Error 2

    > Process Exit Code: 2
    > Time Taken: 00:01

    all i did was add the IR movement, just like before.

    i didn’t add my button detection yet. and all my joystick movements are commented out.

    • durdadan says:

      i rewrote the code and got different errors, along the same lines

      > “make”
      main.c
      linking … tutorial6.elf
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(wpad.o): In function `WPAD_Shutdown’:
      wpad.c:(.text.WPAD_Shutdown+0xbc): undefined reference to `BTE_Shutdown’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(wpad.o): In function `WPAD_Init’:
      wpad.c:(.text.WPAD_Init+0x158): undefined reference to `BTE_Init’
      wpad.c:(.text.WPAD_Init+0x164): undefined reference to `BTE_InitCore’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(wpad.o): In function `__initcore_finished’:
      wpad.c:(.text.__initcore_finished+0x28): undefined reference to `BTE_ReadStoredLinkKey’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(wpad.o): In function `__readlinkkey_finished’:
      wpad.c:(.text.__readlinkkey_finished+0x20): undefined reference to `BTE_ApplyPatch’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(wpad.o): In function `__wpad_patch_finished’:
      wpad.c:(.text.__wpad_patch_finished+0x14): undefined reference to `BTE_InitSub’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(dynamics.o): In function `calc_joystick_state’:
      dynamics.c:(.text.calc_joystick_state+0xa0): undefined reference to `atanf’
      dynamics.c:(.text.calc_joystick_state+0xf0): undefined reference to `sqrt’
      dynamics.c:(.text.calc_joystick_state+0x154): undefined reference to `atanf’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(dynamics.o): In function `calculate_orientation’:
      dynamics.c:(.text.calculate_orientation+0x230): undefined reference to `atan2f’
      dynamics.c:(.text.calculate_orientation+0x25c): undefined reference to `atan2f’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(io_wii.o): In function `wiiuse_io_write’:
      io_wii.c:(.text.wiiuse_io_write+0x28): undefined reference to `bte_sendmessageasync’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(io_wii.o): In function `wiiuse_disconnect’:
      io_wii.c:(.text.wiiuse_disconnect+0x2c): undefined reference to `bte_disconnect’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(io_wii.o): In function `wiiuse_register’:
      io_wii.c:(.text.wiiuse_register+0x38): undefined reference to `bte_new’
      io_wii.c:(.text.wiiuse_register+0x4c): undefined reference to `bte_arg’
      io_wii.c:(.text.wiiuse_register+0x5c): undefined reference to `bte_received’
      io_wii.c:(.text.wiiuse_register+0x6c): undefined reference to `bte_disconnected’
      io_wii.c:(.text.wiiuse_register+0x80): undefined reference to `bte_registerdeviceasync’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(ir.o): In function `calc_yaw’:
      ir.c:(.text.calc_yaw+0x28): undefined reference to `atanf’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(ir.o): In function `apply_ir_smoothing’:
      ir.c:(.text.apply_ir_smoothing+0x3c): undefined reference to `sqrtf’
      ir.c:(.text.apply_ir_smoothing+0xa4): undefined reference to `atan2f’
      ir.c:(.text.apply_ir_smoothing+0xac): undefined reference to `cosf’
      ir.c:(.text.apply_ir_smoothing+0xc8): undefined reference to `sinf’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(ir.o): In function `rotate_dots’:
      ir.c:(.text.rotate_dots+0xa0): undefined reference to `cos’
      ir.c:(.text.rotate_dots+0xb4): undefined reference to `sin’
      c:/devkitPro/libogc/lib/wii\libwiiuse.a(ir.o): In function `find_sensorbar’:
      ir.c:(.text.find_sensorbar+0x5d4): undefined reference to `atan2′
      ir.c:(.text.find_sensorbar+0x624): undefined reference to `atan2′
      ir.c:(.text.find_sensorbar+0x8d4): undefined reference to `atan2′
      collect2: ld returned 1 exit status
      make[1]: *** [/c/devkitpro/examples/gamecube/tutorial6/tutorial6.elf] Error 1
      “make”: *** [build] Error 2

      > Process Exit Code: 2
      > Time Taken: 00:01

  9. Jacic says:

    I bet youre getting tired of me finding errors in your examples, Im sorry, I dont try! This was the error I got from an unchanged example(tutorial6-image)(the first one).

    > “make”
    main.c
    In file included from c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeg/jpgogc.h:12,
    from c:/devkitPro/examples/gamecube/tutorial6/source/main.c:7:
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘FAR’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:70: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JBLOCK’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘FAR’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:72: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:73: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘FAR’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:88: error: expected specifier-qualifier-list before ‘UINT16’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:102: error: expected specifier-qualifier-list before ‘UINT8’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:139: error: expected specifier-qualifier-list before ‘JDIMENSION’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:193: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:196: error: expected specifier-qualifier-list before ‘jpeg_saved_marker_ptr’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:279: error: expected specifier-qualifier-list before ‘JDIMENSION’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:420: error: expected specifier-qualifier-list before ‘JDIMENSION’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:645: error: expected specifier-qualifier-list before ‘JMETHOD’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:702: error: expected specifier-qualifier-list before ‘JMETHOD’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:714: error: expected specifier-qualifier-list before ‘JOCTET’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:726: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘*’ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:758: error: expected specifier-qualifier-list before ‘JMETHOD’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:809: error: expected declaration specifiers or ‘…’ before ‘jpeg_marker_parser_method’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:809: error: expected declaration specifiers or ‘…’ before ‘(‘ token
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h: In function ‘EXTERN’:
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:884: error: expected declaration specifiers before ‘jpeg_std_error’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:900: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:902: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:905: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:906: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:910: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:911: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:912: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:915: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:917: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:919: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:920: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:922: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:925: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:929: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:930: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:931: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:933: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:934: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:937: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:939: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:942: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:945: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:950: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:954: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:956: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:960: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:963: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:976: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:977: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:980: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:983: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:988: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:989: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:991: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:992: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:993: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:994: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1003: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1006: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1011: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1016: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1017: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1019: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1028: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1029: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1034: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1035: error: expected declaration specifiers before ‘EXTERN’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1038: error: expected declaration specifiers before ‘EXTERN’
    In file included from c:/devkitPro/examples/gamecube/tutorial6/source/main.c:7:
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeg/jpgogc.h:25: error: storage class specified for parameter ‘JPEGIMG’
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeg/jpgogc.h:27: error: expected ‘)’ before ‘*’ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:9: error: storage class specified for parameter ‘picdata’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:10: error: storage class specified for parameter ‘piclength’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:12: error: storage class specified for parameter ‘xfb’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:13: error: storage class specified for parameter ‘rmode’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:15: error: expected ‘)’ before ‘jpeg’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:49: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:60: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:77: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:121: error: expected declaration specifiers before ‘return’
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:122: error: expected declaration specifiers before ‘}’ token
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:122: error: old-style parameter declarations in prototyped function definition
    c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:884: error: parameter name omitted
    c:/devkitPro/examples/gamecube/tutorial6/source/main.c:122: error: expected ‘{‘ at end of input
    make[1]: *** [main.o] Error 1
    “make”: *** [build] Error 2

    > Process Exit Code: 2
    > Time Taken: 00:00

    I tried finding where it was missing, but with no success.

    • teknecal says:

      Seems like the same issue as last time it seems.

      c:\devkitpro\devkitppc\bin\../lib/gcc/powerpc-gekko/4.2.4/../../../../powerpc-gekko/include/jpeglib.h:1016:
      shows the jpeglib.h in the include folder when it should be in the jpeg folder.

      • Jacic says:

        Its better, but now theres this:

        > “make”
        main.c
        c:/devkitPro/examples/gamecube/tutorial6/source/main.c:121: error: expected identifier or ‘(‘ before ‘return’
        c:/devkitPro/examples/gamecube/tutorial6/source/main.c:122: error: expected identifier or ‘(‘ before ‘}’ token
        make[1]: *** [main.o] Error 1
        “make”: *** [build] Error 2

        > Process Exit Code: 2
        > Time Taken: 00:03

        • teknecal says:

          That’s weird. Maybe try changing return 0 to return 1 or removing return 0; all together?

          Also can you try removing various parts of the source, like the while(1) { loop, and try re-compiling, etc?

  10. Jacic says:

    I found the problem! The last ‘}’ in the main.c file shouldnt be there, and neither should “return 0;”. I removed those and it worked.

  11. IceWolf says:

    When I point at the screen and am pressing Button A, there is a wrong position output: “x = -2147892716 y = 1”.

    if (buttonsDown & WPAD_BUTTON_A) {
    printf(“x = %i y = %i\n”, ir.x, ir.y);
    usleep(500000);
    }

    –>
    warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘double’
    warning: format ‘%i’ expects type ‘int’, but argument 3 has type ‘double’
    warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘double’
    warning: format ‘%i’ expects type ‘int’, but argument 3 has type ‘double’

  12. Timptation says:

    There’s something wrong with the display_jpeg function. It doesn’t display the image in the correct place. I’m not sure about the reason for it (something to do with the size of the screen buffer attributes versus the resolution I assume), but it needs to do the same thing that the line drawing functions are, which is the “x >>= 1;” line sometime before the for loops.

  13. Cockmongler says:

    I’m pretty sure %d is decimal integer and %g is double.

  14. Bruceliste says:

    Хорошего дня.

Leave a Reply