Skip to content

Commit

Permalink
Emulate left joystick with dpad to control the plane
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 committed Apr 28, 2019
1 parent 72639b4 commit 481a60f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ players are created by default, which have assigned the corresponding
gamepad to their player number.

The default controls are:
- Up/Down: left joystick
- Up/Down: left joystick or directional pad
- Guns: Y button
- Bombs: B button
- Roll: X button
Expand Down
22 changes: 21 additions & 1 deletion src/io/joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,27 @@ static int is_joystick_action_active(int t, const joystick_action * a) {
if (a->type == 1) {
return SDL_GameControllerGetButton(joydev[t], (SDL_GameControllerButton)a->n);
} else if (a->type == 2) {
Sint16 v = SDL_GameControllerGetAxis(joydev[t], (SDL_GameControllerAxis)a->n);

SDL_GameControllerAxis axis = (SDL_GameControllerAxis)a->n;

if (axis == SDL_CONTROLLER_AXIS_LEFTY) {
if (a->threshold_dir == 0 && SDL_GameControllerGetButton(joydev[t], SDL_CONTROLLER_BUTTON_DPAD_DOWN)) {
return 1;
}
else if (a->threshold_dir == 1 && SDL_GameControllerGetButton(joydev[t], SDL_CONTROLLER_BUTTON_DPAD_UP)) {
return 1;
}
}
else if (axis == SDL_CONTROLLER_AXIS_LEFTX) {
if (a->threshold_dir == 0 && SDL_GameControllerGetButton(joydev[t], SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) {
return 1;
}
else if (a->threshold_dir == 1 && SDL_GameControllerGetButton(joydev[t], SDL_CONTROLLER_BUTTON_DPAD_LEFT)) {
return 1;
}
}

Sint16 v = SDL_GameControllerGetAxis(joydev[t], axis);
if (a->threshold_dir == 1) /* upper bound */
return (v < a->threshold);
else
Expand Down
2 changes: 1 addition & 1 deletion switch/appstore-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"url": "https://github.com/sergiou87/triplane-turmoil/",
"license": "GPLv3",
"description": "Sidescrolling dogfighting flying game",
"details": "Triplane Turmoil is a sidescrolling dogfighting flying game originally written for MS-DOS by Finnish developer Dodekaedron Software.\\n\\nThe game features four nations: Finland, England, Germany and Japan. Each nation has a single player campaign. There are also multiplayer levels which can be played with human or computer controlled pilots. The countries' planes differ from each other in terms of speed, maneuverability, bomb load capacity, endurance, ammunition capacity and fuel capacity.\\n\\nPlay against the computer or against other human opponents via a split-screen display. Do well and receive medals, ribbons, and promotions. Form alliances with other players or go it alone. Attack other planes in the air or drop bombs on enemy forces on the ground. Your objective is to destroy as much of the enemy as possible, and to defend your own forces!\\n\\nControls:\\n- Up/Down: left joystick\\n- Guns: Y button\\n- Bombs: B button\\n- Roll: X button\\n- Power: R button\\n- Exit/back: - button\\n- Help: + button\\n",
"details": "Triplane Turmoil is a sidescrolling dogfighting flying game originally written for MS-DOS by Finnish developer Dodekaedron Software.\\n\\nThe game features four nations: Finland, England, Germany and Japan. Each nation has a single player campaign. There are also multiplayer levels which can be played with human or computer controlled pilots. The countries' planes differ from each other in terms of speed, maneuverability, bomb load capacity, endurance, ammunition capacity and fuel capacity.\\n\\nPlay against the computer or against other human opponents via a split-screen display. Do well and receive medals, ribbons, and promotions. Form alliances with other players or go it alone. Attack other planes in the air or drop bombs on enemy forces on the ground. Your objective is to destroy as much of the enemy as possible, and to defend your own forces!\\n\\nControls:\\n- Up/Down: left joystick or directional pad\\n- Guns: Y button\\n- Bombs: B button\\n- Roll: X button\\n- Power: R button\\n- Exit/back: - button\\n- Help: + button\\n",
"changelog": ""
}

0 comments on commit 481a60f

Please sign in to comment.