Skip to content

Commit

Permalink
Merge pull request #5 from Kilvoctu/pad-help
Browse files Browse the repository at this point in the history
janky gamepad help
  • Loading branch information
Kilvoctu authored Feb 9, 2020
2 parents 4788984 + 70b3226 commit dec745a
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@
"name": "Display keybindings menu",
"bindings": [ { "input_method": "keyboard", "key": "?" } ]
},
{
"type": "keybinding",
"id": "HELP_GAMEPAD",
"name": "Display PS3 buttonbinds",
"bindings": [ { "input_method": "keyboard", "key": "]" } ]
},
{
"type": "keybinding",
"id": "FILTER",
Expand Down
1 change: 1 addition & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,7 @@ input_context get_default_mode_input_context()
ctxt.register_action( "messages" );
ctxt.register_action( "help" );
ctxt.register_action( "HELP_KEYBINDINGS" );
ctxt.register_action( "HELP_GAMEPAD" );
ctxt.register_action( "open_options" );
ctxt.register_action( "open_autopickup" );
ctxt.register_action( "open_autonotes" );
Expand Down
88 changes: 88 additions & 0 deletions src/gpkey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once
#ifndef GPKEY_H
#define GPKEY_H

#include <map>
#include <string>
#include <utility>
#include <vector>
#include <initializer_list>

void gamepad( );

std::vector<tripoint> display_gamepad_menu( );
std::vector<std::string> registered_buttons = {
"Button:", "Command",
"Dpad:", "Movement",
"LStick:", "Mouse Movement",
"L3:", "Left-click",
"RStick X-axis:", "Left/Right Tab Through Menus",
"RStick Y-axis:", "Move Up/Down Z-Levels",
"R3:", "Walk/Run/Crouch",
"Cross (Tap):", "Actions Menu",
"Cross (Hold):", "Smash",
"Square (Tap):", "Examine",
"Square (Hold):", "Get Items",
"Triangle (Tap):", "Inventory",
"Triangle (Hold):", "Execute Action",
"Circle (Tap):", "Main Menu",
"Circle (Hold):", "Close",
"L1:", "Modifier 1",
"L2:", "Modifier 2",
"R1 (Tap):", "Look",
"R1 (Hold):", "Peek",
"R2:", "Pass Turn (hold to keep passing)",
"Select (Tap):", "Player Info",
"Select (Hold):", "Message Log",
"Start (Tap):", "Overmap / (Vehicle) Repair",
"Start (Hold):", "List Nearby Items",

"L1+Dpad:", "Diagonal Movement",
"L1+LStick:", "Full Numpad",
"L1+L3:", "Numpad 5",
"L1+RStick X-axis:", "Unknown",
"L1+RStick Y-axis:", "Page Up/Page Down",
"L1+R3:", "Sidebar Options",
"L1+Cross:", "Unused",
"L1+Square (Tap):", "Craft",
"L1+Square (Hold):", "Construction",
"L1+Triangle (Tap):", "Consume Item",
"L1+Triangle (Hold):", "Read Item",
"L1+Circle (Tap):", "Wait",
"L1+Circle (Hold):", "Sleep",
"L1+L2:", "Unused",
"L1+R1 (Tap):", "Drop Item",
"L1+R1 (Hold):", "Haul Item",
"L1+R2 (Tap):", "Ignore Monster",
"L1+R2 (Hold):", "Toggle Safe Mode",
"L1+Select (Tap):", "Morale",
"L1+Select (Hold):", "Scores",
"L1+Start (Tap):", "Zoom In",
"L1+Start (Hold):", "Zoom Out",

"L2+Dpad Down:", "Sort Armor",
"L2+Dpad Left:", "Zones Manager",
"L2+Dpad Up (Tap):", "Wear Item / (Overmap) Fast Travel",
"L2+Dpad Up (Hold):", "Take Off Item",
"L2+Dpad Right:", "Unused",
"L2+LStick:", "Move View",
"L2+L3:", "Reset View",
"L2+RStick X-axis:", "Unused",
"L2+RStick Y-axis:", "Mousewheel Scroll",
"L2+R3:", "Keybindind",
"L2+Cross (Tap):", "Aim Weapon / (While Aiming) Current Aim",
"L2+Cross (Hold):", "Wield Item",
"L2+Square (Tap):", "Use Item / (While Aiming) Regular Aim",
"L2+Square (Hold):", "Grab",
"L2+Triangle (Tap):", "Bionics / (While Aiming) Precise Aim",
"L2+Triangle (Hold):", "Talk",
"L2+Circle (Tap):", "(While Aiming) Careful Aim",
"L2+Circle (Hold):", "(Vehicle) Remove",
"L2+L1:", "Unused",
"L2+R1 (Tap):", "Reload Item",
"L2+R1 (Hold):", "Unload Item",
"L2+R2:", "Pass Turn (hold to keep passing)",
"L2+Select:", "Advanced Inventory",
"L2+Start:", "Unused",
};
#endif
27 changes: 27 additions & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "debug.h"
#include "filesystem.h"
#include "game.h"
#include "gpkey.h"
#include "help.h"
#include "ime.h"
#include "json.h"
Expand Down Expand Up @@ -622,6 +623,7 @@ void input_context::clear_conflicting_keybindings( const input_event &event )
const std::string CATA_ERROR = "ERROR";
const std::string ANY_INPUT = "ANY_INPUT";
const std::string HELP_KEYBINDINGS = "HELP_KEYBINDINGS";
const std::string HELP_GAMEPAD = "HELP_GAMEPAD";
const std::string COORDINATE = "COORDINATE";
const std::string TIMEOUT = "TIMEOUT";

Expand Down Expand Up @@ -875,6 +877,14 @@ const std::string &input_context::handle_input( const int timeout )
result = &HELP_KEYBINDINGS;
break;
}
// Gamepad keybinds
if( action == "HELP_GAMEPAD" ) {
inp_mngr.reset_timeout();
display_gamepad_menu();
inp_mngr.set_timeout( timeout );
result = &HELP_GAMEPAD;
break;
}

if( next_action.type == CATA_INPUT_MOUSE ) {
if( !handling_coordinate_input && action == CATA_ERROR ) {
Expand Down Expand Up @@ -906,6 +916,23 @@ const std::string &input_context::handle_input( const int timeout )
return *result;
}

std::vector<tripoint> display_gamepad_menu( )
{
std::vector<tripoint> ret;

int maxwidth = max( FULL_SCREEN_WIDTH, TERMX );
int width = min( 80, maxwidth );
int maxheight = max( FULL_SCREEN_HEIGHT, TERMY );
int top = 1;

catacurses::window w = catacurses::newwin( maxheight - 2, width - 2,
point( maxwidth / 2 - width / 2, top ) );

std::vector<std::string> filtered_registered_actions( registered_buttons );
display_table( w, _( "Gamepad Controls" ), 2, filtered_registered_actions );
return ret;
}

void input_context::register_directions()
{
register_cardinal();
Expand Down

0 comments on commit dec745a

Please sign in to comment.