Skip to content

Commit

Permalink
run rename python script
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai committed Jan 4, 2025
1 parent 278d046 commit 1646b96
Show file tree
Hide file tree
Showing 26 changed files with 240 additions and 240 deletions.
4 changes: 2 additions & 2 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ std::string Context::GetShortName() {

std::string Context::GetAppBundlePath() {
#if defined(__ANDROID__)
const char* externaldir = SDL_AndroidGetExternalStoragePath();
const char* externaldir = SDL_GetAndroidExternalStoragePath();
if (externaldir != NULL) {
return externaldir;
}
Expand Down Expand Up @@ -416,7 +416,7 @@ std::string Context::GetAppBundlePath() {

std::string Context::GetAppDirectoryPath(std::string appName) {
#if defined(__ANDROID__)
const char* externaldir = SDL_AndroidGetExternalStoragePath();
const char* externaldir = SDL_GetAndroidExternalStoragePath();
if (externaldir != NULL) {
return externaldir;
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio/SDLAudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool SDLAudioPlayer::DoInit() {
SDL_AudioSpec want, have;
SDL_zero(want);
want.freq = this->GetSampleRate();
want.format = AUDIO_S16SYS;
want.format = SDL_AUDIO_S16;
want.channels = 2;
want.samples = this->GetSampleLength();
want.callback = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ AxisDirectionMappingFactory::CreateDefaultSDLAxisDirectionMappings(ShipDeviceInd
std::shared_ptr<ControllerAxisDirectionMapping>
AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t portIndex, StickIndex stickIndex,
Direction direction) {
std::unordered_map<ShipDeviceIndex, SDL_GameController*> sdlControllers;
std::unordered_map<ShipDeviceIndex, SDL_Gamepad*> sdlControllers;
std::shared_ptr<ControllerAxisDirectionMapping> mapping = nullptr;
for (auto [lusIndex, indexMapping] :
Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) {
Expand All @@ -171,17 +171,17 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port

auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex();

if (!SDL_IsGameController(sdlIndex)) {
if (!SDL_IsGamepad(sdlIndex)) {
// this SDL device isn't a game controller
continue;
}

sdlControllers[lusIndex] = SDL_GameControllerOpen(sdlIndex);
sdlControllers[lusIndex] = SDL_OpenGamepad(sdlIndex);
}

for (auto [lusIndex, controller] : sdlControllers) {
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
for (int32_t button = SDL_GAMEPAD_BUTTON_SOUTH; button < SDL_GAMEPAD_BUTTON_COUNT; button++) {
if (SDL_GetGamepadButton(controller, static_cast<SDL_GamepadButton>(button))) {
mapping = std::make_shared<SDLButtonToAxisDirectionMapping>(lusIndex, portIndex, stickIndex, direction,
button);
break;
Expand All @@ -192,9 +192,9 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
break;
}

for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
const auto axis = static_cast<SDL_GameControllerAxis>(i);
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
for (int32_t i = SDL_GAMEPAD_AXIS_LEFTX; i < SDL_GAMEPAD_AXIS_COUNT; i++) {
const auto axis = static_cast<SDL_GamepadAxis>(i);
const auto axisValue = SDL_GetGamepadAxis(controller, axis) / 32767.0f;
int32_t axisDirection = 0;
if (axisValue < -0.7f) {
axisDirection = NEGATIVE;
Expand All @@ -213,7 +213,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
}

for (auto [i, controller] : sdlControllers) {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}

return mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,73 +172,73 @@ ButtonMappingFactory::CreateDefaultSDLButtonMappings(ShipDeviceIndex shipDeviceI
switch (bitmask) {
case BTN_A:
mappings.push_back(
std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_A, SDL_CONTROLLER_BUTTON_A));
std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_A, SDL_GAMEPAD_BUTTON_SOUTH));
break;
case BTN_B:
mappings.push_back(
std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_B, SDL_CONTROLLER_BUTTON_B));
std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_B, SDL_GAMEPAD_BUTTON_EAST));
break;
case BTN_L:
if (!isGameCube) {
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_L,
SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER));
}
break;
case BTN_R:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_R,
SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1));
SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 1));
break;
case BTN_Z:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_Z,
SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1));
SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 1));
break;
case BTN_START:
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_START,
SDL_CONTROLLER_BUTTON_START));
SDL_GAMEPAD_BUTTON_START));
break;
case BTN_CUP:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CUP,
SDL_CONTROLLER_AXIS_RIGHTY, -1));
SDL_GAMEPAD_AXIS_RIGHTY, -1));
break;
case BTN_CDOWN:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CDOWN,
SDL_CONTROLLER_AXIS_RIGHTY, 1));
SDL_GAMEPAD_AXIS_RIGHTY, 1));
if (isGameCube) {
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CDOWN,
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER));
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER));
}
break;
case BTN_CLEFT:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT,
SDL_CONTROLLER_AXIS_RIGHTX, -1));
SDL_GAMEPAD_AXIS_RIGHTX, -1));
if (isGameCube) {
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT,
SDL_CONTROLLER_BUTTON_Y));
SDL_GAMEPAD_BUTTON_NORTH));
}
break;
case BTN_CRIGHT:
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CRIGHT,
SDL_CONTROLLER_AXIS_RIGHTX, 1));
SDL_GAMEPAD_AXIS_RIGHTX, 1));
if (isGameCube) {
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CRIGHT,
SDL_CONTROLLER_BUTTON_X));
SDL_GAMEPAD_BUTTON_WEST));
}
break;
case BTN_DUP:
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DUP,
SDL_CONTROLLER_BUTTON_DPAD_UP));
SDL_GAMEPAD_BUTTON_DPAD_UP));
break;
case BTN_DDOWN:
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DDOWN,
SDL_CONTROLLER_BUTTON_DPAD_DOWN));
SDL_GAMEPAD_BUTTON_DPAD_DOWN));
break;
case BTN_DLEFT:
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DLEFT,
SDL_CONTROLLER_BUTTON_DPAD_LEFT));
SDL_GAMEPAD_BUTTON_DPAD_LEFT));
break;
case BTN_DRIGHT:
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DRIGHT,
SDL_CONTROLLER_BUTTON_DPAD_RIGHT));
SDL_GAMEPAD_BUTTON_DPAD_RIGHT));
break;
}

