/* * button.h * * Header file for list structure to hold enumerated playstation button values * * Author: ScoTT Campbell * Date: 27/8/98 * * It is up to the user of this package to ensure that they do not pass * NULL lists to functions. */ #ifndef __BUTTONLIST #define __BUTTONLIST #define NULL_BUTTON_LIST ((void*) 0) enum buttons{CROSS, SQUARE, TRIANGLE, CIRCLE}; typedef enum buttons button_type; typedef struct button_node* button_list_node_ptr; typedef struct button_node{ button_list_node_ptr next, previous; button_type buttonValue; }button_list_node; typedef struct button_head{ button_list_node_ptr front; button_list_node_ptr back; button_list_node_ptr current; unsigned long length; }button_list_head; typedef button_list_head* button_list; button_list CreateButtonList(); /* Returns a new empty button list */ int BLClear(button_list); /* Emptys a button list */ /* Returns 1 if successful; 0 otherwise */ int BLIsEmpty(button_list); /* Returns 1 if the button list is empty; 0 otherwise */ int BLLength(button_list); /* Returns the number of nodes in a button list */ /* Following functions return 0 if successful; 1 otherwise */ int BLAddFront(button_list, button_type); /* Adds node to front of a button list and stores value of arg2 in it */ int BLAddBack(button_list, button_type); /* Adds node to back of a button list and stores value of arg2 in it */ int BLAddBehindCurrent(button_list, button_type); /* Adds node behind the current node and stores the value of arg2 in it */ int BLAddInFrontCurrent(button_list, button_type); /* Adds node in front of the current node and stores the value of arg2 in it */ int BLGetFront(button_list, button_type*); /* Removes node from front of a button list and puts the value held into *arg2 */ int BLGetBack(button_list, button_type*); /* Removes node from back of a button list and puts the value held into *arg2 */ int BLGetCurrent(button_list, button_type*); /* Removes node pointed to by the current pointer and puts the value held into *arg2 */ int BLReturnFront(button_list, button_type*); /* Puts value held at front of list into *arg2 */ int BLReturnBack(button_list, button_type*); /* Puts value held at back of list into *arg2 */ int BLReturnCurrent(button_list, button_type*); /* Puts value held ad node pointed to by current pointer into *arg2 */ int BLSetCurrentToFront(button_list); /* Sets current pointer to the value of the front pointer */ int BLSetCurrentToBack(button_list); /* Sets current pointer to the value of the front pointer */ int BLAdvanceCurrent(button_list); /* Moves the current pointer to the next node if possible */ int BLRetreatCurrent(button_list); /* Moves the current pointer to the previous node if possible */ /* Functions for specific use. Pretty ugly and not very general */ /* Return 0 if succesful; 1 otherwise */ int BLAdvanceHead(button_list); /* Makes the next node the front of the list */ /* Does not affect the length of the list */ int BLRetreatHead(button_list); /* Makes the previous node the front of the list */ /* Does not affect the length of the list */ int BLAdvanceTail(button_list); /* Makes the next node the back of the list */ /* Does not affect the length of the list */ int BLRetreatTail(button_list); /* Makes the previous node the back of the list */ /* Does not affect the length of the list */ int BLResetHeadAndTail(button_list); /* Makes the head and tail point to their 'correct' positions */ #endif