Welcome! Log In Create A New Profile

Advanced

Some help with my first homebrew wii programs

Posted by datalogger 
Some help with my first homebrew wii programs
February 07, 2010 06:35AM
I would like to start learning about using the Wiimotes in a Homebrew app.

I was searching the internet and found an basic sounding source to start with, but it is so
old and it seems libogc has changed so much since it was written that it won't compile.
it is at [forums.qj.net]
(Trying to read its source code is very hard because it has all comments in Spanish.)


All I want is a simple app source to give me a start in the right direction.
Im pretty good and modifing source to work the way I want, just not so at getting started.

--What I want to do--

When my friends come to visit and bring their wiimotes, I want to have a Homebrew app that I can start and it will show the serial number unique to each wiimote so I can write that down and know who has what remote number.
Before they leave we can check to make sure thay have the right one.

I read the wiiuse functions, but I cant understand them well enough to get this to work.

void handle_read(struct wiimote_t* wm, byte* data, unsigned short len) {
int i = 0;

printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
printf("finished read of size %i\n", len);
for (; i < len; ++i) {
if (!(i%16))
printf("\n");
printf("%x ", data);
}
printf("\n\n");
}





Any assistance please?
Re: Some help with my first homebrew wii programs
February 07, 2010 07:24AM
Why not use the sync buttons on the wii and wiimotes when they bring theirs over, wouldn't that be easier? After they are done and go home then resync them back to there own wii's? This post actually may belong in the coding section.
Re: Some help with my first homebrew wii programs
February 07, 2010 09:02AM
Quote
dirtrider73068
Why not use the sync buttons on the wii and wiimotes when they bring theirs over, wouldn't that be easier? After they are done and go home then resync them back to there own wii's? This post actually may belong in the coding section.

Thank you for replying.

The sync buttons won't tell me who brought which remote to my place.
They all look the same.

I will post my question in the coding area like you suggested.
Thanks!
Re: Some help with my first homebrew wii programs
February 09, 2010 03:49AM
I'm gonna quote a post from another topic that was discussing wiimotes. The following quoted post below should provide the necessary information you want and help you save a lot of trouble and time.

Quote
ekeeke
You need to permanently register the wiimotes in the System Menu, this is different from the temporary synchronization that you got by pressing 1+2. Read your Wii user manual to know how to register additional wiimotes (using the red sync buttons).

The reason is that wiimotes are shutdown when leaving the system menu and homebrew applications need to retrieve bluetooth informations to be able to automatically reconnect them. These infos are in a configuration file stored in internal memory, but (apparently) does not include wiimotes that were temporary synchronized.

Older homebrew were using temporary synchronization as well but it was painful to press 1+2 everytime you started a new app, it's easier to have them permanently registered anyway.

So dont register them by pressing the sync buttons on each of them with the wii console. You can temporarily connect your friends wiimotes, and be able to use them, however only your wiimote should be able to turn your console off and on, since it will be permanently registered to your console via the first time you synced your wiimote to the console via the sync buttons on each.

Hope that helps.
Re: Some help with my first homebrew wii programs
February 09, 2010 10:20AM
This part I understand.
I think I'm not wording my issue clearly, so sorry for this.

We want/need to be able to know internally who's wiimote belongs to who.
This will stop the "problem" of people bringing over their "suspect" working correctly wiimotes, then "accidently" leaving a broken one behind.

We have several Wii's where I live (not a home, in the normal sense).
People come and people go.
Sometimes they are here for a week, sometimes a month,sometimes longer.
We all get together and play the wii's provided to us.

It would just make things more sane if we could identify who's remote belongs to who (internally)

That being said, I'm just about done fumbling my way through this APP, using the trial and err (and err, and err) method.
I can get the Wii to display the BT Addresses, but the format is wierd.



Edited 3 time(s). Last edit at 02/10/2010 08:43AM by datalogger.
Re: Some help with my first homebrew wii programs
February 09, 2010 06:07PM
That is bogus man! Totally bogus! If I am reading you correctly, people are trying to switch their crap wiimotes for working ones, under the guise of friendship? That's low. If there were a way to deliver electric shock via the wiimote... well I'm just saying.
Re: Some help with my first homebrew wii programs
February 09, 2010 06:37PM
Hi, I think it would be a lot simpler to put a sticker with your name in the Wii Remote under the batteries. No one will know, except if they changed your wiimote batteries.

Or simply put your Mii on the Wiimote to identify it.

EDIT
In the other forum Daid suggested the same thing, that's funny: [forum.wiibrew.org]



Edited 1 time(s). Last edit at 02/09/2010 07:02PM by Crayon.
Re: Some help with my first homebrew wii programs
February 10, 2010 02:46AM
--Merging in posts from a coexisting identical and active thread--
Making a program to read the wiimote id's
February 07, 2010 09:09AM
(dupe info)



Edited 5 time(s). Last edit at 02/10/2010 08:44AM by datalogger.
Re: Making a program to read the wiimote id's
February 07, 2010 11:28AM
I'm getting closer, but need a little help (hope it's just a little )


Using devkitpro, I can compile WinterMute's sample "How_to_use_the_Wiimote" source from here just fine.
[www.wiibrew.org]

