Skip to content

Commit

Permalink
remove unused functions and merge keypress with input
Browse files Browse the repository at this point in the history
  • Loading branch information
illi-kun committed Feb 25, 2014
1 parent 2256662 commit 11907f9
Show file tree
Hide file tree
Showing 34 changed files with 55 additions and 159 deletions.
2 changes: 0 additions & 2 deletions CataclysmWin.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@
<Unit filename="src/iuse_software_sokoban.h" />
<Unit filename="src/json.cpp" />
<Unit filename="src/json.h" />
<Unit filename="src/keypress.cpp" />
<Unit filename="src/keypress.h" />
<Unit filename="src/lightmap.cpp" />
<Unit filename="src/lightmap.h" />
<Unit filename="src/line.cpp" />
Expand Down
2 changes: 0 additions & 2 deletions msvc110/Cataclysm.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
<ClCompile Include="..\src\iuse_software_snake.cpp" />
<ClCompile Include="..\src\iuse_software_sokoban.cpp" />
<ClCompile Include="..\src\json.cpp" />
<ClCompile Include="..\src\keypress.cpp" />
<ClCompile Include="..\src\lightmap.cpp" />
<ClCompile Include="..\src\line.cpp" />
<ClCompile Include="..\src\live_view.cpp" />
Expand Down Expand Up @@ -272,7 +271,6 @@
<ClInclude Include="..\src\iuse_software_snake.h" />
<ClInclude Include="..\src\iuse_software_sokoban.h" />
<ClInclude Include="..\src\json.h" />
<ClInclude Include="..\src\keypress.h" />
<ClInclude Include="..\src\lightmap.h" />
<ClInclude Include="..\src\line.h" />
<ClInclude Include="..\src\live_view.h" />
Expand Down
6 changes: 0 additions & 6 deletions msvc110/Cataclysm.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@
<ClCompile Include="..\src\json.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\keypress.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\lightmap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -557,9 +554,6 @@
<ClInclude Include="..\src\json.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\keypress.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\lightmap.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion src/action.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "action.h"
#include "keypress.h"
#include "output.h"
#include <istream>
#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "game.h"
#include "keypress.h"
#include "output.h"
#include "map.h"
#include <map>
Expand Down
1 change: 0 additions & 1 deletion src/auto_pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "auto_pickup.h"
#include "output.h"
#include "debug.h"
#include "keypress.h"
#include "item_factory.h"
#include "catacharset.h"
#include "translations.h"
Expand Down
1 change: 0 additions & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "game.h"
#include "rng.h"
#include "input.h"
#include "keypress.h"
#include "item.h"
#include "bionics.h"
#include "line.h"
Expand Down
1 change: 0 additions & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "game.h"
#include "output.h"
#include "keypress.h"
#include "player.h"
#include "inventory.h"
#include "mapdata.h"
Expand Down
1 change: 0 additions & 1 deletion src/defense.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "gamemode.h"
#include "game.h"
#include "setvector.h"
#include "keypress.h"
#include "itype.h"
#include "mtype.h"
#include "overmapbuffer.h"
Expand Down
1 change: 0 additions & 1 deletion src/editmap.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "game.h"
#include "input.h"
#include "keypress.h"
#include "output.h"
#include "line.h"
#include "computer.h"
Expand Down
1 change: 0 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "game.h"
#include "rng.h"
#include "input.h"
#include "keypress.h"
#include "output.h"
#include "skill.h"
#include "line.h"
Expand Down
2 changes: 1 addition & 1 deletion src/help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "action.h"
#include "auto_pickup.h"
#include "catacharset.h"
#include "keypress.h"
#include "input.h"
#include "options.h"
#include "output.h"
#include "rng.h"
Expand Down
8 changes: 0 additions & 8 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
//
// iexamine.cpp
// Cataclysm
//
// Livingstone
//

#include "item_factory.h"
#include "iuse.h"
#include "game.h"
#include "mapdata.h"
#include "keypress.h"
#include "output.h"
#include "rng.h"
#include "line.h"
Expand Down
47 changes: 46 additions & 1 deletion src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,58 @@
#include "input.h"
#include "json.h"
#include "output.h"
#include "keypress.h"
#include "game.h"
#include <fstream>
#include <errno.h>

