FreeStick  0.3
Cross Platform Open Sorce Joystick Lib
FSWindowsJoystickDeviceManager.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
28 //direct input
31 
32 //Xinput
35 
38 #include "common/FSTypes.h"
39 #include <memory>
40 #include <functional>
41 
43 typedef std::unique_ptr<managerType> unique_ptr_of_managers;
44 
45 namespace freestick {
46 
48  {
49  public:
52  void update();
53  void init( );
55  const FSUSBJoystick * getUSBJoystickDevice(idNumber deviceID){return static_cast<const FSUSBJoystick *>(getDevice(deviceID));}
57  void ListenForAllJoysticksForEventTypes(unsigned int eventFlags,IFSJoystickListener & listener);
58  void UnListenForAllJoysticksForEventTypes(unsigned int eventFlags,IFSJoystickListener & listener);
59 
60  //add or replace mapping
61  //void addMappingForButton(unsigned int vendorUSBID,unsigned int productUSBID,unsigned int controlUSBID,FSDeviceInput deviceInput);
62  void addMapping(vendorIDType vendorUSBID,productIDType productUSBID, idNumber controlUSBID,FSDeviceInput deviceInput);
63  void addMapping(idNumber deviceID, idNumber controlID,FSDeviceInput deviceInput);
64  //FSUSBElementInfoMap lookUpDeviceInputFromID(unsigned int deviceID, unsigned int controlID);
67  FSUSBElementInfoMap infoMapForInputType(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor );
68 
70  bool doesElementHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID , idNumber elementID, FSDeviceInput inputToLookFor );
71  bool doesDeviceHaveDeviceInput(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor);
72  bool doesDeviceHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID ,FSDeviceInput inputToLookFor,physicalValueNumber value );
74 
76 
77  private:
78  bool _listeningForEvents;
79  std::vector<unique_ptr_of_managers> managers;
80  bool DoesDeviceHaveInput(std::function<bool(unique_ptr_of_managers&)>const &func);
81 
82 
83 
84  };
85 
86 }
Definition: IFSJoystickListener.h:34
FSUSBElementInfoMap infoMapForInputType(vendorIDType vendorUSBID, productIDType productUSBID, FSDeviceInput inputToLookFor)
Definition: FSWindowsJoystickDeviceManager.cpp:133
bool doesDeviceHaveDeviceInput(idNumber deviceID, FSDeviceInput inputToLookFor)
Definition: FSWindowsJoystickDeviceManager.cpp:147
void UnListenForAllJoysticksForEventTypes(unsigned int eventFlags, IFSJoystickListener &listener)
Definition: FSWindowsJoystickDeviceManager.cpp:38
Definition: FSWindowsJoystickDeviceManager.h:47
bool doesElementHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID, idNumber elementID, FSDeviceInput inputToLookFor)
Definition: FSWindowsJoystickDeviceManager.cpp:153
void init()
Definition: FSWindowsJoystickDeviceManager.cpp:45
bool doesDeviceHaveDeviceInputForValue(vendorIDType vendorUSBID, productIDType productUSBID, FSDeviceInput inputToLookFor, physicalValueNumber value)
Definition: FSWindowsJoystickDeviceManager.cpp:165
const FSUSBJoystick * getUSBJoystickDevice(idNumber deviceID)
Definition: FSWindowsJoystickDeviceManager.h:55
freestick::FSUpdatableJoystickDeviceManager managerType
Definition: FSWindowsJoystickDeviceManager.h:42
uint32_t idNumber
Definition: FSTypes.h:33
FSUSBElementInfoMap lookUpDeviceInputFromID(idNumber deviceID, idNumber controlID, minMaxNumber min, minMaxNumber max, physicalValueNumber value)
Definition: FSWindowsJoystickDeviceManager.cpp:108
Definition: IFSDeviceIDCreator.h:30
virtual ~FSWindowsJoystickDeviceManager()
Definition: FSWindowsJoystickDeviceManager.cpp:27
Definition: FSUSBDeviceManager.h:82
void addMapping(vendorIDType vendorUSBID, productIDType productUSBID, idNumber controlUSBID, FSDeviceInput deviceInput)
Definition: FSWindowsJoystickDeviceManager.cpp:93
const FSBaseDevice * getDevice(idNumber deviceID)
Definition: FSWindowsJoystickDeviceManager.cpp:58
managerType * findManagerForDevice(idNumber deviceID)
Definition: FSWindowsJoystickDeviceManager.cpp:72
std::unique_ptr< managerType > unique_ptr_of_managers
Definition: FSMultJoystickDeviceManger.h:35
uint32_t productIDType
Definition: FSTypes.h:39
Definition: FSBaseDevice.h:32
Definition: FSUSBJoystick.h:36
uint64_t deviceID
Definition: FSTypes.h:37
void ListenForAllJoysticksForEventTypes(unsigned int eventFlags, IFSJoystickListener &listener)
Definition: FSWindowsJoystickDeviceManager.cpp:32
std::unique_ptr< managerType > unique_ptr_of_managers
Definition: FSWindowsJoystickDeviceManager.h:43
elementID getNextID()
Definition: FSWindowsJoystickDeviceManager.cpp:87
uint32_t vendorIDType
Definition: FSTypes.h:38
FSUSBElementInfoMap lookUpDeviceInputFromUSBID(vendorIDType vendorUSBID, productIDType productUSBID, idNumber controlID, minMaxNumber min, minMaxNumber max, physicalValueNumber value)
Definition: FSWindowsJoystickDeviceManager.cpp:118
Definition: FSUpdatableJoystickDeviceManager.h:32
unsigned int elementID
Definition: FSTypes.h:36
void update()
Definition: FSWindowsJoystickDeviceManager.cpp:52
Definition: FSBaseDevice.h:35
int32_t physicalValueNumber
Definition: FSTypes.h:35
FSWindowsJoystickDeviceManager()
Definition: FSWindowsJoystickDeviceManager.cpp:20
FSDeviceInput
Definition: IFSDevice.h:31
int32_t minMaxNumber
Definition: FSTypes.h:34