VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
JoystickAxisScheme.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef JOYSTICKAXISSCHEME_H
18 #define JOYSTICKAXISSCHEME_H
19 
20 #include "ControllerEvent.h"
21 #include "InputScheme.h"
22 #include "JoystickAxisCodes.h"
23 
28 class JoystickAxisScheme : public InputScheme<JoystickAxisCode> {
29 public:
34 
40  : InputScheme<JoystickAxisCode>(scheme) { }
41 
46  virtual bool handlesControllerEvent(const ControllerEvent* event) const override {
48  for (const auto& joystickStatePair : event->getJoystickAxisStates()) {
49  // Will handle if the event has joystick data for a mapped joystick axis
50  if (InputScheme<JoystickAxisCode>::hasActionFor(joystickStatePair.first)) {
51  return true;
52  }
53  }
54  }
55  return false;
56  }
57 };
58 
59 #endif // JOYSTICKAXISSCHEME_H
bool empty() const
Returns whether or not the InputScheme contains any mappings.
Definition: InputScheme.h:59
const JoystickAxisStates & getJoystickAxisStates() const
Returns joystick axis value changes for all joystick axes contained in this event.
Definition: ControllerEvent.h:118
virtual bool handlesControllerEvent(const ControllerEvent *event) const override
Returns whether or not this JoystickAxisScheme would handle event.
Definition: JoystickAxisScheme.h:46
A platform independent event generated by controller device.
Definition: ControllerEvent.h:34
Represents a scheme mapping input joystick axes to output actions.
Definition: JoystickAxisScheme.h:28
bool hasJoystickAxisInfo() const
Returns whether or not this ControllerEvent contains any axis information for the specified joystick ...
Definition: ControllerEvent.h:102
JoystickAxisScheme()
Constructs an empty JoystickAxisScheme.
Definition: JoystickAxisScheme.h:33
JoystickAxisCode
Codes that uniquely identify each joystick axis, independent of platform.
Definition: JoystickAxisCodes.h:24
JoystickAxisScheme(const typename InputScheme< JoystickAxisCode >::Map &scheme)
Constructs a JoystickAxisScheme from the specified scheme.
Definition: JoystickAxisScheme.h:39
Represents a scheme mapping generic input "events" to output "actions".
Definition: InputScheme.h:28