VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
TriggerAxisScheme.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 TRIGGERAXISSCHEME_H
18 #define TRIGGERAXISSCHEME_H
19 
20 #include "ControllerEvent.h"
21 #include "InputScheme.h"
22 #include "TriggerAxisCodes.h"
23 
28 class TriggerAxisScheme : public InputScheme<TriggerAxisCode> {
29 public:
34 
40  : InputScheme<TriggerAxisCode>(scheme) { }
41 
46  virtual bool handlesControllerEvent(const ControllerEvent* event) const override {
48  for (const auto& triggerStatePair : event->getTriggerAxisStates()) {
49  // Will handle if the event has data for a mapped trigger axis
50  if (InputScheme<TriggerAxisCode>::hasActionFor(triggerStatePair.first)) {
51  return true;
52  }
53  }
54  }
55  return false;
56  }
57 };
58 
59 #endif // TRIGGERAXISSCHEME_H
const TriggerAxisStates & getTriggerAxisStates() const
Returns trigger axis value changes for all trigger axes contained in this event.
Definition: ControllerEvent.h:146
Represents a scheme mapping input trigger axes to output actions.
Definition: TriggerAxisScheme.h:28
bool empty() const
Returns whether or not the InputScheme contains any mappings.
Definition: InputScheme.h:59
bool hasTriggerAxisInfo() const
Returns whether or not this ControllerEvent contains any axis information for the specified trigger a...
Definition: ControllerEvent.h:130
A platform independent event generated by controller device.
Definition: ControllerEvent.h:34
virtual bool handlesControllerEvent(const ControllerEvent *event) const override
Returns whether or not this TriggerAxisScheme would handle event.
Definition: TriggerAxisScheme.h:46
TriggerAxisScheme(const typename InputScheme< TriggerAxisCode >::Map &scheme)
Constructs a TriggerAxisScheme from the specified scheme.
Definition: TriggerAxisScheme.h:39
TriggerAxisScheme()
Constructs an empty TriggerAxisScheme.
Definition: TriggerAxisScheme.h:33
TriggerAxisCode
Codes that uniquely identify each trigger axis, independent of platform.
Definition: TriggerAxisCodes.h:24
Represents a scheme mapping generic input "events" to output "actions".
Definition: InputScheme.h:28