Giter Site home page Giter Site logo

jkuhlmann / gainput Goto Github PK

View Code? Open in Web Editor NEW
846.0 45.0 103.0 2.88 MB

Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch

Home Page: http://gainput.johanneskuhlmann.de/

License: MIT License

C++ 88.10% Objective-C 0.15% Objective-C++ 6.27% C 0.27% CMake 0.96% Java 3.23% HTML 1.01%
unified-interface low-level gestures android android-ndk multi-touch linux windows ios input

gainput's People

Contributors

jkuhlmann avatar johan-ronnkvist avatar kdavison avatar zeyonaut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gainput's Issues

Reduce the amount of plattform specific code users have to write

Hi,
I recently got fed up with using the not very C++ish API OIS provides; then I found your lib and started liking the API much more (the lack of * in your example really gives one a feeling of memory safety).

However, when integrating gainput into my code I found that there was rather a lot of plattform specific code I had to write. I used your sample framework as a reference and got it working at some point,
but it seems to me, that a lot of code from the samples could simply be pulled into the main library, thereby saving the users of your lib a day of hassle.

Now of course there will be some platform specific code necessary to initialize gainput and assign it the correct window and so on. But even for that I could imagine that 80% of the cases could be solved in a generic way.
E.g. to initialize the library one could list the windows opened by the current process and simply attach to the first one.

gainputtest Visual Studio linker error

I use Visual studio 2015. Generate project by cmake -G 'Visual Studio 14'. Got error when build gainputtest target:
MSVCRT.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)

Programmatically trigger input events with custom platform

Hello! I am working with a custom platform that is not Linux, Windows, or Android, but I want to be able to use your event handlers with my custom platform so that objects listening for events in my software can react to gamepad events from the platform. This is what I mean in pseudocode:

if(custompaltforminput.isButtonDown(...))
{
map button in custom platform to user defined button
create event with user defined button name, coordinates, etc.
trigger event
}

Is this possible?

Make Error on Ubuntu

Hey! I have an error when running the make command in the build folder. I get an error that I should use C++ 11, But i'm unsure how to do this, I read you do it in the Makefile, but how?

from /home/thybe/Desktop/gainput/lib/source/gainput/GainputAllocator.cpp:2:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \

screenshot from 2018-03-14 19-30-29

gainputstatic has unresolved external symbols

building is no problem, but when it comes to using the .lib...

1>gainputstatic.lib(GainputInputDevicePad.obj) : error LNK2001: unresolved external symbol XInputGetState
1>gainputstatic.lib(GainputInputDevicePad.obj) : error LNK2001: unresolved external symbol XInputSetState
1>gainputstatic.lib(GainputInputRecording.obj) : error LNK2001: unresolved external symbol __imp_htonl
1>gainputstatic.lib(GainputInputRecording.obj) : error LNK2001: unresolved external symbol __imp_ntohl

Build Errors

When running 'waf build' I get:

    Build failed
     -> task in 'listenersample' failed (exit status 1):
            {task 49072224L: cxx SampleFramework.cpp -> SampleFramework.cpp.1.o}
    ['G:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\BIN\\amd64\\CL.exe',
    '-O2',
    '/IC:\\Users\\Travis\\Desktop\\Gainput\\build\\release\\lib\\include',
    '/IC:\\Users\\Travis\\Desktop\\Gainput\\lib\\include',
    '/IG:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\INCLUDE',
    '/IG:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\ATLMFC\\INCLUDE',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\shared',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\um',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\winrt',
    '/DGAINPUT_LIB_BUILD=1',
    '/DNDEBUG=1',
    '',
    '..\\..\\samples\\samplefw\\SampleFramework.cpp',
    '/FC',
    '/c',
    '/Fo',
    'samples\\samplefw\\SampleFramework.cpp.1.o']
     -> task in 'recordingsample' failed (exit status 1):
            {task 49072672L: cxx SampleFramework.cpp -> SampleFramework.cpp.1.o}
    ['G:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\BIN\\amd64\\CL.exe',
    '-O2',
    '/IC:\\Users\\Travis\\Desktop\\Gainput\\build\\release\\lib\\include',
    '/IC:\\Users\\Travis\\Desktop\\Gainput\\lib\\include',
    '/IG:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\INCLUDE',
    '/IG:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\ATLMFC\\INCLUDE',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\shared',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\um',
    '/IC:\\Program Files (x86)\\Windows Kits\\8.0\\include\\winrt',
    '/DGAINPUT_LIB_BUILD=1',
    '/DNDEBUG=1',
    '',
    '..\\..\\samples\\samplefw\\SampleFramework.cpp',
    '/FC',
    '/c',
    '/Fo',
    'samples\\samplefw\\SampleFramework.cpp.1.o']

If I re-run it without deleting any folders it passes but I am getting linker errors when I try to use it.

Is a Joystick supported?

So, I've properly set up gainput into my Qt project, at least mouse and keyboard inputs are recognized by gainput. Now I am trying to bring my joystick to life but without success so far. Now I am wondering, is it even supported in your library? Is a joystick considered a gamepad? :D
Your PadButtons enumerations start with 17, though I know my joystick buttons range from 0 - 11. Thanks in advance!

Deterministic input recording/playback

Hey, really liking the library.

I noticed you use a time stamp for recording and playing back input events. While this works for the most part, I don't believe it can achieve true deterministic reliability (for replaying a session). The framework using your library would have to update its state/input at a fixed frequency, which would replace time stamps with a simple integer counter.

I plan on making this change for my engine, but I figured I give you a heads up in case you also wanted to support an integer counter for playback. Don't know when I'll get around to it, but I'll submit a pull if you're interested.

Error in compilation for android

Hi,
When trying to compile the source for android using instructions in the Readme, I encountered the following error:

