- else if( ev->type == SDL_CONTROLLERBUTTONDOWN ){
- struct vg_controller *active = NULL;
-
- if( vg_input.active_controller_index >= 0 )
- active = &vg_input.controllers[vg_input.active_controller_index];
-
- if( !active || (ev->cbutton.which != active->instance_id) ){
- active = NULL;
- vg_input.active_controller_index = -1;
- vg_input.display_input_method = k_input_method_kbm;
-
- for( int i=0; i<VG_MAX_CONTROLLERS; i++ ){
- if( vg_input.controllers[i].instance_id == ev->cbutton.which ){
- active = &vg_input.controllers[i];
- vg_input.active_controller_index = i;
- vg_input.display_input_type =
- SDL_GameControllerGetType(active->handle);
- break;
- }
- }
-
- if( active ){
- vg_info( "Switching active controller index to #%d\n",
- vg_input.active_controller_index );
- }
- else{
- vg_error( "Input out of range (SDL_JoystickID#%d)\n",
- ev->cbutton.which );
- }
- }
-
- if( active ){
- if( vg_input.display_input_method != k_input_method_controller ){
- vg_input.display_input_method = k_input_method_controller;
- vg_info( "display_input: k_input_method_controller\n" );
+ else if( ev->type == SDL_CONTROLLERBUTTONDOWN )
+ {
+ for( int i=0; i<VG_MAX_CONTROLLERS; i++ )
+ {
+ struct vg_controller *esta = &vg_input.controllers[i];
+ if( esta->instance_id == ev->cbutton.which )
+ {
+ vg_input_set_active_controller( i, "Button press" );
+ esta->buttons[ ev->cbutton.button ] = 1;
+ break;