Panda3D
clientAnalogDevice.h
1 // Filename: clientAnalogDevice.h
2 // Created by: drose (26Jan01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CLIENTANALOGDEVICE_H
16 #define CLIENTANALOGDEVICE_H
17 
18 #include "pandabase.h"
19 
20 #include "clientDevice.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ClientAnalogDevice
24 // Description : A device, attached to the ClientBase by a
25 // AnalogNode, that records the data from a single
26 // named analog device. The named device can contain
27 // any number of analog controls, numbered in
28 // sequence beginning at zero.
29 //
30 // Each analog control returns a value ranging from -1
31 // to 1, reflecting the current position of the control
32 // within its total range of motion.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_DEVICE ClientAnalogDevice : public ClientDevice {
35 protected:
36  INLINE ClientAnalogDevice(ClientBase *client, const string &device_name);
37 
38 public:
39  INLINE int get_num_controls() const;
40 
41  INLINE void set_control_state(int index, double state);
42  INLINE double get_control_state(int index) const;
43  INLINE bool is_control_known(int index) const;
44 
45  virtual void write(ostream &out, int indent_level = 0) const;
46  void write_controls(ostream &out, int indent_level) const;
47 
48 private:
49  void ensure_control_index(int index);
50 
51 protected:
52  class AnalogState {
53  public:
54  INLINE AnalogState();
55 
56  double _state;
57  bool _known;
58  };
59 
61  Controls _controls;
62 
63 
64 public:
65  static TypeHandle get_class_type() {
66  return _type_handle;
67  }
68  static void init_type() {
69  ClientDevice::init_type();
70  register_type(_type_handle, "ClientAnalogDevice",
71  ClientDevice::get_class_type());
72  }
73  virtual TypeHandle get_type() const {
74  return get_class_type();
75  }
76  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
77 
78 private:
79  static TypeHandle _type_handle;
80 };
81 
82 #include "clientAnalogDevice.I"
83 
84 #endif
A device, attached to the ClientBase by a AnalogNode, that records the data from a single named analo...
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
Definition: clientBase.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Any of a number of different devices that might be attached to a ClientBase, including trackers...
Definition: clientDevice.h:35