"/lib/source/gainput/touch/GainputInputDeviceTouch.cpp:32:6: error: 'variant' was not declared in this scope"

I got it compiled by changing the line:

InputDeviceTouch::InputDeviceTouch(InputManager& manager, DeviceId device, unsigned index, DeviceVariant /variant/) :

to:

InputDeviceTouch::InputDeviceTouch(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant) :

Am I right to uncomment variant?

integrate with SFML

Hi,
how can i integrate Gainput with SFML, SFML expose only the Window ID, and how to integrate gainput event handling with sfml event Handling ?

Receiving both WM_LBUTTONDOWN and WM_LBUTTONUP in same frame

If these two messages occur and are processed in the same frame (via InputManager::HandleMessage()), by the time InputManager::Update() is invoked it will essentially think nothing happened as the boolean has been flipped back already.

Under normal circumstances a "down" and "up" message for either mouse or keyboard usually doesn't get processed in the same frame. At least can't make it happen without the use of breakpoints in code.

However I have an ELO touchscreen hooked into a Windows 7 embedded image, which is responsible for sending these mouse events, to emulate mouse stuff for programs that don't understand touch. When I tap the screen the WM_LBUTTONDOWN and WM_LBUTTONUP get sent essentially at the same time (in order), and cause the input to be ignored as explained above.

I should be able to hack my way around this problem, but I figured I'd mention it here.

Program crashes when using InputManager

I have built and linked gainput.
As soon as I add line:
gainput::InputManager input;

I get no warnings/errors, but program crashed right after start. Even a minimal example crashed.

Any ideas would be appreciated!

EDIT: I am using msvc 2013 64 bit

Raw input not working

I want to work with raw input (windows) and thought this library was a good fit for me.
I tried to modify the listener example to use raw input but was not able to do so.

Steps to reproduce:

  1. Build the project for x64 (I used VS2017 Community)

  2. Change the following code snippet in listenersample.cpp:
    manager.CreateDevice<gainput::InputDeviceKeyboard>(gainput::InputDevice::DV_RAW);
    const gainput::DeviceId keyboardId = manager.CreateDevice<gainput::InputDeviceKeyboard>();
    manager.CreateDevice<gainput::InputDeviceMouse>(gainput::InputDevice::DV_RAW);
    const gainput::DeviceId mouseId = manager.CreateDevice<gainput::InputDeviceMouse>();
    manager.CreateDevice<gainput::InputDevicePad>();
    manager.CreateDevice<gainput::InputDevicePad>();
    manager.CreateDevice<gainput::InputDeviceTouch>();
    to
    const gainput::DeviceId keyboardId = manager.CreateDevice<gainput::InputDeviceKeyboard>(gainput::InputDevice::AutoIndex, gainput::InputDevice::DV_RAW);
    //manager.CreateDevice<gainput::InputDeviceKeyboard>();
    const gainput::DeviceId mouseId = manager.CreateDevice<gainput::InputDeviceMouse>(gainput::InputDevice::AutoIndex, gainput::InputDevice::DV_RAW);
    //manager.CreateDevice<gainput::InputDeviceMouse>();
    //manager.CreateDevice<gainput::InputDevicePad>();
    //manager.CreateDevice<gainput::InputDevicePad>();
    //manager.CreateDevice<gainput::InputDeviceTouch>();

  3. Run the sample project

  4. Observe that there is no mouse input being reported

Potential solution:

I believe that the problem lies in how the library gets the raw input data in GainputInputDeviceMouseWinRaw.h and GainputInputDeviceKeyboardWinRaw.h

For x64 dwSize variable must be 48 instead of 40. A better way would be to get the size needed from the system itself.

Check the revisions of this gist.

NOTE: I have used C++ 11 features (shared_ptr) for my modifications.

Kindly let me know if you need anything more from my side

Undefined reference errors when using inside a DLL

I am currently building a tiny game engine, and chose gainput for the input.
The engine gets compiled to a dll, which is then linked against and used by a little test game.
However, when i have the input system enabled (and link the dll against gainputstatic.a with -lgainputstatic). My library stops "working:" i get tons of undefined reference erros on the linking stage, which are not directly related to gainput, but are related to my engines internal classes and functions:
C:\Windows\system32\cmd.exe /C C:/TDM-GCC-64/bin/mingw32-make.exe -j8 SHELL=cmd.exe -e -f Makefile "----------Building project:[ cysslib_test - Debug_win64 ]----------" mingw32-make.exe[1]: Entering directory 'C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test' C:/TDM-GCC-64/bin/g++.exe -c "C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/MyGame.cpp" -g -pg -Wall -m64 -std=c++11 -lOpenCL -o ./bin/Debug/win64//src_MyGame.cpp.o -I. -I../cysslib/include -I./include C:/TDM-GCC-64/bin/g++.exe -c "C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp" -g -pg -Wall -m64 -std=c++11 -lOpenCL -o ./bin/Debug/win64//src_main.cpp.o -I. -I../cysslib/include -I./include C:/TDM-GCC-64/bin/g++.exe -o ./bin/Debug/win64//cysslib_test @"cysslib_test.txt" -L. -L./bin/Debug/win64/ -L../cysslib/bin/Debug/win64/ -lcysslib -pg -O0 ./bin/Debug/win64//src_main.cpp.o: In functionmain':
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:9: undefined reference to cyss::GameWindow::GameWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int)' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:10: undefined reference tocyss::SimpleRenderer::SimpleRenderer(unsigned int, unsigned int)'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:11: undefined reference to cyss::Texture2D::Texture2D(unsigned int, unsigned int, bool)' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:12: undefined reference tocyss::Texture2D::loadFile(std::_cxx11::basic_string<char, std::char_traits, std::allocator >)'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:13: undefined reference to cyss::GameWindow::show()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:14: undefined reference tocyss::GameWindow::shouldClose()'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:16: undefined reference to cyss::GameWindow::update()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:17: undefined reference tocyss::GameWindow::clear()'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:18: undefined reference to cyss::SimpleRenderer::reset()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:20: undefined reference tocyss::SimpleRenderer::drawTexture(cyss::Texture2D
, float, float, float, float)'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:22: undefined reference to cyss::GameWindow::swapBuffers()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:11: undefined reference tocyss::Texture2D::~Texture2D()'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:10: undefined reference to cyss::SimpleRenderer::~SimpleRenderer()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:9: undefined reference tocyss::GameWindow::~GameWindow()'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:11: undefined reference to cyss::Texture2D::~Texture2D()' C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:10: undefined reference tocyss::SimpleRenderer::~SimpleRenderer()'
C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test/src/main.cpp:9: undefined reference to cyss::GameWindow::~GameWindow()' collect2.exe: error: ld returned 1 exit status mingw32-make.exe[1]: *_\* [bin/Debug/win64//cysslib_test] Error 1 cysslib_test.mk:78: recipe for target 'bin/Debug/win64//cysslib_test' failed mingw32-make.exe[1]: Leaving directory 'C:/Users/Daniel Wanner/Documents/Projekte/C++/cysslib/cysslib_test' mingw32-make.exe: **\* [All] Error 2 Makefile:4: recipe for target 'All' failed ====18 errors, 0 warnings====

