byte GetPosition(unsigned char *joystick_rpt); //function prototype GetPosition(joystick_report); //function call GetPosition(unsigned char *joystick_rpt) //Function { int position = 0; unsigned char old_position = 0; unsigned char currrent_position = 0; if(old_position != PORTB & 0xC0) { position++; old_position = PORTB & 0xC0; joystick_report[2] = position & 0x00ff; joystick_report[1] = position >> 8; } return 1; }