VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
TouchNavigationRouter.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 TOUCHNAVIGATIONROUTER_H
18 #define TOUCHNAVIGATIONROUTER_H
19 
20 #include <vector>
21 #include "ControllerEvent.h"
22 #include "ControllerFactory.h"
23 #include "InputRouter.h"
24 #include "JoystickAxisScheme.h"
25 #include "KeyScheme.h"
26 
33 public:
40  public:
47  const KeyScheme& keyScheme,
48  const JoystickAxisScheme& joystickAxisScheme
49  );
50 
51  virtual VirtualController* createNewController(int deviceId) const override;
52 
53  virtual bool intersects(const ControllerFactory& otherFactory) const override;
61  bool intersects(const TouchNavigationControllerFactory& otherFactory) const;
62 
63  virtual bool handlesControllerEvent(const ControllerEvent* event) const override;
64 
68  static std::set<KeyCode> sValidKeyCodes;
72  static std::set<JoystickAxisCode> sValidJoystickAxisCodes;
73 
74  private:
75  KeyScheme mKeyScheme;
76  JoystickAxisScheme mJoystickAxisScheme;
77  };
78 
85 
90 
91 private:
96 
97  // Singleton instance of the TouchNavigationRouter
98  static TouchNavigationRouter* sInstance;
99 };
100 
101 #endif // TOUCHNAVIGATIONROUTER_H
Software represention and state capable of describing almost all physical controllers.
Definition: VirtualController.h:36
Base interface for constructing virtual controllers from a deviceId.
Definition: ControllerFactory.h:34
bool addTouchNavigationControllerFactory(const TouchNavigationControllerFactory &factory)
Adds the specified TouchNavigationControllerFactory to the list of factories to route by...
Routes gamepad-related ControllerEvents according to inherent TouchNativationControllerFactory specif...
Definition: TouchNavigationRouter.h:32
virtual bool intersects(const ControllerFactory &otherFactory) const override
Returns whether or not this ControllerFactory intersects (i.e. overlaps input schemes) with the speci...
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
virtual VirtualController * createNewController(int deviceId) const override
Returns a new VirtualController for the specified deviceId.
TouchNavigationControllerFactory(const KeyScheme &keyScheme, const JoystickAxisScheme &joystickAxisScheme)
Constructs a TouchNavigationControllerFactory from input schemes.
Represents a scheme mapping keyboard input to output actions.
Definition: KeyScheme.h:28
virtual bool handlesControllerEvent(const ControllerEvent *event) const override
Returns whether or not this ControllerFactory can process the specified event.
static TouchNavigationRouter * getInstance()
Returns singleton instance of TouchNavigationRouter.
Factory for constructing VirtualControllers to represent touch navigation devices as controllers...
Definition: TouchNavigationRouter.h:39
Routes ControllerEvents according to inherent ControllerFactory specifications.
Definition: InputRouter.h:40
static std::set< KeyCode > sValidKeyCodes
Set of KeyCodes valid as input on a touch navigation device.
Definition: TouchNavigationRouter.h:68
static std::set< JoystickAxisCode > sValidJoystickAxisCodes
Set of JoystickAxisCodes valid as input on a touch navigation device.
Definition: TouchNavigationRouter.h:72