Unlucky for me though, it doesn't use any of the WIIUSE calls, only the WPAD calls.
WPAD does not have any functions to read the wiimote id.
If it did- I'd be done and sleeping by now :)


...There's something it doesn't like when I try and add the code above to read the wiimote id's

I get the following errors in devkitpro
L:\devkitPro\wintermutes_sample>make clean
clean ...
L:\devkitPro\wintermutes_sample>make
main.c
l:/devkitPro/wintermutes_sample/source/main.c:54: error: 'byte' has not been declared
make[1]: *** [main.o] Error 1
make: *** [build] Error 2


Any ideas what I'm doing wrong?
Re: Making a program to read the wiimote id's
February 08, 2010 04:08PM
Quote
datalogger
When my friends come to visit and bring their wiimotes, I want to have a Homebrew app that I can start and it will show the serial number unique to each wiimote so I can write that down and know who has what remote number.
Before they leave we can check to make sure thay have the right one.
Until you get this working I suggest you use a marker to write your name in the battery compartment. Works even when your wii is off!
Re: Making a program to read the wiimote id's
February 08, 2010 06:07PM
Pieces of tape work as well.

Also, "byte" needs to be declared, try:

typedef unsigned char byte;

...up at the top of your file.
Re: Making a program to read the wiimote id's
February 08, 2010 10:29PM
Quote
dancinninja
Pieces of tape work as well.

Also, "byte" needs to be declared, try:

typedef unsigned char byte;

...up at the top of your file.

That fixed it so it compiles without errors, Thanks!

Now to figure out how to call this function.
If I can get it to run and just show me the printf statements, I think I'll be good to go.

What do I need to prepare to call into this?

The comments on the source say:

/**
 *    @brief Callback that handles a read event.
 *
 *    @param wm        Pointer to a wiimote_t structure.
 *    @param data        Pointer to the filled data block.
 *    @param len        Length in bytes of the data block.
 *
 *    This function is called automatically by the wiiuse library when
 *    the wiimote has returned the full data requested by a previous
 *    call to wiiuse_read_data().
 *
 *    You can read data on the wiimote, such as Mii data, if
 *    you know the offset address and the length.
 *
 *    The \a data pointer was specified on the call to wiiuse_read_data().
 *    At the time of this function being called, it is not safe to deallocate
 *    this buffer.
 */
void handle_read(struct wiimote_t* wm, byte* data, unsigned short len) {
    int i = 0;

    printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
    printf("finished read of size %i\n", len);
    for (; i < len; ++i) {
        if (!(i%16))
            printf("\n");
        printf("%x ", data);
    }
    printf("\n\n");
}



Edited 1 time(s). Last edit at 02/08/2010 11:02PM by datalogger.
Re: Making a program to read the wiimote id's
February 09, 2010 04:01AM
Maybe I should be looking at the \bte\bd_addr.h and bte.h lib for answers?

Can someone please give me a hint on how I can use this?

#ifndef __BD_ADDR_H__
#define __BD_ADDR_H__

#include 

#ifdef __cplusplus
   extern "C" {
#endif /* __cplusplus */

struct bd_addr {
  u8 addr[6];
};

#define BD_ADDR_LEN			6

#define BD_ADDR_ANY			(&(struct bd_addr){{0,0,0,0,0,0}})
#define BD_ADDR_LOCAL		(&(struct bd_addr){{0,0,0,0xff,0xff,0xff}})

#define BD_ADDR(bdaddr, a, b, c, d, e, f) do{ \
                                        (bdaddr)->addr[0] = a; \
				        (bdaddr)->addr[1] = b; \
				        (bdaddr)->addr[2] = c; \
				        (bdaddr)->addr[3] = d; \
				        (bdaddr)->addr[4] = e; \
						(bdaddr)->addr[5] = f; }while(0)
//TODO: USE memcmp????
#define bd_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
				   ((addr1)->addr[1] == (addr2)->addr[1]) && \
				   ((addr1)->addr[2] == (addr2)->addr[2]) && \
				   ((addr1)->addr[3] == (addr2)->addr[3]) && \
				   ((addr1)->addr[4] == (addr2)->addr[4]) && \
				   ((addr1)->addr[5] == (addr2)->addr[5]))
//TODO: USE memcpy????
#define bd_addr_set(addr1, addr2) do { \
                                   (addr1)->addr[0] = (addr2)->addr[0]; \
				   (addr1)->addr[1] = (addr2)->addr[1]; \
				   (addr1)->addr[2] = (addr2)->addr[2]; \
				   (addr1)->addr[3] = (addr2)->addr[3]; \
				   (addr1)->addr[4] = (addr2)->addr[4]; \
				   (addr1)->addr[5] = (addr2)->addr[5]; }while(0)


#ifdef __cplusplus
   }
#endif /* __cplusplus */

#endif /* __BD_ADDR_H__ */
Re: Making a program to read the wiimote id's
February 09, 2010 09:23AM
So far, by trial and err(mostly err) I have this working except the proper way to
format printing BD_ADDR

