USB Host Shield plus 2 identical joysticks
Not quite the question that was asked but part of the problem.

This is a simple introduction to pointers.

int variable = 42;                              // Create a variable
int* pointer = &amp;variable;                       // Create a pointer to the variable (by getting its address)
*pointer = 99;                                  // Set the address to a new value
printf ("variable has the value %d", variable); // Print 99.


&amp;x get the address of x

*y dereferences the pointer y, which means it 'turns it back to a variable' (this is simplistic view which isn't really true, but will do for now). 
So you could, if you wanted (which you wouldn't) do this *&amp;z which would be the same as doing z.

Basically think of &amp; and * as a pair of complimentary operators like - and + or * and /.  (They aren't operators, but to start with it might help).

The next problem is when you do this

SomeFunction(&amp;variable);


All function parameters in C/C++ are passed by value by default.  This means the function gets a copy of them not the actual value.  So if you had:

void FunctionOne (int val)
{
    val = 99;
}
int val = 4;
FunctionOne(val);
printf("val = %d", val);   // You will see 4 printed.


If you pass by reference then you will see 99 printed, to pass by reference you can do it one of two ways.

void FunctionTwo (int&amp; valByRef);
void FunctionThree (int* valPointer);


FunctionTwo only works with C++ (It will work with an Arduino).

FunctionThree might cause a segmentation error if NULL is passed in and the function writes to it.

If it helps in my opinion pointers was one of the hardest concepts to grasp in classic C/C++ so don't worry if you don't understand it just have a play with it and see what you can do.

Calling Methods


object.method() - Call the function method on the instance called
object which is of type X. 
object-&gt;method() - Call the function method on the instance called
object which is a pointer of type X. 
object::method() - call the function method
which is a static member of class object (static means it doesn't
change any data within an instance of a class)
*object->method() - Avoid this like the plague.  It either means *(object-&gt;method()) or (*object)-&gt;method() to know you would need to look at the type of object and the return type of the function.  Its easier just to bracket it to remove ambiguity.


As for *object.&amp;method() I've never come across that one, but that doesn't mean it doesn't exist. :)