[Orxonox-commit 1250] r5968 - in code/branches/console/src/libraries/core: . input
rgrieder at orxonox.net
rgrieder at orxonox.net
Tue Oct 20 18:46:50 CEST 2009
Author: rgrieder
Date: 2009-10-20 18:46:50 +0200 (Tue, 20 Oct 2009)
New Revision: 5968
Added:
code/branches/console/src/libraries/core/IOConsole.h
Modified:
code/branches/console/src/libraries/core/CMakeLists.txt
code/branches/console/src/libraries/core/input/InputBuffer.cc
code/branches/console/src/libraries/core/input/InputBuffer.h
code/branches/console/src/libraries/core/input/InputHandler.h
Log:
Basic construct of an IOConsole for Unix, using Oli's console from GSDedicated.
MAY NOT COMPILE, PROBABLY DOESN'T RUN!
And surely does neither on Windows.
Modified: code/branches/console/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/console/src/libraries/core/CMakeLists.txt 2009-10-19 20:52:10 UTC (rev 5967)
+++ code/branches/console/src/libraries/core/CMakeLists.txt 2009-10-20 16:46:50 UTC (rev 5968)
@@ -28,6 +28,7 @@
GameState.cc
GraphicsManager.cc
GUIManager.cc
+ IOConsole.cc
Language.cc
LuaState.cc
ObjectListBase.cc
Added: code/branches/console/src/libraries/core/IOConsole.h
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.h (rev 0)
+++ code/branches/console/src/libraries/core/IOConsole.h 2009-10-20 16:46:50 UTC (rev 5968)
@@ -0,0 +1,87 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _IOConsole_H__
+#define _IOConsole_H__
+
+#include "CorePrereqs.h"
+
+#include <queue>
+#include <boost/scoped_ptr.hpp>
+#include "util/Singleton.h"
+#include "core/Shell.h"
+
+struct termios;
+
+namespace orxonox
+{
+ class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
+ {
+ friend class Singleton<IOConsole>;
+
+ public:
+ IOConsole();
+ ~IOConsole();
+
+ void update(const Clock& time);
+
+ private:
+ void setTerminalMode();
+ static void resetTerminalMode();
+
+ void printOutputLine(const std::string& line);
+ void printInputLine();
+ void insertCharacter(unsigned int position, char c);
+ void deleteCharacter(unsigned int position);
+
+ // Methods from ShellListener
+ void linesChanged();
+ void onlyLastLineChanged();
+ void lineAdded();
+ void inputChanged();
+ void cursorChanged();
+ void exit();
+
+ Shell& shell_;
+ bool cleanLine_;
+ bool bEscapeMode_;
+ std::string escapeSequence_;
+ InputBuffer* buffer_;
+ unsigned char* commandLine_;
+ unsigned int inputIterator_;
+ static termios* originalTerminalSettings_;
+
+ unsigned int cursorX_;
+ unsigned int cursorY_;
+
+ static IOConsole* singletonPtr_s;
+ };
+}
+
+#endif /* _IOConsole_H__ */
Modified: code/branches/console/src/libraries/core/input/InputBuffer.cc
===================================================================
--- code/branches/console/src/libraries/core/input/InputBuffer.cc 2009-10-19 20:52:10 UTC (rev 5967)
+++ code/branches/console/src/libraries/core/input/InputBuffer.cc 2009-10-20 16:46:50 UTC (rev 5968)
@@ -185,6 +185,7 @@
void InputBuffer::processKey(const KeyEvent& evt)
{
+ // Prevent disaster when switching applications
if (evt.isModifierDown(KeyboardModifier::Alt) && evt.getKeyCode() == KeyCode::Tab)
return;
@@ -221,7 +222,7 @@
}
/**
- @brief This update() function is called by the InputManager if the InputBuffer is active.
+ @brief This update() function is called by the InputState if the InputBuffer is active.
@param dt Delta time
*/
void InputBuffer::keyboardUpdated(float dt)
Modified: code/branches/console/src/libraries/core/input/InputBuffer.h
===================================================================
--- code/branches/console/src/libraries/core/input/InputBuffer.h 2009-10-19 20:52:10 UTC (rev 5967)
+++ code/branches/console/src/libraries/core/input/InputBuffer.h 2009-10-20 16:46:50 UTC (rev 5968)
@@ -161,10 +161,11 @@
inline void decreaseCursor()
{ if (this->cursor_ > 0) { --this->cursor_; } }
+ void buttonPressed(const KeyEvent& evt);
+
private:
bool charIsAllowed(const char& input);
- void buttonPressed(const KeyEvent& evt);
void buttonHeld (const KeyEvent& evt);
void processKey (const KeyEvent& evt);
Modified: code/branches/console/src/libraries/core/input/InputHandler.h
===================================================================
--- code/branches/console/src/libraries/core/input/InputHandler.h 2009-10-19 20:52:10 UTC (rev 5967)
+++ code/branches/console/src/libraries/core/input/InputHandler.h 2009-10-20 16:46:50 UTC (rev 5968)
@@ -72,6 +72,11 @@
, text_(evt.text)
, modifiers_(0)
{ }
+ KeyEvent(KeyCode::ByEnum key, unsigned int text, int modifiers)
+ : key_(key)
+ , text_(text)
+ , modifiers_(modifiers)
+ { }
bool operator==(const KeyEvent& rhs) const
{ return rhs.key_ == key_; }
bool operator!=(const KeyEvent& rhs) const
More information about the Orxonox-commit
mailing list