<commit_before>#include <SDL.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
	int x_move;
	int y_move;
	int garbage;
	int i;
	int done;
	SDL_Event event;
	SDL_Joystick *joystick;
	/* Initialize SDL */
	if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
		exit(1);
	}
	//garbage = SDL_JoystickEventState(SDL_ENABLE);
	joystick = SDL_JoystickOpen(0);
	if (SDL_JoystickOpened(0)) {
		printf("JoystickOpened!\n");
	}
	else {
		printf("Fail: JoystickOpened\n");
	}

	for (i=0;i<100;i++) {
	printf("count: %d\n",i);
		done=0;
		while ( ! done ) {
			while ( SDL_PollEvent(&event) ) {
				switch (event.type) {
				    case SDL_JOYAXISMOTION:
					printf("Joystick %d axis %d value: %d\n",
					       event.jaxis.which,
					       event.jaxis.axis,
					       event.jaxis.value);
					break;
				    case SDL_KEYDOWN:
					if ( event.key.keysym.sym != SDLK_ESCAPE ) {
						break;
					}
					/* Fall through to signal quit */
				    case SDL_QUIT:
					done = 1;
					break;
				    default:
					break;
				}
			}
			x_move = (((int)SDL_JoystickGetAxis(joystick, 0))+32768);
			y_move = (((int)SDL_JoystickGetAxis(joystick, 1))+32768);
			//printf("x_move: %d\n",x_move);
			//printf("y_move: %d\n",y_move);
		}
		sleep(1);
		/*SDL_JoystickUpdate;
		x_move=SDL_JoystickGetAxis(joystick, 0);
		printf("x_move: %d\n",x_move);
		sleep(1);*/
	}











	  // Close if opened
	if(SDL_JoystickOpened(0))
		SDL_JoystickClose(joystick);
	SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}






<commit_msg>updated joystick functionality<commit_after>#include <SDL.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
	int x_move;
	int y_move;
	int garbage;
	int i;
	int done;
	int buttons = 0;
	int dPadX = 0;
	int dPadY = 0;
	int leftAnalogX = 0;
	int leftAnalogY = 0;
	int rightAnalogX = 0;
	int rightAnalogY = 0;
	SDL_Event event;
	SDL_Joystick *joystick;
	//setup starts:
	/* Initialize SDL */
	if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
		exit(1);
	}
	//garbage = SDL_JoystickEventState(SDL_ENABLE);
	joystick = SDL_JoystickOpen(0);
	if (SDL_JoystickOpened(0)) {
		printf("Joystick Opened!\n");
	}
	else {
		printf("Failed to open joystick!\n");
	}
	done=0;
	SDL_PollEvent(&event);//clear out any bad data
	//setup ends
	//main loop starts:
	while ( ! done ) {
		while ( SDL_PollEvent(&event) ) {
			switch (event.type) {
			    case SDL_JOYAXISMOTION:
				//printf("Joystick %d axis %d value: %d\n",
				       //event.jaxis.which,
				       //event.jaxis.axis,
				       //event.jaxis.value);
				switch (event.jaxis.axis) {
					case 4:
						dPadX=event.jaxis.value;
						printf("dPadX: %d\n", dPadX);
					break;
					case 5:
						dPadY=event.jaxis.value;
						printf("dPadY: %d\n", dPadY);
					break;
					case 0:
						leftAnalogX=event.jaxis.value;
						printf("leftAnalogX: %d\n", leftAnalogX);
					break;
					case 1:
						leftAnalogY=event.jaxis.value;
						printf("leftAnalogY: %d\n", leftAnalogY);
					break;
					case 2:
						rightAnalogX=event.jaxis.value;
						printf("rightAnalogX: %d\n", rightAnalogX);
					break;
					case 3:
						rightAnalogY=event.jaxis.value;
						printf("rightAnalogY: %d\n", rightAnalogY);
					break;
					default:
					break;
				}
				break;
			    case SDL_JOYBUTTONDOWN:
				//printf("Joystick %d button %d down\n",
				       //event.jbutton.which,
				       //event.jbutton.button);
				       buttons = buttons | 1<<event.jbutton.button;
						printf("buttons: %d\n", buttons);
				break;
			    case SDL_JOYBUTTONUP:
				//printf("Joystick %d button %d up\n",
				       //event.jbutton.which,
				       //event.jbutton.button);
				       buttons = buttons & ~1<<event.jbutton.button;
						printf("buttons: %d\n", buttons);
				break;
			    case SDL_KEYDOWN:
				if ( event.key.keysym.sym != SDLK_ESCAPE ) {//this line doesnt work
					break;
				}
				/* Fall through to signal quit */
			    case SDL_QUIT:
				done = 1;
				break;
			    default:
				break;
			}
		}
	}
	//main loop ends
	
	//shutdown starts:
	  // Close if opened
	if(SDL_JoystickOpened(0)) {
		SDL_JoystickClose(joystick);
	}
	SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
	//shutdown ends
	return 0;
}







{'fraction_non_alphanumeric': 0.14720930232558138, 'fraction_numerical': 0.011395348837209301, 'mean_word_length': 2.6542056074766354, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '501104', 'n_tokens_mistral': 2122, 'n_tokens_neox': 1654, 'n_words': 324}