My APP compiles and runs on the Wii, but the compiler complains about how I'm printf'ing the macro, and I can't find any help to show me how to do it right.

I can see the Bluetooth numbers, but they are not in the correct format.

Can someone please help me by telling me how to properly printf BD_ADDR(bdaddr, a, b, c, d, e, f) ?
I can do the rest myself, but I'm having trouble with this part.


Please??


struct bd_addr {
  u8 addr[6];
};

#define BD_ADDR_LEN			6

#define BD_ADDR_ANY		(&(struct bd_addr){{0,0,0,0,0,0}})
#define BD_ADDR_LOCAL		(&(struct bd_addr){{0,0,0,0xff,0xff,0xff}})

#define BD_ADDR(bdaddr, a, b, c, d, e, f) do{ \
                                       (bdaddr)->addr[0] = a; \
		       (bdaddr)->addr[1] = b; \
		       (bdaddr)->addr[2] = c; \
		       (bdaddr)->addr[3] = d; \
		       (bdaddr)->addr[4] = e; \
		       (bdaddr)->addr[5] = f; }while(0)

If I'm asking these questions in the wrong forum, I'm sorry and would appreciate a MOD moving my post to the correct location.
I'm just beginning using devkitpro, so I don't think I should be posting the coding forums.



Edited 3 time(s). Last edit at 02/09/2010 09:29AM by datalogger.
Re: Some help with my first homebrew wii programs
February 10, 2010 02:46AM
--Merge Complete--
Re: Some help with my first homebrew wii programs
February 10, 2010 07:12AM
On a c-programming user group, I was told to try the code below, but it DSI's on my wii.

Any chance a wii expert can look at this and tell me how to "wii"-ize this to work?


Ersek said:
int main(void)
{
     FILE *file = fopen("output.txt","wb");
     struct bd_addr *BD_ADDR;

     BD_ADDR->addr[0] = 0xff;
     BD_ADDR->addr[1] = 0xff;
     BD_ADDR->addr[2] = 0xff;
     BD_ADDR->addr[3] = 0xff;
     BD_ADDR->addr[4] = 0xff;
     BD_ADDR->addr[5] = 0xff;

     printf_bd_addr(file,&BD_ADDR);
     fclose(file);
     return 0;

}
int print_bd_addr(FILE *f, const struct bd_addr *p)
{
  return fprintf(f,"BD_ADDR = %2x:%2x:%2x:%2x:%2x:%2x",
      (unsigned)p->addr[0],(unsigned)p->addr[1],
      (unsigned)p->addr[2],(unsigned)p->addr[3],
      (unsigned)p->addr[4],(unsigned)p->addr[5]
  );
}



Edited 2 time(s). Last edit at 02/10/2010 08:26AM by datalogger.
Re: Making a program to read the wiimote id's
February 10, 2010 08:48AM
I think I'm going to give up on this.
It seem to complicated for me to figure out on my own.

Three days with little sleep trying to do this isn't worth the cost of a few wii remotes.
The tape idea will have to do, although I think that's going to get found out quickly and defeated (like me now) :(

Thanks to everyone who made suggestions!

(Mod can close this thead now)



Edited 1 time(s). Last edit at 02/10/2010 08:51AM by datalogger.
Re: Some help with my first homebrew wii programs
February 10, 2010 11:15PM
Quote
datalogger
Ersek said:
1)Im pretty sure that code is for a PC Wiimote library

2)You're most likely not going to get any serious help from any other forum (I'm not just saying this because I help to run this forum -- I'm entirely serious)



Edited 1 time(s). Last edit at 02/12/2010 01:06AM by Arikado.
Re: Some help with my first homebrew wii programs
February 11, 2010 08:54AM
I wasn’t going to say anything else because no matter how I word it, it sounds like I’m a whiner.
This maybe so, but what I have to say is still valid if you think about it.

[whine]

My experience from this is that you are correct in saying no one else on the net was going to give me useable help while I tried to figure this out.
The only people that offered any help in the form of example code were from non-Wii related C-Programming forums.
I got all kinds of help there and, even though it was all of no use, at least they tried (and tried, and tried).

There are many, many wii related places that have some extremely intelligent wii coders, but doing something that doesn’t crack anything is of no interest to them.

If I was trying to make some new program that let people run some new hacked wii game or do something to make a hacked game they already have better, I’d have more suggestions than I’d know what to do with.

As far as I can tell, the people that made the original code that runs all this Homebrew for the Wii are no where to be found. The few (very few) I’ve been able to get any responses from left email messages saying basically that they don’t do this anymore because they don’t want to be associated with any Wii game hacking.

I know if I could locate the right person, they could tell me how to do this without even breaking a sweat. The problem is they are all gone and all that’s left are people telling me I’m wasting my time and what good is this going to do because it doesn’t make running any hacked games any better.

All I was after was something that I thought would be cool to have, and might actually be of some valid use

I even tried to think of some way to make this something the game hackers might be able to use, thinking they might help me then, but I don’t know anything about hacking games so I didn't go that route.

[/whine]

So I'll use the low-tech "tape in the batteries", thanks to those that suggested that.

jm
Sorry, only registered users may post in this forum.

Click here to login