VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
KeyboardRouter.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 KEYBOARDROUTER_H
18 #define KEYBOARDROUTER_H
19 
20 #include <vector>
21 #include "ControllerEvent.h"
22 #include "ControllerFactory.h"
23 #include "InputRouter.h"
24 #include "KeyScheme.h"
25 
31 class KeyboardRouter : public InputRouter {
32 public:
39  public:
45  const KeyScheme& keyScheme
46  );
47 
48  virtual bool intersects(const ControllerFactory& otherFactory) const override;
56  bool intersects(const KeyboardControllerFactory& otherFactory) const;
57 
58  virtual bool handlesControllerEvent(const ControllerEvent* event) const override;
59 
60  virtual VirtualController* createNewController(int deviceId) const override;
61 
62  private:
63  KeyScheme mKeyScheme;
64  };
65 
71 
75  static KeyboardRouter* getInstance();
76 
77 private:
82 
83  // Singleton instance of the KeyboardRouter
84  static KeyboardRouter* sInstance;
85 };
86 
87 #endif // KEYBOARDROUTER_H
Factory for constructing VirtualControllers to represent keyboard devices as controllers.
Definition: KeyboardRouter.h:38
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
virtual VirtualController * createNewController(int deviceId) const override
Returns a new VirtualController for the specified deviceId.
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 ControllerFactory can process the specified event.
KeyboardControllerFactory(const KeyScheme &keyScheme)
Constructs a KeyboardControllerFactory from input schemes.
Represents a scheme mapping keyboard input to output actions.
Definition: KeyScheme.h:28
Routes ControllerEvents according to inherent ControllerFactory specifications.
Definition: InputRouter.h:40
bool addKeyboardControllerFactory(const KeyboardControllerFactory &factory)
Adds the specified KeyboardControllerFactory to the list of factories to route by.
virtual bool intersects(const ControllerFactory &otherFactory) const override
Returns whether or not this ControllerFactory intersects (i.e. overlaps input schemes) with the speci...
Routes Keyboard-related ControllerEvents according to inherent KeyboardControllerFactory specificatio...
Definition: KeyboardRouter.h:31
static KeyboardRouter * getInstance()
Returns the singleton instance of the KeyboardRouter.