FreeStick  0.3
Cross Platform Open Sorce Joystick Lib
FSMultJoystickDeviceManger.h
Go to the documentation of this file.
1 /**************************************************************************
2  Created by Alan Uthoff on 10/8/2013
3  Copyright (C) 2015.
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 #pragma once
30 #include "common/FSTypes.h"
31 #include <memory>
32 #include <functional>
33 
35 typedef std::unique_ptr<managerType> unique_ptr_of_managers;
36 
37 namespace freestick {
38 
40  {
41  public:
43  virtual ~FSMultJoystickDeviceManger() override;
44  virtual void update();
45  void init( );
46  elementID getNextID() override;
47  const FSUSBJoystick * getUSBJoystickDevice(idNumber deviceID){return static_cast<const FSUSBJoystick *>(getDevice(deviceID));}
49  void ListenForAllJoysticksForEventTypes(unsigned int eventFlags,IFSJoystickListener & listener);
50  void UnListenForAllJoysticksForEventTypes(unsigned int eventFlags,IFSJoystickListener & listener);
51 
52  //add or replace mapping
53  //void addMappingForButton(unsigned int vendorUSBID,unsigned int productUSBID,unsigned int controlUSBID,FSDeviceInput deviceInput);
54  void addMapping(vendorIDType vendorUSBID,productIDType productUSBID, idNumber controlUSBID,FSDeviceInput deviceInput);
55  void addMapping(idNumber deviceID, idNumber controlID,FSDeviceInput deviceInput);
56  //FSUSBElementInfoMap lookUpDeviceInputFromID(unsigned int deviceID, unsigned int controlID);
59  FSUSBElementInfoMap infoMapForInputType(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor );
60 
62  bool doesElementHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID , idNumber elementID, FSDeviceInput inputToLookFor );
63  bool doesDeviceHaveDeviceInput(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor);
64  bool doesDeviceHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor,physicalValueNumber value );
66 
68 
69  protected:
71  std::vector<unique_ptr_of_managers> managers;
72  bool DoesDeviceHaveInput(std::function<bool(unique_ptr_of_managers&)>const &func);
73  };
74 
75 }
Definition: IFSJoystickListener.h:34
bool doesDeviceHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID, FSDeviceInput inputToLookFor, physicalValueNumber value)
Definition: FSMultJoystickDeviceManger.cpp:165
FSMultJoystickDeviceManger()
Definition: FSMultJoystickDeviceManger.cpp:20
virtual void update()
Definition: FSMultJoystickDeviceManger.cpp:52
bool _listeningForEvents
Definition: FSMultJoystickDeviceManger.h:70
FSUSBElementInfoMap lookUpDeviceInputFromUSBID(vendorIDType vendorUSBID, productIDType productUSBID, idNumber controlID, minMaxNumber min, minMaxNumber max, physicalValueNumber value)
Definition: FSMultJoystickDeviceManger.cpp:118
Definition: FSMultJoystickDeviceManger.h:39
freestick::FSUpdatableJoystickDeviceManager managerType
Definition: FSMultJoystickDeviceManger.h:34
virtual ~FSMultJoystickDeviceManger() override
Definition: FSMultJoystickDeviceManger.cpp:27
void addMapping(vendorIDType vendorUSBID, productIDType productUSBID, idNumber controlUSBID, FSDeviceInput deviceInput)
Definition: FSMultJoystickDeviceManger.cpp:93
elementID getNextID() override
Definition: FSMultJoystickDeviceManger.cpp:87
bool DoesDeviceHaveInput(std::function< bool(unique_ptr_of_managers &)>const &func)
Definition: FSMultJoystickDeviceManger.cpp:5
uint32_t idNumber
Definition: FSTypes.h:33
Definition: IFSDeviceIDCreator.h:30
Definition: FSUSBDeviceManager.h:82
const FSUSBJoystick * getUSBJoystickDevice(idNumber deviceID)
Definition: FSMultJoystickDeviceManger.h:47
std::vector< unique_ptr_of_managers > managers
Definition: FSMultJoystickDeviceManger.h:71
std::unique_ptr< managerType > unique_ptr_of_managers
Definition: FSMultJoystickDeviceManger.h:35
const FSBaseDevice * getDevice(idNumber deviceID)
Definition: FSMultJoystickDeviceManger.cpp:58
uint32_t productIDType
Definition: FSTypes.h:39
Definition: FSBaseDevice.h:32
Definition: FSUSBJoystick.h:36
uint64_t deviceID
Definition: FSTypes.h:37
uint32_t vendorIDType
Definition: FSTypes.h:38
FSUSBElementInfoMap lookUpDeviceInputFromID(idNumber deviceID, idNumber controlID, minMaxNumber min, minMaxNumber max, physicalValueNumber value)
Definition: FSMultJoystickDeviceManger.cpp:108
Definition: FSUpdatableJoystickDeviceManager.h:32
void UnListenForAllJoysticksForEventTypes(unsigned int eventFlags, IFSJoystickListener &listener)
Definition: FSMultJoystickDeviceManger.cpp:38
unsigned int elementID
Definition: FSTypes.h:36
bool doesElementHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID, idNumber elementID, FSDeviceInput inputToLookFor)
Definition: FSMultJoystickDeviceManger.cpp:153
FSUSBElementInfoMap infoMapForInputType(vendorIDType vendorUSBID, productIDType productUSBID, FSDeviceInput inputToLookFor)
Definition: FSMultJoystickDeviceManger.cpp:133
Definition: FSBaseDevice.h:35
bool doesDeviceHaveDeviceInput(idNumber deviceID, FSDeviceInput inputToLookFor)
Definition: FSMultJoystickDeviceManger.cpp:147
managerType * findManagerForDevice(idNumber deviceID)
Definition: FSMultJoystickDeviceManger.cpp:72
int32_t physicalValueNumber
Definition: FSTypes.h:35
void ListenForAllJoysticksForEventTypes(unsigned int eventFlags, IFSJoystickListener &listener)
Definition: FSMultJoystickDeviceManger.cpp:32
FSDeviceInput
Definition: IFSDevice.h:31
void init()
Definition: FSMultJoystickDeviceManger.cpp:45
int32_t minMaxNumber
Definition: FSTypes.h:34