Expand All @@ -247,7 +247,7 @@ ButtonMappingFactory::CreateDefaultSDLButtonMappings(ShipDeviceIndex shipDeviceI

std::shared_ptr<ControllerButtonMapping>
ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask) {
std::unordered_map<ShipDeviceIndex, SDL_GameController*> sdlControllers;
std::unordered_map<ShipDeviceIndex, SDL_Gamepad*> sdlControllers;
std::shared_ptr<ControllerButtonMapping> mapping = nullptr;
for (auto [lusIndex, indexMapping] :
Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) {
Expand All @@ -260,17 +260,17 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL

auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex();

if (!SDL_IsGameController(sdlIndex)) {
if (!SDL_IsGamepad(sdlIndex)) {
// this SDL device isn't a game controller
continue;
}

sdlControllers[lusIndex] = SDL_GameControllerOpen(sdlIndex);
sdlControllers[lusIndex] = SDL_OpenGamepad(sdlIndex);
}

for (auto [lusIndex, controller] : sdlControllers) {
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
for (int32_t button = SDL_GAMEPAD_BUTTON_SOUTH; button < SDL_GAMEPAD_BUTTON_COUNT; button++) {
if (SDL_GetGamepadButton(controller, static_cast<SDL_GamepadButton>(button))) {
mapping = std::make_shared<SDLButtonToButtonMapping>(lusIndex, portIndex, bitmask, button);
break;
}
Expand All @@ -280,9 +280,9 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL
break;
}

for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
const auto axis = static_cast<SDL_GameControllerAxis>(i);
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
for (int32_t i = SDL_GAMEPAD_AXIS_LEFTX; i < SDL_GAMEPAD_AXIS_COUNT; i++) {
const auto axis = static_cast<SDL_GamepadAxis>(i);
const auto axisValue = SDL_GetGamepadAxis(controller, axis) / 32767.0f;
int32_t axisDirection = 0;
if (axisValue < -0.7f) {
axisDirection = NEGATIVE;
Expand All @@ -301,7 +301,7 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL
}

for (auto [i, controller] : sdlControllers) {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}

return mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
}

std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFromSDLInput(uint8_t portIndex) {
std::unordered_map<ShipDeviceIndex, SDL_GameController*> sdlControllersWithGyro;
std::unordered_map<ShipDeviceIndex, SDL_Gamepad*> sdlControllersWithGyro;
std::shared_ptr<ControllerGyroMapping> mapping = nullptr;
for (auto [lusIndex, indexMapping] :
Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) {
Expand All @@ -58,22 +58,22 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom

auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex();

if (!SDL_IsGameController(sdlIndex)) {
if (!SDL_IsGamepad(sdlIndex)) {
// this SDL device isn't a game controller
continue;
}

auto controller = SDL_GameControllerOpen(sdlIndex);
if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO)) {
sdlControllersWithGyro[lusIndex] = SDL_GameControllerOpen(sdlIndex);
auto controller = SDL_OpenGamepad(sdlIndex);
if (SDL_GamepadHasSensor(controller, SDL_SENSOR_GYRO)) {
sdlControllersWithGyro[lusIndex] = SDL_OpenGamepad(sdlIndex);
} else {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}
}

for (auto [lusIndex, controller] : sdlControllersWithGyro) {
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
for (int32_t button = SDL_GAMEPAD_BUTTON_SOUTH; button < SDL_GAMEPAD_BUTTON_COUNT; button++) {
if (SDL_GetGamepadButton(controller, static_cast<SDL_GamepadButton>(button))) {
mapping = std::make_shared<SDLGyroMapping>(lusIndex, portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
mapping->Recalibrate();
break;
Expand All @@ -84,9 +84,9 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
break;
}

for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
const auto axis = static_cast<SDL_GameControllerAxis>(i);
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
for (int32_t i = SDL_GAMEPAD_AXIS_LEFTX; i < SDL_GAMEPAD_AXIS_COUNT; i++) {
const auto axis = static_cast<SDL_GamepadAxis>(i);
const auto axisValue = SDL_GetGamepadAxis(controller, axis) / 32767.0f;
int32_t axisDirection = 0;
if (axisValue < -0.7f) {
axisDirection = NEGATIVE;
Expand All @@ -105,7 +105,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
}

for (auto [i, controller] : sdlControllersWithGyro) {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}

return mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromCon
}

std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDLInput(uint8_t portIndex) {
std::unordered_map<ShipDeviceIndex, SDL_GameController*> sdlControllersWithLEDs;
std::unordered_map<ShipDeviceIndex, SDL_Gamepad*> sdlControllersWithLEDs;
std::shared_ptr<ControllerLEDMapping> mapping = nullptr;
for (auto [lusIndex, indexMapping] :
Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) {
Expand All @@ -56,22 +56,22 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL

auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex();

if (!SDL_IsGameController(sdlIndex)) {
if (!SDL_IsGamepad(sdlIndex)) {
// this SDL device isn't a game controller
continue;
}

auto controller = SDL_GameControllerOpen(sdlIndex);
auto controller = SDL_OpenGamepad(sdlIndex);
if (SDL_GameControllerHasLED(controller)) {
sdlControllersWithLEDs[lusIndex] = SDL_GameControllerOpen(sdlIndex);
sdlControllersWithLEDs[lusIndex] = SDL_OpenGamepad(sdlIndex);
} else {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}
}

for (auto [lusIndex, controller] : sdlControllersWithLEDs) {
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
for (int32_t button = SDL_GAMEPAD_BUTTON_SOUTH; button < SDL_GAMEPAD_BUTTON_COUNT; button++) {
if (SDL_GetGamepadButton(controller, static_cast<SDL_GamepadButton>(button))) {
mapping = std::make_shared<SDLLEDMapping>(lusIndex, portIndex, 0, Color_RGB8({ 0, 0, 0 }));
break;
}
Expand All @@ -81,9 +81,9 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL
break;
}

for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
const auto axis = static_cast<SDL_GameControllerAxis>(i);
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
for (int32_t i = SDL_GAMEPAD_AXIS_LEFTX; i < SDL_GAMEPAD_AXIS_COUNT; i++) {
const auto axis = static_cast<SDL_GamepadAxis>(i);
const auto axisValue = SDL_GetGamepadAxis(controller, axis) / 32767.0f;
int32_t axisDirection = 0;
if (axisValue < -0.7f) {
axisDirection = NEGATIVE;
Expand All @@ -101,7 +101,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL
}

for (auto [i, controller] : sdlControllersWithLEDs) {
SDL_GameControllerClose(controller);
SDL_CloseGamepad(controller);
}

return mapping;
Expand Down
Loading

0 comments on commit 1646b96

Please sign in to comment.