src/joystick/SDL_gamecontroller.c
changeset 6850 ad3416a14319
parent 6847 c0fa29d3fade
child 6854 7b1d78036e84
equal deleted inserted replaced
6849:b9dcf6242476 6850:ad3416a14319
   127 {
   127 {
   128 	switch( event->type )
   128 	switch( event->type )
   129 	{
   129 	{
   130 	case SDL_JOYAXISMOTION:
   130 	case SDL_JOYAXISMOTION:
   131 		{
   131 		{
       
   132 			SDL_GameController *controllerlist;
       
   133 
   132 			if ( event->jaxis.axis >= k_nMaxReverseEntries ) break;
   134 			if ( event->jaxis.axis >= k_nMaxReverseEntries ) break;
   133 
   135 
   134 			SDL_GameController *controllerlist = SDL_gamecontrollers;
   136 			controllerlist = SDL_gamecontrollers;
   135 			while ( controllerlist )
   137 			while ( controllerlist )
   136 			{
   138 			{
   137 				if ( controllerlist->joystick->instance_id == event->jaxis.which )
   139 				if ( controllerlist->joystick->instance_id == event->jaxis.which )
   138 				{
   140 				{
   139 					if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) // simple axis to axis, send it through
   141 					if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) // simple axis to axis, send it through
   151 		}
   153 		}
   152 		break;
   154 		break;
   153 	case SDL_JOYBUTTONDOWN:
   155 	case SDL_JOYBUTTONDOWN:
   154 	case SDL_JOYBUTTONUP:
   156 	case SDL_JOYBUTTONUP:
   155 		{
   157 		{
       
   158 			SDL_GameController *controllerlist;
       
   159 
   156 			if ( event->jbutton.button >= k_nMaxReverseEntries ) break;
   160 			if ( event->jbutton.button >= k_nMaxReverseEntries ) break;
   157 
   161 
   158 			SDL_GameController *controllerlist = SDL_gamecontrollers;
   162 			controllerlist = SDL_gamecontrollers;
   159 			while ( controllerlist )
   163 			while ( controllerlist )
   160 			{
   164 			{
   161 				if ( controllerlist->joystick->instance_id == event->jbutton.which )
   165 				if ( controllerlist->joystick->instance_id == event->jbutton.which )
   162 				{
   166 				{
   163 					if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) // simple button as button
   167 					if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) // simple button as button
   174 			}
   178 			}
   175 		}
   179 		}
   176 		break;
   180 		break;
   177 	case SDL_JOYHATMOTION:
   181 	case SDL_JOYHATMOTION:
   178 		{
   182 		{
       
   183 			SDL_GameController *controllerlist;
       
   184 
   179 			if ( event->jhat.hat >= 4 ) break;
   185 			if ( event->jhat.hat >= 4 ) break;
   180 
   186 
   181 			SDL_GameController *controllerlist = SDL_gamecontrollers;
   187 			controllerlist = SDL_gamecontrollers;
   182 			while ( controllerlist )
   188 			while ( controllerlist )
   183 			{
   189 			{
   184 				if ( controllerlist->joystick->instance_id == event->jhat.which )
   190 				if ( controllerlist->joystick->instance_id == event->jhat.which )
   185 				{
   191 				{
   186 					Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value;
   192 					Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value;