These undefined reference errors dont occur when not enabling the input system, and thus not linking against gainput.

does anyone used this for controlling your app through your smartphone?

hey, i have an app that uses OpenGL, and i want to control the camera through gestures on my smart phone.
for that I wanted to use the HTTP version inside tools.
unfortunately i can't get it to work, i tried running the dynamicSample which can turn on the DevSetHttp function which enables the software to work through the http, but nothing really happens when i connect with my phone, anyone has any ideas for me?

Thanks

Trouble building in Visual Studio 2015 for Xbox UWP x64 cocos2d-x app

Decided to give gainput a try after researching controller libraries that could be used with Cocos2d-x, based on some discussions and recommendations on their forums. However, I've been having some problems deploying anything to the Xbox with gainput added.

Basically, I have a cocos2d-x 3.15 Visual Studio solution for our game and I used cmake to generate the VS 2015 x64 gainput solution using the command cmake -G "Visual Studio 14 2015 Win64". I then added the "gainput" project to our cocos2d-x VS solution and set it as a build dependency.

I also needed to add the gainput\lib\include folder to "Additional Include Directories" and for the Linker, added gainput-d.lib to "Additional Dependencies" and added the lib\Debug output directory to "Additional Library Directories".

I now get source-code completion, and the sample gainput code from the basic example builds and everything links. However, when deploying to the Xbox, I get the error message "A dependent dll was not found.

I thought this was because in the AppX folder, the gainput-d.dll file was missing, however copying it there and re-deploying was unsuccessful. I used the Dependency Walker tool and it seems gaininput-d.dll needs kernel32.dll, user32.dll, xinput9_1_0.dll, ws2_32.dll, vcruntime140D.dll, and ucrtbased.dll.

This seemed strange because these look like win32 specific dependencies so I checked the preprocesser build flags for the "gainput" project and sure enough, they included WIN32 and _WINDOWS, which I don't think should be there for x64 builds.

Sorry for the long write-up but wanted to be detailed on exactly what was going on. Do you know of anyone who has been able to use your library for Xbox UWP x64 apps, or even Windows 10 UWP x64 apps? Building/running the samples worked fine for me, but those are simply win32 desktop builds, so it's not a fair comparison. I could very well be running an incorrect build configuration.

I'd like to try using the library on the Xbox for our game, any help on this would be greatly appreciated.

Thanks!
Mark

[iOS] Issue with touch pressure + Fix

I'm currently working on an app based on a GameViewCotnroller + Metalkit.
I have added the Gainputview as a subview to the MTKView but I have found an issue with the function initWithFrame of GainputView when trying to detect the iOS windows.
Coming from this line:

UIWindow* window = [UIApplication sharedApplication].keyWindow;

I have replaced it with:
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
And it now detects the window correctly.

Mingw64&MSYS2 : Erreur de compilation

CMakeFiles/gainput.dir/source/gainput/pad/GainputInputDevicePad.cpp.o:GainputInputDevicePad.cpp:(.text$_ZN
7gainput21InputDevicePadImplWin6UpdateEPNS_15InputDeltaStateE[_ZN7gainput21InputDevicePadImplWin6UpdateEPN
S_15InputDeltaStateE]+0x1e): undefined reference to XInputGetState' CMakeFiles/gainput.dir/source/gainput/pad/GainputInputDevicePad.cpp.o:GainputInputDevicePad.cpp:(.text$_ZN 7gainput21InputDevicePadImplWin7VibrateEff[_ZN7gainput21InputDevicePadImplWin7VibrateEff]+0xc6): undefined reference to XInputSetState'
CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecording.cpp.o:GainputInputRecording.cpp:(.tex
t$ZN7gainput6Stream4ReadIjEEyRT[ZN7gainput6Stream4ReadIjEEyRT]+0x3d): undefined reference to __imp_nt ohl' CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecording.cpp.o:GainputInputRecording.cpp:(.tex t$_ZN7gainput6Stream4ReadIfEEyRT_[_ZN7gainput6Stream4ReadIfEEyRT_]+0x3d): undefined reference to __imp_nt
ohl'
CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecording.cpp.o:GainputInputRecording.cpp:(.tex
t$ZN7gainput6Stream5WriteIjEEyRKT[ZN7gainput6Stream5WriteIjEEyRKT]+0x1b): undefined reference to __im p_htonl' CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecording.cpp.o:GainputInputRecording.cpp:(.tex t$_ZN7gainput6Stream5WriteIfEEyRKT_[_ZN7gainput6Stream5WriteIfEEyRKT_]+0x1b): undefined reference to __im
p_htonl'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [lib/CMakeFiles/gainput.dir/build.make:849: lib/msys-gainput-1.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:88: lib/CMakeFiles/gainput.dir/all] Error 2
make: *** [Makefile:128: all] Error 2

