Gamepad.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   Gamepad.h
00004 Content     :   Cross platform Gamepad interface.
00005 Created     :   May 6, 2013
00006 Authors     :   Lee Cooper
00007 
00008 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00009 
00010 Licensed under the Apache License, Version 2.0 (the "License");
00011 you may not use this file except in compliance with the License.
00012 You may obtain a copy of the License at
00013 
00014 http://www.apache.org/licenses/LICENSE-2.0
00015 
00016 Unless required by applicable law or agreed to in writing, software
00017 distributed under the License is distributed on an "AS IS" BASIS,
00018 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 See the License for the specific language governing permissions and
00020 limitations under the License.
00021 
00022 ************************************************************************************/
00023 
00024 #ifndef OVR_Gamepad_h
00025 #define OVR_Gamepad_h
00026 
00027 #include <OVR.h>
00028 
00029 namespace OVR { namespace Platform {
00030 
00031 // Buttons on a typical gamepad controller.
00032 enum GamepadButtons
00033 {
00034     Gamepad_A               = 0x1000,
00035     Gamepad_CROSS           = 0x1000,
00036     Gamepad_B               = 0x2000,
00037     Gamepad_CIRCLE          = 0x2000,
00038     Gamepad_X               = 0x4000,
00039     Gamepad_SQUARE          = 0x4000,
00040     Gamepad_Y               = 0x8000,
00041     Gamepad_TRIANGLE        = 0x8000,
00042     Gamepad_Up              = 0x0001,
00043     Gamepad_Down            = 0x0002,
00044     Gamepad_Left            = 0x0004,
00045     Gamepad_Right           = 0x0008,
00046     Gamepad_Start           = 0x0010,
00047     Gamepad_Back            = 0x0020,
00048     Gamepad_LStick          = 0x0040,
00049     Gamepad_RStick          = 0x0080,
00050     Gamepad_L1              = 0x0100,
00051     Gamepad_R1              = 0x0200,
00052 };
00053 
00054 //-------------------------------------------------------------------------------------
00055 // ***** GamepadState
00056 
00057 // Describes the state of the controller buttons and analog inputs.
00058 struct GamepadState
00059 {
00060     UInt32  Buttons;            // Bitfield representing button state.
00061     float   LX;                 // Left stick X axis [-1,1]
00062     float   LY;                 // Left stick Y axis [-1,1]
00063     float   RX;                 // Right stick X axis [-1,1]
00064     float   RY;                 // Right stick Y axis [-1,1]
00065     float   LT;                 // Left trigger [0,1]
00066     float   RT;                 // Right trigger [0,1]
00067 
00068     GamepadState() : Buttons(0), LX(0), LY(0), RX(0), RY(0), LT(0), RT(0) {}
00069 
00070     bool operator==(const GamepadState& b) const
00071     {
00072         return Buttons == b.Buttons && LX == b.LX && LY == b.LY && RX == b.RX && RY == b.RY && LT == b.LT && RT == b.RT;
00073     }
00074     bool operator!=(const GamepadState& b) const
00075     {
00076         return !(*this == b);
00077     }
00078         void Debug()
00079         {
00080                 OVR_DEBUG_LOG(("Buttons:0x%4x LX:%.2f LY:%.2f RX:%.2f RY:%.2f LT:%.2f RT:%.2f", Buttons, LX, LY, RX, RY, LT, RT));
00081         }
00082 };
00083 
00084 //-------------------------------------------------------------------------------------
00085 // ***** GamepadManager
00086 
00087 // GamepadManager provides a cross platform interface for accessing gamepad controller
00088 // state.
00089 class GamepadManager : public RefCountBase<GamepadManager>
00090 {
00091 public:
00092 
00093     // Get the number of connected gamepads.
00094     virtual UInt32  GetGamepadCount() = 0;
00095 
00096     // Get the state of the gamepad with a given index.
00097     virtual bool    GetGamepadState(UInt32 index, GamepadState* pState) = 0;
00098 };
00099 
00100 }} // OVR::Platform
00101 
00102 #endif // OVR_Gamepad_h


oculus_sdk
Author(s): Tully Foote
autogenerated on Thu Jun 6 2019 20:13:48