Pie Noon
An open source project by FPL.
 All Classes Pages
touchscreen_controller.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef TOUCHSCREEN_CONTROLLER_H_
16 #define TOUCHSCREEN_CONTROLLER_H_
17 
18 #include "audio_config_generated.h"
19 #include "character_state_machine_def_generated.h"
20 #include "config_generated.h"
21 #include "controller.h"
22 #include "fplbase/input.h"
23 #include "game_state.h"
24 #include "pie_noon_common_generated.h"
25 #include "player_controller.h"
26 #include "precompiled.h"
27 #include "timeline_generated.h"
28 
29 namespace fpl {
30 namespace pie_noon {
31 
32 // A TouchscreenController tracks the current state of a human player's logical
33 // inputs. It is responsible for polling the touchscreen for the current state
34 // of the physical inputs that map to logical actions.
36  public:
38 
39  // Set up a controller using the given input system and control scheme.
40  // The input_system and scheme pointers are unowned and must outlive this
41  // object.
42  void Initialize(fplbase::InputSystem* input_system, vec2 window_size,
43  const Config* config, const GameState* game_state);
44 
45  // Map the input from the physical inputs to logical game inputs.
46  virtual void AdvanceFrame(WorldTime delta_time);
47 
48  private:
49  mathfu::vec3 CameraRayFromScreenCoord(const mathfu::vec2i& screen) const;
50  CharacterId CharacterIdFromRay(const mathfu::vec3& ray,
51  const mathfu::vec3& position) const;
52 
53  // A pointer to the object to query for the current input state.
54  fplbase::InputSystem* input_system_;
55  vec2 window_size_;
56  const Config* config_;
57  const GameState* game_state_;
58  WorldTime deflect_time_remaining_;
59 };
60 
61 } // pie_noon
62 } // fpl
63 
64 #endif // TOUCHSCREEN_CONTROLLER_H_
Definition: touchscreen_controller.h:35
Definition: game_state.h:56
Definition: controller.h:26