FreeStick  0.3
Cross Platform Open Sorce Joystick Lib
IFSEvent.h
Go to the documentation of this file.
1 /**************************************************************************
2 Created by Alan Uthoff on 10/8/2013
3 Copyright (C) 2013.
4 
5 This Code is free software; you can redistribute it and/or
6 modify it under the terms of the zlib/libpng License as published
7 by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9 This software is provided 'as-is', without any express or implied warranty.
10 
11 In no event will the authors be held liable for any damages arising from the use of this software.
12 
13 Permission is granted to anyone to use this software for any purpose,
14 including commercial applications, and to alter it and redistribute
15 it freely, subject to the following restrictions:
16 
17 1. The origin of this software must not be misrepresented;
18 you must not claim that you wrote the original software.
19 If you use this software in a product, an acknowledgment
20 in the product documentation would be appreciated but is not required.
21 
22 2. Altered source versions must be plainly marked as such,
23 and must not be misrepresented as being the original software.
24 
25 3. This notice may not be removed or altered from any source distribution.
26 **************************************************************************/
27 
28 #pragma once
29 #include "IFSDevice.h"
30 #include <assert.h>
31 #include <functional>
32 
33 
34 namespace freestick
35 {
36  typedef enum
37  {
41  FS_AXIS_EVENT = 1<<4,
45 
46  typedef enum
47  {
52 
53  } FSEventAction;
54 
55  class IFSEvent
56  {
57  public:
58  virtual unsigned int getTimeStamp() = 0;
59  virtual FreeStickEventType getEventType() = 0;
60  virtual FSEventAction getEventAction() = 0;
62  {
63  if(Button0 <= inputType && inputType < LastButton )
64  {
65  return FS_BUTTON_EVENT;
66  }
67  else if(XAxis <= inputType && inputType < LastAxis )
68  {
69  return FS_AXIS_EVENT;
70  }
71  else if(DPadUp <= inputType && inputType <= DPadRight)
72  {
73  return FS_BUTTON_EVENT;
74  }
75  else if(Trigger1 <= inputType && inputType < LastTrigger)
76  {
77  return FS_TRIGGER_EVENT;
78  }
79  //assert(false);
80  return FS_LAST_EVENT;
81  }
82  };
83 
84 }
85 
86 
87 namespace std
88 {
89  template<>
91  std::size_t operator()(const freestick::FreeStickEventType &pt) const {
92  return static_cast<unsigned int>(pt);
93  }
94  };
95 
96  template<>
97  struct hash<freestick::FSEventAction>{
98  std::size_t operator()(const freestick::FSEventAction &pt) const {
99  return static_cast<unsigned int>(pt);
100  }
101  };
102 }
Definition: IFSDevice.h:33
static FreeStickEventType getEventFromInputType(FSDeviceInput inputType)
Definition: IFSEvent.h:61
Definition: IFSEvent.h:43
Definition: IFSEvent.h:40
Definition: IFSEvent.h:51
Definition: IFSDevice.h:87
FSEventAction
Definition: IFSEvent.h:46
Definition: IFSEvent.h:87
virtual FSEventAction getEventAction()=0
Definition: IFSDevice.h:46
Definition: IFSEvent.h:55
Definition: IFSDevice.h:85
FreeStickEventType
Definition: IFSEvent.h:36
std::size_t operator()(const freestick::FSEventAction &pt) const
Definition: IFSEvent.h:98
Definition: IFSDevice.h:39
Definition: IFSDevice.h:84
Definition: IFSEvent.h:48
Definition: FSBaseDevice.h:32
Definition: IFSDevice.h:40
virtual FreeStickEventType getEventType()=0
Definition: IFSDevice.h:43
Definition: IFSEvent.h:49
Definition: IFSEvent.h:42
virtual unsigned int getTimeStamp()=0
std::size_t operator()(const freestick::FreeStickEventType &pt) const
Definition: IFSEvent.h:91
Definition: IFSEvent.h:41
FSDeviceInput
Definition: IFSDevice.h:31
Definition: IFSEvent.h:50