/* TODO Replace the hardcoded values with an abstraction layer.
* Lower redundancy across the methods. */

long input(long ch)
{
if (ch == -1) {
ch = get_keypress();
}

switch (ch)
{
case KEY_UP: return 'k';
case KEY_LEFT: return 'h';
case KEY_RIGHT: return 'l';
case KEY_DOWN: return 'j';
case KEY_NPAGE: return '>';
case KEY_PPAGE: return '<';
case 459: return '\n';
default: return ch;
}
}

long get_keypress()
{
long ch = getch();

// Our current tiles and Windows code doesn't have ungetch()
#if !(defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS)
if (ch != ERR) {
int newch;

// Clear the buffer of characters that match the one we're going to act on.
timeout(0);
do {
newch = getch();
} while( newch != ERR && newch == ch );
timeout(-1);

// If we read a different character than the one we're going to act on, re-queue it.
if (newch != ERR && newch != ch) {
ungetch(newch);
}
}
#endif

return ch;
}

InputEvent get_input(int ch)
{
if (ch == '\0') {
Expand Down
8 changes: 6 additions & 2 deletions src/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#define GAMEPAD_ENABLED
#endif

#define KEY_ESCAPE 27

enum InputEvent {
Confirm,
Cancel,
Expand Down Expand Up @@ -42,6 +44,10 @@ bool is_mouse_enabled();
void get_direction(int &x, int &y, InputEvent &input);
std::string get_input_string_from_file(std::string fname="input.txt");

// Simple text input--translates numpad to vikeys
long input(long ch = -1);
long get_keypress();

enum mouse_buttons { MOUSE_BUTTON_LEFT=1, MOUSE_BUTTON_RIGHT, SCROLLWHEEL_UP, SCROLLWHEEL_DOWN, MOUSE_MOVE };

enum input_event_t {
Expand Down Expand Up @@ -122,8 +128,6 @@ struct input_event {

// Definitions for joystick/gamepad.



// On the joystick there's a maximum of 256 key states.
// So for joy axis events, we simply use a number larger
// than that.
Expand Down
1 change: 0 additions & 1 deletion src/inventory.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <sstream>
#include "inventory.h"
#include "game.h"
#include "keypress.h"
#include "mapdata.h"
#include "item_factory.h"

Expand Down
1 change: 0 additions & 1 deletion src/inventory_ui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "game.h"
#include "output.h"
#include "uistate.h"
#include "keypress.h"
#include "translations.h"
#include "item_factory.h"
#include "options.h"
Expand Down
1 change: 0 additions & 1 deletion src/iuse.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "iuse.h"
#include "game.h"
#include "mapdata.h"
#include "keypress.h"
#include "output.h"
#include "options.h"
#include "rng.h"
Expand Down
1 change: 0 additions & 1 deletion src/iuse_software.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define _IUSE_SOFTWARE_H_

#include <string>
#include "keypress.h"
#include "game.h"
#include "output.h"
#include "catacharset.h"
Expand Down
100 changes: 0 additions & 100 deletions src/keypress.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions src/keypress.h

This file was deleted.

1 change: 0 additions & 1 deletion src/main_menu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "game.h"
#include "keypress.h"
#include "debug.h"
#include "input.h"
#include "mapbuffer.h"
Expand Down
1 change: 0 additions & 1 deletion src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "bionics.h"
#include "debug.h"
#include "game.h"
#include "keypress.h"
#include "martialarts.h"
#include <sstream>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/mod_manager_ui.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "mod_manager.h"
#include "input.h"
#include "output.h"
#include "keypress.h"
#include "debug.h"
#include <algorithm>

Expand Down
1 change: 0 additions & 1 deletion src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "input.h"
#include "output.h"
#include "rng.h"
#include "keypress.h"
#include "game.h"
#include "options.h"
#include "catacharset.h"
Expand Down
Loading

0 comments on commit 11907f9

Please sign in to comment.