aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/CommonSrc/Util/OptionMenu.h
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/CommonSrc/Util/OptionMenu.h')
-rw-r--r--Samples/CommonSrc/Util/OptionMenu.h66
1 files changed, 40 insertions, 26 deletions
diff --git a/Samples/CommonSrc/Util/OptionMenu.h b/Samples/CommonSrc/Util/OptionMenu.h
index d52ba5c..5eea9bd 100644
--- a/Samples/CommonSrc/Util/OptionMenu.h
+++ b/Samples/CommonSrc/Util/OptionMenu.h
@@ -24,7 +24,7 @@ limitations under the License.
#ifndef INC_OptionMenu_h
#define INC_OptionMenu_h
-#include "OVR.h"
+#include "OVR_Kernel.h"
#include "../Platform/Platform_Default.h"
#include "../Render/Render_Device.h"
@@ -37,11 +37,11 @@ using namespace OVR::Util::Render;
#include <Kernel/OVR_Log.h>
#include <Kernel/OVR_Timer.h>
-#include "OVR_DeviceConstants.h"
+#include "Sensors/OVR_DeviceConstants.h"
using namespace OVR;
-using namespace OVR::Platform;
+using namespace OVR::OvrPlatform;
using namespace OVR::Render;
@@ -108,7 +108,7 @@ struct ShortcutKey
struct OptionShortcut
{
Array<ShortcutKey> Keys;
- Array<UInt32> GamepadButtons;
+ Array<uint32_t> GamepadButtons;
FunctionNotifyBase* pNotify;
OptionShortcut() : pNotify(NULL) {}
@@ -116,10 +116,10 @@ struct OptionShortcut
~OptionShortcut() { if (pNotify) delete pNotify; }
void AddShortcut(ShortcutKey key) { Keys.PushBack(key); }
- void AddShortcut(UInt32 gamepadButton) { GamepadButtons.PushBack(gamepadButton); }
+ void AddShortcut(uint32_t gamepadButton) { GamepadButtons.PushBack(gamepadButton); }
bool MatchKey(OVR::KeyCode key, bool shift) const;
- bool MatchGamepadButton(UInt32 gamepadButtonMask) const;
+ bool MatchGamepadButton(uint32_t gamepadButtonMask) const;
};
@@ -142,7 +142,7 @@ public:
// Returns empty string if shortcut not handled
virtual String ProcessShortcutKey(OVR::KeyCode key, bool shift) = 0;
- virtual String ProcessShortcutButton(UInt32 buttonMask) = 0;
+ virtual String ProcessShortcutButton(uint32_t buttonMask) = 0;
virtual bool IsMenu() const { return false; }
@@ -165,7 +165,8 @@ public:
Type_Enum,
Type_Int,
Type_Float,
- Type_Bool
+ Type_Bool,
+ Type_Trigger,
};
typedef String (*FormatFunction)(OptionVar*);
@@ -176,14 +177,15 @@ public:
static String FormatFloat(OptionVar* var);
static String FormatTan(OptionVar* var);
static String FormatBool(OptionVar* var);
+ static String FormatTrigger(OptionVar* var);
OptionVar(const char* name, void* pVar, VarType type,
FormatFunction formatFunction,
UpdateFunction updateFunction = NULL);
// Integer with range and step size.
- OptionVar(const char* name, SInt32* pVar,
- SInt32 min, SInt32 max, SInt32 stepSize=1,
+ OptionVar(const char* name, int32_t* pVar,
+ int32_t min, int32_t max, int32_t stepSize=1,
const char* formatString = "%d",
FormatFunction formatFunction = 0, // Default int formatting.
UpdateFunction updateFunction = NULL);
@@ -197,10 +199,12 @@ public:
virtual ~OptionVar();
- SInt32* AsInt() { return reinterpret_cast<SInt32*>(pVar); }
- bool* AsBool() { return reinterpret_cast<bool*>(pVar); }
- float* AsFloat() { return reinterpret_cast<float*>(pVar); }
- VarType GetType() { return Type; }
+ int32_t* AsInt() { return reinterpret_cast<int32_t*>(pVar); }
+ bool* AsBool() { return reinterpret_cast<bool*>(pVar); }
+ float* AsFloat() { return reinterpret_cast<float*>(pVar); }
+ VarType GetType() { return Type; }
+
+ //virtual void Select() { if(Type == Type_Trigger) SignalUpdate(); }
// Step through values (wrap for enums).
virtual void NextValue(bool* pFastStep);
@@ -210,9 +214,9 @@ public:
// Returns empty string for no action.
String HandleShortcutUpdate();
virtual String ProcessShortcutKey(OVR::KeyCode key, bool shift);
- virtual String ProcessShortcutButton(UInt32 buttonMask);
+ virtual String ProcessShortcutButton(uint32_t buttonMask);
- OptionVar& AddEnumValue(const char* displayName, SInt32 value);
+ OptionVar& AddEnumValue(const char* displayName, int32_t value);
template<class C>
OptionVar& SetNotify(C* p, void (C::*fn)(OptionVar*))
@@ -231,7 +235,7 @@ public:
OptionVar& AddShortcutUpKey(OVR::KeyCode key,
ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_Modify)
{ ShortcutUp.AddShortcut(ShortcutKey(key, shiftUsage)); return *this; }
- OptionVar& AddShortcutUpButton(UInt32 gamepadButton)
+ OptionVar& AddShortcutUpButton(uint32_t gamepadButton)
{ ShortcutUp.AddShortcut(gamepadButton); return *this; }
OptionVar& AddShortcutDownKey(const ShortcutKey& shortcut)
@@ -239,7 +243,7 @@ public:
OptionVar& AddShortcutDownKey(OVR::KeyCode key,
ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_Modify)
{ ShortcutDown.AddShortcut(ShortcutKey(key, shiftUsage)); return *this; }
- OptionVar& AddShortcutDownButton(UInt32 gamepadButton)
+ OptionVar& AddShortcutDownButton(uint32_t gamepadButton)
{ ShortcutDown.AddShortcut(gamepadButton); return *this; }
OptionVar& AddShortcutKey(const ShortcutKey& shortcut)
@@ -247,7 +251,7 @@ public:
OptionVar& AddShortcutKey(OVR::KeyCode key,
ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_RequireOff)
{ return AddShortcutUpKey(key, shiftUsage); }
- OptionVar& AddShortcutButton(UInt32 gamepadButton)
+ OptionVar& AddShortcutButton(uint32_t gamepadButton)
{ return AddShortcutUpButton(gamepadButton); }
private:
@@ -262,13 +266,13 @@ private:
{
// Human readable name for enum.
String Name;
- SInt32 Value;
+ int32_t Value;
};
// Array of possible enum values.
Array<EnumEntry> EnumValues;
// Gets the index of the current enum value.
- UInt32 GetEnumIndex();
+ uint32_t GetEnumIndex();
FormatFunction fFormat;
UpdateFunction fUpdate;
@@ -286,9 +290,11 @@ private:
float StepFloat;
float FormatScale; // Multiply float by this before rendering
- SInt32 MinInt;
- SInt32 MaxInt;
- SInt32 StepInt;
+ int32_t MinInt;
+ int32_t MaxInt;
+ int32_t StepInt;
+
+ int SelectedIndex;
};
@@ -312,7 +318,7 @@ public:
bool OnKey(OVR::KeyCode key, int chr, bool down, int modifiers);
- bool OnGamepad(UInt32 buttonMask);
+ bool OnGamepad(uint32_t buttonMask);
void Render(RenderDevice* prender, String title = "");
@@ -353,12 +359,20 @@ public:
AddItem(p);
return *p;
}
+
+ OptionVar& AddTrigger( const char* name, OptionVar::UpdateFunction updateFunction = 0 )
+ {
+ OptionVar* p = new OptionVar(name, NULL, OptionVar::Type_Trigger,
+ NULL, updateFunction);
+ AddItem(p);
+ return *p;
+ }
virtual void Select();
virtual String GetLabel() { return Label + " >"; }
virtual String ProcessShortcutKey(OVR::KeyCode key, bool shift);
- virtual String ProcessShortcutButton(UInt32 buttonMask);
+ virtual String ProcessShortcutButton(uint32_t buttonMask);
// Sets a message to display with a time-out. Default time-out is 4 seconds.
// This uses the same overlay approach as used for shortcut notifications.