~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/mac/include/vrpn/vrpn_Tracker_RazerHydra.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
        @brief Header
 
3
 
 
4
        @date 2011
 
5
 
 
6
        @author
 
7
        Ryan Pavlik
 
8
        <rpavlik@iastate.edu> and <abiryan@ryand.net>
 
9
        http://academic.cleardefinition.com/
 
10
        Iowa State University Virtual Reality Applications Center
 
11
        Human-Computer Interaction Graduate Program
 
12
*/
 
13
 
 
14
//          Copyright Iowa State University 2011.
 
15
// Distributed under the Boost Software License, Version 1.0.
 
16
//    (See accompanying file LICENSE_1_0.txt or copy at
 
17
//          http://www.boost.org/LICENSE_1_0.txt)
 
18
 
 
19
#pragma once
 
20
#ifndef INCLUDED_vrpn_Tracker_RazerHydra_h_GUID_8c30e762_d7e7_40c5_9308_b9bc118959fd
 
21
#define INCLUDED_vrpn_Tracker_RazerHydra_h_GUID_8c30e762_d7e7_40c5_9308_b9bc118959fd
 
22
 
 
23
// Internal Includes
 
24
#include "vrpn_Configure.h"
 
25
#include "vrpn_HumanInterface.h"
 
26
#include "vrpn_Analog.h"
 
27
#include "vrpn_Button.h"
 
28
#include "vrpn_Tracker.h"
 
29
 
 
30
// Library/third-party includes
 
31
// - none
 
32
 
 
33
// Standard includes
 
34
// - none
 
35
 
 
36
#ifdef VRPN_USE_HID
 
37
 
 
38
/** @brief Device supporting the Razer Hydra game controller as a tracker,
 
39
        analog device, and button device, using the USB HID protocol directly
 
40
 
 
41
        The left wand (the one with LB and LT on its "end" buttons) is sensor 0.
 
42
        Be sure to have the wands resting in their positions on the base when
 
43
        starting - haven't figured out how to do the calibration yet.
 
44
 
 
45
        The base coordinate system is right-handed with the axes:
 
46
        * X - out the right of the base
 
47
        * Y - out the front of the base
 
48
        * Z - down
 
49
 
 
50
        The wand coordinates are also right-handed, with the tracked point somewhere near
 
51
        the cable entry to the controller. When held with the joystick vertical, the axes
 
52
        are:
 
53
        * X - to the right
 
54
        * Y - out the front of the controller (trigger buttons)
 
55
        * Z - Up, along the joystick
 
56
 
 
57
        Buttons are as follows, with the right controller's button channels starting
 
58
        at 8 instead of 0:
 
59
        * 0 - "middle" button below joystick
 
60
        * 1-4 - numbered buttons
 
61
        * 5 - "bumper" button (above trigger)
 
62
        * 6 - joystick button (if you push straight down on the joystick)
 
63
 
 
64
        Analog channels are as follows, with the right controller starting at 3
 
65
        instead of 0:
 
66
        * 0 - joystick left/right: centered at 0, right is positive, in [-1, 1]
 
67
        * 1 - joystick up/down: centered at 0, up is positive, in [-1, 1]
 
68
        * 2 - analog trigger, in range 0 (not pressed) to 1 (fully pressed).
 
69
*/
 
70
class VRPN_API vrpn_Tracker_RazerHydra: public vrpn_Analog, public vrpn_Button_Filter, public vrpn_Tracker, vrpn_HidInterface {
 
71
        public:
 
72
                vrpn_Tracker_RazerHydra(const char * name, vrpn_Connection * trackercon);
 
73
                ~vrpn_Tracker_RazerHydra();
 
74
 
 
75
                virtual void mainloop();
 
76
                virtual void reconnect();
 
77
 
 
78
                virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer);
 
79
 
 
80
        protected:
 
81
                enum HydraStatus {
 
82
                        HYDRA_WAITING_FOR_CONNECT,
 
83
                        HYDRA_LISTENING_AFTER_CONNECT,
 
84
                        HYDRA_LISTENING_AFTER_SET_FEATURE,
 
85
                        HYDRA_REPORTING
 
86
                };
 
87
 
 
88
                void _waiting_for_connect();
 
89
                void _listening_after_connect();
 
90
                void _listening_after_set_feature();
 
91
 
 
92
                void _enter_motion_controller_mode();
 
93
 
 
94
                void _report_for_sensor(int sensorNum, vrpn_uint8 * data);
 
95
 
 
96
                HydraStatus status;
 
97
                bool _wasInGamepadMode;
 
98
                int _attempt;
 
99
                struct timeval _timestamp;
 
100
                struct timeval _connected;
 
101
                struct timeval _set_feature;
 
102
};
 
103
 
 
104
#endif
 
105
 
 
106
#endif // INCLUDED_vrpn_Tracker_RazerHydra_h_GUID_8c30e762_d7e7_40c5_9308_b9bc118959fd