diff --git a/XInputSimulator/.DS_Store b/XInputSimulator/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/XInputSimulator/.DS_Store differ diff --git a/XInputSimulator/.idea/.name b/XInputSimulator/.idea/.name new file mode 100644 index 0000000..a78e637 --- /dev/null +++ b/XInputSimulator/.idea/.name @@ -0,0 +1 @@ +XInputSimulator \ No newline at end of file diff --git a/XInputSimulator/.idea/XInputSimulator.iml b/XInputSimulator/.idea/XInputSimulator.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/XInputSimulator/.idea/XInputSimulator.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/XInputSimulator/.idea/misc.xml b/XInputSimulator/.idea/misc.xml new file mode 100644 index 0000000..9601a91 --- /dev/null +++ b/XInputSimulator/.idea/misc.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/XInputSimulator/.idea/modules.xml b/XInputSimulator/.idea/modules.xml new file mode 100644 index 0000000..83ec3aa --- /dev/null +++ b/XInputSimulator/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/XInputSimulator/.idea/vcs.xml b/XInputSimulator/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/XInputSimulator/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/XInputSimulator/.idea/workspace.xml b/XInputSimulator/.idea/workspace.xml new file mode 100644 index 0000000..09d9f31 --- /dev/null +++ b/XInputSimulator/.idea/workspace.xml @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1423944103583 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/XInputSimulator/CMakeLists.txt b/XInputSimulator/CMakeLists.txt new file mode 100644 index 0000000..8e2b620 --- /dev/null +++ b/XInputSimulator/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.8.4) +project(XInputSimulator) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +set(SOURCE_FILES + main.cpp + notimplementedexception.cpp + notimplementedexception.h + xinputsimulator.cpp + xinputsimulator.h + xinputsimulatorimpl.cpp + xinputsimulatorimpl.h + xinputsimulatorimpllinux.cpp + xinputsimulatorimpllinux.h + xinputsimulatorimplmacos.cpp + xinputsimulatorimplmacos.h + xinputsimulatorimplwin.cpp + xinputsimulatorimplwin.h) + + # Linux + if(UNIX AND NOT APPLE) + find_library(X_11 X11) + find_library(X_TST Xtst) + set(EXTRA_LIBS ${X_11} ${X_TST}) + endif(UNIX AND NOT APPLE) + + # Apple + if(APPLE) + find_library(APP_SERVICES ApplicationServices) + find_library(CARBON Carbon) + find_library(CORE_FOUNDATION CoreFoundation ) + set(EXTRA_LIBS ${APP_SERVICES_LIBRARY} ${CARBON} ${CORE_FOUNDATION}) + endif(APPLE) + +add_executable(XInputSimulator ${SOURCE_FILES}) +target_link_libraries(XInputSimulator ${EXTRA_LIBS} ) \ No newline at end of file diff --git a/XInputSimulator/XInputSimulator.xcodeproj/project.pbxproj b/XInputSimulator/XInputSimulator.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5390d98 --- /dev/null +++ b/XInputSimulator/XInputSimulator.xcodeproj/project.pbxproj @@ -0,0 +1,293 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + D2C6A1F61A8FD9E900CAA80C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1E81A8FD9E900CAA80C /* main.cpp */; }; + D2C6A1F71A8FD9E900CAA80C /* notimplementedexception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1E91A8FD9E900CAA80C /* notimplementedexception.cpp */; }; + D2C6A1F81A8FD9E900CAA80C /* xinputsimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1EB1A8FD9E900CAA80C /* xinputsimulator.cpp */; }; + D2C6A1F91A8FD9E900CAA80C /* xinputsimulatorimpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1EE1A8FD9E900CAA80C /* xinputsimulatorimpl.cpp */; }; + D2C6A1FA1A8FD9E900CAA80C /* xinputsimulatorimpllinux.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1F01A8FD9E900CAA80C /* xinputsimulatorimpllinux.cpp */; }; + D2C6A1FB1A8FD9E900CAA80C /* xinputsimulatorimplmacos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1F21A8FD9E900CAA80C /* xinputsimulatorimplmacos.cpp */; }; + D2C6A1FC1A8FD9E900CAA80C /* xinputsimulatorimplwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A1F41A8FD9E900CAA80C /* xinputsimulatorimplwin.cpp */; }; + D2C6A1FE1A8FDBF400CAA80C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2C6A1FD1A8FDBF400CAA80C /* ApplicationServices.framework */; }; + D2C6A2001A8FF30700CAA80C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2C6A1FF1A8FF30700CAA80C /* Carbon.framework */; }; + D2C6A2021A8FF33300CAA80C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2C6A2011A8FF33300CAA80C /* CoreFoundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + D2C6A1D81A8FD8CF00CAA80C /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + D2C6A1DA1A8FD8CF00CAA80C /* XInputSimulator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = XInputSimulator; sourceTree = BUILT_PRODUCTS_DIR; }; + D2C6A1E61A8FD9E900CAA80C /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING; sourceTree = ""; }; + D2C6A1E71A8FD9E900CAA80C /* COPYING.LESSER */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING.LESSER; sourceTree = ""; }; + D2C6A1E81A8FD9E900CAA80C /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + D2C6A1E91A8FD9E900CAA80C /* notimplementedexception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = notimplementedexception.cpp; sourceTree = ""; }; + D2C6A1EA1A8FD9E900CAA80C /* notimplementedexception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notimplementedexception.h; sourceTree = ""; }; + D2C6A1EB1A8FD9E900CAA80C /* xinputsimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xinputsimulator.cpp; sourceTree = ""; }; + D2C6A1EC1A8FD9E900CAA80C /* xinputsimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xinputsimulator.h; sourceTree = ""; }; + D2C6A1ED1A8FD9E900CAA80C /* XInputSimulator.pro */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = XInputSimulator.pro; sourceTree = ""; }; + D2C6A1EE1A8FD9E900CAA80C /* xinputsimulatorimpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xinputsimulatorimpl.cpp; sourceTree = ""; }; + D2C6A1EF1A8FD9E900CAA80C /* xinputsimulatorimpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xinputsimulatorimpl.h; sourceTree = ""; }; + D2C6A1F01A8FD9E900CAA80C /* xinputsimulatorimpllinux.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xinputsimulatorimpllinux.cpp; sourceTree = ""; }; + D2C6A1F11A8FD9E900CAA80C /* xinputsimulatorimpllinux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xinputsimulatorimpllinux.h; sourceTree = ""; }; + D2C6A1F21A8FD9E900CAA80C /* xinputsimulatorimplmacos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xinputsimulatorimplmacos.cpp; sourceTree = ""; }; + D2C6A1F31A8FD9E900CAA80C /* xinputsimulatorimplmacos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xinputsimulatorimplmacos.h; sourceTree = ""; }; + D2C6A1F41A8FD9E900CAA80C /* xinputsimulatorimplwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xinputsimulatorimplwin.cpp; sourceTree = ""; }; + D2C6A1F51A8FD9E900CAA80C /* xinputsimulatorimplwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xinputsimulatorimplwin.h; sourceTree = ""; }; + D2C6A1FD1A8FDBF400CAA80C /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; + D2C6A1FF1A8FF30700CAA80C /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; + D2C6A2011A8FF33300CAA80C /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D2C6A1D71A8FD8CF00CAA80C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D2C6A2021A8FF33300CAA80C /* CoreFoundation.framework in Frameworks */, + D2C6A2001A8FF30700CAA80C /* Carbon.framework in Frameworks */, + D2C6A1FE1A8FDBF400CAA80C /* ApplicationServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + D2C6A1D11A8FD8CF00CAA80C = { + isa = PBXGroup; + children = ( + D2C6A2011A8FF33300CAA80C /* CoreFoundation.framework */, + D2C6A1FF1A8FF30700CAA80C /* Carbon.framework */, + D2C6A1FD1A8FDBF400CAA80C /* ApplicationServices.framework */, + D2C6A1E61A8FD9E900CAA80C /* COPYING */, + D2C6A1E71A8FD9E900CAA80C /* COPYING.LESSER */, + D2C6A1E81A8FD9E900CAA80C /* main.cpp */, + D2C6A1E91A8FD9E900CAA80C /* notimplementedexception.cpp */, + D2C6A1EA1A8FD9E900CAA80C /* notimplementedexception.h */, + D2C6A1EB1A8FD9E900CAA80C /* xinputsimulator.cpp */, + D2C6A1EC1A8FD9E900CAA80C /* xinputsimulator.h */, + D2C6A1ED1A8FD9E900CAA80C /* XInputSimulator.pro */, + D2C6A1EE1A8FD9E900CAA80C /* xinputsimulatorimpl.cpp */, + D2C6A1EF1A8FD9E900CAA80C /* xinputsimulatorimpl.h */, + D2C6A1F01A8FD9E900CAA80C /* xinputsimulatorimpllinux.cpp */, + D2C6A1F11A8FD9E900CAA80C /* xinputsimulatorimpllinux.h */, + D2C6A1F21A8FD9E900CAA80C /* xinputsimulatorimplmacos.cpp */, + D2C6A1F31A8FD9E900CAA80C /* xinputsimulatorimplmacos.h */, + D2C6A1F41A8FD9E900CAA80C /* xinputsimulatorimplwin.cpp */, + D2C6A1F51A8FD9E900CAA80C /* xinputsimulatorimplwin.h */, + D2C6A1DC1A8FD8CF00CAA80C /* XInputSimulator */, + D2C6A1DB1A8FD8CF00CAA80C /* Products */, + ); + sourceTree = ""; + }; + D2C6A1DB1A8FD8CF00CAA80C /* Products */ = { + isa = PBXGroup; + children = ( + D2C6A1DA1A8FD8CF00CAA80C /* XInputSimulator */, + ); + name = Products; + sourceTree = ""; + }; + D2C6A1DC1A8FD8CF00CAA80C /* XInputSimulator */ = { + isa = PBXGroup; + children = ( + ); + path = XInputSimulator; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + D2C6A1D91A8FD8CF00CAA80C /* XInputSimulator */ = { + isa = PBXNativeTarget; + buildConfigurationList = D2C6A1E11A8FD8CF00CAA80C /* Build configuration list for PBXNativeTarget "XInputSimulator" */; + buildPhases = ( + D2C6A1D61A8FD8CF00CAA80C /* Sources */, + D2C6A1D71A8FD8CF00CAA80C /* Frameworks */, + D2C6A1D81A8FD8CF00CAA80C /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XInputSimulator; + productName = XInputSimulator; + productReference = D2C6A1DA1A8FD8CF00CAA80C /* XInputSimulator */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D2C6A1D21A8FD8CF00CAA80C /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = "Peter Mueller inc."; + TargetAttributes = { + D2C6A1D91A8FD8CF00CAA80C = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = D2C6A1D51A8FD8CF00CAA80C /* Build configuration list for PBXProject "XInputSimulator" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = D2C6A1D11A8FD8CF00CAA80C; + productRefGroup = D2C6A1DB1A8FD8CF00CAA80C /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2C6A1D91A8FD8CF00CAA80C /* XInputSimulator */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + D2C6A1D61A8FD8CF00CAA80C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D2C6A1FB1A8FD9E900CAA80C /* xinputsimulatorimplmacos.cpp in Sources */, + D2C6A1F81A8FD9E900CAA80C /* xinputsimulator.cpp in Sources */, + D2C6A1F71A8FD9E900CAA80C /* notimplementedexception.cpp in Sources */, + D2C6A1F91A8FD9E900CAA80C /* xinputsimulatorimpl.cpp in Sources */, + D2C6A1FA1A8FD9E900CAA80C /* xinputsimulatorimpllinux.cpp in Sources */, + D2C6A1FC1A8FD9E900CAA80C /* xinputsimulatorimplwin.cpp in Sources */, + D2C6A1F61A8FD9E900CAA80C /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + D2C6A1DF1A8FD8CF00CAA80C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + D2C6A1E01A8FD8CF00CAA80C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + D2C6A1E21A8FD8CF00CAA80C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + D2C6A1E31A8FD8CF00CAA80C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D2C6A1D51A8FD8CF00CAA80C /* Build configuration list for PBXProject "XInputSimulator" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D2C6A1DF1A8FD8CF00CAA80C /* Debug */, + D2C6A1E01A8FD8CF00CAA80C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D2C6A1E11A8FD8CF00CAA80C /* Build configuration list for PBXNativeTarget "XInputSimulator" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D2C6A1E21A8FD8CF00CAA80C /* Debug */, + D2C6A1E31A8FD8CF00CAA80C /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = D2C6A1D21A8FD8CF00CAA80C /* Project object */; +} diff --git a/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..41fcde0 --- /dev/null +++ b/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/xcuserdata/naikon.xcuserdatad/UserInterfaceState.xcuserstate b/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/xcuserdata/naikon.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..216aaf3 Binary files /dev/null and b/XInputSimulator/XInputSimulator.xcodeproj/project.xcworkspace/xcuserdata/naikon.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..1d789d4 --- /dev/null +++ b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/XInputSimulator.xcscheme b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/XInputSimulator.xcscheme new file mode 100644 index 0000000..12048d2 --- /dev/null +++ b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/XInputSimulator.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/xcschememanagement.plist b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..649d2c3 --- /dev/null +++ b/XInputSimulator/XInputSimulator.xcodeproj/xcuserdata/naikon.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + XInputSimulator.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + D2C6A1D91A8FD8CF00CAA80C + + primary + + + + + diff --git a/XInputSimulator/XInputSimulator/.DS_Store b/XInputSimulator/XInputSimulator/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/XInputSimulator/XInputSimulator/.DS_Store differ diff --git a/XInputSimulator/main.cpp b/XInputSimulator/main.cpp index 6334c93..3288bdf 100644 --- a/XInputSimulator/main.cpp +++ b/XInputSimulator/main.cpp @@ -29,35 +29,36 @@ int main() cout << "Hello World!" << endl; XInputSimulator &sim = XInputSimulator::getInstance(); - waitABit(); - sim.mouseMoveTo(500,400); - waitABit(); - sim.mouseMoveRelative(400, -100); - waitABit(); - sim.mouseDown(XInputSimulator::LEFT_MOUSE_BUTTON); - waitABit(); - sim.mouseMoveRelative(0, 300); - waitABit(); - sim.mouseUp(XInputSimulator::LEFT_MOUSE_BUTTON); - waitABit(); - //scroll down and up - sim.mouseScrollY(10); - waitABit(); - sim.mouseScrollY(-10); - //scroll left and right - waitABit(); - sim.mouseScrollX(10); - waitABit(); - sim.mouseScrollX(-10); -// char anA = 'a'; -// cout << "a: " << (int)anA << " " << sim.charToKeyCode(anA) << endl; -// std::cout << std::endl; + waitABit(); +// sim.mouseMoveTo(500,400); // waitABit(); -// sim.keyClick(sim.charToKeyCode(anA)); -// std::cout << std::endl; +// sim.mouseMoveRelative(400, -100); // waitABit(); -// sim.keySequence(" Simple sentence Here 123 "); +// sim.mouseDown(XIS::LEFT_MOUSE_BUTTON); +// waitABit(); +// sim.mouseMoveRelative(0, 300); +// waitABit(); +// sim.mouseUp(XIS::LEFT_MOUSE_BUTTON); +// waitABit(); +// //scroll down and up +// sim.mouseScrollY(10); +// waitABit(); +// sim.mouseScrollY(-10); +// //scroll left and right +// waitABit(); +// sim.mouseScrollX(10); +// waitABit(); +// sim.mouseScrollX(-10); + + char anA = 'a'; + cout << "a: " << (int)anA << " " << sim.charToKeyCode(anA) << endl; + std::cout << std::endl; + waitABit(); + sim.keyClick(sim.charToKeyCode(anA)); + std::cout << std::endl; + waitABit(); + sim.keySequence(" Simple sentence Here 123 "); @@ -68,5 +69,5 @@ int main() void waitABit() { //std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - sleep(2); + sleep(1); } diff --git a/XInputSimulator/xinputsimulator.h b/XInputSimulator/xinputsimulator.h index 103ff88..e00abc7 100644 --- a/XInputSimulator/xinputsimulator.h +++ b/XInputSimulator/xinputsimulator.h @@ -81,5 +81,6 @@ public: static const int MIDDLE_MOUSE_BUTTON = 3; }; +typedef XInputSimulator XIS; #endif // XINPUTSIMULATOR_H diff --git a/XInputSimulator/xinputsimulatorimpllinux.cpp b/XInputSimulator/xinputsimulatorimpllinux.cpp index 2d084a4..0924b54 100644 --- a/XInputSimulator/xinputsimulatorimpllinux.cpp +++ b/XInputSimulator/xinputsimulatorimpllinux.cpp @@ -168,6 +168,7 @@ int XInputSimulatorImplLinux::charToKeyCode(char key_char) std::cout << "cchar: " << (int)key_char << std::endl; int keyCode = XKeysymToKeycode(display, key_char); +// int keyCode = XKeysymToKeycode(display, XStringToKeysym(&key_char)); std::cout << "ccode: " << keyCode << std::endl; return keyCode; @@ -180,7 +181,19 @@ void XInputSimulatorImplLinux::keySequence(const std::string &sequence) std::cout << "cahr: " << c << std::endl; int keyCode = this->charToKeyCode(c); std::cout << "key code: " << keyCode << std::endl; - this->keyClick(keyCode); + + if (isupper(c)) { + std::cout << "upper " << c << std::endl; + + this->keyDown(XKeysymToKeycode(display, XK_Shift_L)); + this->keyClick(keyCode); + this->keyUp(XKeysymToKeycode(display, XK_Shift_L)); + } + else { + this->keyClick(keyCode); + } + + std::cout << std::endl; } diff --git a/XInputSimulator/xinputsimulatorimplmacos.cpp b/XInputSimulator/xinputsimulatorimplmacos.cpp index ea56afe..f4ebf9d 100644 --- a/XInputSimulator/xinputsimulatorimplmacos.cpp +++ b/XInputSimulator/xinputsimulatorimplmacos.cpp @@ -20,16 +20,13 @@ #include -//quartz CG... stuff -#include - //sleep #include #include "xinputsimulatorimplmacos.h" #include "notimplementedexception.h" -#include +//#include XInputSimulatorImplMacOs::XInputSimulatorImplMacOs() @@ -83,7 +80,7 @@ void XInputSimulatorImplMacOs::mouseMoveRelative(int x, int y) if(newX < 0 || newX > this->displayX || newY < 0 || newY > this->displayY ) { - std::cout << "mouse moved beyound screensize." << endl; + std::cout << "mouse moved beyound screensize." << std::endl; return; } @@ -193,26 +190,109 @@ void XInputSimulatorImplMacOs::mouseScrollY(int length) void XInputSimulatorImplMacOs::keyDown(int key) { - throw NotImplementedException(); + CGKeyCode keycode = key; + CGEventRef commandDown = CGEventCreateKeyboardEvent(NULL, keycode, true); + CGEventPost(kCGAnnotatedSessionEventTap, commandDown); + CFRelease(commandDown); } void XInputSimulatorImplMacOs::keyUp(int key) { - throw NotImplementedException(); + CGKeyCode keycode = key; + CGEventRef commandUp = CGEventCreateKeyboardEvent(NULL, keycode, false); + CGEventPost(kCGAnnotatedSessionEventTap, commandUp); + CFRelease(commandUp); } void XInputSimulatorImplMacOs::keyClick(int key) { - throw NotImplementedException(); + std::cout << "key click: " << key << std::endl; + + this->keyDown(key); + this->keyUp(key); +} + +CFStringRef XInputSimulatorImplMacOs::createStringForKey(CGKeyCode keyCode) +{ + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + //CFDataRef layoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + + const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); + + UInt32 keysDown = 0; + UniChar chars[4]; + UniCharCount realLength; + + UCKeyTranslate(keyboardLayout, + keyCode, + kUCKeyActionDisplay, + 0, + LMGetKbdType(), + kUCKeyTranslateNoDeadKeysBit, + &keysDown, + sizeof(chars) / sizeof(chars[0]), + &realLength, + chars); + + CFRelease(currentKeyboard); + + return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); + + return NULL; } int XInputSimulatorImplMacOs::charToKeyCode(char key_char) { - throw NotImplementedException(); + static CFMutableDictionaryRef charToCodeDict = NULL; + CGKeyCode code; + UniChar character = key_char; + CFStringRef charStr = NULL; + + /* Generate table of keycodes and characters. */ + if (charToCodeDict == NULL) { + size_t i; + charToCodeDict = CFDictionaryCreateMutable(kCFAllocatorDefault, + 128, + &kCFCopyStringDictionaryKeyCallBacks, + NULL); + if (charToCodeDict == NULL) return UINT16_MAX; + + /* Loop through every keycode (0 - 127) to find its current mapping. */ + for (i = 0; i < 128; ++i) { + CFStringRef string = createStringForKey((CGKeyCode)i); + if (string != NULL) { + CFDictionaryAddValue(charToCodeDict, string, (const void *)i); + CFRelease(string); + } + } + } + + charStr = CFStringCreateWithCharacters(kCFAllocatorDefault, &character, 1); + + /* Our values may be NULL (0), so we need to use this function. */ + if (!CFDictionaryGetValueIfPresent(charToCodeDict, + charStr, + (const void **)&code)) { + code = UINT16_MAX; + } + + CFRelease(charStr); + return code; } void XInputSimulatorImplMacOs::keySequence(const std::string &sequence) { - throw NotImplementedException(); + std::cout << "key seq: " << sequence << std::endl; + + for(const char c : sequence) { + std::cout << "cahr: " << c << std::endl; + int keyCode = this->charToKeyCode(c); + std::cout << "key code: " << keyCode << std::endl; + this->keyClick(keyCode); + std::cout << std::endl; + } + + //throw NotImplementedException(); } #endif //apple