mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 02:29:49 -06:00
- Some cleanup of LuaConsole
- Moved dedicated Lua commands into a visible property - Disallow non-ASCII characters - Remove unused KeyboardController - Remove unused DeviceIdentifier - Some cleanup of LogFactory - Move and use documentation into the class
This commit is contained in:
@@ -28,12 +28,16 @@
|
||||
#include <memory>
|
||||
|
||||
namespace ghoul {
|
||||
|
||||
class Dictionary;
|
||||
namespace logging { class Log; }
|
||||
}
|
||||
|
||||
} // namespace ghoul
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
/**
|
||||
* This function provides the capabilities to create a new ghoul::logging::Log from the
|
||||
* provided ghoul::Dictionary%. The Dictionary must at least contain a <code>Type</code>
|
||||
@@ -44,15 +48,24 @@ namespace openspace {
|
||||
* created . Both logs can be customized using the <code>Append</code>,
|
||||
* <code>TimeStamping</code>, <code>DateStamping</code>, <code>CategoryStamping</code>,
|
||||
* and <code>LogLevelStamping</code> values.
|
||||
* \param dictionary The dictionary from which the ghoul::logging::Log should be created
|
||||
*
|
||||
* \param dictionary The dictionary from which the ghoul::logging::Log should be created
|
||||
* \return The created ghoul::logging::Log
|
||||
* \post The return value will not be <code>nullptr</code>
|
||||
* \throw ghoul::RuntimeError If there was an error creating the ghoul::logging::Log
|
||||
* \sa ghoul::logging::TextLeg
|
||||
* \sa ghoul::logging::HTMLLog
|
||||
* \post The return value will not be <code>nullptr</code>
|
||||
* \throw ghoul::RuntimeError If there was an error creating the ghoul::logging::Log
|
||||
* \sa ghoul::logging::TextLog
|
||||
* \sa ghoul::logging::HTMLLog
|
||||
*/
|
||||
std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictionary);
|
||||
|
||||
/**
|
||||
* Returns the Documentation that describes a Dictionary used to create a log by using the
|
||||
* function createLog.
|
||||
* \return The Documentation that describes an acceptable Dictionary for the method
|
||||
* createLog
|
||||
*/
|
||||
documentation::Documentation LogFactoryDocumentation();
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___LOGFACTORY___H__
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___DEVICEIDENTIFIER___H__
|
||||
#define __OPENSPACE_CORE___DEVICEIDENTIFIER___H__
|
||||
|
||||
// std includes
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
#define MAXDEVICES 16
|
||||
|
||||
enum class InputDevice {NONE, UNKNOWN, SPACENAVIGATOR, XBOX};
|
||||
|
||||
class DeviceIdentifier {
|
||||
public:
|
||||
static DeviceIdentifier& ref();
|
||||
virtual ~DeviceIdentifier();
|
||||
|
||||
static void init();
|
||||
static void deinit();
|
||||
static bool isInitialized();
|
||||
|
||||
void scanDevices();
|
||||
const int numberOfDevices() const;
|
||||
const InputDevice type(const int device) const;
|
||||
|
||||
void update();
|
||||
void update(const int device);
|
||||
|
||||
const int getButtons(const int device, unsigned char **buttons = nullptr) const;
|
||||
const int getAxes(const int device, float **axespos = nullptr) const;
|
||||
void get(const int device, unsigned char **buttons, float **axespos) const;
|
||||
|
||||
private:
|
||||
// singleton
|
||||
static DeviceIdentifier* this_;
|
||||
DeviceIdentifier(void);
|
||||
DeviceIdentifier(const DeviceIdentifier& src);
|
||||
DeviceIdentifier& operator=(const DeviceIdentifier& rhs);
|
||||
|
||||
|
||||
// member variables
|
||||
int devices_;
|
||||
std::array<InputDevice, MAXDEVICES> inputDevice_;
|
||||
std::array<int, MAXDEVICES> numberOfAxes_;
|
||||
std::array<int, MAXDEVICES> numberOfButtons_;
|
||||
std::array<float *, MAXDEVICES> axesPos_;
|
||||
std::array<unsigned char *, MAXDEVICES> buttons_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___DEVICEIDENTIFIER___H__
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifndef __OPENSPACE_CORE___INTERACTIONHANDLER___H__
|
||||
#define __OPENSPACE_CORE___INTERACTIONHANDLER___H__
|
||||
|
||||
#include <openspace/interaction/keyboardcontroller.h>
|
||||
#include <openspace/interaction/interactionmode.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifndef __OPENSPACE_CORE___INTERACTIONMODE___H__
|
||||
#define __OPENSPACE_CORE___INTERACTIONMODE___H__
|
||||
|
||||
#include <openspace/interaction/keyboardcontroller.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__
|
||||
#define __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__
|
||||
|
||||
#include <openspace/interaction/controller.h>
|
||||
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
class KeyboardController : public Controller {
|
||||
public:
|
||||
virtual ~KeyboardController() {};
|
||||
virtual void keyPressed(KeyAction action, Key key, KeyModifier modifier) = 0;
|
||||
};
|
||||
|
||||
class KeyboardControllerFixed : public KeyboardController {
|
||||
public:
|
||||
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
|
||||
};
|
||||
|
||||
class KeyboardControllerLua : public KeyboardController {
|
||||
public:
|
||||
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
|
||||
|
||||
protected:
|
||||
std::string keyToString(Key key, KeyModifier mod) const;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__
|
||||
@@ -25,9 +25,10 @@
|
||||
#ifndef __OPENSPACE_CORE___LUACONSOLE___H__
|
||||
#define __OPENSPACE_CORE___LUACONSOLE___H__
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
#include <string>
|
||||
@@ -35,50 +36,35 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class LuaConsole {
|
||||
class LuaConsole : public properties::PropertyOwner {
|
||||
public:
|
||||
LuaConsole();
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
bool keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
void charCallback(unsigned int codepoint, KeyModifier modifier);
|
||||
|
||||
void render();
|
||||
|
||||
Key commandInputButton();
|
||||
|
||||
bool isVisible() const;
|
||||
void setVisible(bool visible);
|
||||
bool isRemoteScripting() const;
|
||||
void setRemoteScripting(bool remoteScripting);
|
||||
|
||||
void toggleMode();
|
||||
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
|
||||
private:
|
||||
void parallelConnectionChanged(const ParallelConnection::Status& status);
|
||||
void addToCommand(std::string c);
|
||||
std::string UnicodeToUTF8(unsigned int codepoint);
|
||||
|
||||
properties::BoolProperty _isVisible;
|
||||
bool _remoteScripting;
|
||||
|
||||
size_t _inputPosition;
|
||||
std::vector<std::string> _commandsHistory;
|
||||
size_t _activeCommand;
|
||||
std::vector<std::string> _commands;
|
||||
|
||||
std::string _filename;
|
||||
|
||||
struct {
|
||||
int lastIndex;
|
||||
bool hasInitialValue;
|
||||
std::string initialValue;
|
||||
} _autoCompleteInfo;
|
||||
|
||||
bool _isVisible;
|
||||
bool _remoteScripting;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -218,7 +218,6 @@ struct KeyWithModifier {
|
||||
KeyWithModifier stringToKey(std::string str);
|
||||
bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs);
|
||||
|
||||
|
||||
static const std::map<std::string, KeyModifier> KeyModifierMapping = {
|
||||
{ "SHIFT", KeyModifier::Shift },
|
||||
{ "ALT", KeyModifier::Alt },
|
||||
|
||||
Reference in New Issue
Block a user