summaryrefslogtreecommitdiffhomepage
path: root/SixenseSDK/include/sixense_utils
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-18 05:02:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-09 10:27:50 +0200
commit24e37795d2db8fdc6f7809e793dadbae80211d26 (patch)
treef2fd152fb44518222e290e555f0274af18d877bd /SixenseSDK/include/sixense_utils
parent9a87e2cb6e588641e3cff52655013594c492e033 (diff)
add SDKs
Diffstat (limited to 'SixenseSDK/include/sixense_utils')
-rwxr-xr-xSixenseSDK/include/sixense_utils/accelerometer.hpp0
-rwxr-xr-xSixenseSDK/include/sixense_utils/button_states.hpp106
-rwxr-xr-xSixenseSDK/include/sixense_utils/controller_manager/controller_manager.hpp91
-rwxr-xr-xSixenseSDK/include/sixense_utils/derivatives.hpp63
-rwxr-xr-xSixenseSDK/include/sixense_utils/event_triggers.hpp110
-rwxr-xr-xSixenseSDK/include/sixense_utils/export.hpp27
-rwxr-xr-xSixenseSDK/include/sixense_utils/fps.hpp327
-rwxr-xr-xSixenseSDK/include/sixense_utils/fps_rewrite.hpp270
-rwxr-xr-xSixenseSDK/include/sixense_utils/interfaces.hpp442
-rwxr-xr-xSixenseSDK/include/sixense_utils/keyboard_and_mouse_win32.hpp227
-rwxr-xr-xSixenseSDK/include/sixense_utils/laser_pointer.hpp81
-rwxr-xr-xSixenseSDK/include/sixense_utils/mouse_pointer.hpp76
-rwxr-xr-xSixenseSDK/include/sixense_utils/sixense_utils_string.hpp77
-rwxr-xr-xSixenseSDK/include/sixense_utils/time.hpp23
14 files changed, 1920 insertions, 0 deletions
diff --git a/SixenseSDK/include/sixense_utils/accelerometer.hpp b/SixenseSDK/include/sixense_utils/accelerometer.hpp
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/accelerometer.hpp
diff --git a/SixenseSDK/include/sixense_utils/button_states.hpp b/SixenseSDK/include/sixense_utils/button_states.hpp
new file mode 100755
index 0000000..a1d1936
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/button_states.hpp
@@ -0,0 +1,106 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_BUTTON_STATES_HPP
+#define SIXENSE_UTILS_BUTTON_STATES_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+#include <sixense.h>
+#include <sixense_math.hpp>
+
+namespace sixenseUtils {
+
+ // LaserPointer computes a ray that shoots from the controller and intersects with the screen.
+ class SIXENSE_UTILS_EXPORT ButtonStates : public IButtonStates {
+
+ public:
+
+ ButtonStates();
+ void update( sixenseControllerData *cd );
+ bool buttonJustPressed( unsigned short which_button );
+ bool buttonJustReleased( unsigned short which_button );
+
+ void setTriggerThreshold( float thresh );
+ bool triggerJustPressed();
+ bool triggerJustReleased();
+
+ void setStickThreshold( float thresh );
+ bool stickJustPressed( Direction which );
+ bool stickJustReleased( Direction which );
+
+ void setAbsoluteTiltAngleThresholdInDeg( float thresh );
+ void setRelativeTiltAngleThresholdInDeg( float thresh );
+
+ // Relative tilts are an orientation change relative to the orientation last time setRelativeOrigin() was called
+ void setRelativeOrigin();
+ void startPointGesture();
+ void stopPointGesture();
+ bool relativeTiltJustStarted( Direction which );
+ bool relativeTiltJustStopped( Direction which );
+
+ // Absolute gestures are just relative to the world
+ bool absoluteTiltJustStarted( Direction which );
+ bool absoluteTiltJustStopped( Direction which );
+
+ float _trigger_threshold;
+
+ bool justStarted( ActionType action, int arg );
+ bool justStopped( ActionType action, int arg );
+
+ protected:
+ void updateJoystick( sixenseControllerData *cd );
+ void updateTrigger( sixenseControllerData *cd );
+ void updateButtons( sixenseControllerData *cd );
+ void updateTilt( sixenseControllerData *cd );
+
+ private:
+
+ // buttons
+ unsigned short _just_pressed;
+ unsigned short _just_released;
+ unsigned short _last_buttons;
+
+ // trigger
+ bool _trigger_just_pressed;
+ bool _trigger_just_released;
+ float _last_trigger_state;
+
+ // joystick
+ float _joystick_threshold;
+ float _last_joystick[2];
+ bool _joystick_just_pressed[4], _joystick_just_released[4]; // 4 stick directions
+
+
+ // tilt
+ float _absolute_tilt_angle_threshold_in_deg, _relative_tilt_angle_threshold_in_deg;
+ sixenseMath::Vector3 _last_point_vec;
+
+ bool _point_gesture_active;
+
+ bool _last_relative_tilt_states[6];
+ bool _relative_tilt_just_started[6], _relative_tilt_just_stopped[6]; // 6 tilt directions
+
+ bool _last_absolute_tilt_states[6];
+ bool _absolute_tilt_just_started[6], _absolute_tilt_just_stopped[6]; // 6 tilt directions
+ bool _should_zero_relative_origin;
+ sixenseMath::Matrix3 _relative_origin;
+
+ };
+
+}
+
+#pragma warning(pop)
+
+#endif
+
diff --git a/SixenseSDK/include/sixense_utils/controller_manager/controller_manager.hpp b/SixenseSDK/include/sixense_utils/controller_manager/controller_manager.hpp
new file mode 100755
index 0000000..f6b674d
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/controller_manager/controller_manager.hpp
@@ -0,0 +1,91 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef CONTROLLER_MANAGER_HPP
+#define CONTROLLER_MANAGER_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+#include "sixense_utils/sixense_utils_string.hpp"
+
+#include <string>
+#include <vector>
+#include <map>
+
+#include <sixense.h>
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT ControllerManager : public IControllerManager {
+
+ public:
+ ~ControllerManager();
+
+ void setGameType( game_type gt );
+ game_type getGameType();
+
+ // Update the ControllerManager. Should be called each frame.
+ void update( sixenseAllControllerData * );
+
+ // Get the controller index for the given description, ie player 1's left hand is controller index 3
+ int getIndex( controller_desc );
+
+ // Force the user to rebind the controllers to the player slots.
+ void rebind();
+
+ // Register a callback that will get called when the mode changes
+ void registerSetupCallback( setup_callback );
+
+ // Returns true if the application should show the menu system
+ bool isMenuVisible();
+
+ // Returns the filename of the recommended texture for this step
+ const char* getTextureFileName();
+
+ // Returns a string describing this step
+ const char* getStepString();
+
+
+ ControllerManager::sound_type shouldPlaySound();
+
+ static ControllerManager *getTheControllerManager();
+
+ static controller_desc controllerDescFromString( sixense_utils_string str );
+
+ setup_step getCurrentStep();
+
+ protected:
+ ControllerManager();
+
+ game_type _game_type;
+
+ // A pointer to the current step
+ setup_step _current_step;
+
+ // A list of maps, one map of steps for each of the game_types.
+ std::vector< std::map< setup_step, class base_step*> >_steps;
+
+ int _controller_map[LAST_CONTROLLER_DESC];
+
+ setup_callback _callback;
+
+ };
+
+ // Singleton
+ SIXENSE_UTILS_EXPORT ControllerManager *getTheControllerManager();
+
+}
+
+#pragma warning(pop)
+
+#endif
+
diff --git a/SixenseSDK/include/sixense_utils/derivatives.hpp b/SixenseSDK/include/sixense_utils/derivatives.hpp
new file mode 100755
index 0000000..cd3c31f
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/derivatives.hpp
@@ -0,0 +1,63 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_DERIVATIVES_HPP
+#define SIXENSE_UTILS_DERIVATIVES_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense.h"
+#include "sixense_math.hpp"
+
+#include <deque>
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT Derivatives : public IDerivatives {
+
+ public:
+ Derivatives( sixenseMath::Vector3 offset_vec = sixenseMath::Vector3() );
+
+ void update( sixenseControllerData *cd );
+
+ sixenseMath::Vector3 getPosition();
+ sixenseMath::Vector3 getVelocity();
+ sixenseMath::Vector3 getAcceleration();
+
+ sixenseMath::Vector3 getRSquared();
+
+ void setOffset( sixenseMath::Vector3 offset );
+ sixenseMath::Vector3 getOffset();
+
+ protected:
+ std::deque<unsigned char> _last_n_sequence;
+
+ std::deque<float> _last_n_times;
+
+ std::deque<sixenseMath::Vector3> _last_n_pos;
+
+ sixenseMath::Vector3 _pos;
+ sixenseMath::Vector3 _vel;
+ sixenseMath::Vector3 _accel;
+
+ sixenseMath::Vector3 _r_squared;
+
+ sixenseMath::Vector3 _offset_vec;
+
+ };
+
+}
+
+#pragma warning(pop)
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/event_triggers.hpp b/SixenseSDK/include/sixense_utils/event_triggers.hpp
new file mode 100755
index 0000000..53454ef
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/event_triggers.hpp
@@ -0,0 +1,110 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef EVENT_TRIGGERS_HPP
+#define EVENT_TRIGGERS_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include <sixense_math.hpp>
+
+namespace sixenseUtils {
+
+ // Classes for triggering events based on joystick or trigger positions
+
+ // These are classes that call the supplied EventTriggerBase's 'trigger()' events when triggered. They can be
+ // created and bound to a switch.
+
+ class EventTriggerBase {
+ public:
+ virtual void trigger() const = 0;
+ };
+
+ // Do nothing
+ class NullEventTrigger : public EventTriggerBase {
+ public:
+ virtual void trigger() const {};
+ };
+
+
+
+ // These classes monitor a floating point value, and trigger their events when the value crosses
+ // a threshold, both rising and falling.
+
+ class EventSwitchBase {
+ public:
+ EventSwitchBase( float thresh, const EventTriggerBase *positive_transition_event, const EventTriggerBase *negative_transition_event ) : _last_state(false), _thresh(thresh), _positive_transition_event(positive_transition_event), _negative_transition_event(negative_transition_event) {}
+ ~EventSwitchBase() {
+ delete _positive_transition_event;
+ delete _negative_transition_event;
+ }
+ void test( float val ) {
+ if( val > _thresh && !_last_state ) {
+ if( _positive_transition_event ) {
+ _positive_transition_event->trigger();
+ }
+ _last_state = true;
+ }
+ if( val < _thresh && _last_state ) {
+ if( _negative_transition_event ) {
+ _negative_transition_event->trigger();
+ }
+ _last_state = false;
+ }
+ }
+
+ bool getLastState( void ) {
+ return _last_state;
+ }
+
+ protected:
+ bool _last_state;
+ float _thresh;
+ const EventTriggerBase *_positive_transition_event;
+ const EventTriggerBase *_negative_transition_event;
+
+ private:
+ EventSwitchBase() {}
+ };
+
+ class PlaneCrossEventSwitch : public EventSwitchBase {
+ public:
+ PlaneCrossEventSwitch( sixenseMath::Plane plane, float thresh, const EventTriggerBase *positive_transition_event, const EventTriggerBase *negative_transition_event ) : EventSwitchBase( thresh, positive_transition_event, negative_transition_event ),
+ _plane(plane) {}
+
+ void test( sixenseMath::Vector3 pt ) {
+ EventSwitchBase::test( -1.0f * (float)_plane.whichSide( pt ) );
+ }
+ private:
+ sixenseMath::Plane _plane;
+ };
+
+ class BinaryEventSwitch : public EventSwitchBase {
+ public:
+ BinaryEventSwitch( const EventTriggerBase *positive_transition_event, const EventTriggerBase *negative_transition_event ) : EventSwitchBase( 0.5f, positive_transition_event, negative_transition_event ) {}
+
+ void test( bool val ) {
+ EventSwitchBase::test( val ? 1.0f : 0.0f );
+ }
+ };
+
+ class ValuatorEventSwitch : public EventSwitchBase {
+ public:
+ ValuatorEventSwitch( float thresh, const EventTriggerBase *positive_transition_event, const EventTriggerBase *negative_transition_event ) : EventSwitchBase( thresh, positive_transition_event, negative_transition_event ){}
+ void test( float val ) {
+ EventSwitchBase::test( val );
+ }
+ };
+
+
+}
+#pragma warning(pop)
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/export.hpp b/SixenseSDK/include/sixense_utils/export.hpp
new file mode 100755
index 0000000..3f22ce7
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/export.hpp
@@ -0,0 +1,27 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_EXPORT_HPP
+#define SIXENSE_UTILS_EXPORT_HPP
+
+#if defined(WIN32)
+ #ifdef SIXENSE_UTILS_STATIC_LIB
+ #define SIXENSE_UTILS_EXPORT
+ #else
+ #ifdef BUILDING_SIXENSE_UTILS
+ #define SIXENSE_UTILS_EXPORT __declspec(dllexport)
+ #else
+ #define SIXENSE_UTILS_EXPORT __declspec(dllimport)
+ #endif
+ #endif
+#else
+ #define SIXENSE_UTILS_EXPORT
+#endif
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/fps.hpp b/SixenseSDK/include/sixense_utils/fps.hpp
new file mode 100755
index 0000000..44bcb51
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/fps.hpp
@@ -0,0 +1,327 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_PORT_UTILS_FPS_HPP
+#define SIXENSE_PORT_UTILS_FPS_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense.h"
+#include "sixense_math.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+#include <vector>
+#include <map>
+
+using sixenseMath::Vector2;
+using sixenseMath::Vector3;
+using sixenseMath::Matrix3;
+using sixenseMath::Matrix4;
+using sixenseMath::Quat;
+
+#include "export.hpp"
+
+#include "sixense_utils/derivatives.hpp"
+#include "sixense_utils/button_states.hpp"
+#include "sixense_utils/sixense_utils_string.hpp"
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT FPSViewAngles : public IFPSViewAngles {
+
+ public:
+ FPSViewAngles();
+
+ void setGame( const char* game_name );
+
+ void setMode( fps_mode mode );
+ fps_mode getMode();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ Vector3 getViewAngles(); // The final view angles, ie the feet plus the aiming from the controller
+ Vector3 getViewAngleOffset(); // The negative controller aim, used to keep the camera stationary in metroid mode
+
+ Vector3 getSpinSpeed();
+
+ void forceViewAngles( fps_mode mode, Vector3 ); // Used to initialize the view direction when switching into stick spin mode
+
+ void setFeetAnglesMetroid( Vector3 angles );
+ Vector3 getFeetAnglesMetroid();
+
+ float getTestVal();
+
+ void setParameter( fps_params param, float val );
+ float getParameter( fps_params param );
+
+ void setFov( float hfov, float vfov );
+ void getFov( float *hfov, float *vfov );
+
+ void setHoldingTurnSpeed( float horiz, float vert );
+
+ void setRatcheting( bool );
+ bool isRatcheting();
+
+ void reset();
+
+ void forceMetroidBlend( float blend_fraction );
+
+ protected:
+ void computeAimOffset1to1( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms );
+ void computeAimOffsetPointer( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms );
+
+ void computeFeetAnglesOffsetStickSpin( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms );
+ void computeFeetAnglesOffsetMetroid( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms );
+ void computeFeetAnglesOffsetRatchet( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms );
+
+ void computeSpringViewOffset();
+
+ Vector3 clampViewAngles( Vector3 angles, Vector3 max_vals );
+
+ private:
+ fps_mode _mode;
+
+ // Keep track of the game so we can do
+ std::string _game_name;
+
+ // Different types of aim offsets
+ Vector3 _aim_offset_1to1_metroid, _aim_offset_1to1_mouselook; // need two because they're scaled differently
+ Vector3 _aim_offset_pointer;
+
+ Vector3 _spring_view_offset;
+ float _spring_vel;
+ Quat _spring_view;
+
+ // Different types of feet angles
+ Vector3 _feet_angles_stick_spin;
+ Vector3 _feet_angles_metroid;
+ Vector3 _feet_angles_ratchet;
+
+ Vector3 _feet_angles, _aim_offset_1to1;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ ButtonStates _left_button_watcher, _right_button_watcher;
+
+ Vector3 _ratchet_base_orientation;
+
+ // Are we flicking? (0-1)
+ float _flicking;
+
+ bool _ratcheting;
+ bool _just_started_ratcheting, _just_stopped_ratcheting;
+
+ float _roll;
+
+ // Keep track of the fov
+ float _hfov, _vfov;
+
+ // This is used to blend pitch smoothly between modes
+ float _blend_pitch_val;
+
+ Vector3 _blend_view_offset;
+ Vector3 _prev_blend_view_offset;
+
+ Vector3 _mode_switch_blend_angle_start, _mode_switch_blend_angle_end, _mode_switch_blend_angles;
+
+ double _mode_switch_blend_duration_ms;
+ double _mode_switch_blend_start_time;
+
+ float _test_val;
+
+ Vector3 _holding_turn_speed;
+
+ // Allow metroid spinning to blend in over time. Useful when switching from 1-to-1 mode.
+ float _metroid_blend_start_time;
+ int _metroid_blend_in_or_out; // 0 == in, 1 == out
+
+ Vector3 _metroid_spin_speed, _stick_spin_speed;
+
+ float _force_blend_aim_metroid_start_time;
+ float _force_blend_aim_metroid_pitch_mult;
+ float _force_blend_aim_metroid_heading_mult;
+ };
+
+
+
+
+ class SIXENSE_UTILS_EXPORT FPSEvents : public IFPSEvents {
+
+ public:
+
+ FPSEvents();
+
+ void setGame( const char* game_name );
+
+ void setBinding( fps_event, fps_controller, fps_action, int param );
+
+ void setPointGestureButton( int );
+
+ bool isPointGestureActive();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ bool eventActive( fps_event event_query );
+ bool eventStarted( fps_event event_query );
+ bool eventStopped( fps_event event_query );
+
+ Vector3 getGrenadeThrowVelocity();
+
+ void setParameter( fps_params param, float val );
+ float getParameter( fps_params param );
+
+ private:
+
+ typedef struct {
+ fps_event _event;
+ fps_controller _controller;
+ fps_action _action;
+ int _param;
+ } fps_binding;
+
+ protected:
+ bool testButtonBinding( fps_binding );
+ bool testJoystickBinding( fps_binding );
+ bool testTriggerBinding( fps_binding );
+ bool testTiltBinding( fps_binding );
+ bool testPointBinding( fps_binding );
+ bool testVelocityBinding( fps_binding );
+
+ private:
+
+ // keep them in a map so there's only one binding per event
+ std::map <fps_event, fps_binding> _bindings;
+
+ ButtonStates _button_states[2]; // one for each controller, in order of fps_controller, so 0=left 1=right
+
+ std::vector<bool> _event_started, _event_stopped, _event_persistent_state;
+ Derivatives _left_deriv, _right_deriv;
+ Derivatives _left_deriv_offset, _right_deriv_offset;
+
+ // Keep track of the velocity of the hand when a grenade is thrown
+ Vector3 _grenade_throw_vel;
+
+ // Keep track of the game so we can do
+ std::string _game_name;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ // The z depth at which one to one mode started.
+ Vector3 _one_to_one_start_pos;
+
+ // This is set when a point gesture is in process
+ bool _point_gesture_active;
+
+ // The button that is used to engage point gestures
+ unsigned short _point_gesture_button;
+
+ };
+
+
+ class SIXENSE_UTILS_EXPORT FPSPlayerMovement : public IFPSPlayerMovement{
+
+ public:
+ FPSPlayerMovement();
+
+ void setGame( const char* game_name );
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ Vector2 getWalkDir();
+
+ void setParameter( fps_movement_params param, float val );
+ float getParameter( fps_movement_params param );
+
+ private:
+ Vector2 _walk_dir;
+ std::string _game_name;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ };
+
+ class SIXENSE_UTILS_EXPORT FPSMeleeWeapon {
+ public:
+ FPSMeleeWeapon();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ // Weapon movement
+ Vector3 getMeleeWeaponPos();
+ Vector3 getMeleeWeaponBladePos();
+ Matrix3 getMeleeWeaponMatrix();
+
+ // Attack
+ bool swingAttackStarted(); // since last update
+ bool isAttacking();
+
+ // 1-to-1 mode (when the melee weapon should be moving with the controller and not animated
+ bool OneToOneModeStarted();
+ bool OneToOneModeStopped();
+ bool isInOneToOneMode();
+
+ Vector3 getSwingAttackStartPos();
+ Vector3 getSwingAttackDir();
+
+ void setToggleMode( bool mode );
+
+ void forceOneToOneMode( bool mode );
+
+ // Parameters to control the different modes
+ typedef enum {
+ SWING_START_VELOCITY,
+ SWING_STOP_VELOCITY,
+ SWING_REARM_VELOCITY,
+ BLADE_LENGTH,
+ CONTROLLER_ANGLE,
+
+ LEFT_HANDED,
+
+ LAST_MELEE_EVENTS_PARAM
+ } melee_params;
+
+ void setParameter( melee_params param, float val );
+ float getParameter( melee_params param );
+
+
+ private:
+ Derivatives _left_deriv, _right_deriv;
+ bool _armed; // Can we attack again?
+ bool _just_started_attack, _attacking;
+ bool _just_started_1to1, _just_stopped_1to1, _in_1to1_mode;
+ int _swing_wait_count; // How many frames to wait until starting a swing
+ int _swing_count; // How long have we been swinging?
+ Matrix4 _start_swing_mat;
+ Vector3 _swing_dir_vec; // Direction we are attacking in
+ Vector3 _swing_start_pos; // Position swing started from
+
+ float _last_trigger_pos;
+
+ Vector3 _weap_pos, _last_weap_pos;
+ Matrix3 _weap_mat, _last_weap_mat;
+
+ Vector3 _weap_blade_pos;
+
+ bool _toggle_mode;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ };
+
+}
+
+#endif
+
+#pragma warning(pop)
+
diff --git a/SixenseSDK/include/sixense_utils/fps_rewrite.hpp b/SixenseSDK/include/sixense_utils/fps_rewrite.hpp
new file mode 100755
index 0000000..f1ddd19
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/fps_rewrite.hpp
@@ -0,0 +1,270 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_PORT_UTILS_FPS_HPP
+#define SIXENSE_PORT_UTILS_FPS_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense.h"
+#include "sixense_math.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+#include <vector>
+#include <map>
+
+using sixenseMath::Vector2;
+using sixenseMath::Vector3;
+using sixenseMath::Matrix3;
+using sixenseMath::Matrix4;
+using sixenseMath::Quat;
+
+#include "export.hpp"
+
+#include "sixense_utils/derivatives.hpp"
+#include "sixense_utils/button_states.hpp"
+#include "sixense_utils/sixense_utils_string.hpp"
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT FPSViewAngles : public IFPSViewAngles {
+
+ public:
+ FPSViewAngles();
+
+ void setGame( const char* game_name );
+
+ void setMode( fps_mode mode );
+ fps_mode getMode();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ Vector3 getViewAngles(); // The final view angles, ie the feet plus the aiming from the controller
+ Vector3 getViewAngleOffset(); // The negative controller aim, used to keep the camera stationary in metroid mode
+
+ Vector3 getSpinSpeed();
+
+ void forceViewAngles( fps_mode mode, Vector3 ); // Used to initialize the view direction when switching into stick spin mode
+
+ void setFeetAnglesMetroid( Vector3 angles );
+ Vector3 getFeetAnglesMetroid();
+
+ float getTestVal();
+
+ void setParameter( fps_params param, float val );
+ float getParameter( fps_params param );
+
+ void setFov( float hfov, float vfov );
+ void getFov( float *hfov, float *vfov );
+
+ void setHoldingTurnSpeed( float horiz, float vert );
+
+ void setRatcheting( bool );
+ bool isRatcheting();
+
+ void reset();
+
+ void forceMetroidBlend( float blend_fraction );
+
+ protected:
+ Vector2 _feet_angles;
+ Vector2 _torso_angles;
+ Vector2 _view_offset;
+
+ Vector2 _ratchet_base_angles;
+
+ private:
+ fps_mode _mode;
+
+ // Keep track of the game so we can do
+ std::string _game_name;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ bool _ratcheting;
+ bool _just_started_ratcheting, _just_stopped_ratcheting;
+ };
+
+
+
+
+ class SIXENSE_UTILS_EXPORT FPSEvents : public IFPSEvents {
+
+ public:
+
+ FPSEvents();
+
+ void setGame( const char* game_name );
+
+ void setBinding( fps_event, fps_controller, fps_action, int param );
+
+ void setPointGestureButton( int );
+
+ bool isPointGestureActive();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ bool eventActive( fps_event event_query );
+ bool eventStarted( fps_event event_query );
+ bool eventStopped( fps_event event_query );
+
+ Vector3 getGrenadeThrowVelocity();
+
+ void setParameter( fps_params param, float val );
+ float getParameter( fps_params param );
+
+ private:
+
+ typedef struct {
+ fps_event _event;
+ fps_controller _controller;
+ fps_action _action;
+ int _param;
+ } fps_binding;
+
+ protected:
+ bool testButtonBinding( fps_binding );
+ bool testJoystickBinding( fps_binding );
+ bool testTriggerBinding( fps_binding );
+ bool testTiltBinding( fps_binding );
+ bool testPointBinding( fps_binding );
+ bool testVelocityBinding( fps_binding );
+
+ private:
+
+ // keep them in a map so there's only one binding per event
+ std::map <fps_event, fps_binding> _bindings;
+
+ ButtonStates _button_states[2]; // one for each controller, in order of fps_controller, so 0=left 1=right
+
+ std::vector<bool> _event_started, _event_stopped, _event_persistent_state;
+ Derivatives _left_deriv, _right_deriv;
+ Derivatives _left_deriv_offset, _right_deriv_offset;
+
+ // Keep track of the velocity of the hand when a grenade is thrown
+ Vector3 _grenade_throw_vel;
+
+ // Keep track of the game so we can do
+ std::string _game_name;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ // The z depth at which one to one mode started.
+ Vector3 _one_to_one_start_pos;
+
+ // This is set when a point gesture is in process
+ bool _point_gesture_active;
+
+ // The button that is used to engage point gestures
+ unsigned short _point_gesture_button;
+
+ };
+
+
+ class SIXENSE_UTILS_EXPORT FPSPlayerMovement : public IFPSPlayerMovement{
+
+ public:
+ FPSPlayerMovement();
+
+ void setGame( const char* game_name );
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ Vector2 getWalkDir();
+
+ void setParameter( fps_movement_params param, float val );
+ float getParameter( fps_movement_params param );
+
+ private:
+ Vector2 _walk_dir;
+ std::string _game_name;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ };
+
+ class SIXENSE_UTILS_EXPORT FPSMeleeWeapon {
+ public:
+ FPSMeleeWeapon();
+
+ int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f );
+
+ // Weapon movement
+ Vector3 getMeleeWeaponPos();
+ Vector3 getMeleeWeaponBladePos();
+ Matrix3 getMeleeWeaponMatrix();
+
+ // Attack
+ bool swingAttackStarted(); // since last update
+ bool isAttacking();
+
+ // 1-to-1 mode (when the melee weapon should be moving with the controller and not animated
+ bool OneToOneModeStarted();
+ bool OneToOneModeStopped();
+ bool isInOneToOneMode();
+
+ Vector3 getSwingAttackStartPos();
+ Vector3 getSwingAttackDir();
+
+ void setToggleMode( bool mode );
+
+ void forceOneToOneMode( bool mode );
+
+ // Parameters to control the different modes
+ typedef enum {
+ SWING_START_VELOCITY,
+ SWING_STOP_VELOCITY,
+ SWING_REARM_VELOCITY,
+ BLADE_LENGTH,
+ CONTROLLER_ANGLE,
+
+ LEFT_HANDED,
+
+ LAST_MELEE_EVENTS_PARAM
+ } melee_params;
+
+ void setParameter( melee_params param, float val );
+ float getParameter( melee_params param );
+
+
+ private:
+ Derivatives _left_deriv, _right_deriv;
+ bool _armed; // Can we attack again?
+ bool _just_started_attack, _attacking;
+ bool _just_started_1to1, _just_stopped_1to1, _in_1to1_mode;
+ int _swing_wait_count; // How many frames to wait until starting a swing
+ int _swing_count; // How long have we been swinging?
+ Matrix4 _start_swing_mat;
+ Vector3 _swing_dir_vec; // Direction we are attacking in
+ Vector3 _swing_start_pos; // Position swing started from
+
+ float _last_trigger_pos;
+
+ Vector3 _weap_pos, _last_weap_pos;
+ Matrix3 _weap_mat, _last_weap_mat;
+
+ Vector3 _weap_blade_pos;
+
+ bool _toggle_mode;
+
+ // Parameters to control the different modes
+ std::vector<float> _param_vals;
+
+ };
+
+}
+
+#endif
+
+#pragma warning(pop)
+
diff --git a/SixenseSDK/include/sixense_utils/interfaces.hpp b/SixenseSDK/include/sixense_utils/interfaces.hpp
new file mode 100755
index 0000000..5470221
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/interfaces.hpp
@@ -0,0 +1,442 @@
+#ifndef SIXENSE_UTILS_INTERFACES_HPP
+#define SIXENSE_UTILS_INTERFACES_HPP
+
+#include <sixense.h>
+#include <sixense_math.hpp>
+
+namespace sixenseUtils {
+
+ class IButtonStates {
+ public:
+
+ typedef enum {
+ DIR_UP,
+ DIR_DOWN,
+ DIR_LEFT,
+ DIR_RIGHT,
+ DIR_CW,
+ DIR_CCW,
+ DIR_FORWARD,
+ DIR_BACKWARD
+ } Direction;
+
+ typedef enum {
+ ACTION_BUTTON_PRESS,
+ ACTION_JOYSTICK_MOVE,
+ ACTION_TRIGGER_PRESS,
+ ACTION_TILT_GESTURE,
+ ACTION_POINT_GESTURE,
+ ACTION_VELOCITY_GESTURE
+ } ActionType;
+
+ virtual void update( sixenseControllerData *cd )=0;
+ virtual bool buttonJustPressed( unsigned short which_button )=0;
+ virtual bool buttonJustReleased( unsigned short which_button )=0;
+
+ virtual void setTriggerThreshold( float thresh )=0;
+ virtual bool triggerJustPressed()=0;
+ virtual bool triggerJustReleased()=0;
+
+ virtual void setStickThreshold( float thresh )=0;
+ virtual bool stickJustPressed( Direction which )=0;
+ virtual bool stickJustReleased( Direction which )=0;
+
+ virtual void setAbsoluteTiltAngleThresholdInDeg( float thresh )=0;
+ virtual void setRelativeTiltAngleThresholdInDeg( float thresh )=0;
+
+ // Relative tilts are an orientation change relative to the orientation last time setRelativeOrigin() was called
+ virtual void setRelativeOrigin()=0;
+ virtual void startPointGesture()=0;
+ virtual void stopPointGesture()=0;
+ virtual bool relativeTiltJustStarted( Direction which )=0;
+ virtual bool relativeTiltJustStopped( Direction which )=0;
+
+ // Absolute gestures are just relative to the world
+ virtual bool absoluteTiltJustStarted( Direction which )=0;
+ virtual bool absoluteTiltJustStopped( Direction which )=0;
+
+ virtual bool justStarted( ActionType action, int arg )=0;
+ virtual bool justStopped( ActionType action, int arg )=0;
+
+ };
+
+ class IDerivatives {
+ public:
+ virtual void update( sixenseControllerData *cd )=0;
+
+ virtual sixenseMath::Vector3 getPosition()=0;
+ virtual sixenseMath::Vector3 getVelocity()=0;
+ virtual sixenseMath::Vector3 getAcceleration()=0;
+
+ virtual sixenseMath::Vector3 getRSquared()=0;
+
+ virtual void setOffset( sixenseMath::Vector3 offset )=0;
+ virtual sixenseMath::Vector3 getOffset()=0;
+ };
+
+ class IFPSViewAngles {
+
+ public:
+ virtual void setGame( const char* game_name )=0;
+
+ typedef enum {
+ MOUSELOOK,
+ FREE_AIM_TWO_CONTROLLER,
+ FREE_AIM_ONE_CONTROLLER,
+ DUAL_ANALOG
+ } fps_mode;
+
+ virtual void setMode( fps_mode mode )=0;
+ virtual fps_mode getMode()=0;
+
+ virtual int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f )=0;
+
+ virtual sixenseMath::Vector3 getViewAngles()=0; // The final view angles, ie the feet plus the aiming from the controller
+ virtual sixenseMath::Vector3 getViewAngleOffset()=0; // The negative controller aim, used to keep the camera stationary in metroid mode
+
+ virtual sixenseMath::Vector3 getSpinSpeed()=0;
+
+ virtual void forceViewAngles( fps_mode mode, sixenseMath::Vector3 )=0; // Used to initialize the view direction when switching into stick spin mode
+
+ virtual void setFeetAnglesMetroid( sixenseMath::Vector3 angles )=0;
+ virtual sixenseMath::Vector3 getFeetAnglesMetroid()=0;
+
+ virtual float getTestVal()=0;
+
+ // Parameters to control the different modes
+ typedef enum {
+ CONTROLLER_ANGLE_MODE,
+
+ AIM_1TO1_HEADING_MULTIPLIER,
+ AIM_1TO1_PITCH_MULTIPLIER,
+ AIM_1TO1_RATCHET_VERTICAL,
+
+ AIM_METROID_HEADING_MULTIPLIER,
+ AIM_METROID_PITCH_MULTIPLIER,
+ AIM_METROID_DEAD_ZONE_RADIUS,
+ AIM_METROID_ACCEL_BAND_SIZE,
+ AIM_METROID_MAX_SPEED,
+ AIM_METROID_AUTO_LEVEL_RATE,
+ AIM_METROID_ACCEL_BAND_EXPONENT,
+ AIM_METROID_SWITCH_BLEND_TIME_ENTER,
+ AIM_METROID_SWITCH_BLEND_TIME_EXIT,
+
+ FEET_ANGLES_OFFSET_STICK_SPIN_HORIZ_MULTIPLIER,
+ FEET_ANGLES_OFFSET_STICK_SPIN_VERT_MULTIPLIER,
+ FEET_ANGLES_OFFSET_STICK_SPIN_INVERT_PITCH,
+ FEET_ANGLES_OFFSET_STICK_SPIN_EXPONENT,
+
+ PITCH_CHANGE_BLEND_VAL,
+
+ SPRING_VIEW_ENABLED,
+ SPRING_VIEW_MIN_SPRING,
+ SPRING_VIEW_MAX_SPRING,
+ SPRING_VIEW_MIN_ANGLE,
+ SPRING_VIEW_MAX_ANGLE,
+
+ FEET_ANGLES_ALLOW_VERT_STICK_SPIN,
+
+ AIM_METROID_ACCEL_BAND_POWER,
+
+ HOLDING_TURN_SPEED,
+
+ ROLL_CORRECTION_BLEND,
+ EXIT_METROID_BLEND,
+
+ LEFT_HANDED,
+
+ LAST_FPS_VIEW_ANGLES_PARAM
+ } fps_params;
+
+ virtual void setParameter( fps_params param, float val )=0;
+ virtual float getParameter( fps_params param )=0;
+
+ virtual void setFov( float hfov, float vfov )=0;
+ virtual void getFov( float *hfov, float *vfov )=0;
+
+ virtual void setHoldingTurnSpeed( float horiz, float vert )=0;
+
+ virtual void setRatcheting( bool )=0;
+ virtual bool isRatcheting()=0;
+
+ virtual void reset()=0;
+
+ virtual void forceMetroidBlend( float blend_fraction )=0;
+ };
+
+ class IFPSEvents {
+
+ public:
+ typedef enum {
+ WALK_LEFT,
+ WALK_RIGHT,
+ WALK_FORWARD,
+ WALK_BACK,
+ JUMP,
+ USE,
+ PRIMARY_FIRE,
+ SECONDARY_FIRE,
+ ZOOM,
+ MELEE,
+ LEAN_LEFT,
+ LEAN_RIGHT,
+ CROUCH,
+ SPRINT,
+ THROW_GRENADE,
+ FLASHLIGHT,
+ NIGHTVISION,
+ RELOAD,
+ NEXT_WEAPON,
+ PREV_WEAPON,
+ ESC_KEY,
+ EQUIP_GRENADE,
+ MEDPACK_SWITCH,
+ GIVE,
+ NEXT_PRIMARY_WEAPON,
+ ONE_TO_ONE_CARRY,
+ EQUIP_MELEE,
+ EQUIP_MACHINEGUN,
+ EQUIP_PISTOL,
+ RATCHET,
+ LAST_FPS_EVENT
+ } fps_event;
+
+ typedef enum {
+ CONTROLLER_LEFT,
+ CONTROLLER_RIGHT
+ } fps_controller;
+
+ typedef enum {
+ ACTION_BUTTON_PRESS,
+ ACTION_JOYSTICK_MOVE,
+ ACTION_TRIGGER_PRESS,
+ ACTION_TILT_GESTURE,
+ ACTION_POINT_GESTURE,
+ ACTION_VELOCITY_GESTURE
+ } fps_action;
+
+ typedef enum {
+ DIR_UP,
+ DIR_DOWN,
+ DIR_LEFT,
+ DIR_RIGHT,
+ DIR_FORWARD,
+ DIR_BACKWARD,
+ DIR_CW,
+ DIR_CCW
+ } fps_direction;
+
+ virtual void setGame( const char* game_name )=0;
+
+ virtual void setBinding( fps_event, fps_controller, fps_action, int param )=0;
+
+ virtual void setPointGestureButton( int )=0;
+
+ virtual bool isPointGestureActive()=0;
+
+ virtual int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f )=0;
+
+ virtual bool eventActive( fps_event event_query )=0;
+ virtual bool eventStarted( fps_event event_query )=0;
+ virtual bool eventStopped( fps_event event_query )=0;
+
+ virtual sixenseMath::Vector3 getGrenadeThrowVelocity()=0;
+
+ // Parameters to control the different modes
+ typedef enum {
+ MELEE_SENSITIVITY,
+ WEAPON_SELECT_SENSITIVITY,
+ CROUCH_SENSITIVITY,
+ JUMP_SENSITIVITY,
+ RELOAD_SENSITIVITY,
+ THROW_SENSITIVITY,
+
+ CONTROLLER_ANGLE_MODE,
+
+ AUTO_ONE_TO_ONE_START_VEL,
+ AUTO_ONE_TO_ONE_START_ACCEL,
+ AUTO_ONE_TO_ONE_START_ACCEL_TIMER,
+ AUTO_ONE_TO_ONE_START_ANGLE_THRESH,
+
+ AUTO_ONE_TO_ONE_STOP_XY_DIST,
+ AUTO_ONE_TO_ONE_STOP_Z_DIST,
+
+ LEFT_HANDED,
+
+ LAST_FPS_EVENTS_PARAM
+ } fps_params;
+
+ virtual void setParameter( fps_params param, float val )=0;
+ virtual float getParameter( fps_params param )=0;
+
+
+ };
+
+ class IFPSPlayerMovement {
+ public:
+ virtual void setGame( const char* game_name )=0;
+
+ virtual int update( sixenseControllerData *left_cd, sixenseControllerData *right_cd, float frametime_in_ms=0.0f )=0;
+
+ virtual sixenseMath::Vector2 getWalkDir()=0;
+
+ // Parameters to control the different modes
+ typedef enum {
+ DEAD_ZONE_PERCENT,
+ EXPONENTIAL,
+ USE_RIGHT_HAND,
+
+ LEFT_HANDED,
+
+ LAST_FPS_MOVEMENT_PARAM
+ } fps_movement_params;
+
+ virtual void setParameter( fps_movement_params param, float val )=0;
+ virtual float getParameter( fps_movement_params param )=0;
+
+ };
+
+ class ILaserPointer {
+ public:
+ virtual void setScreenSize( sixenseMath::Vector2 width_and_height_in_mm )=0;
+ virtual void setScreenCenterOffsetFromBase( sixenseMath::Vector3 offset_in_mm )=0;
+
+ virtual sixenseMath::Vector2 getScreenSize()=0;
+ virtual sixenseMath::Vector3 getScreenCenterOffsetFromBase()=0;
+
+ virtual sixenseMath::Vector2 getIntersection( sixenseMath::Vector3 position, sixenseMath::Matrix3 rotation )=0;
+ };
+
+ class IMousePointer {
+ public:
+ virtual sixenseMath::Vector2 update( sixenseControllerData *cd )=0;
+
+ virtual void setSensitivity( float sensitivity )=0;
+ virtual void setAcceleration( float acceleration )=0;
+ virtual void setSlideEnabled( bool slide_enabled )=0;
+ virtual void setAspectRatio( float aspect_ratio )=0;
+
+ virtual float getRollAngle()=0;
+
+ virtual void setCenter()=0;
+ };
+
+ class IControllerManager {
+ public:
+
+ // Define the steps the manager goes through for the different modes
+ typedef enum {
+
+ SETUP_COMPLETE,
+
+ // P1C1 = One player, 1 controller
+
+ // One player one controller
+ P1C1_START, //1
+ P1C1_POWER_UP_0,
+ P1C1_POWER_UP_DONE,
+ P1C1_AIM_P1L,
+ P1C1_DONE,
+ P1C1_OUT_OF_RANGE,
+ P1C1_IDLE, // 7
+
+ // One player two controllers
+ P1C2_START, // 8
+ P1C2_POWER_UP_0,
+ P1C2_POWER_UP_1,
+ P1C2_POWER_UP_DONE,
+ P1C2_AIM_P1L, // 12
+ P1C2_AIM_P1R,
+ P1C2_DONE,
+ P1C2_OUT_OF_RANGE,
+ P1C2_IDLE // 16
+
+ } setup_step;
+
+
+ typedef enum {
+ NO_SOUND,
+ SUCCESS_BEEP,
+ FAIL_BEEP
+ } sound_type;
+
+ typedef void (*setup_callback)( setup_step );
+
+ typedef enum {
+ ONE_PLAYER_ONE_CONTROLLER,
+ ONE_PLAYER_TWO_CONTROLLER,
+ TWO_PLAYER_ONE_CONTROLLER,
+ TWO_PLAYER_TWO_CONTROLLER,
+ THREE_PLAYER_ONE_CONTROLLER,
+ THREE_PLAYER_TWO_CONTROLLER,
+ FOUR_PLAYER_ONE_CONTROLLER,
+ FOUR_PLAYER_TWO_CONTROLLER
+ } game_type;
+
+ typedef enum {
+ P1L,
+ P1R,
+ P2L,
+ P2R,
+ P3L,
+ P3R,
+ P4L,
+ P4R,
+ LAST_CONTROLLER_DESC
+ } controller_desc;
+
+ virtual void setGameType( game_type gt )=0;
+ virtual game_type getGameType()=0;
+
+ // Update the controller_manager. Should be called each frame.
+ virtual void update( sixenseAllControllerData * )=0;
+
+ // Get the controller index for the given description, ie player 1's left hand is controller index 3
+ virtual int getIndex( controller_desc )=0;
+
+ // Force the user to rebind the controllers to the player slots.
+ virtual void rebind()=0;
+
+ // Register a callback that will get called when the mode changes
+ virtual void registerSetupCallback( setup_callback )=0;
+
+ // Returns true if the application should show the menu system
+ virtual bool isMenuVisible()=0;
+
+ // Returns the filename of the recommended texture for this step
+ virtual const char* getTextureFileName()=0;
+
+ // Returns a string describing this step
+ virtual const char* getStepString()=0;
+
+
+ virtual IControllerManager::sound_type shouldPlaySound()=0;
+
+ virtual setup_step getCurrentStep()=0;
+
+ };
+
+ class IMouseAndKeyboard {
+ public:
+ virtual void sendMouseClick( int click, int release ) = 0; // 0 = none, 1 = left, 2 = right
+ virtual void sendMouseClick( int click, int release, int delay) = 0; // 0 = none, 1 = left, 2 = right
+ virtual void sendMouseWheelMove( int dir ) = 0; // in 'clicks', + = forwards - = backwards
+ virtual void sendKeyState( char key, int press, int release ) = 0;
+ virtual void sendKeyState( char key, int press, int release, int delay ) = 0;
+ virtual void releaseKey( char key ) = 0;
+ virtual void releaseMouseButton( int release ) = 0;
+ virtual void sendAbsoluteMouseMove( float x, float y ) = 0;
+ virtual void sendRelativeMouseMove( float x, float y ) = 0;
+ virtual void sendAbsoluteMouseMoveInPixels( int x, int y ) = 0;
+
+ virtual void getMousePos( int *x, int *y ) = 0;
+ virtual void getPrimaryScreenResolution( int *x, int *y ) = 0;
+
+ virtual void sendMouseClick( float x, float y, int click, int release ) = 0;
+
+ // This should be called once per 10ms or so...
+ virtual void processQueue() = 0;
+ };
+}
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/keyboard_and_mouse_win32.hpp b/SixenseSDK/include/sixense_utils/keyboard_and_mouse_win32.hpp
new file mode 100755
index 0000000..16223b9
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/keyboard_and_mouse_win32.hpp
@@ -0,0 +1,227 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_KEYBOARD_AND_MOUSE_WIN32_HPP
+#define SIXENSE_UTILS_KEYBOARD_AND_MOUSE_WIN32_HPP
+
+#include "export.hpp"
+
+#include "sixense_utils/interfaces.hpp"
+
+namespace sixenseUtils {
+
+ const int key_esc = 0x01;
+
+#define KEY_ESCAPE 0x01
+#define KEY_1 0x02
+#define KEY_2 0x03
+#define KEY_3 0x04
+#define KEY_4 0x05
+#define KEY_5 0x06
+#define KEY_6 0x07
+#define KEY_7 0x08
+#define KEY_8 0x09
+#define KEY_9 0x0A
+#define KEY_0 0x0B
+#define KEY_MINUS 0x0C /* - on main keyboard */
+#define KEY_EQUALS 0x0D
+#define KEY_BACK 0x0E /* backspace */
+#define KEY_TAB 0x0F
+#define KEY_Q 0x10
+#define KEY_W 0x11
+#define KEY_E 0x12
+#define KEY_R 0x13
+#define KEY_T 0x14
+#define KEY_Y 0x15
+#define KEY_U 0x16
+#define KEY_I 0x17
+#define KEY_O 0x18
+#define KEY_P 0x19
+#define KEY_LBRACKET 0x1A
+#define KEY_RBRACKET 0x1B
+#define KEY_RETURN 0x1C /* Enter on main keyboard */
+#define KEY_LCONTROL 0x1D
+#define KEY_A 0x1E
+#define KEY_S 0x1F
+#define KEY_D 0x20
+#define KEY_F 0x21
+#define KEY_G 0x22
+#define KEY_H 0x23
+#define KEY_J 0x24
+#define KEY_K 0x25
+#define KEY_L 0x26
+#define KEY_SEMICOLON 0x27
+#define KEY_APOSTROPHE 0x28
+#define KEY_GRAVE 0x29 /* accent grave */
+#define KEY_LSHIFT 0x2A
+#define KEY_BACKSLASH 0x2B
+#define KEY_Z 0x2C
+#define KEY_X 0x2D
+#define KEY_C 0x2E
+#define KEY_V 0x2F
+#define KEY_B 0x30
+#define KEY_N 0x31
+#define KEY_M 0x32
+#define KEY_COMMA 0x33
+#define KEY_PERIOD 0x34 /* . on main keyboard */
+#define KEY_SLASH 0x35 /* / on main keyboard */
+#define KEY_RSHIFT 0x36
+#define KEY_MULTIPLY 0x37 /* * on numeric keypad */
+#define KEY_LMENU 0x38 /* left Alt */
+#define KEY_SPACE 0x39
+#define KEY_CAPITAL 0x3A
+#define KEY_F1 0x3B
+#define KEY_F2 0x3C
+#define KEY_F3 0x3D
+#define KEY_F4 0x3E
+#define KEY_F5 0x3F
+#define KEY_F6 0x40
+#define KEY_F7 0x41
+#define KEY_F8 0x42
+#define KEY_F9 0x43
+#define KEY_F10 0x44
+#define KEY_NUMLOCK 0x45
+#define KEY_SCROLL 0x46 /* Scroll Lock */
+#define KEY_NUMPAD7 0x47
+#define KEY_NUMPAD8 0x48
+#define KEY_NUMPAD9 0x49
+#define KEY_SUBTRACT 0x4A /* - on numeric keypad */
+#define KEY_NUMPAD4 0x4B
+#define KEY_NUMPAD5 0x4C
+#define KEY_NUMPAD6 0x4D
+#define KEY_ADD 0x4E /* + on numeric keypad */
+#define KEY_NUMPAD1 0x4F
+#define KEY_NUMPAD2 0x50
+#define KEY_NUMPAD3 0x51
+#define KEY_NUMPAD0 0x52
+#define KEY_DECIMAL 0x53 /* . on numeric keypad */
+#define KEY_F11 0x57
+#define KEY_F12 0x58
+#define KEY_F13 0x64 /* (NEC PC98) */
+#define KEY_F14 0x65 /* (NEC PC98) */
+#define KEY_F15 0x66 /* (NEC PC98) */
+
+#define KEY_KANA 0x70 /* (Japanese keyboard) */
+#define KEY_CONVERT 0x79 /* (Japanese keyboard) */
+#define KEY_NOCONVERT 0x7B /* (Japanese keyboard) */
+#define KEY_YEN 0x7D /* (Japanese keyboard) */
+#define KEY_BREAK 0x7E
+#define KEY_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
+#define KEY_CIRCUMFLEX 0x90 /* (Japanese keyboard) */
+#define KEY_AT 0x91 /* (NEC PC98) */
+#define KEY_COLON 0x92 /* (NEC PC98) */
+#define KEY_UNDERLINE 0x93 /* (NEC PC98) */
+#define KEY_KANJI 0x94 /* (Japanese keyboard) */
+#define KEY_STOP 0x95 /* (NEC PC98) */
+#define KEY_AX 0x96 /* (Japan AX) */
+#define KEY_UNLABELED 0x97 /* (J3100) */
+#define KEY_NUMPADENTER 0x9C /* Enter on numeric keypad */
+#define KEY_RCONTROL 0x9D
+#define KEY_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */
+#define KEY_DIVIDE 0xB5 /* / on numeric keypad */
+#define KEY_SYSRQ 0xB7
+#define KEY_RMENU 0xB8 /* right Alt */
+#define KEY_HOME 0xC7 /* Home on arrow keypad */
+#define KEY_UP 0xC8 /* UpArrow on arrow keypad */
+#define KEY_PRIOR 0xC9 /* PgUp on arrow keypad */
+#define KEY_LEFT 0xCB /* LeftArrow on arrow keypad */
+#define KEY_RIGHT 0xCD /* RightArrow on arrow keypad */
+#define KEY_END 0xCF /* End on arrow keypad */
+#define KEY_DOWN 0xD0 /* DownArrow on arrow keypad */
+#define KEY_NEXT 0xD1 /* PgDn on arrow keypad */
+#define KEY_INSERT 0xD2 /* Insert on arrow keypad */
+#define KEY_DELETE 0xD3 /* Delete on arrow keypad */
+#define KEY_LWIN 0xDB /* Left Windows key */
+#define KEY_RWIN 0xDC /* Right Windows key */
+#define KEY_APPS 0xDD /* AppMenu key */
+
+ class SIXENSE_UTILS_EXPORT mouseAndKeyboardWin32 {
+ public:
+ static void sendMouseClick( int click, int release ); // 0 = none, 1 = left, 2 = right
+ static void sendMouseClick( int click, int release, int delay); // 0 = none, 1 = left, 2 = right
+ static void sendMouseWheelMove( int dir ); // in 'clicks', + = forwards - = backwards
+ static void sendKeyState( char key, int press, int release );
+ static void sendKeyState( char key, int press, int release, int delay );
+ static void releaseKey( char key );
+ static void releaseMouseButton( int release );
+ static void sendAbsoluteMouseMove( float x, float y );
+ static void sendRelativeMouseMove( float x, float y );
+ static void sendAbsoluteMouseMoveInPixels( int x, int y );
+
+ static void getMousePos( int *x, int *y );
+ static void getPrimaryScreenResolution( int *x, int *y );
+
+ static void sendMouseClick( float x, float y, int click, int release );
+
+ // This should be called once per 10ms or so...
+ static void processQueue();
+
+ private:
+ static double _last_click_time;
+ static float _last_absolute_mouse_pos_x;
+ static float _last_absolute_mouse_pos_y;
+ static float _last_absolute_mouse_pos_x_when_clicked;
+ static float _last_absolute_mouse_pos_y_when_clicked;
+ };
+
+ // Define a non-static class for use by the factory constructor. These calls just
+ // pass through to the static calls above.
+ class MouseAndKeyboardWin32 : public IMouseAndKeyboard {
+ public:
+ virtual void sendMouseClick( int click, int release ) {
+ mouseAndKeyboardWin32::sendMouseClick( click, release );
+ }
+ virtual void sendMouseClick( int click, int release, int delay) {
+ mouseAndKeyboardWin32::sendMouseClick( click, release, delay );
+ }
+ virtual void sendMouseWheelMove( int dir ) {
+ mouseAndKeyboardWin32::sendMouseWheelMove( dir );
+ }
+ virtual void sendKeyState( char key, int press, int release ) {
+ mouseAndKeyboardWin32::sendKeyState( key, press, release );
+ }
+ virtual void sendKeyState( char key, int press, int release, int delay ) {
+ mouseAndKeyboardWin32::sendKeyState( key, press, release, delay );
+ }
+ virtual void releaseKey( char key ) {
+ mouseAndKeyboardWin32::releaseKey( key );
+ }
+ virtual void releaseMouseButton( int release ) {
+ mouseAndKeyboardWin32::releaseMouseButton( release );
+ }
+ virtual void sendAbsoluteMouseMove( float x, float y ) {
+ mouseAndKeyboardWin32::sendAbsoluteMouseMove( x, y );
+ }
+ virtual void sendRelativeMouseMove( float x, float y ) {
+ mouseAndKeyboardWin32::sendRelativeMouseMove( x, y );
+ }
+ virtual void sendAbsoluteMouseMoveInPixels( int x, int y ) {
+ mouseAndKeyboardWin32::sendAbsoluteMouseMoveInPixels( x, y );
+ }
+ virtual void getMousePos( int *x, int *y ) {
+ mouseAndKeyboardWin32::getMousePos( x, y );
+ }
+ virtual void getPrimaryScreenResolution( int *x, int *y ) {
+ mouseAndKeyboardWin32::getPrimaryScreenResolution( x, y );
+ }
+
+ virtual void sendMouseClick( float x, float y, int click, int release ) {
+ mouseAndKeyboardWin32::sendMouseClick( x, y, click, release );
+ }
+ // This should be called once per 10ms or so...
+ virtual void processQueue() {
+ mouseAndKeyboardWin32::processQueue();
+ }
+
+ };
+
+}
+
+#endif
+
diff --git a/SixenseSDK/include/sixense_utils/laser_pointer.hpp b/SixenseSDK/include/sixense_utils/laser_pointer.hpp
new file mode 100755
index 0000000..d845ae9
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/laser_pointer.hpp
@@ -0,0 +1,81 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_PORT_UTILS_LASER_POINTER_HPP
+#define SIXENSE_PORT_UTILS_LASER_POINTER_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+#include "sixense_math.hpp"
+
+using sixenseMath::Vector2;
+using sixenseMath::Vector3;
+using sixenseMath::Matrix3;
+
+namespace sixenseUtils {
+
+ // LaserPointer computes a ray that shoots from the controller and intersects with the screen.
+ class SIXENSE_UTILS_EXPORT LaserPointer {
+
+ public:
+ LaserPointer();
+
+ void setScreenSize( Vector2 width_and_height_in_mm );
+ void setScreenCenterOffsetFromBase( Vector3 offset_in_mm );
+
+ Vector2 getScreenSize();
+ Vector3 getScreenCenterOffsetFromBase();
+
+ Vector2 getIntersection( Vector3 position, Matrix3 rotation );
+
+ private:
+ Vector2 _width_and_height_in_mm;
+ Vector3 _offset_in_mm;
+
+ };
+
+
+ // This class can be used to compute the required parameters for the LaserPointer by having the user aim the controller at the
+ // corners of the screen.
+ class SIXENSE_UTILS_EXPORT LaserPointerCalib {
+ public:
+
+ LaserPointerCalib() { _has_computed = false; }
+
+ // Calibrate using 4 ray casts, bottom left and top right from 2 distinct positions in space
+ bool compute(
+ Vector3 bottom_left_ray_from_point_A,
+ Vector3 top_right_ray_from_point_A,
+ Vector3 bottom_left_ray_from_point_B,
+ Vector3 top_right_ray_from_point_B );
+
+ // Calibrate using 2 ray casts plus the screen size, bottom left and top right
+ bool compute(
+ float screen_width_in_mm, float screen_aspect,
+ Vector3 bottom_left_ray_from_point_A,
+ Vector3 top_right_ray_from_point_A );
+
+ bool hasComputed() { return _has_computed; }
+ Vector2 getScrenSize();
+ Vector3 setScreenCenterOffsetFromBase();
+
+ private:
+ bool _has_computed;
+ Vector2 _width_and_height_in_mm;
+ Vector3 _offset_in_mm;
+ };
+};
+
+#pragma warning(pop)
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/mouse_pointer.hpp b/SixenseSDK/include/sixense_utils/mouse_pointer.hpp
new file mode 100755
index 0000000..fb16e6a
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/mouse_pointer.hpp
@@ -0,0 +1,76 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_MOUSE_POINTER_HPP
+#define SIXENSE_UTILS_MOUSE_POINTER_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+using sixenseMath::Vector2;
+using sixenseMath::Vector3;
+using sixenseMath::Matrix3;
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT MousePointer : public IMousePointer {
+
+ public:
+ MousePointer();
+ sixenseMath::Vector2 update( sixenseControllerData *cd );
+
+ void setSensitivity( float sensitivity );
+ void setAcceleration( float acceleration );
+ void setSlideEnabled( bool slide_enabled );
+ void setAspectRatio( float aspect_ratio );
+ void setLockRelativeToWindow(bool lock);
+ void setLockRelativeToClientBounds(bool client);
+
+ Vector2 getMouseOffset() { return mouse_offset; }
+ void setMouseOffset( Vector2 offset ) { mouse_offset = offset; }
+ float getRollAngle();
+
+ void setCenter();
+ void setWindowCenter();
+
+ private:
+ bool _slide_enabled;
+ float _aspect_ratio;
+ float _sensitivity;
+ float _screen_width_in_mm;
+
+ // velocity params
+ float _min_vel, _max_vel;
+ float _acceleration;
+
+ // This offset is the position of the center of the virtual screen relative to the base
+ Vector2 mouse_offset;
+
+ // Keep track of the previous mouse pos so we can compute velocity
+ Vector2 _last_mouse_pos;
+
+ // Keep track of the last accel so we can filter it
+ float _last_accel;
+
+ float _roll_angle;
+
+ bool _center_mouse_requested;
+ bool _center_mouse_on_window;
+
+ bool _lock_relative_to_window;
+ bool _lock_relative_using_client_bounds;
+ };
+}
+
+#pragma warning(pop)
+
+#endif
diff --git a/SixenseSDK/include/sixense_utils/sixense_utils_string.hpp b/SixenseSDK/include/sixense_utils/sixense_utils_string.hpp
new file mode 100755
index 0000000..31ee7c6
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/sixense_utils_string.hpp
@@ -0,0 +1,77 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_UTILS_STRING_HPP
+#define SIXENSE_UTILS_STRING_HPP
+
+SIXENSE_UTILS_EXPORT void* sixense_utils_alloc(size_t);
+SIXENSE_UTILS_EXPORT void sixense_utils_free(void*);
+
+#include <string>
+#include <cstddef>
+
+template<class MY_TYPE>
+class sixense_utils_allocator
+{
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef MY_TYPE* pointer;
+ typedef const MY_TYPE* const_pointer;
+ typedef MY_TYPE& reference;
+ typedef const MY_TYPE& const_reference;
+ typedef MY_TYPE value_type;
+
+ sixense_utils_allocator () {}
+ template <class U> sixense_utils_allocator(const sixense_utils_allocator<U>&) {}
+ template <class U> struct rebind { typedef sixense_utils_allocator<U> other; };
+
+ pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
+ {
+ return reinterpret_cast<pointer>(sixense_utils_alloc(n * sizeof(MY_TYPE)));
+ }
+ void construct(pointer p, const_reference val)
+ {
+ ::new(p) MY_TYPE(val);
+ }
+ void destroy(pointer p)
+ {
+ p->~MY_TYPE();
+ }
+ void deallocate(pointer p, size_type n)
+ {
+ sixense_utils_free(p);
+ }
+ size_type max_size() const throw()
+ {
+ return ~size_type(0);
+ }
+};
+
+template<class MY_TYPE>
+bool operator==(const sixense_utils_allocator<MY_TYPE>& left, const sixense_utils_allocator<MY_TYPE>& right) throw()
+{
+ return true;
+}
+
+template<class MY_TYPE>
+bool operator!=(const sixense_utils_allocator<MY_TYPE>& left, const sixense_utils_allocator<MY_TYPE>& right) throw()
+{
+ return false;
+}
+
+namespace sixenseUtils {
+
+ typedef std::basic_string< char, std::char_traits<char>, sixense_utils_allocator<char> > sixense_utils_string;
+
+}
+
+
+#endif
+
diff --git a/SixenseSDK/include/sixense_utils/time.hpp b/SixenseSDK/include/sixense_utils/time.hpp
new file mode 100755
index 0000000..314ed64
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/time.hpp
@@ -0,0 +1,23 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#include "sixense_utils/export.hpp"
+
+namespace sixenseUtils {
+
+ class SIXENSE_UTILS_EXPORT Time {
+ public:
+ static double getTimeInMilliseconds();
+
+ // Return the number of milliseconds since this was last called with the given token
+ static double getElapsedMilliseconds( int token );
+ };
+
+}
+