emscripten support

hi there.

Are there any plans to support emscripten? Meaning being able to compile a gainput app with the emcc compiler and have proper keyboard, mouse and gamepad support.

Windows build and multiple Joystick support?

It would be nice to have a section in readme for how to do Windows build. Also, it would be great to include a sample that shows how to select and use joystick if you have multiple ones. The reason this is important is because Unreal engine has a very poor support for game input devices, especially joysticks on Windows, and this library can really help bridge the gap.

Documentation Ambiguity

What exactly SetDisplaySize does?..

"It sets display size" -> why document the name of the method? rather document the reason of existence of that method. The current description tell no new about the method

1)Does it creates a window with a given size? In that case, how can we create a window with GL or DX context? (says for a game)

2)Does it let Gainput to know the size of your pre-existing window? wich one?

Build Issues: Widnows Server 2008 R2

Attempting to build gainput off of a Widnows Server 2008 R2 machine.

Build fails with the following error:

Project "Gainput\build\Project.sln" (1) is building "Gainput\build\lib\gainput.vcxproj.metaproj" (9) on node 1 (default targets).
Project "Gainput\build\lib\gainput.vcxproj.metaproj" (9) is building "Gainput\build\lib\gainput.vcxproj" (10) on node 1 (default targets).
PrepareForBuild:
Creating directory "gainput.dir\Debug".
InitializeBuildStatus:
Creating "gainput.dir\Debug\gainput.unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
Building Custom Rule gainput/lib/CMakeLists.txt
CMake does not need to re-run because Gainput\build\lib\CMakeFiles\generate.stamp is up-to-date.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /I"C:/Jenkins_Jobs/workspace/Gainput-Win/gainput-upstream/lib/include" /Zi /nologo /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D GAINPUT_LIB_DYNAMIC=1 /D "CMAKE_INTDIR="Debug"" /D gainput_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"gainput.dir\Debug" /Fd"gainput.dir\Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:queue ....\lib\source\gainput\builtin\GainputInputDeviceBuiltIn.cpp ....\lib\source\gainput\dev\GainputDev.cpp ....\lib\source\gainput\dev\GainputMemoryStream.cpp ....\lib\source\gainput\dev\GainputNetAddress.cpp ....\lib\source\gainput\dev\GainputNetConnection.cpp ....\lib\source\gainput\dev\GainputNetListener.cpp ....\lib\source\gainput\gainput.cpp ....\lib\source\gainput\GainputAllocator.cpp ....\lib\source\gainput\GainputInputDeltaState.cpp ....\lib\source\gainput\GainputInputDevice.cpp ....\lib\source\gainput\GainputInputManager.cpp ....\lib\source\gainput\GainputInputMap.cpp ....\lib\source\gainput\GainputInputState.cpp ....\lib\source\gainput\GainputMapFilters.cpp ....\lib\source\gainput\gestures\GainputButtonStickGesture.cpp ....\lib\source\gainput\gestures\GainputDoubleClickGesture.cpp ....\lib\source\gainput\gestures\GainputHoldGesture.cpp ....\lib\source\gainput\gestures\GainputPinchGesture.cpp ....\lib\source\gainput\gestures\GainputRotateGesture.cpp ....\lib\source\gainput\gestures\GainputSimultaneouslyDownGesture.cpp ....\lib\source\gainput\gestures\GainputTapGesture.cpp ....\lib\source\gainput\keyboard\GainputInputDeviceKeyboard.cpp ....\lib\source\gainput\keyboard\GainputInputDeviceKeyboardMac.cpp ....\lib\source\gainput\mouse\GainputInputDeviceMouse.cpp ....\lib\source\gainput\pad\GainputInputDevicePad.cpp ....\lib\source\gainput\pad\GainputInputDevicePadMac.cpp ....\lib\source\gainput\recorder\GainputInputPlayer.cpp ....\lib\source\gainput\recorder\GainputInputRecorder.cpp ....\lib\source\gainput\recorder\GainputInputRecording.cpp ....\lib\source\gainput\touch\GainputInputDeviceTouch.cpp
GainputInputDeviceBuiltIn.cpp
....\lib\source\gainput\builtin\GainputInputDeviceBuiltIn.cpp(118): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(188) : see declaration of 'strncpy'
GainputDev.cpp
GainputMemoryStream.cpp
GainputNetAddress.cpp
GainputNetConnection.cpp
GainputNetListener.cpp
gainput.cpp
GainputAllocator.cpp
GainputInputDeltaState.cpp
GainputInputDevice.cpp
GainputInputManager.cpp
GainputInputMap.cpp
....\lib\source\gainput\GainputInputMap.cpp(64): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
GainputInputState.cpp
GainputMapFilters.cpp
GainputButtonStickGesture.cpp
GainputDoubleClickGesture.cpp
GainputHoldGesture.cpp
GainputPinchGesture.cpp
GainputRotateGesture.cpp
GainputSimultaneouslyDownGesture.cpp
Generating Code...
Compiling...
GainputTapGesture.cpp
GainputInputDeviceKeyboard.cpp
....\lib\source\gainput\keyboard\GainputInputDeviceKeyboard.cpp(137): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(188) : see declaration of 'strncpy'
GainputInputDeviceKeyboardMac.cpp
GainputInputDeviceMouse.cpp
....\lib\source\gainput\mouse\GainputInputDeviceMouse.cpp(121): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(188) : see declaration of 'strncpy'
GainputInputDevicePad.cpp
....\lib\source\gainput\pad\GainputInputDevicePad.cpp(231): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(188) : see declaration of 'strncpy'
GainputInputDevicePadMac.cpp
GainputInputPlayer.cpp
GainputInputRecorder.cpp
GainputInputRecording.cpp
GainputInputDeviceTouch.cpp
....\lib\source\gainput\touch\GainputInputDeviceTouch.cpp(106): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [Gainput\build\lib\gainput.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(188) : see declaration of 'strncpy'
Generating Code...
ManifestResourceCompile:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"gainput.dir\Debug\gainput.dll.embed.manifest.res" gainput.dir\Debug\gainput_manifest.rc
Link:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"Gainput\build\lib\Debug\gainput.dll" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib Xinput9_1_0.lib ws2_32.lib /MANIFEST /ManifestFile:"gainput.dir\Debug\gainput.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:/Jenkins_Jobs/workspace/Gainput-Win/gainput-upstream/build/lib/Debug/gainput.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Jenkins_Jobs/workspace/Gainput-Win/gainput-upstream/build/lib/Debug/gainput.lib" /MACHINE:X86 /DLL gainput.dir\Debug\gainput.dll.embed.manifest.res
gainput.dir\Debug\GainputInputDeviceBuiltIn.obj
gainput.dir\Debug\GainputDev.obj
gainput.dir\Debug\GainputMemoryStream.obj
gainput.dir\Debug\GainputNetAddress.obj
gainput.dir\Debug\GainputNetConnection.obj
gainput.dir\Debug\GainputNetListener.obj
gainput.dir\Debug\gainput.obj
gainput.dir\Debug\GainputAllocator.obj
gainput.dir\Debug\GainputInputDeltaState.obj
gainput.dir\Debug\GainputInputDevice.obj
gainput.dir\Debug\GainputInputManager.obj
gainput.dir\Debug\GainputInputMap.obj
gainput.dir\Debug\GainputInputState.obj
gainput.dir\Debug\GainputMapFilters.obj
gainput.dir\Debug\GainputButtonStickGesture.obj
gainput.dir\Debug\GainputDoubleClickGesture.obj
gainput.dir\Debug\GainputHoldGesture.obj
gainput.dir\Debug\GainputPinchGesture.obj
gainput.dir\Debug\GainputRotateGesture.obj
gainput.dir\Debug\GainputSimultaneouslyDownGesture.obj
gainput.dir\Debug\GainputTapGesture.obj
gainput.dir\Debug\GainputInputDeviceKeyboard.obj
gainput.dir\Debug\GainputInputDeviceKeyboardMac.obj
gainput.dir\Debug\GainputInputDeviceMouse.obj
gainput.dir\Debug\GainputInputDevicePad.obj
gainput.dir\Debug\GainputInputDevicePadMac.obj
gainput.dir\Debug\GainputInputPlayer.obj
gainput.dir\Debug\GainputInputRecorder.obj
gainput.dir\Debug\GainputInputRecording.obj
gainput.dir\Debug\GainputInputDeviceTouch.obj /machine:X86 /debug
LINK : fatal error LNK1104: cannot open file 'Xinput9_1_0.lib' [gainput\build\lib\gainput.vcxproj]
Done Building Project "Gainput\build\lib\gainput.vcxproj" (default targets) -- FAILED.

Xinput 9.1.0 and lastest Windows SDK installed.

Xinput9_1_0.lib appears to be installed normally as part of windows 7 is this just a limitation of the platform? is that exact version of xinput required or can it be another?

OpenGL SwapBuffers interferes with input detection.

Hi,

So I have created a window using GLFW, I'm using the glfw win32 window handle to get the required HWND value. Whenever I setup my OpenGL renderer to contain a swap buffer (with a swap interval of 1) the input of the mouse is barely detected, and the input of the keys are pretty much non-existent

Here's an example of my OpenGL window creation

glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

glfwSetErrorCallback(error_callback);

if (!glfwInit())
{
	glfwTerminate();
	exit(EXIT_FAILURE);
}

window = glfwCreateWindow(width, height, title, nullptr, nullptr);

int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
std::cout << "OpenGL Version " << major << "." << minor << "." << revision << std::endl;

glfwSetWindowUserPointer(window, this);

if (!window)
{
	glfwTerminate();
	exit(EXIT_FAILURE);
}

glfwMakeContextCurrent(window);
glfwSwapInterval(1);

glfwGetFramebufferSize(window, &width, &height);

And here's an example of my render function

glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//Main render loop

glfwSwapBuffers(window);
glfwPollEvents();

If I remove the buffer swap it works as intended. Is there someone that could help me out with this? (I'm probably doing something wrong).

Network events do not take into account timestamps for the transmission.

Network events do not take into account timestamps for the transmission. Therefore events are not played in the same manner as they are recorded. For example, this leads to wrong results when calculating touch speed.

A solution could be to record timestamps and play them with the same time diff as recorded.

MouseButtonLeft triggers KeyLeft true and keeps KeyLeft true when application looses focus

I have a bare bones cocos2d-x 3.9 project. I just noticed that once the running application loses focus, the GetBool() function starts to always return true. This doesn't stop when the application window comes back into focus.

Edit: Okay so heres what I see now. Left mouse actually causes the key left for keyboard input to register. So when I press left mouse button down, I actually get true for GetBool(KeyLeft). And then once the window looses focus, the GetBool(KeyLeft) stays registered as true until the application is closed.

Im using the latest version of gainput. Built on mac OS X 10.11.2.

Heres some snippets of how I'm using gainput.

enum Key
{
    KeyLeft
};

enum Mouse
{
    MouseLeft
};

gainput::InputManager manager;
const gainput::DeviceId keyboardId = manager.CreateDevice<gainput::InputDeviceKeyboard>();
const gainput::DeviceId mouseId = manager.CreateDevice<gainput::InputDeviceMouse>();

manager.SetDisplaySize(visibleSize.width, visibleSize.height);
map.MapBool(KeyLeft, keyboardId, gainput::KeyLeft);
map.MapBool(MouseLeft, mouseId, gainput::MouseButtonLeft);

void HelloWorld::update(float delta)
{
    manager.Update();]

// This returns true when the mouse left key is down. And then always returns true with the application looses focus
    if (map.GetBool(KeyLeft)) {
        log("LEFT");
    }

}

macOS build error

I have added gainput as git submodule, and my project build fails on

gainput/lib/source/gainput/mouse/GainputInputDeviceMouseMac.mm:110:27: error: no matching function for call to 'CGEventTapCreate'
        CFMachPortRef eventTap = CGEventTapCreate(kCGSessionEventTap,

Build fails on cmake and on generated Xcode project

Can i create an InputDevice to get raw input on linux without X11?

I tried to create a raw InputDeviceMouse with:

gainput::InputManager manager;
const auto id = manager.CreateDevice<gainput::InputDeviceMouse>(gainput::InputDevice::DV_RAW);
gainput::InputMap map(manager);
map.MapFloat(MouseX, id, gainput::MouseAxisX);

But both map.GetFloat(MouseX) and map.GetFloatDelta(MouseX) always return 0.

unable to build with visual studio 8 (2005) from scratch

many complains about missing XInput.h. I Believe CMakeLists should be fixed to search for DirectX SDK

1>d:\projects-rusyanov\gainput\lib\source\gainput\pad\GainputInputDevicePadWin.h(8) : fatal error C1083: Cannot open include file: 'XInput.h': No such file or directory 1>GainputInputDeviceMouse.cpp 2>d:\projects-rusyanov\gainput\lib\source\gainput\pad\GainputInputDevicePadWin.h(8) : fatal error C1083: Cannot open include file: 'XInput.h': No such file or directory 2>GainputInputDeviceMouse.cpp 1>d:\projects-rusyanov\gainput\lib\source\gainput\mouse\GainputInputDeviceMouseWin.h(78) : error C2065: 'WM_XBUTTONDOWN' : undeclared identifier 1>d:\projects-rusyanov\gainput\lib\source\gainput\mouse\GainputInputDeviceMouseWin.h(78) : error C2051: case expression not constant

Build Issues - OSX 10.9.5

I just attempted to download and build this project, however there seem to be linker issues...

Macara-2:Downloads jmartin$ unzip gainput-master.zip
Archive: gainput-master.zip
d039050
creating: gainput-master/
inflating: gainput-master/.gitignore
......................
inflating: gainput-master/tools/html5client/index.html
inflating: gainput-master/tools/html5client/touch.html
Macara-2:Downloads jmartin$ cd gainput-master
Macara-2:gainput-master jmartin$ ls
CMakeLists.txt LICENSE extern samples tools
Doxyfile README.md lib test
Macara-2:gainput-master jmartin$ mkdir build
Macara-2:gainput-master jmartin$ cd build/
Macara-2:build jmartin$ cmake ..
-- The C compiler identification is AppleClang 5.1.0.5030040
-- The CXX compiler identification is AppleClang 5.1.0.5030040
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

gainput

This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/jmartin/Downloads/gainput-master/build
Macara-2:build jmartin$ ls
CMakeCache.txt Makefile lib test
CMakeFiles cmake_install.cmake samples
Macara-2:build jmartin$ make
Scanning dependencies of target gainput
[ 1%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/builtin/GainputInputDeviceBuiltIn.cpp.o
[ 2%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/dev/GainputDev.cpp.o
[ 4%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/dev/GainputMemoryStream.cpp.o
[ 5%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/dev/GainputNetAddress.cpp.o
[ 7%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/dev/GainputNetConnection.cpp.o
[ 8%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/dev/GainputNetListener.cpp.o
[ 10%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gainput.cpp.o
[ 11%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputAllocator.cpp.o
[ 12%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputInputDeltaState.cpp.o
[ 14%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputInputDevice.cpp.o
[ 15%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputInputManager.cpp.o
[ 17%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputInputMap.cpp.o
[ 18%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/GainputInputState.cpp.o
[ 20%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputButtonStickGesture.cpp.o
[ 21%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputDoubleClickGesture.cpp.o
[ 22%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputHoldGesture.cpp.o
[ 24%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputPinchGesture.cpp.o
[ 25%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputRotateGesture.cpp.o
[ 27%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputSimultaneouslyDownGesture.cpp.o
[ 28%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/gestures/GainputTapGesture.cpp.o
[ 30%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/keyboard/GainputInputDeviceKeyboard.cpp.o
[ 31%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/keyboard/GainputInputDeviceKeyboardMac.cpp.o
[ 32%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/mouse/GainputInputDeviceMouse.cpp.o
[ 34%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/pad/GainputInputDevicePad.cpp.o
[ 35%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputPlayer.cpp.o
[ 37%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecorder.cpp.o
[ 38%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/recorder/GainputInputRecording.cpp.o
[ 40%] Building CXX object lib/CMakeFiles/gainput.dir/source/gainput/touch/GainputInputDeviceTouch.cpp.o
Linking CXX shared library libgainput.dylib
Undefined symbols for architecture x86_64:
"_CFDictionaryCreate", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_CFGetTypeID", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_CFNumberCreate", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_CFRelease", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
gainput::InputDeviceKeyboardImplMac::~InputDeviceKeyboardImplMac() in GainputInputDeviceKeyboardMac.cpp.o
"CFRunLoopGetCurrent", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
gainput::InputDeviceKeyboardImplMac::~InputDeviceKeyboardImplMac() in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDElementGetUsage", referenced from:
gainput::(anonymous namespace)::OnDeviceInput(void
, int, void
, IOHIDValue) in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDElementGetUsagePage", referenced from:
gainput::(anonymous namespace)::OnDeviceInput(void
, int, void
, _IOHIDValue) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerClose", referenced from:
gainput::InputDeviceKeyboardImplMac::~InputDeviceKeyboardImplMac() in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerCreate", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerGetTypeID", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerOpen", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerRegisterDeviceMatchingCallback", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerRegisterDeviceRemovalCallback", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerRegisterInputValueCallback", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_IOHIDManagerScheduleWithRunLoop", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDManagerSetDeviceMatching", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDManagerUnscheduleFromRunLoop", referenced from:
gainput::InputDeviceKeyboardImplMac::~InputDeviceKeyboardImplMac() in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDValueGetElement", referenced from:
gainput::(anonymous namespace)::OnDeviceInput(void
, int, void
, IOHIDValue) in GainputInputDeviceKeyboardMac.cpp.o
"IOHIDValueGetIntegerValue", referenced from:
gainput::(anonymous namespace)::OnDeviceInput(void
, int, void
, IOHIDValue) in GainputInputDeviceKeyboardMac.cpp.o
"gainput::MacIsApplicationKey()", referenced from:
gainput::(anonymous namespace)::OnDeviceInput(void
, int, void
, IOHIDValue) in GainputInputDeviceKeyboardMac.cpp.o
"gainput::InputDeviceMouseImplMac::InputDeviceMouseImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&)", referenced from:
gainput::InputDeviceMouseImplMac
gainput::Allocator::New<gainput::InputDeviceMouseImplMac, gainput::InputManager, gainput::InputDeviceMouse, gainput::InputState, gainput::InputState>(gainput::InputManager&, gainput::InputDeviceMouse&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceMouse.cpp.o
"___CFConstantStringClassReference", referenced from:
CFString in GainputInputDeviceKeyboardMac.cpp.o
CFString in GainputInputDeviceKeyboardMac.cpp.o
"_kCFAllocatorDefault", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_kCFRunLoopDefaultMode", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
gainput::InputDeviceKeyboardImplMac::~InputDeviceKeyboardImplMac() in GainputInputDeviceKeyboardMac.cpp.o
"_kCFTypeDictionaryKeyCallBacks", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
"_kCFTypeDictionaryValueCallBacks", referenced from:
gainput::InputDeviceKeyboardImplMac::InputDeviceKeyboardImplMac(gainput::InputManager&, gainput::InputDevice&, gainput::InputState&, gainput::InputState&) in GainputInputDeviceKeyboardMac.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libgainput.dylib] Error 1
make[1]: *** [lib/CMakeFiles/gainput.dir/all] Error 2
make: *** [all] Error 2
Macara-2:build jmartin$ cmake --version
cmake version 3.1.0

Can't differentiate multiple gamepad inputs on macOS

I connect two PS4 controllers to my mac (10.13) and create two gainput::InputDevicePad instances.

_gamepads.push_back(_inputManager->CreateDevice<gainput::InputDevicePad>());
_gamepads.push_back(_inputManager->CreateDevice<gainput::InputDevicePad>());

In a polling loop I print the state of the left and right analog sticks for the two devices.

auto device1 = _inputManager->GetDevice(_gamepads[0]);
auto device2 = _inputManager->GetDevice(_gamepads[1]);

vec2 leftStick1(device1->GetFloat(gainput::PadButtonLeftStickX),device1->GetFloat(gainput::PadButtonLeftStickY));
vec2 rightStick1(device1->GetFloat(gainput::PadButtonRightStickX),device1->GetFloat(gainput::PadButtonRightStickY));
vec2 leftStick2(device2->GetFloat(gainput::PadButtonLeftStickX),device2->GetFloat(gainput::PadButtonLeftStickY));
vec2 rightStick2(device2->GetFloat(gainput::PadButtonRightStickX),device2->GetFloat(gainput::PadButtonRightStickY));

cout << "leftStick1: " << leftStick1 << " rightStick1:" << rightStick1 << endl;
cout << "leftStick2: " << leftStick2 << " rightStick2:" << rightStick2 << endl << endl;

If I move the analog sticks on either gamepad 1 or 2, I see its position reflected in both device1 and device2.

gainput is, I guess, merging the state of the two controllers.

Am I creating the devices incorrectly?

Ignore last mouse event

i'm working on free fly camera, and i move the cursor on window center, but this generate an event and gainput update his listener with it, how can i ignore this event with gainput ? (or set internal mouse position to the center of my window ?)

Setup Visual Studio

How exactly do I configure Visual Studio to allow it to use this library? I've tried everything that I can find online and it just keeps saying that it can't find the header file.

Mouse Scrolling

Hi,

I have one simple question: For mouse input i use a gainput::InputDeviceMouse object and id didn't find out, how to capture mouse scrolling (i work on Windows 7). I initialized the InputDeviceMouse with
gainput::InputDevice::AutoIndex and gainput::InputDevice::DV_STANDARD, as with gainput::InputDevice::DV_RAW it didn't work, at all (no mouse input was registered). As a next step i tested all mouse buttons, but no one did the wished result.

So: How is it possible to capture mouse scrolling?

Programmatically trigger input events?

Cool project! Is it possible to programmatically trigger input events, such as a mouse click or key press? My use case is to listen for user input events, and then be able to replay those same input events programmatically. Also, is it possible to trigger input events directly (from a mouse, keyboard or gamepad) without the first step of listening for them?

Per the docs, I noticed one of the features is "Supports recording and playback of input sequences", and I wanted to make sure I was understanding that correctly. Thanks!

Error while compiling

An error while compiling gainput occured:
-- Selecting Windows SDK version to target Windows 6.1.7601.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
No CMAKE_C_COMPILER could be found.

CMake Error in CMakeLists.txt:
No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "C:/gainput/CMakeFiles/CMakeOutput.log".
See also "C:/gainput/CMakeFiles/CMakeError.log".

The buttons MouseButtonWheelUp and MouseButtonWheelDown don't work.

The buttons gainput::MouseButtonWheelUp and gainput::MouseButtonWheelDown don't work.

My code example:
m_InputMap.MapBool ( EButton::MouseWheelUp, m_MouseId, gainput::MouseButtonWheelUp );
m_InputMap.MapBool ( EButton::MenuUp, m_PadId, gainput::PadButtonUp );
m_InputMap.MapBool ( EButton::MouseWheelDown, m_MouseId, gainput::MouseButtonWheelDown );
m_InputMap.MapBool ( EButton::MenuDown, m_PadId, gainput::PadButtonDown );

// Checks for a "menu up" input action.
bool IsMenuUp() { return m_InputMap.GetBoolWasDown( EButton::MenuUp ) || m_InputMap.GetBool( EButton::MouseWheelUp ); }
// Checks for a "menu down" input action.
bool IsMenuDown() { return m_InputMap.GetBoolWasDown( EButton::MenuDown ) || m_InputMap.GetBool( EButton::MouseWheelDown ); }

What am I doing wrong?

Does the API support a way to enumerate connected devices?

Multiple devices can be registered with the InputManager by means of repeated calls to CreateDevice(). I don't see any clear way to verify that a device is in fact a real connected device, though. It seems like no matter how many devices I register of any type (significantly more than are actually present), the variant of the registered device is always DV_STANDARD, never DV_NULL.

Am I thinking about this completely the wrong way, or is there something to check device validity that I'm not seeing, or is this genuinely a missing feature?

Not detecting input on Mac OSX 10.10.5

Title pretty much says it all. Everything builds just find, I can setup an input manager and map inputs, but when I check for input, nothing happens.

Compile error

Hello. I'm developing game for android by NDK and OGRE 3D. I try just include header file gainput/gainput.h in my source and when I started compile application, compiler show error: gainput/lib/include/gainput/GainputContainers.h:233:1: error: global qualification of class name is invalid before '{' token

When I configured Gainput, I had problem with path to toolchain arm-linux-androideabi-4.6. Path in wscript point to android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin, but I have it in android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin. And I replace path in wscript for solve.

My target api is 14 (Android 4.0). I'm using GNU/Linux.

waf needs admin rights

Hey everyone! I just wanted to compile GAInput, but I got an error (see below). I used the following command: waf build_release. Building debug worked perfectly fine.

As you can see, I use Windows 8.1 x64 with VS12:

[...]
[62/71] cxx: samples\sync\syncsample.cpp -> build\release\samples\sync\syncsampl
e.cpp.1.o
SampleFramework.cpp
E:\GAInput\samples\samplefw\SampleFramework.cpp : fatal error C1083: Cannot open
 compiler generated file: 'samples\samplefw\SampleFramework.cpp.1.o': Permission
 denied
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

SampleFramework.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

recordingsample.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

syncsample.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Waf: Leaving directory `E:\GAInput\build\release'
Build failed
 -> task in 'listenersample' failed (exit status 1):
        {task 48915064: cxx SampleFramework.cpp -> SampleFramework.cpp.1.o}
['L:\\opt\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\CL.exe', '-O2', '/IE:\\
GAInput\\build\\release\\lib\\include', '/IE:\\GAInput\\lib\\include', '/IL:\\op
t\\Microsoft Visual Studio 12.0\\VC\\INCLUDE', '/IL:\\opt\\Microsoft Visual Stud
io 12.0\\VC\\ATLMFC\\INCLUDE', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\in
clude\\shared', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um', '/I
C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt', '/DGAINPUT_LIB_BUIL
D=1', '/DNDEBUG=1', '', '..\\..\\samples\\samplefw\\SampleFramework.cpp', '/FC',
 '/c', '/Fo', 'samples\\samplefw\\SampleFramework.cpp.1.o']

E:\GAInput>

"Permission Denied" got me a strange feeling, so I started cmd as admin and reconfigured and rebuild release. As a result, the builkd was successful So I want to suggest adding this useful piece of information to the description.
'build_release' finished successfully (0.917s)

Symbol problems on Windows, Also weird filesizes

Hey,
I've built your library on windows using cmake, default settings. Compiled it in msvc2013.
The first thing that I noticed was:
The static library file is almost 4 MB in size. The dynamic library file is 200kb + 200kb. Is this correct?

Next issue that I am having:
When using the static library, It seems that some xinput symbols cant be found. Im not sure how i could fix this?

gainputstatic_d.lib(GainputInputDevicePad.obj) : error LNK2019: unresolved external symbol _XInputGetState@8 referenced in function "public: virtual void __thiscall gainput::InputDevicePadImplWin::Update

Edit:
It works all fine with the dynamic library. Guess im gonna be using that for now! Would be great to have a proper static lib though, since i prefer not having lots of .dlls around.
Somehow cmake seems to be messing up the static compile for windows, might be worth looking into.

Thank you very much for your time

Angled brackets vs "" in includes

Hi,

First of all, thanks for this great library! I'm trying to compile gainput on OSX and I'm hitting an error about headers not being correctly found:

"'gainput/gainput.h' file not found with include; use "quotes" instead"

It seems like you use angled brackets in gainput which Xcode treats as system headers. There's an option called Always Search User Paths (deprecated) that fixes the issue but ideally I wouldn't need to rely on this behavior as it's also marked as deprecated so will disappear in the future.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.