void control_ship( USERCONFIG *conf, SHIPCONTROL *ctrl ) { int j, joystick; float mouse_dx; float mouse_dy; float pitch_sign; float turn_sign; float MaxMove, MaxTurbo, MaxTurn, MaxRoll, MaxBank; ctrl->pitch = 0.0F; ctrl->yaw = 0.0F; ctrl->roll = 0.0F; ctrl->bank = 0.0F; ctrl->right = 0.0F; ctrl->up = 0.0F; ctrl->forward = 0.0F; ctrl->cruise_control = 0; ctrl->turbo = 0; ctrl->fire_primary = 0; ctrl->fire_secondary = 0; ctrl->fire_mine = 0; ctrl->select_primary = 0; ctrl->select_secondary = 0; ctrl->select_next_primary = 0; ctrl->select_prev_primary = 0; ctrl->select_next_secondary = 0; ctrl->select_prev_secondary = 0; ctrl->drop_primary = 0; ctrl->drop_secondary = 0; ctrl->drop_shield = 0; ctrl->drop_ammo = 0; if ( !conf ) return; // bail if no config supplied if ( CurrentMenu ) return; // disable bike controls if using menus mouse_dx = mouse_states[ new_input ].xrel * conf->mouse_x_sensitivity * 4.0F; mouse_dy = mouse_states[ new_input ].yrel * conf->mouse_y_sensitivity * 4.0F; #if 0 if ( mouse_dx < -MAX_MOUSE_DELTA_X ) mouse_dx = -MAX_MOUSE_DELTA_X; else if ( mouse_dx > MAX_MOUSE_DELTA_X ) mouse_dx = MAX_MOUSE_DELTA_X; if ( mouse_dy < -MAX_MOUSE_DELTA_Y ) mouse_dy = -MAX_MOUSE_DELTA_Y; else if ( mouse_dy > MAX_MOUSE_DELTA_Y ) mouse_dy = MAX_MOUSE_DELTA_Y; #endif // TODO // win32 appear to return greator values even in some resolution // we should also configure a fine control setting for the mouse to turn on/off the fabs() trick #ifdef WIN32 mouse_dx = mouse_dx * (float) fabs( mouse_dx ) * MouseXFactor; // factor = 0.000625 mouse_dy = mouse_dy * (float) fabs( mouse_dy ) * MouseYFactor; // factor = -0.000625 #else mouse_dx = mouse_dx * (float) fabs( mouse_dx ) * 0.01f; // tweaked for linux mouse_dy = mouse_dy * (float) fabs( mouse_dy ) * -0.01f; #endif #if 0 if ( mouse_dx < -framelag ) mouse_dx = -framelag; if ( mouse_dx > framelag ) mouse_dx = framelag; if ( mouse_dy < -framelag ) mouse_dy = -framelag; if ( mouse_dy > framelag ) mouse_dy = framelag; #endif pitch_sign = ( conf->invert_pitch ) ? -1.0F : 1.0F; turn_sign = ( conf->invert_turn ) ? -1.0F : 1.0F; if ( key_held( &conf->full_rear_view ) ) FullRearView = true; else FullRearView = false; if( key_held( &conf->show_messages)) ShowMessages = true; else ShowMessages = false; if( key_held( &conf->show_stats)) ShowStatistics = true; else ShowStatistics = false; if( key_held( &conf->show_networkinfo)) ShowNetworkInfo = true; else ShowNetworkInfo = false; if ( key_pressed( &conf->headlights ) ) Ships[WhoIAm].headlights = !Ships[WhoIAm].headlights; ctrl->slide_mode = key_held( &conf->move ); ctrl->roll_mode = key_held( &conf->roll ); if ( ctrl->slide_mode ) { if ( key_held( &conf->left ) ) { ctrl->right -= MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->right ) ) { ctrl->right += MoveAccell * MaxMoveSpeed * framelag; } if ( mouse_dx != 0.0F ) { ctrl->right += MoveAccell * MaxMoveSpeed * mouse_dx; } if ( key_held( &conf->up ) ) { ctrl->up += MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->down ) ) { ctrl->up -= MoveAccell * MaxMoveSpeed * framelag; } if ( mouse_dy != 0.0F ) { ctrl->up += MoveAccell * MaxMoveSpeed * mouse_dy; } } else { if ( ctrl->roll_mode ) { if ( key_held( &conf->left ) ) { ctrl->roll += RollAccell * MaxRollSpeed * framelag; } if ( key_held( &conf->right ) ) { ctrl->roll -= RollAccell * MaxRollSpeed * framelag; } if ( mouse_dx != 0.0F ) { ctrl->roll -= RollAccell * MaxRollSpeed* mouse_dx; } } else { if ( key_held( &conf->left ) ) { ctrl->yaw -= TurnAccell * MaxTurnSpeed * framelag; ctrl->bank += BankAccell * MaxBankAngle * framelag; } if ( key_held( &conf->right ) ) { ctrl->yaw += TurnAccell * MaxTurnSpeed * framelag; ctrl->bank -= BankAccell * MaxBankAngle * framelag; } if ( mouse_dx != 0.0F ) { ctrl->yaw += TurnAccell * MaxTurnSpeed * mouse_dx * turn_sign; ctrl->bank -= BankAccell * MaxBankAngle * mouse_dx * turn_sign; } } if ( key_held( &conf->down ) ) { ctrl->pitch -= TurnAccell * MaxTurnSpeed * framelag; } if ( key_held( &conf->up ) ) { ctrl->pitch += TurnAccell * MaxTurnSpeed * framelag; } if ( mouse_dy != 0.0F ) { ctrl->pitch += TurnAccell * MaxTurnSpeed * pitch_sign * mouse_dy ; } } if ( key_held( &conf->move_left ) ) { ctrl->right -= MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->move_right ) ) { ctrl->right += MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->move_down ) ) { ctrl->up -= MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->move_up ) ) { ctrl->up += MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->roll_left ) ) { ctrl->roll += RollAccell * MaxRollSpeed * framelag; } if ( key_held( &conf->roll_right ) ) { ctrl->roll -= RollAccell * MaxRollSpeed * framelag; } if( NitroFuel && ( key_pressed ( &conf->turbo ) ) ) { PlaySfx( SFX_NitroStart, 0.66F ); } ctrl->turbo = key_held( &conf->turbo ); if ( ctrl->turbo ) { if ( NitroFuel > 0.0F ) { ctrl->forward += TurboAccell * MaxTurboSpeed * framelag; } else { ctrl->forward += MoveAccell * MaxMoveSpeed * framelag; } } else if ( key_held( &conf->move_forward ) ) { ctrl->forward += MoveAccell * MaxMoveSpeed * framelag; } if ( key_held( &conf->move_backward ) ) { ctrl->forward -= MoveAccell * MaxMoveSpeed * framelag; } if ( key_pressed( &conf->cruise_faster ) ) ctrl->cruise_control++; if ( key_pressed( &conf->cruise_slower ) ) ctrl->cruise_control--; ctrl->fire_primary = key_held( &conf->fire_primary ); ctrl->fire_secondary = key_held( &conf->fire_secondary ); ctrl->fire_mine = key_pressed( &conf->fire_mine ); ctrl->select_next_primary = key_pressed( &conf->select_next_primary ); ctrl->select_prev_primary = key_pressed( &conf->select_prev_primary ); ctrl->select_next_secondary = key_pressed( &conf->select_next_secondary ); ctrl->select_prev_secondary = key_pressed( &conf->select_prev_secondary ); ctrl->drop_primary = key_pressed( &conf->drop_primary ); ctrl->drop_secondary = key_pressed( &conf->drop_secondary ); ctrl->drop_shield = key_pressed( &conf->drop_shield ); ctrl->drop_ammo = key_pressed( &conf->drop_ammo ); ctrl->select_primary = 0; for ( j = 0; j < MAX_PRIMARY_WEAPONS; j++ ) { if ( key_pressed( &conf->select_primary[ j ] ) ) { ctrl->select_primary = j + 1; } } ctrl->select_secondary = 0; for ( j = 0; j < MAX_SECONDARY_WEAPONS; j++ ) { if ( key_pressed( &conf->select_secondary[ j ] ) ) { ctrl->select_secondary = j + 1; } } if ( ( SDL_GetModState() & KMOD_CTRL ) && key_pressed( &conf->send_msg ) && MyGameStatus == STATUS_Normal ) { MenuRestart( &MENU_QuickTextSendWhisper ); } else if ( ( key_pressed( &conf->send_msg ) ) && MyGameStatus == STATUS_Normal ) { MenuRestart( &MENU_QuickTextSend ); } #ifdef PLAYER_SPEECH_TAUNTS if( key_pressed( &conf->send_speech ) ) { PlaySpecificBikerSpeech( SFX_BIKER_TN, Ships[ WhoIAm ].Object.Group, &Ships[WhoIAm].Object.Pos, 0.0F, player_config->bike, -1, false ); // don't update if( MyGameStatus == STATUS_Normal ) { SendBikerTaunt(); // (Sfx.c) //SendGameMessage(MSG_TEXTMSG, 0, 0, TEXTMSGTYPE_SpeechTaunt, 0); } } #endif if ( JoystickInput ) { for (joystick = 0; joystick < Num_Joysticks; joystick++) { if (JoystickInfo[joystick].connected && JoystickInfo[joystick].assigned) ReadJoystickInput(ctrl, joystick); } } #ifdef LUA_BOT ProcessBot1(); #endif MaxMove = MoveAccell * MaxMoveSpeed * framelag; MaxTurbo = TurboAccell * MaxTurboSpeed * framelag; MaxTurn = TurnAccell * MaxTurnSpeed * framelag; MaxRoll = RollAccell * MaxRollSpeed * framelag; MaxBank = BankAccell * MaxBankAngle * framelag; CLAMP( ctrl->pitch, MaxTurn ); CLAMP( ctrl->yaw, MaxTurn ); CLAMP( ctrl->roll, MaxRoll ); CLAMP( ctrl->bank, MaxBank ); CLAMP( ctrl->right, MaxMove ); CLAMP( ctrl->up, MaxMove ); if ( ctrl->turbo && NitroFuel > 0.0F ) { if ( ctrl->forward > MaxTurbo ) ctrl->forward = MaxTurbo; else if ( ctrl->forward < -MaxMove ) ctrl->forward = -MaxMove; } else { CLAMP( ctrl->forward, MaxMove ); } }
void buttontest() { vid_vsync(); key_poll(); while(key_is_up(KEY_B)){ vid_vsync(); key_poll(); tte_write("#{es}"); tte_write("#{P:0,0}GBA Button Test\n"); tte_write("Hold buttons to test. B will exit.\n"); if (key_held(KEY_L)){ tte_write("L\n"); } if (key_held(KEY_R)){ tte_write("R\n"); } if (key_held(KEY_UP)){ tte_write("Up\n"); } if (key_held(KEY_DOWN)){ tte_write("Down\n"); } if (key_held(KEY_LEFT)){ tte_write("Left\n"); } if (key_held(KEY_RIGHT)){ tte_write("Right\n"); } if (key_held(KEY_START)){ tte_write("Start\n"); } if (key_held(KEY_SELECT)){ tte_write("Select\n"); } if (key_held(KEY_A)){ tte_write("A\n"); } if (key_held(KEY_B)){ tte_write("B\n"); } vid_vsync(); key_poll(); } }