From eee6dab226b2f056598d621aeed16691bbce7fe7 Mon Sep 17 00:00:00 2001 From: Joel Davis Date: Mon, 15 Jun 2015 09:23:57 -0700 Subject: [PATCH] iOS example working based on modified OpenGL3 example + Synergy --- examples/ios_example/.gitignore | 3 + examples/ios_example/README.md | 35 + .../imguiex.xcodeproj/project.pbxproj | 365 ++++++++ examples/ios_example/imguiex/AppDelegate.h | 13 + examples/ios_example/imguiex/AppDelegate.m | 41 + .../imguiex/Base.lproj/LaunchScreen.xib | 32 + .../imguiex/Base.lproj/Main.storyboard | 44 + .../ios_example/imguiex/GameViewController.h | 13 + .../ios_example/imguiex/GameViewController.m | 481 ++++++++++ .../AppIcon.appiconset/Contents.json | 72 ++ .../icon_imgui_60@2x~iphone.png | Bin 0 -> 4491 bytes .../icon_imgui_60@3x~iphone.png | Bin 0 -> 7022 bytes .../icon_imgui_76@2x~ipad.png | Bin 0 -> 5727 bytes .../AppIcon.appiconset/icon_imgui_76~ipad.png | Bin 0 -> 2838 bytes examples/ios_example/imguiex/Info.plist | 49 ++ .../ios_example/imguiex/Shaders/Shader.fsh | 10 + .../ios_example/imguiex/Shaders/Shader.vsh | 25 + examples/ios_example/imguiex/debug_hud.cpp | 53 ++ examples/ios_example/imguiex/debug_hud.h | 28 + .../ios_example/imguiex/imgui_ex_icon.png | Bin 0 -> 16394 bytes examples/ios_example/imguiex/imgui_impl_ios.h | 26 + .../ios_example/imguiex/imgui_impl_ios.mm | 825 ++++++++++++++++++ examples/ios_example/imguiex/main.m | 13 + examples/libs/usynergy/uSynergy.c | 636 ++++++++++++++ examples/libs/usynergy/uSynergy.h | 420 +++++++++ 25 files changed, 3184 insertions(+) create mode 100644 examples/ios_example/.gitignore create mode 100644 examples/ios_example/README.md create mode 100644 examples/ios_example/imguiex.xcodeproj/project.pbxproj create mode 100644 examples/ios_example/imguiex/AppDelegate.h create mode 100644 examples/ios_example/imguiex/AppDelegate.m create mode 100644 examples/ios_example/imguiex/Base.lproj/LaunchScreen.xib create mode 100644 examples/ios_example/imguiex/Base.lproj/Main.storyboard create mode 100644 examples/ios_example/imguiex/GameViewController.h create mode 100644 examples/ios_example/imguiex/GameViewController.m create mode 100644 examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png create mode 100644 examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png create mode 100644 examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png create mode 100644 examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png create mode 100644 examples/ios_example/imguiex/Info.plist create mode 100644 examples/ios_example/imguiex/Shaders/Shader.fsh create mode 100644 examples/ios_example/imguiex/Shaders/Shader.vsh create mode 100644 examples/ios_example/imguiex/debug_hud.cpp create mode 100644 examples/ios_example/imguiex/debug_hud.h create mode 100644 examples/ios_example/imguiex/imgui_ex_icon.png create mode 100644 examples/ios_example/imguiex/imgui_impl_ios.h create mode 100644 examples/ios_example/imguiex/imgui_impl_ios.mm create mode 100644 examples/ios_example/imguiex/main.m create mode 100644 examples/libs/usynergy/uSynergy.c create mode 100644 examples/libs/usynergy/uSynergy.h diff --git a/examples/ios_example/.gitignore b/examples/ios_example/.gitignore new file mode 100644 index 000000000..8feda89d3 --- /dev/null +++ b/examples/ios_example/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +imguiex.xcodeproj/project.xcworkspace/ +imguiex.xcodeproj/xcuserdata/ \ No newline at end of file diff --git a/examples/ios_example/README.md b/examples/ios_example/README.md new file mode 100644 index 000000000..fc179f0d0 --- /dev/null +++ b/examples/ios_example/README.md @@ -0,0 +1,35 @@ +# iOS example + +---- +## Introduction + +This example is the default XCode "OpenGL" example code, modified to support IMGUI and [Synergy](http://synergy-project.org/). + +Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use IMGUI without it. Synergy includes a "uSynergy" library that allows embedding a synergy client, this is what is used here. IMGUI supports "Touch Padding", and this is enabled when Synergy is not active. + +## How to Use +---- + +0. In Synergy, go to Preferences, and uncheck "Use SSL encryption" +0. Run the example app. +0. Tap the "servername" button in the corner +0. Enter the name or the IP of your synergy host +0. If you had previously connected to a server, you may need to kill and re-start the app. + +---- +## Notes and TODOs + +Things that would be nice but I didn't get around to doing: + +* iOS software keyboard not supported for text inputs +* iOS hardware (bluetooth) keyboards not supported +* Graceful disconnect/reconnect from uSynergy. +* Copy/Paste not well-supported + +---- +## C++ on iOS +IMGUI is a c++ library. If you want to include it directly, rename your Obj-C file to have the ".mm" extension. + +Alternatively, you can wrap your debug code in a C interface, this is what I am demonstrating here with the "debug_hud.h" interface. Either approach works, use whatever you prefer. + +In my case, most of my game code is already in C++ so it's not really an issue and I can use IMGUI directly. diff --git a/examples/ios_example/imguiex.xcodeproj/project.pbxproj b/examples/ios_example/imguiex.xcodeproj/project.pbxproj new file mode 100644 index 000000000..5e9b015f8 --- /dev/null +++ b/examples/ios_example/imguiex.xcodeproj/project.pbxproj @@ -0,0 +1,365 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; }; + 6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; }; + 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC55C1B2E632000C130BA /* AppDelegate.m */; }; + 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC55E1B2E632000C130BA /* Shader.fsh */; }; + 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5601B2E632000C130BA /* Shader.vsh */; }; + 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5631B2E632000C130BA /* GameViewController.m */; }; + 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5651B2E632000C130BA /* Main.storyboard */; }; + 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5681B2E632000C130BA /* Images.xcassets */; }; + 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */; }; + 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */; }; + 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5861B2E64AB00C130BA /* imgui.cpp */; }; + 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; }; + 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5901B30773F00C130BA /* CFNetwork.framework */; }; + 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = ""; }; + 6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = ""; }; + 6D2FC5541B2E632000C130BA /* imguiex.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = imguiex.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D2FC5581B2E632000C130BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6D2FC5591B2E632000C130BA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6D2FC55B1B2E632000C130BA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 6D2FC55C1B2E632000C130BA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 6D2FC55E1B2E632000C130BA /* Shader.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = ""; }; + 6D2FC5601B2E632000C130BA /* Shader.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = ""; }; + 6D2FC5621B2E632000C130BA /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = ""; }; + 6D2FC5631B2E632000C130BA /* GameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameViewController.m; sourceTree = ""; }; + 6D2FC5661B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6D2FC5681B2E632000C130BA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 6D2FC56B1B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = imgui_impl_ios.mm; sourceTree = ""; }; + 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imgui_impl_ios.h; sourceTree = ""; }; + 6D2FC5851B2E64AB00C130BA /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; + 6D2FC5861B2E64AB00C130BA /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; + 6D2FC5871B2E64AB00C130BA /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; + 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = debug_hud.cpp; sourceTree = ""; }; + 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug_hud.h; sourceTree = ""; }; + 6D2FC5901B30773F00C130BA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; + 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6D2FC5511B2E632000C130BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */, + 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6D1E39141B35EEF10017B40F /* usynergy */ = { + isa = PBXGroup; + children = ( + 6D1E39151B35EEF10017B40F /* uSynergy.c */, + 6D1E39161B35EEF10017B40F /* uSynergy.h */, + ); + name = usynergy; + path = ../libs/usynergy; + sourceTree = ""; + }; + 6D2FC54B1B2E632000C130BA = { + isa = PBXGroup; + children = ( + 6D1E39141B35EEF10017B40F /* usynergy */, + 6D2FC5841B2E648D00C130BA /* imgui */, + 6D2FC5561B2E632000C130BA /* imguiex */, + 6D2FC5551B2E632000C130BA /* Products */, + ); + sourceTree = ""; + }; + 6D2FC5551B2E632000C130BA /* Products */ = { + isa = PBXGroup; + children = ( + 6D2FC5541B2E632000C130BA /* imguiex.app */, + ); + name = Products; + sourceTree = ""; + }; + 6D2FC5561B2E632000C130BA /* imguiex */ = { + isa = PBXGroup; + children = ( + 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */, + 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */, + 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */, + 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */, + 6D2FC55B1B2E632000C130BA /* AppDelegate.h */, + 6D2FC55C1B2E632000C130BA /* AppDelegate.m */, + 6D2FC55E1B2E632000C130BA /* Shader.fsh */, + 6D2FC5601B2E632000C130BA /* Shader.vsh */, + 6D2FC5621B2E632000C130BA /* GameViewController.h */, + 6D2FC5631B2E632000C130BA /* GameViewController.m */, + 6D2FC5651B2E632000C130BA /* Main.storyboard */, + 6D2FC5681B2E632000C130BA /* Images.xcassets */, + 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */, + 6D2FC5571B2E632000C130BA /* Supporting Files */, + ); + path = imguiex; + sourceTree = ""; + }; + 6D2FC5571B2E632000C130BA /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */, + 6D2FC5901B30773F00C130BA /* CFNetwork.framework */, + 6D2FC5581B2E632000C130BA /* Info.plist */, + 6D2FC5591B2E632000C130BA /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 6D2FC5841B2E648D00C130BA /* imgui */ = { + isa = PBXGroup; + children = ( + 6D2FC5851B2E64AB00C130BA /* imconfig.h */, + 6D2FC5861B2E64AB00C130BA /* imgui.cpp */, + 6D2FC5871B2E64AB00C130BA /* imgui.h */, + ); + name = imgui; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6D2FC5531B2E632000C130BA /* imguiex */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex" */; + buildPhases = ( + 6D2FC5501B2E632000C130BA /* Sources */, + 6D2FC5511B2E632000C130BA /* Frameworks */, + 6D2FC5521B2E632000C130BA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = imguiex; + productName = imguiex; + productReference = 6D2FC5541B2E632000C130BA /* imguiex.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6D2FC54C1B2E632000C130BA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "Joel Davis"; + TargetAttributes = { + 6D2FC5531B2E632000C130BA = { + CreatedOnToolsVersion = 6.3.2; + }; + }; + }; + buildConfigurationList = 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6D2FC54B1B2E632000C130BA; + productRefGroup = 6D2FC5551B2E632000C130BA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6D2FC5531B2E632000C130BA /* imguiex */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6D2FC5521B2E632000C130BA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */, + 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */, + 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */, + 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */, + 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6D2FC5501B2E632000C130BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */, + 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */, + 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */, + 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */, + 6D2FC55A1B2E632000C130BA /* main.m in Sources */, + 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */, + 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6D2FC5651B2E632000C130BA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D2FC5661B2E632000C130BA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 6D2FC56B1B2E632000C130BA /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6D2FC5791B2E632000C130BA /* 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; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6D2FC57A1B2E632000C130BA /* 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; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6D2FC57C1B2E632000C130BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = imguiex/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 6D2FC57D1B2E632000C130BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = imguiex/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D2FC5791B2E632000C130BA /* Debug */, + 6D2FC57A1B2E632000C130BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D2FC57C1B2E632000C130BA /* Debug */, + 6D2FC57D1B2E632000C130BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6D2FC54C1B2E632000C130BA /* Project object */; +} diff --git a/examples/ios_example/imguiex/AppDelegate.h b/examples/ios_example/imguiex/AppDelegate.h new file mode 100644 index 000000000..82f1542eb --- /dev/null +++ b/examples/ios_example/imguiex/AppDelegate.h @@ -0,0 +1,13 @@ +// +// AppDelegate.h +// imguiex + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/examples/ios_example/imguiex/AppDelegate.m b/examples/ios_example/imguiex/AppDelegate.m new file mode 100644 index 000000000..ab83101e7 --- /dev/null +++ b/examples/ios_example/imguiex/AppDelegate.m @@ -0,0 +1,41 @@ +// +// AppDelegate.m +// imguiex + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/examples/ios_example/imguiex/Base.lproj/LaunchScreen.xib b/examples/ios_example/imguiex/Base.lproj/LaunchScreen.xib new file mode 100644 index 000000000..5717c00e2 --- /dev/null +++ b/examples/ios_example/imguiex/Base.lproj/LaunchScreen.xib @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ios_example/imguiex/Base.lproj/Main.storyboard b/examples/ios_example/imguiex/Base.lproj/Main.storyboard new file mode 100644 index 000000000..90dfb2e67 --- /dev/null +++ b/examples/ios_example/imguiex/Base.lproj/Main.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ios_example/imguiex/GameViewController.h b/examples/ios_example/imguiex/GameViewController.h new file mode 100644 index 000000000..7c7eeeae5 --- /dev/null +++ b/examples/ios_example/imguiex/GameViewController.h @@ -0,0 +1,13 @@ +// +// GameViewController.h +// imguiex + +// This is the OpenGL Example template from XCode, modified to +// support IMGUI + +#import +#import + +@interface GameViewController : GLKViewController + +@end diff --git a/examples/ios_example/imguiex/GameViewController.m b/examples/ios_example/imguiex/GameViewController.m new file mode 100644 index 000000000..e902f7ac2 --- /dev/null +++ b/examples/ios_example/imguiex/GameViewController.m @@ -0,0 +1,481 @@ +// +// GameViewController.m +// imguiex +// +#import "GameViewController.h" +#import + +#import "imgui_impl_ios.h" +#import "debug_hud.h" + +#define BUFFER_OFFSET(i) ((char *)NULL + (i)) + +#define SERVERNAME_KEY @"ServerName" + +#define SERVERNAME_ALERT_TAG (10) + +// Uniform index. +enum +{ + UNIFORM_MODELVIEWPROJECTION_MATRIX, + UNIFORM_NORMAL_MATRIX, + UNIFORM_DIFFUSE_COLOR, + + NUM_UNIFORMS +}; +GLint uniforms[NUM_UNIFORMS]; + +// Attribute index. +enum +{ + ATTRIB_VERTEX, + ATTRIB_NORMAL, + NUM_ATTRIBUTES +}; + +GLfloat gCubeVertexData[216] = +{ + // Data layout for each line below is: + // positionX, positionY, positionZ, normalX, normalY, normalZ, + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + + 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + + -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + + -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + + 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f +}; + +@interface GameViewController () +{ + GLuint _program; + + GLKMatrix4 _modelViewProjectionMatrix; + GLKMatrix3 _normalMatrix; + float _rotation; + + GLuint _vertexArray; + GLuint _vertexBuffer; + + DebugHUD _hud; +} +@property (strong, nonatomic) EAGLContext *context; +@property (strong, nonatomic) GLKBaseEffect *effect; +@property (strong, nonatomic) ImGuiHelper *imgui; +@property (weak, nonatomic) IBOutlet UIButton *btnServername; + +@property (strong, nonatomic) NSString *serverName; + +- (IBAction)onServernameTapped:(id)sender; + +- (void)setupGL; +- (void)tearDownGL; + +- (BOOL)loadShaders; +- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file; +- (BOOL)linkProgram:(GLuint)prog; +- (BOOL)validateProgram:(GLuint)prog; +@end + +@implementation GameViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + + if (!self.context) { + NSLog(@"Failed to create ES context"); + } + + GLKView *view = (GLKView *)self.view; + view.context = self.context; + view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + + [self.btnServername setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + + [self setupGL]; + + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + self.serverName = [userDefaults objectForKey: SERVERNAME_KEY ]; + self.imgui = [[ImGuiHelper alloc] initWithView:self.view ]; + if (self.serverName) + { + [self.btnServername setTitle:self.serverName forState:UIControlStateNormal]; + [self.imgui connectServer: self.serverName ]; + } + + DebugHUD_InitDefaults( &_hud ); +} + +- (void)dealloc +{ + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + + if ([self isViewLoaded] && ([[self view] window] == nil)) { + self.view = nil; + + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } + self.context = nil; + } + + // Dispose of any resources that can be recreated. +} + + +- (BOOL)prefersStatusBarHidden { + return YES; +} + +- (IBAction)onServernameTapped:(id)sender +{ + UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Set Server" message:@"Enter server name or IP for uSynergy" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil ]; + alert.alertViewStyle = UIAlertViewStylePlainTextInput; + alert.tag = SERVERNAME_ALERT_TAG; // cheezy way to tell which alert view we're responding to + [alert show]; +} + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if ((buttonIndex==0)&&(alertView.tag==SERVERNAME_ALERT_TAG)) + { + // This is really janky. I usually just hardcode the servername since I'm building it anyway. + // If you want to properly handle updating the server, you'll want to tear down and recreate + // the usynergy stuff in connectServer + BOOL serverNameWasSet = self.serverName.length > 0; + NSString *serverName = [[alertView textFieldAtIndex:0] text]; + + if ([serverName length] > 0) { + self.serverName = serverName; + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + [userDefaults setObject:serverName forKey:SERVERNAME_KEY ]; + [userDefaults synchronize]; + + [self.btnServername setTitle:self.serverName forState:UIControlStateNormal]; + + // If we hadn't previously connected, try now + if (!serverNameWasSet) { + [self.imgui connectServer:self.serverName]; + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Servername Updated" + message:@"Restart the app to connect the server" + delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; + [alert show]; + } + } + } +} + +- (void)setupGL +{ + [EAGLContext setCurrentContext:self.context]; + + [self loadShaders]; + + self.effect = [[GLKBaseEffect alloc] init]; + self.effect.light0.enabled = GL_TRUE; + self.effect.light0.diffuseColor = GLKVector4Make(1.0f, 0.4f, 0.4f, 1.0f); + + glEnable(GL_DEPTH_TEST); + + glGenVertexArraysOES(1, &_vertexArray); + glBindVertexArrayOES(_vertexArray); + + glGenBuffers(1, &_vertexBuffer); + glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW); + + glEnableVertexAttribArray(GLKVertexAttribPosition); + glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0)); + glEnableVertexAttribArray(GLKVertexAttribNormal); + glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12)); + + glBindVertexArrayOES(0); + + +} + +- (void)tearDownGL +{ + [EAGLContext setCurrentContext:self.context]; + + glDeleteBuffers(1, &_vertexBuffer); + glDeleteVertexArraysOES(1, &_vertexArray); + + self.effect = nil; + + if (_program) { + glDeleteProgram(_program); + _program = 0; + } +} + +#pragma mark - GLKView and GLKViewController delegate methods + +- (void)update +{ + float aspect = fabs(self.view.bounds.size.width / self.view.bounds.size.height); + GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f); + + self.effect.transform.projectionMatrix = projectionMatrix; + + GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f); + baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation, 0.0f, 1.0f, 0.0f); + + // Compute the model view matrix for the object rendered with GLKit + GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -1.5f); + modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); + modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); + + self.effect.transform.modelviewMatrix = modelViewMatrix; + + // Compute the model view matrix for the object rendered with ES2 + modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f); + modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); + modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); + + _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL); + + _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix); + + _rotation += self.timeSinceLastUpdate * (_hud.rotation_speed * (M_PI / 180.0)); +} + + +- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect +{ + glClearColor(0.65f, 0.65f, 0.65f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBindVertexArrayOES(_vertexArray); + + // Render the object with GLKit + [self.effect prepareToDraw]; + + glDrawArrays(GL_TRIANGLES, 0, 36); + + // Render the object again with ES2 + glUseProgram(_program); + + glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, _modelViewProjectionMatrix.m); + glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, _normalMatrix.m); + glUniform3f(uniforms[UNIFORM_DIFFUSE_COLOR], _hud.cubeColor1[0], _hud.cubeColor1[1], _hud.cubeColor1[2] ); + + glDrawArrays(GL_TRIANGLES, 0, 36); + + [self.imgui newFrame]; + + // Now do our ImGUI UI + DebugHUD_DoInterface( &_hud ); + + self.effect.light0.diffuseColor = GLKVector4Make( _hud.cubeColor2[0], _hud.cubeColor2[1], _hud.cubeColor2[2], 1.0f); + + // Now render Imgui + [self.imgui render]; + +} + +#pragma mark - OpenGL ES 2 shader compilation + +- (BOOL)loadShaders +{ + GLuint vertShader, fragShader; + NSString *vertShaderPathname, *fragShaderPathname; + + // Create shader program. + _program = glCreateProgram(); + + // Create and compile vertex shader. + vertShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"]; + if (![self compileShader:&vertShader type:GL_VERTEX_SHADER file:vertShaderPathname]) { + NSLog(@"Failed to compile vertex shader"); + return NO; + } + + // Create and compile fragment shader. + fragShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"]; + if (![self compileShader:&fragShader type:GL_FRAGMENT_SHADER file:fragShaderPathname]) { + NSLog(@"Failed to compile fragment shader"); + return NO; + } + + // Attach vertex shader to program. + glAttachShader(_program, vertShader); + + // Attach fragment shader to program. + glAttachShader(_program, fragShader); + + // Bind attribute locations. + // This needs to be done prior to linking. + glBindAttribLocation(_program, GLKVertexAttribPosition, "position"); + glBindAttribLocation(_program, GLKVertexAttribNormal, "normal"); + + // Link program. + if (![self linkProgram:_program]) { + NSLog(@"Failed to link program: %d", _program); + + if (vertShader) { + glDeleteShader(vertShader); + vertShader = 0; + } + if (fragShader) { + glDeleteShader(fragShader); + fragShader = 0; + } + if (_program) { + glDeleteProgram(_program); + _program = 0; + } + + return NO; + } + + // Get uniform locations. + uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX] = glGetUniformLocation(_program, "modelViewProjectionMatrix"); + uniforms[UNIFORM_NORMAL_MATRIX] = glGetUniformLocation(_program, "normalMatrix"); + uniforms[UNIFORM_DIFFUSE_COLOR] = glGetUniformLocation(_program, "diffuseColor"); + + // Release vertex and fragment shaders. + if (vertShader) { + glDetachShader(_program, vertShader); + glDeleteShader(vertShader); + } + if (fragShader) { + glDetachShader(_program, fragShader); + glDeleteShader(fragShader); + } + + return YES; +} + +- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file +{ + GLint status; + const GLchar *source; + + source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String]; + if (!source) { + NSLog(@"Failed to load vertex shader"); + return NO; + } + + *shader = glCreateShader(type); + glShaderSource(*shader, 1, &source, NULL); + glCompileShader(*shader); + +#if defined(DEBUG) + GLint logLength; + glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength); + if (logLength > 0) { + GLchar *log = (GLchar *)malloc(logLength); + glGetShaderInfoLog(*shader, logLength, &logLength, log); + NSLog(@"Shader compile log:\n%s", log); + free(log); + } +#endif + + glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); + if (status == 0) { + glDeleteShader(*shader); + return NO; + } + + return YES; +} + +- (BOOL)linkProgram:(GLuint)prog +{ + GLint status; + glLinkProgram(prog); + +#if defined(DEBUG) + GLint logLength; + glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength); + if (logLength > 0) { + GLchar *log = (GLchar *)malloc(logLength); + glGetProgramInfoLog(prog, logLength, &logLength, log); + NSLog(@"Program link log:\n%s", log); + free(log); + } +#endif + + glGetProgramiv(prog, GL_LINK_STATUS, &status); + if (status == 0) { + return NO; + } + + return YES; +} + +- (BOOL)validateProgram:(GLuint)prog +{ + GLint logLength, status; + + glValidateProgram(prog); + glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength); + if (logLength > 0) { + GLchar *log = (GLchar *)malloc(logLength); + glGetProgramInfoLog(prog, logLength, &logLength, log); + NSLog(@"Program validate log:\n%s", log); + free(log); + } + + glGetProgramiv(prog, GL_VALIDATE_STATUS, &status); + if (status == 0) { + return NO; + } + + return YES; +} + +@end diff --git a/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/Contents.json b/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..a05a29bbf --- /dev/null +++ b/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,72 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "icon_imgui_60@2x~iphone.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "icon_imgui_60@3x~iphone.png", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon_imgui_76~ipad.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon_imgui_76@2x~ipad.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png b/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png new file mode 100644 index 0000000000000000000000000000000000000000..0b154f349e126ce471a1f78a6ce98899084932e0 GIT binary patch literal 4491 zcmV;65p?c}P) zd3;nww#VyK-P`wer`IHGPe2`62NXqAL>-i621i9<6cG_eMaDr{B!oZ+3A>8Uj63+A zsN)kyP+7+1@#f>g{&8FeL>>$=fItW#ko4Yt``%ks?~mKTkaR+KCpL!M?}tB{^j)fd z_w=b#r%zSEu-`65CJ6ulgt+k%A&z+bKWQSgNTbdt00BpgF^UjJ2oOTX3jmA(r!BWB zbbTn(2(j4h9$B&r!~y_1)nc(wR0(LBf-yk|qtxX#g+2{%&JaQ#cW1Y&qeZmVnseN9 z=(-vRoviVeGo}NORJBe)XvR1|lPzuf?VmNkIVHr>sY8z}o0~Dpn9l2X4giFSkmKoW zw`Cu%+OH@fjD?i6PF83DkR(DWk9QGuB;_0dAONIktkp`*2oXDX>McnQooayK46}*L z&2?R~Sme%~`jl7fiK&s4>^do-0YFi-!h$<4zw|=JImTzm$vHxZ7cYEw|M$mbN#wj) zz4JMNbKXApVp($NR0Y6|9R>iDQ9{HH?Ykd6wx{JS8UQGzTes~SF}z>G1NQDKFKw+V z17o^9E8Agjr!%bymE%Vvpj5X?4!5ggjrS8%HFIXa|pGyvnw>1dBhvMQq_g*Glv8C(7C4h(=X1^@uy91((l zIDGPpe}12pB^#o*E;whRV3B19XADrXhQc|sh_YD(BQMz|uImW=4 z@gzAyXv2qJheA<8l741CBY<-*h%zBUiX#yYKrEsaah~MENkJV9plS5&HQVF2;v8dK z;|+cK*`BN{iL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kuq!e5wLVOcS#7 z6g*X9DjHkgKMVT%i-f*}XK4f(vyj!3hNr`0EQE=k9a^v%rAQtb9Y}Y{=U`WLw$BiuSS;6|?Fng&|h z@S7PmG^J3Is@>CL>c&c{#kI@A=rZ-Hd5Xp$WU$q#B-=hGKvdL1C2P~(%U@yG=R@fN z4Z!f_J3VqLe+TAwnQEOaEXMmwi?pKLJQLUqX$lq>Wnr!}X8nAx&UUd0R=0I;-Waxc zfIpt+(O9Y-mQT^_v$W4t_-@N$ZSgVQ?P@;z&}pO<^}Ys~YBdGxz~M*t*<5?gi>LdJ tA%|W6QAz)AtKq*Zxqs^rkT&Np$#96FFGYjMUQ**2prx*_Rt2*Q{~u`V6D9xv literal 0 HcmV?d00001 diff --git a/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png b/examples/ios_example/imguiex/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png new file mode 100644 index 0000000000000000000000000000000000000000..8813551e6bf63329171151e62cc080f72d82c87d GIT binary patch literal 2838 zcmV+x3+eQUP)UL74FmB_r8^xc>^;*kR4_TB1MEDsF8pu2`aK9iYS|LjTV)Zq$;MgjAbZNBJKqN zajT#SB~jF9+@gS@R4Qd8Ff76V&Ol~(@4n@}ch^4oao;R&nD^$QGxKJ^ujU8ua=ZI{ zeNOi|-RE4GI{o*ghX4o&6o@t=A%p+`rHl|D1amj!xjF>^X#9bM06|1-r^8N!Elf%B z`n-K4$%`lqBbiLags>>(xp`(KiHMqRLgqux8Rs-FJP}24(ZEn>0B16g^o;99vi|fD zRgL84*)~Z;lq5cMNNJPe5D5S%iW*iDoOLlz5W*_$GqgA~&=#gGOp-QNB1^sj{eDz5gn@)h3{W6iL)-WS`fkt278B!F0gC^2mk@n zXkdso04*&Urs;9ZGFz;!4A3^8GDcIH@$!}(gb+kx+kz1C#h$}o{-?(0lZEJ7JpvRJ z^d|({VgN!2&O8OdQbfC%eJ0u_Y1^V#(6?h(b@hSTrs>(bZM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.example.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/ios_example/imguiex/Shaders/Shader.fsh b/examples/ios_example/imguiex/Shaders/Shader.fsh new file mode 100644 index 000000000..4000524fc --- /dev/null +++ b/examples/ios_example/imguiex/Shaders/Shader.fsh @@ -0,0 +1,10 @@ +// +// Shader.fsh +// imguiex + +varying lowp vec4 colorVarying; + +void main() +{ + gl_FragColor = colorVarying; +} diff --git a/examples/ios_example/imguiex/Shaders/Shader.vsh b/examples/ios_example/imguiex/Shaders/Shader.vsh new file mode 100644 index 000000000..313c3d7a3 --- /dev/null +++ b/examples/ios_example/imguiex/Shaders/Shader.vsh @@ -0,0 +1,25 @@ +// +// Shader.vsh +// imguiex + +attribute vec4 position; +attribute vec3 normal; + +varying lowp vec4 colorVarying; + +uniform vec3 diffuseColor; +uniform mat4 modelViewProjectionMatrix; +uniform mat3 normalMatrix; + +void main() +{ + vec3 eyeNormal = normalize(normalMatrix * normal); + vec3 lightPosition = vec3(0.0, 0.0, 1.0); + + float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition))); + + vec3 colorLit = diffuseColor * nDotVP; + colorVarying = vec4( colorLit.x, colorLit.y, colorLit.z, 1.0 ); + + gl_Position = modelViewProjectionMatrix * position; +} diff --git a/examples/ios_example/imguiex/debug_hud.cpp b/examples/ios_example/imguiex/debug_hud.cpp new file mode 100644 index 000000000..5d364d7b4 --- /dev/null +++ b/examples/ios_example/imguiex/debug_hud.cpp @@ -0,0 +1,53 @@ +// +// debug_hud.cpp +// imguiex + +#include + +#include "debug_hud.h" +#include "imgui.h" + +void DebugHUD_InitDefaults( DebugHUD *hud ) +{ + hud->show_test_window = 1; + hud->show_example_window = 1; + hud->rotation_speed = 15.0; + + hud->cubeColor1[0] = 0.4; + hud->cubeColor1[1] = 0.4; + hud->cubeColor1[2] = 1.0; + hud->cubeColor1[3] = 1.0; + + hud->cubeColor2[0] = 1.0; + hud->cubeColor2[1] = 0.4; + hud->cubeColor2[2] = 0.4; + hud->cubeColor2[3] = 1.0; + +} + +void DebugHUD_DoInterface( DebugHUD *hud ) +{ + if (hud->show_test_window) + { + ImGui::SetNextWindowPos( ImVec2( 400, 20 ), ImGuiSetCond_FirstUseEver ); + bool show_test_window = hud->show_test_window; + ImGui::ShowTestWindow( &show_test_window ); + hud->show_test_window = show_test_window; + } + + if (hud->show_example_window) + { + bool show_window = hud->show_example_window; + ImGui::SetNextWindowPos( ImVec2( 20, 20 ), ImGuiSetCond_FirstUseEver ); + ImGui::SetNextWindowSize( ImVec2( 350, 200 ), ImGuiSetCond_FirstUseEver ); + ImGui::Begin("Another Window", &show_window); + hud->show_example_window = show_window; + + ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1); + ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2); + ImGui::SliderFloat("Rotation Speed", &(hud->rotation_speed), 0.0f, 200.0f); + + ImGui::End(); + } + +} \ No newline at end of file diff --git a/examples/ios_example/imguiex/debug_hud.h b/examples/ios_example/imguiex/debug_hud.h new file mode 100644 index 000000000..6df9ff0cb --- /dev/null +++ b/examples/ios_example/imguiex/debug_hud.h @@ -0,0 +1,28 @@ +// +// debug_hud.h +// imguiex + +#ifndef __imguiex__debug_hud__ +#define __imguiex__debug_hud__ + +typedef struct DebugHUD +{ + int show_test_window; + int show_example_window; + float rotation_speed; + float cubeColor1[4]; + float cubeColor2[4]; +} DebugHUD; + +#if __cplusplus +extern "C" { +#endif + +void DebugHUD_InitDefaults( DebugHUD *hud ); +void DebugHUD_DoInterface( DebugHUD *hud ); + +#if __cplusplus +} +#endif + +#endif /* defined(__imguiex__debug_hud__) */ diff --git a/examples/ios_example/imguiex/imgui_ex_icon.png b/examples/ios_example/imguiex/imgui_ex_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c83d2e777ea9b9b0bfd78e7c2f9787de7de59d5a GIT binary patch literal 16394 zcmb`u2UL^Ywk{k*L8YmP2q>UPm)@j1T6cv>!y@S$g=pBNhl+b(c zgx-6Ag#Y!s`#blXf82e}y?gA8k?|&P)|&5JYt6OhGoLy0`IWjN*-hG;AP|U5S?Pr) z2y_Mbcm;I*&&7vUt_Zl$xXSCfYQZdBJxt+HkgNsF49ckNU}^=`gqm7-Id?!MKp;Xk z8*M#TJ++r&<}e3t(?4yvJsq5Y-XM^Kw5OA)xgFG%(F|&3<0$!fryli~(Z)jZF<3~A zSItQdYHg$B4ToxZt81Hk+nI}6JeHPXl<*V-1UNulO&L8M>>XXiJS89hC07ji{O2~$ zW5&OlxY|iR{$EPzsl8&9gTbMULfpb!=Dd7@j3T1kd_uw^q9RWj`GM~|yw7;}dAWE+ z#e@XJc=;Ls@p=qA4Q^p6rujnQAI}25Nj|oAb#)Ts;qmbB;Pw#UhQY0P_(VlTd3gDG z`1!ej7F;e~j;^MjT#hbGe@l1)buowAIJw%u92x&eG&O^{xk^3;H2q&gaB%t$v5qeP zm?mJtcsxy=c=)(^{|xExhH7g6eNzXA|7h*vstNty`u-mUyJ&kkL3uQxE-*K^Ik0e+ zOn)BbBqj%kn!3W^+Ax^?-?RA28s-Xfv4%M@%E|pTYm97arsg(|e{Qn>)k{rHOxe-J z)zr}(s{BIoF(8NA#>PTSL{LahR-Rv$S5{D#k567mlvnndth@rRpqvn&+;ahezx%#` znY%ea9bNzKYw^GPKL4kE{}_a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3#c)v5(~N(ylAMH#=9U^(1ChWkz&QlRp~W1( zU%Gb(gmi5lc7*`Tnbei-vA;P!joPkGxUEspDdYQm0VuW8QDQ zEuU}K8e+vdft=({qF|mPg$TyO5$D|YgQ?9Pd9-pTV%);gO0lg~7`3luU~o2kMkbch z^D|`@$n~^biUI`RAdl`77FO|!g9%2FBJjSd%fbGB;c;o2^wL~<(|!8V{SBdk;0FKC z8JSD<4wLns8!!M#S01%(btBYXs$;!QQq?^zGk^X`Bh~)y?(XjFTqSA+lF@)ww8ti;iBR1T&BU z{J$0oASsOp(mlM0^|+0ZoNTx0VChz-*Yy=4U8ZtG=jT`;TJhiieRJ)OTTksJKY#fW zWy3IJV{oMhwpnxZ5XeKSfezP-Oh}P6725oBW_q69mX<+>9+~m2kb3vmmtT;6ag7u< z9i;8(9(A?e>#5IV7ZANoxMUZM4DTa$ujNA|kS1v9{J!G>6Az<+6+l*;6T17F~w&Ign_5rCXIFZYo8gV6t93z1N*YFYS?LR8OnlOH)2!2I5>h5dP-EFgY3u}`=HrfBzqaCOw)imiHFO+z&0mG@;cu_}y9>Vmly3i +#include + +@interface ImGuiHelper : NSObject + +- (id) initWithView: (UIView *)view; + +- (void)connectServer: (NSString*)serverName; + +- (void)render; +- (void)newFrame; + +@end + + +#endif /* defined(__imguiex__imgui_impl_ios__) */ diff --git a/examples/ios_example/imguiex/imgui_impl_ios.mm b/examples/ios_example/imguiex/imgui_impl_ios.mm new file mode 100644 index 000000000..c7cf41dfb --- /dev/null +++ b/examples/ios_example/imguiex/imgui_impl_ios.mm @@ -0,0 +1,825 @@ +// +// imgui_impl_ios.cpp +// imguiex + +#import +#import + +#include +#include +#include +#include + +#include "imgui_impl_ios.h" +#include "imgui.h" + +#include "uSynergy.h" + +// From Carbon HIToolbox/Events.h +enum { + kVK_ANSI_A = 0x00, + kVK_ANSI_S = 0x01, + kVK_ANSI_D = 0x02, + kVK_ANSI_F = 0x03, + kVK_ANSI_H = 0x04, + kVK_ANSI_G = 0x05, + kVK_ANSI_Z = 0x06, + kVK_ANSI_X = 0x07, + kVK_ANSI_C = 0x08, + kVK_ANSI_V = 0x09, + kVK_ANSI_B = 0x0B, + kVK_ANSI_Q = 0x0C, + kVK_ANSI_W = 0x0D, + kVK_ANSI_E = 0x0E, + kVK_ANSI_R = 0x0F, + kVK_ANSI_Y = 0x10, + kVK_ANSI_T = 0x11, + kVK_ANSI_1 = 0x12, + kVK_ANSI_2 = 0x13, + kVK_ANSI_3 = 0x14, + kVK_ANSI_4 = 0x15, + kVK_ANSI_6 = 0x16, + kVK_ANSI_5 = 0x17, + kVK_ANSI_Equal = 0x18, + kVK_ANSI_9 = 0x19, + kVK_ANSI_7 = 0x1A, + kVK_ANSI_Minus = 0x1B, + kVK_ANSI_8 = 0x1C, + kVK_ANSI_0 = 0x1D, + kVK_ANSI_RightBracket = 0x1E, + kVK_ANSI_O = 0x1F, + kVK_ANSI_U = 0x20, + kVK_ANSI_LeftBracket = 0x21, + kVK_ANSI_I = 0x22, + kVK_ANSI_P = 0x23, + kVK_ANSI_L = 0x25, + kVK_ANSI_J = 0x26, + kVK_ANSI_Quote = 0x27, + kVK_ANSI_K = 0x28, + kVK_ANSI_Semicolon = 0x29, + kVK_ANSI_Backslash = 0x2A, + kVK_ANSI_Comma = 0x2B, + kVK_ANSI_Slash = 0x2C, + kVK_ANSI_N = 0x2D, + kVK_ANSI_M = 0x2E, + kVK_ANSI_Period = 0x2F, + kVK_ANSI_Grave = 0x32, + kVK_ANSI_KeypadDecimal = 0x41, + kVK_ANSI_KeypadMultiply = 0x43, + kVK_ANSI_KeypadPlus = 0x45, + kVK_ANSI_KeypadClear = 0x47, + kVK_ANSI_KeypadDivide = 0x4B, + kVK_ANSI_KeypadEnter = 0x4C, + kVK_ANSI_KeypadMinus = 0x4E, + kVK_ANSI_KeypadEquals = 0x51, + kVK_ANSI_Keypad0 = 0x52, + kVK_ANSI_Keypad1 = 0x53, + kVK_ANSI_Keypad2 = 0x54, + kVK_ANSI_Keypad3 = 0x55, + kVK_ANSI_Keypad4 = 0x56, + kVK_ANSI_Keypad5 = 0x57, + kVK_ANSI_Keypad6 = 0x58, + kVK_ANSI_Keypad7 = 0x59, + kVK_ANSI_Keypad8 = 0x5B, + kVK_ANSI_Keypad9 = 0x5C +}; + +/* keycodes for keys that are independent of keyboard layout*/ +enum { + kVK_Return = 0x24, + kVK_Tab = 0x30, + kVK_Space = 0x31, + kVK_Delete = 0x33, + kVK_Escape = 0x35, + kVK_Command = 0x37, + kVK_Shift = 0x38, + kVK_CapsLock = 0x39, + kVK_Option = 0x3A, + kVK_Control = 0x3B, + kVK_RightShift = 0x3C, + kVK_RightOption = 0x3D, + kVK_RightControl = 0x3E, + kVK_Function = 0x3F, + kVK_F17 = 0x40, + kVK_VolumeUp = 0x48, + kVK_VolumeDown = 0x49, + kVK_Mute = 0x4A, + kVK_F18 = 0x4F, + kVK_F19 = 0x50, + kVK_F20 = 0x5A, + kVK_F5 = 0x60, + kVK_F6 = 0x61, + kVK_F7 = 0x62, + kVK_F3 = 0x63, + kVK_F8 = 0x64, + kVK_F9 = 0x65, + kVK_F11 = 0x67, + kVK_F13 = 0x69, + kVK_F16 = 0x6A, + kVK_F14 = 0x6B, + kVK_F10 = 0x6D, + kVK_F12 = 0x6F, + kVK_F15 = 0x71, + kVK_Help = 0x72, + kVK_Home = 0x73, + kVK_PageUp = 0x74, + kVK_ForwardDelete = 0x75, + kVK_F4 = 0x76, + kVK_End = 0x77, + kVK_F2 = 0x78, + kVK_PageDown = 0x79, + kVK_F1 = 0x7A, + kVK_LeftArrow = 0x7B, + kVK_RightArrow = 0x7C, + kVK_DownArrow = 0x7D, + kVK_UpArrow = 0x7E +}; + +static char g_keycodeCharUnshifted[256] = {}; +static char g_keycodeCharShifted[256] = {}; + +//static double g_Time = 0.0f; +static bool g_MousePressed[3] = { false, false, false }; +static float g_mouseWheelX = 0.0f; +static float g_mouseWheelY = 0.0f; + +static GLuint g_FontTexture = 0; +static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; +static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; +static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0; +static size_t g_VboSize = 0; +static unsigned int g_VboHandle = 0, g_VaoHandle = 0; +static float g_displayScale; + +static int usynergy_sockfd; +static bool g_synergyPtrActive = false; +static uint16_t g_mousePosX = 0; +static uint16_t g_mousePosY = 0; + +static void ImGui_ImplIOS_RenderDrawLists (ImDrawList** const cmd_lists, int cmd_lists_count); +bool ImGui_ImplIOS_CreateDeviceObjects(); + +static NSString *g_serverName; + +uSynergyBool ImGui_ConnectFunc(uSynergyCookie cookie) +{ + // NOTE: You need to turn off "Use SSL Encryption" in Synergy preferences, since + // uSynergy does not support SSL. + + NSLog( @"Connect Func!"); + struct addrinfo hints, *res; + + // first, load up address structs with getaddrinfo(): + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever + hints.ai_socktype = SOCK_STREAM; + + // get server address + getaddrinfo([g_serverName UTF8String], "24800", &hints, &res); + + if (!res) + { + NSLog( @"Could not find server: %@", g_serverName ); + return USYNERGY_FALSE; + } + + // make a socket: + usynergy_sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + + // connect it to the address and port we passed in to getaddrinfo(): + int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen); + if (!ret) { + NSLog( @"Connect suceeded..."); + } else { + NSLog( @"Connect failed, %d", ret ); + } + + + return USYNERGY_TRUE; +} + +uSynergyBool ImGui_SendFunc(uSynergyCookie cookie, const uint8_t *buffer, int length) +{ +// NSLog( @"Send Func" ); + send( usynergy_sockfd, buffer, length, 0 ); + + return USYNERGY_TRUE; +} + +uSynergyBool ImGui_RecvFunc(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength) +{ + *outLength = (int)recv( usynergy_sockfd, buffer, maxLength, 0 ); + + return USYNERGY_TRUE; +} + +void ImGui_SleepFunc(uSynergyCookie cookie, int timeMs) +{ + usleep( timeMs * 1000 ); +} + +uint32_t ImGui_GetTimeFunc() +{ + struct timeval tv; + gettimeofday(&tv, NULL); + + return (int32_t)((tv.tv_sec) * 1000 + (tv.tv_usec) / 1000); +} + +void ImGui_TraceFunc(uSynergyCookie cookie, const char *text) +{ + puts(text); +} + +void ImGui_ScreenActiveCallback(uSynergyCookie cookie, uSynergyBool active) +{ + g_synergyPtrActive = active; +// printf( "Synergy: screen activate %s\n", active?"YES":"NO" ); +} + +void ImGui_MouseCallback(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, + uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle) +{ +// printf("Synergy: mouse callback %d %d -- wheel %d %d\n", x, y, wheelX, wheelY ); + uSynergyContext *ctx = (uSynergyContext*)cookie; + g_mousePosX = x; + g_mousePosY = y; + g_mouseWheelX = wheelX; + g_mouseWheelY = wheelY; + g_MousePressed[0] = buttonLeft; + g_MousePressed[1] = buttonMiddle; + g_MousePressed[2] = buttonRight; + + ctx->m_mouseWheelX = 0; + ctx->m_mouseWheelY = 0; +} + +void ImGui_KeyboardCallback(uSynergyCookie cookie, uint16_t key, + uint16_t modifiers, uSynergyBool down, uSynergyBool repeat) +{ + int scanCode = key-1; +// printf("Synergy: keyboard callback: 0x%02X (%s)", scanCode, down?"true":"false"); + ImGuiIO& io = ImGui::GetIO(); + io.KeysDown[key] = down; + io.KeyShift = modifiers & USYNERGY_MODIFIER_SHIFT; + io.KeyCtrl = modifiers & USYNERGY_MODIFIER_CTRL; + io.KeyAlt = modifiers & USYNERGY_MODIFIER_ALT; + + + // Add this as keyboard input + if ((down) && (key) && (scanCode<256) && !(modifiers & USYNERGY_MODIFIER_CTRL)) { + int charForKeycode = 0; + if (modifiers & USYNERGY_MODIFIER_SHIFT ) { + charForKeycode = g_keycodeCharShifted[ scanCode ]; + } else { + charForKeycode = g_keycodeCharUnshifted[ scanCode ]; + } + + // If this key maps to a character input, apply it + io.AddInputCharacter((unsigned short)charForKeycode); + } + +} + +void ImGui_JoystickCallback(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY) +{ + printf("Synergy: joystick callback TODO\n"); +} + +void ImGui_ClipboardCallback(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size) +{ + printf("Synergy: clipboard callback TODO\n" ); +} + + +@interface ImGuiHelper () +{ + BOOL _mouseDown; + BOOL _mouseTapped; + CGPoint _touchPos; + + uSynergyContext _synergyCtx; + dispatch_queue_t _synergyQueue; +} +@property (nonatomic, weak) UIView *view; +@property (nonatomic, strong) NSString *serverName; + +@end + +@implementation ImGuiHelper + +- (id) initWithView: (UIView *)view +{ + self = [super init]; + if (self) + { + self.view = view; + + [self setupImGuiHooks]; + } + return self; +} + +- (void)setupKeymaps +{ + // The keyboard mapping is a big headache. I tried for a while to find a better way to do this, + // but this was the best I could come up with. There are some device independent API's available + // to convert scan codes to unicode characters, but these are only available on mac and not + // on iOS as far as I can tell (it's part of Carbon). I didn't see any better way to do + // this or any way to get the character codes out of usynergy. + g_keycodeCharUnshifted[ kVK_ANSI_A ]='a'; + g_keycodeCharUnshifted[ kVK_ANSI_S ]='s'; + g_keycodeCharUnshifted[ kVK_ANSI_D ]='d'; + g_keycodeCharUnshifted[ kVK_ANSI_F ]='f'; + g_keycodeCharUnshifted[ kVK_ANSI_H ]='h'; + g_keycodeCharUnshifted[ kVK_ANSI_G ]='g'; + g_keycodeCharUnshifted[ kVK_ANSI_Z ]='z'; + g_keycodeCharUnshifted[ kVK_ANSI_X ]='x'; + g_keycodeCharUnshifted[ kVK_ANSI_C ]='c'; + g_keycodeCharUnshifted[ kVK_ANSI_V ]='v'; + g_keycodeCharUnshifted[ kVK_ANSI_B ]='b'; + g_keycodeCharUnshifted[ kVK_ANSI_Q ]='q'; + g_keycodeCharUnshifted[ kVK_ANSI_W ]='w'; + g_keycodeCharUnshifted[ kVK_ANSI_E ]='e'; + g_keycodeCharUnshifted[ kVK_ANSI_R ]='r'; + g_keycodeCharUnshifted[ kVK_ANSI_Y ]='y'; + g_keycodeCharUnshifted[ kVK_ANSI_T ]='t'; + g_keycodeCharUnshifted[ kVK_ANSI_1 ]='1'; + g_keycodeCharUnshifted[ kVK_ANSI_2 ]='2'; + g_keycodeCharUnshifted[ kVK_ANSI_3 ]='3'; + g_keycodeCharUnshifted[ kVK_ANSI_4 ]='4'; + g_keycodeCharUnshifted[ kVK_ANSI_6 ]='6'; + g_keycodeCharUnshifted[ kVK_ANSI_5 ]='5'; + g_keycodeCharUnshifted[ kVK_ANSI_Equal ]='='; + g_keycodeCharUnshifted[ kVK_ANSI_9 ]='9'; + g_keycodeCharUnshifted[ kVK_ANSI_7 ]='7'; + g_keycodeCharUnshifted[ kVK_ANSI_Minus ]='-'; + g_keycodeCharUnshifted[ kVK_ANSI_8 ]='8'; + g_keycodeCharUnshifted[ kVK_ANSI_0 ]='0'; + g_keycodeCharUnshifted[ kVK_ANSI_RightBracket ]=']'; + g_keycodeCharUnshifted[ kVK_ANSI_O ]='o'; + g_keycodeCharUnshifted[ kVK_ANSI_U ]='u'; + g_keycodeCharUnshifted[ kVK_ANSI_LeftBracket ]='['; + g_keycodeCharUnshifted[ kVK_ANSI_I ]='i'; + g_keycodeCharUnshifted[ kVK_ANSI_P ]='p'; + g_keycodeCharUnshifted[ kVK_ANSI_L ]='l'; + g_keycodeCharUnshifted[ kVK_ANSI_J ]='j'; + g_keycodeCharUnshifted[ kVK_ANSI_Quote ]='\''; + g_keycodeCharUnshifted[ kVK_ANSI_K ]='k'; + g_keycodeCharUnshifted[ kVK_ANSI_Semicolon ]=';'; + g_keycodeCharUnshifted[ kVK_ANSI_Backslash ]='\\'; + g_keycodeCharUnshifted[ kVK_ANSI_Comma ]=','; + g_keycodeCharUnshifted[ kVK_ANSI_Slash ]='/'; + g_keycodeCharUnshifted[ kVK_ANSI_N ]='n'; + g_keycodeCharUnshifted[ kVK_ANSI_M ]='m'; + g_keycodeCharUnshifted[ kVK_ANSI_Period ]='.'; + g_keycodeCharUnshifted[ kVK_ANSI_Grave ]='`'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadDecimal ]='.'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadMultiply ]='*'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadPlus ]='+'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadDivide ]='/'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadEnter ]='\n'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadMinus ]='-'; + g_keycodeCharUnshifted[ kVK_ANSI_KeypadEquals ]='='; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad0 ]='0'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad1 ]='1'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad2 ]='2'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad3 ]='3'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad4 ]='4'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad5 ]='5'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad6 ]='6'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad7 ]='7'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad8 ]='8'; + g_keycodeCharUnshifted[ kVK_ANSI_Keypad9 ]='9'; + g_keycodeCharUnshifted[ kVK_Space ]=' '; + + g_keycodeCharShifted[ kVK_ANSI_A ]='A'; + g_keycodeCharShifted[ kVK_ANSI_S ]='S'; + g_keycodeCharShifted[ kVK_ANSI_D ]='D'; + g_keycodeCharShifted[ kVK_ANSI_F ]='F'; + g_keycodeCharShifted[ kVK_ANSI_H ]='H'; + g_keycodeCharShifted[ kVK_ANSI_G ]='G'; + g_keycodeCharShifted[ kVK_ANSI_Z ]='Z'; + g_keycodeCharShifted[ kVK_ANSI_X ]='X'; + g_keycodeCharShifted[ kVK_ANSI_C ]='C'; + g_keycodeCharShifted[ kVK_ANSI_V ]='V'; + g_keycodeCharShifted[ kVK_ANSI_B ]='B'; + g_keycodeCharShifted[ kVK_ANSI_Q ]='Q'; + g_keycodeCharShifted[ kVK_ANSI_W ]='W'; + g_keycodeCharShifted[ kVK_ANSI_E ]='E'; + g_keycodeCharShifted[ kVK_ANSI_R ]='R'; + g_keycodeCharShifted[ kVK_ANSI_Y ]='Y'; + g_keycodeCharShifted[ kVK_ANSI_T ]='T'; + g_keycodeCharShifted[ kVK_ANSI_1 ]='!'; + g_keycodeCharShifted[ kVK_ANSI_2 ]='@'; + g_keycodeCharShifted[ kVK_ANSI_3 ]='#'; + g_keycodeCharShifted[ kVK_ANSI_4 ]='$'; + g_keycodeCharShifted[ kVK_ANSI_6 ]='^'; + g_keycodeCharShifted[ kVK_ANSI_5 ]='%'; + g_keycodeCharShifted[ kVK_ANSI_Equal ]='+'; + g_keycodeCharShifted[ kVK_ANSI_9 ]='('; + g_keycodeCharShifted[ kVK_ANSI_7 ]='&'; + g_keycodeCharShifted[ kVK_ANSI_Minus ]='_'; + g_keycodeCharShifted[ kVK_ANSI_8 ]='*'; + g_keycodeCharShifted[ kVK_ANSI_0 ]=')'; + g_keycodeCharShifted[ kVK_ANSI_RightBracket ]='}'; + g_keycodeCharShifted[ kVK_ANSI_O ]='O'; + g_keycodeCharShifted[ kVK_ANSI_U ]='U'; + g_keycodeCharShifted[ kVK_ANSI_LeftBracket ]='{'; + g_keycodeCharShifted[ kVK_ANSI_I ]='I'; + g_keycodeCharShifted[ kVK_ANSI_P ]='P'; + g_keycodeCharShifted[ kVK_ANSI_L ]='L'; + g_keycodeCharShifted[ kVK_ANSI_J ]='J'; + g_keycodeCharShifted[ kVK_ANSI_Quote ]='\"'; + g_keycodeCharShifted[ kVK_ANSI_K ]='K'; + g_keycodeCharShifted[ kVK_ANSI_Semicolon ]=':'; + g_keycodeCharShifted[ kVK_ANSI_Backslash ]='|'; + g_keycodeCharShifted[ kVK_ANSI_Comma ]='<'; + g_keycodeCharShifted[ kVK_ANSI_Slash ]='?'; + g_keycodeCharShifted[ kVK_ANSI_N ]='N'; + g_keycodeCharShifted[ kVK_ANSI_M ]='M'; + g_keycodeCharShifted[ kVK_ANSI_Period ]='>'; + g_keycodeCharShifted[ kVK_ANSI_Grave ]='~'; + g_keycodeCharShifted[ kVK_ANSI_KeypadDecimal ]='.'; + g_keycodeCharShifted[ kVK_ANSI_KeypadMultiply ]='*'; + g_keycodeCharShifted[ kVK_ANSI_KeypadPlus ]='+'; + g_keycodeCharShifted[ kVK_ANSI_KeypadDivide ]='/'; + g_keycodeCharShifted[ kVK_ANSI_KeypadEnter ]='\n'; + g_keycodeCharShifted[ kVK_ANSI_KeypadMinus ]='-'; + g_keycodeCharShifted[ kVK_ANSI_KeypadEquals ]='='; + g_keycodeCharShifted[ kVK_ANSI_Keypad0 ]='0'; + g_keycodeCharShifted[ kVK_ANSI_Keypad1 ]='1'; + g_keycodeCharShifted[ kVK_ANSI_Keypad2 ]='2'; + g_keycodeCharShifted[ kVK_ANSI_Keypad3 ]='3'; + g_keycodeCharShifted[ kVK_ANSI_Keypad4 ]='4'; + g_keycodeCharShifted[ kVK_ANSI_Keypad5 ]='5'; + g_keycodeCharShifted[ kVK_ANSI_Keypad6 ]='6'; + g_keycodeCharShifted[ kVK_ANSI_Keypad7 ]='7'; + g_keycodeCharShifted[ kVK_ANSI_Keypad8 ]='8'; + g_keycodeCharShifted[ kVK_ANSI_Keypad9 ]='9'; + g_keycodeCharShifted[ kVK_Space ]=' '; +} + +- (void)setupImGuiHooks +{ + ImGuiIO &io = ImGui::GetIO(); + + [self setupKeymaps]; + + // Account for retina display for glScissor + g_displayScale = [[UIScreen mainScreen] scale]; + + ImGuiStyle &style = ImGui::GetStyle(); + style.TouchExtraPadding = ImVec2( 4.0, 4.0 ); + + io.RenderDrawListsFn = ImGui_ImplIOS_RenderDrawLists; + + UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(viewDidPan:) ]; + [self.view addGestureRecognizer:panRecognizer]; + + UITapGestureRecognizer *tapRecoginzer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector( viewDidTap:)]; + [self.view addGestureRecognizer:tapRecoginzer]; + + // Fill out the Synergy key map + // (for some reason synergy scan codes are off by 1) + io.KeyMap[ImGuiKey_Tab] = kVK_Tab+1; + io.KeyMap[ImGuiKey_LeftArrow] = kVK_LeftArrow+1; + io.KeyMap[ImGuiKey_RightArrow] = kVK_RightArrow+1; + io.KeyMap[ImGuiKey_UpArrow] = kVK_UpArrow+1; + io.KeyMap[ImGuiKey_DownArrow] = kVK_DownArrow+1; + io.KeyMap[ImGuiKey_Home] = kVK_Home+1; + io.KeyMap[ImGuiKey_End] = kVK_End+1; + io.KeyMap[ImGuiKey_Delete] = kVK_ForwardDelete+1; + io.KeyMap[ImGuiKey_Backspace] = kVK_Delete+1; + io.KeyMap[ImGuiKey_Enter] = kVK_Return+1; + io.KeyMap[ImGuiKey_Escape] = kVK_Escape+1; + io.KeyMap[ImGuiKey_A] = kVK_ANSI_A+1; + io.KeyMap[ImGuiKey_C] = kVK_ANSI_C+1; + io.KeyMap[ImGuiKey_V] = kVK_ANSI_V+1; + io.KeyMap[ImGuiKey_X] = kVK_ANSI_X+1; + io.KeyMap[ImGuiKey_Y] = kVK_ANSI_Y+1; + io.KeyMap[ImGuiKey_Z] = kVK_ANSI_Z+1; + + +} + +- (void)connectServer: (NSString*)serverName +{ + self.serverName = serverName; + g_serverName = serverName; + + // Init synergy + NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]; + + uSynergyInit( &_synergyCtx ); + _synergyCtx.m_clientName = strdup( [bundleName UTF8String] ); + _synergyCtx.m_clientWidth = self.view.bounds.size.width; + _synergyCtx.m_clientHeight = self.view.bounds.size.height; + + _synergyCtx.m_connectFunc = ImGui_ConnectFunc; + _synergyCtx.m_sendFunc = ImGui_SendFunc; + _synergyCtx.m_receiveFunc = ImGui_RecvFunc; + _synergyCtx.m_sleepFunc = ImGui_SleepFunc; + _synergyCtx.m_traceFunc = ImGui_TraceFunc; + _synergyCtx.m_getTimeFunc = ImGui_GetTimeFunc; + + _synergyCtx.m_traceFunc = ImGui_TraceFunc; + _synergyCtx.m_screenActiveCallback = ImGui_ScreenActiveCallback; + _synergyCtx.m_mouseCallback = ImGui_MouseCallback; + _synergyCtx.m_keyboardCallback = ImGui_KeyboardCallback; + + _synergyCtx.m_cookie = (uSynergyCookie)&_synergyCtx; + + // Create a background thread for synergy + _synergyQueue = dispatch_queue_create( "imgui-usynergy", NULL ); + dispatch_async( _synergyQueue, ^{ + while (1) { + uSynergyUpdate( &_synergyCtx ); + } + }); +} + + +- (void)viewDidPan: (UIPanGestureRecognizer *)recognizer +{ + + if ((recognizer.state == UIGestureRecognizerStateBegan) || + (recognizer.state == UIGestureRecognizerStateChanged)) + { + _mouseDown = YES; + _touchPos = [recognizer locationInView:self.view]; + } + else + { + _mouseDown = NO; + _touchPos = CGPointMake( -1, -1 ); + } +} + +- (void)viewDidTap: (UITapGestureRecognizer*)recognizer +{ + _touchPos = [recognizer locationInView:self.view]; + _mouseTapped = YES; +} + +- (void)render +{ + ImGui::Render(); +} + +- (void)newFrame +{ + ImGuiIO& io = ImGui::GetIO(); + ImGuiStyle &style = ImGui::GetStyle(); + + if (!g_FontTexture) + { + ImGui_ImplIOS_CreateDeviceObjects(); + } + + io.DisplaySize = ImVec2( _view.bounds.size.width, _view.bounds.size.height ); + + io.MouseDrawCursor = g_synergyPtrActive; + if (g_synergyPtrActive) + { + style.TouchExtraPadding = ImVec2( 0.0, 0.0 ); + io.MousePos = ImVec2( g_mousePosX, g_mousePosY ); + for (int i=0; i < 3; i++) + { + io.MouseDown[i] = g_MousePressed[i]; + } + + // This is an arbitrary scaling factor that works for me. Not sure what units these + // mousewheel values from synergy are supposed to be in + io.MouseWheel = g_mouseWheelY / 500.0; + } + else + { + // Synergy not active, use touch events + style.TouchExtraPadding = ImVec2( 4.0, 4.0 ); + io.MousePos = ImVec2(_touchPos.x, _touchPos.y ); + if ((_mouseDown) || (_mouseTapped)) + { + io.MouseDown[0] = true; + _mouseTapped = NO; + } + else + { + io.MouseDown[0] = false; + } + } + + ImGui::NewFrame(); +} +@end + +// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) +// If text or lines are blurry when integrating ImGui in your engine: +// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) +// NOTE: this is copied pretty much entirely from the opengl3_example, with only minor changes for ES +static void ImGui_ImplIOS_RenderDrawLists (ImDrawList** const cmd_lists, int cmd_lists_count) +{ + if (cmd_lists_count == 0) + { + return; + } + + // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled + GLint last_program, last_texture; + glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glEnable(GL_SCISSOR_TEST); + glActiveTexture(GL_TEXTURE0); + + // Setup orthographic projection matrix + const float width = ImGui::GetIO().DisplaySize.x; + const float height = ImGui::GetIO().DisplaySize.y; + const float ortho_projection[4][4] = + { + { 2.0f/width, 0.0f, 0.0f, 0.0f }, + { 0.0f, 2.0f/-height, 0.0f, 0.0f }, + { 0.0f, 0.0f, -1.0f, 0.0f }, + { -1.0f, 1.0f, 0.0f, 1.0f }, + }; + glUseProgram(g_ShaderHandle); + glUniform1i(g_AttribLocationTex, 0); + glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); + + // Grow our buffer according to what we need + size_t total_vtx_count = 0; + for (int n = 0; n < cmd_lists_count; n++) + total_vtx_count += cmd_lists[n]->vtx_buffer.size(); + glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); + size_t needed_vtx_size = total_vtx_count * sizeof(ImDrawVert); + if (g_VboSize < needed_vtx_size) + { + g_VboSize = needed_vtx_size + 5000 * sizeof(ImDrawVert); // Grow buffer + glBufferData(GL_ARRAY_BUFFER, g_VboSize, NULL, GL_STREAM_DRAW); + } + + // Copy and convert all vertices into a single contiguous buffer + unsigned char* buffer_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, g_VboSize, GL_MAP_WRITE_BIT); + if (!buffer_data) + return; + for (int n = 0; n < cmd_lists_count; n++) + { + const ImDrawList* cmd_list = cmd_lists[n]; + memcpy(buffer_data, &cmd_list->vtx_buffer[0], cmd_list->vtx_buffer.size() * sizeof(ImDrawVert)); + buffer_data += cmd_list->vtx_buffer.size() * sizeof(ImDrawVert); + } + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(g_VaoHandle); + + int cmd_offset = 0; + for (int n = 0; n < cmd_lists_count; n++) + { + const ImDrawList* cmd_list = cmd_lists[n]; + int vtx_offset = cmd_offset; + const ImDrawCmd* pcmd_end = cmd_list->commands.end(); + for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) + { + if (pcmd->user_callback) + { + pcmd->user_callback(cmd_list, pcmd); + } + else + { + glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); + glScissor((int)(pcmd->clip_rect.x * g_displayScale), + (int)((height - pcmd->clip_rect.w) * g_displayScale), + (int)((pcmd->clip_rect.z - pcmd->clip_rect.x) * g_displayScale), + (int)((pcmd->clip_rect.w - pcmd->clip_rect.y) * g_displayScale)); + glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count); + } + vtx_offset += pcmd->vtx_count; + } + cmd_offset = vtx_offset; + } + + + // Restore modified state + glBindVertexArray(0); + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + glUseProgram(last_program); + glDisable(GL_SCISSOR_TEST); + glBindTexture(GL_TEXTURE_2D, last_texture); +} + +void ImGui_ImplIOS_CreateFontsTexture() +{ + ImGuiIO& io = ImGui::GetIO(); + + unsigned char* pixels; + int width, height; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader. + + glGenTextures(1, &g_FontTexture); + glBindTexture(GL_TEXTURE_2D, g_FontTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + // Store our identifier + io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; + + // Cleanup (don't clear the input data if you want to append new fonts later) + io.Fonts->ClearInputData(); + io.Fonts->ClearTexData(); +} + +bool ImGui_ImplIOS_CreateDeviceObjects() +{ + const GLchar *vertex_shader = + "uniform mat4 ProjMtx;\n" + "attribute highp vec2 Position;\n" + "attribute highp vec2 UV;\n" + "attribute highp vec4 Color;\n" + "varying vec2 Frag_UV;\n" + "varying vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" + "}\n"; + + const GLchar* fragment_shader = + "uniform sampler2D Texture;\n" + "varying highp vec2 Frag_UV;\n" + "varying highp vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " gl_FragColor = Frag_Color * texture2D( Texture, Frag_UV.st);\n" + "}\n"; + + g_ShaderHandle = glCreateProgram(); + g_VertHandle = glCreateShader(GL_VERTEX_SHADER); + g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(g_VertHandle, 1, &vertex_shader, 0); + glShaderSource(g_FragHandle, 1, &fragment_shader, 0); + glCompileShader(g_VertHandle); + +#if defined(DEBUG) + GLint logLength; + glGetShaderiv( g_VertHandle, GL_INFO_LOG_LENGTH, &logLength); + if (logLength > 0) { + GLchar *log = (GLchar *)malloc(logLength); + glGetShaderInfoLog(g_VertHandle, logLength, &logLength, log); + NSLog(@"VERTEX Shader compile log:\n%s", log); + free(log); + } +#endif + + glCompileShader(g_FragHandle); + +#if defined(DEBUG) + glGetShaderiv( g_FragHandle, GL_INFO_LOG_LENGTH, &logLength); + if (logLength > 0) { + GLchar *log = (GLchar *)malloc(logLength); + glGetShaderInfoLog(g_FragHandle, logLength, &logLength, log); + NSLog(@"FRAGMENT Shader compile log:\n%s", log); + free(log); + } +#endif + + + glAttachShader(g_ShaderHandle, g_VertHandle); + glAttachShader(g_ShaderHandle, g_FragHandle); + glLinkProgram(g_ShaderHandle); + + g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture"); + g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx"); + g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position"); + g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV"); + g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color"); + + glGenBuffers(1, &g_VboHandle); + + glGenVertexArrays(1, &g_VaoHandle); + glBindVertexArray(g_VaoHandle); + glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); + glEnableVertexAttribArray(g_AttribLocationPosition); + glEnableVertexAttribArray(g_AttribLocationUV); + glEnableVertexAttribArray(g_AttribLocationColor); + +#define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) + glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, pos)); + glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv)); + glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col)); +#undef OFFSETOF + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + ImGui_ImplIOS_CreateFontsTexture(); + + return true; +} + diff --git a/examples/ios_example/imguiex/main.m b/examples/ios_example/imguiex/main.m new file mode 100644 index 000000000..faba09928 --- /dev/null +++ b/examples/ios_example/imguiex/main.m @@ -0,0 +1,13 @@ +// +// main.m +// imguiex +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/examples/libs/usynergy/uSynergy.c b/examples/libs/usynergy/uSynergy.c new file mode 100644 index 000000000..a8d01da41 --- /dev/null +++ b/examples/libs/usynergy/uSynergy.c @@ -0,0 +1,636 @@ +/* +uSynergy client -- Implementation for the embedded Synergy client library + version 1.0.0, July 7th, 2012 + +Copyright (c) 2012 Alex Evans + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#include "uSynergy.h" +#include +#include + + + +//--------------------------------------------------------------------------------------------------------------------- +// Internal helpers +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Read 16 bit integer in network byte order and convert to native byte order +**/ +static int16_t sNetToNative16(const unsigned char *value) +{ +#ifdef USYNERGY_LITTLE_ENDIAN + return value[1] | (value[0] << 8); +#else + return value[0] | (value[1] << 8); +#endif +} + + + +/** +@brief Read 32 bit integer in network byte order and convert to native byte order +**/ +static int32_t sNetToNative32(const unsigned char *value) +{ +#ifdef USYNERGY_LITTLE_ENDIAN + return value[3] | (value[2] << 8) | (value[1] << 16) | (value[0] << 24); +#else + return value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); +#endif +} + + + +/** +@brief Trace text to client +**/ +static void sTrace(uSynergyContext *context, const char* text) +{ + // Don't trace if we don't have a trace function + if (context->m_traceFunc != 0L) + context->m_traceFunc(context->m_cookie, text); +} + + + +/** +@brief Add string to reply packet +**/ +static void sAddString(uSynergyContext *context, const char *string) +{ + size_t len = strlen(string); + memcpy(context->m_replyCur, string, len); + context->m_replyCur += len; +} + + + +/** +@brief Add uint8 to reply packet +**/ +static void sAddUInt8(uSynergyContext *context, uint8_t value) +{ + *context->m_replyCur++ = value; +} + + + +/** +@brief Add uint16 to reply packet +**/ +static void sAddUInt16(uSynergyContext *context, uint16_t value) +{ + uint8_t *reply = context->m_replyCur; + *reply++ = (uint8_t)(value >> 8); + *reply++ = (uint8_t)value; + context->m_replyCur = reply; +} + + + +/** +@brief Add uint32 to reply packet +**/ +static void sAddUInt32(uSynergyContext *context, uint32_t value) +{ + uint8_t *reply = context->m_replyCur; + *reply++ = (uint8_t)(value >> 24); + *reply++ = (uint8_t)(value >> 16); + *reply++ = (uint8_t)(value >> 8); + *reply++ = (uint8_t)value; + context->m_replyCur = reply; +} + + + +/** +@brief Send reply packet +**/ +static uSynergyBool sSendReply(uSynergyContext *context) +{ + // Set header size + uint8_t *reply_buf = context->m_replyBuffer; + uint32_t reply_len = (uint32_t)(context->m_replyCur - reply_buf); /* Total size of reply */ + uint32_t body_len = reply_len - 4; /* Size of body */ + uSynergyBool ret; + reply_buf[0] = (uint8_t)(body_len >> 24); + reply_buf[1] = (uint8_t)(body_len >> 16); + reply_buf[2] = (uint8_t)(body_len >> 8); + reply_buf[3] = (uint8_t)body_len; + + // Send reply + ret = context->m_sendFunc(context->m_cookie, context->m_replyBuffer, reply_len); + + // Reset reply buffer write pointer + context->m_replyCur = context->m_replyBuffer+4; + return ret; +} + + + +/** +@brief Call mouse callback after a mouse event +**/ +static void sSendMouseCallback(uSynergyContext *context) +{ + // Skip if no callback is installed + if (context->m_mouseCallback == 0L) + return; + + // Send callback + context->m_mouseCallback(context->m_cookie, context->m_mouseX, context->m_mouseY, context->m_mouseWheelX, + context->m_mouseWheelY, context->m_mouseButtonLeft, context->m_mouseButtonRight, context->m_mouseButtonMiddle); +} + + + +/** +@brief Send keyboard callback when a key has been pressed or released +**/ +static void sSendKeyboardCallback(uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat) +{ + // Skip if no callback is installed + if (context->m_keyboardCallback == 0L) + return; + + // Send callback + context->m_keyboardCallback(context->m_cookie, key, modifiers, down, repeat); +} + + + +/** +@brief Send joystick callback +**/ +static void sSendJoystickCallback(uSynergyContext *context, uint8_t joyNum) +{ + int8_t *sticks; + + // Skip if no callback is installed + if (context->m_joystickCallback == 0L) + return; + + // Send callback + sticks = context->m_joystickSticks[joyNum]; + context->m_joystickCallback(context->m_cookie, joyNum, context->m_joystickButtons[joyNum], sticks[0], sticks[1], sticks[2], sticks[3]); +} + + + +/** +@brief Parse a single client message, update state, send callbacks and send replies +**/ +#define USYNERGY_IS_PACKET(pkt_id) memcmp(message+4, pkt_id, 4)==0 +static void sProcessMessage(uSynergyContext *context, const uint8_t *message) +{ + // We have a packet! + if (memcmp(message+4, "Synergy", 7)==0) + { + // Welcome message + // kMsgHello = "Synergy%2i%2i" + // kMsgHelloBack = "Synergy%2i%2i%s" + sAddString(context, "Synergy"); + sAddUInt16(context, USYNERGY_PROTOCOL_MAJOR); + sAddUInt16(context, USYNERGY_PROTOCOL_MINOR); + sAddUInt32(context, (uint32_t)strlen(context->m_clientName)); + sAddString(context, context->m_clientName); + if (!sSendReply(context)) + { + // Send reply failed, let's try to reconnect + sTrace(context, "SendReply failed, trying to reconnect in a second"); + context->m_connected = USYNERGY_FALSE; + context->m_sleepFunc(context->m_cookie, 1000); + } + else + { + // Let's assume we're connected + char buffer[256+1]; + sprintf(buffer, "Connected as client \"%s\"", context->m_clientName); + sTrace(context, buffer); + context->m_hasReceivedHello = USYNERGY_TRUE; + } + return; + } + else if (USYNERGY_IS_PACKET("QINF")) + { + // Screen info. Reply with DINF + // kMsgQInfo = "QINF" + // kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i" + uint16_t x = 0, y = 0, warp = 0; + sAddString(context, "DINF"); + sAddUInt16(context, x); + sAddUInt16(context, y); + sAddUInt16(context, context->m_clientWidth); + sAddUInt16(context, context->m_clientHeight); + sAddUInt16(context, warp); + sAddUInt16(context, 0); // mx? + sAddUInt16(context, 0); // my? + sSendReply(context); + return; + } + else if (USYNERGY_IS_PACKET("CIAK")) + { + // Do nothing? + // kMsgCInfoAck = "CIAK" + return; + } + else if (USYNERGY_IS_PACKET("CROP")) + { + // Do nothing? + // kMsgCResetOptions = "CROP" + return; + } + else if (USYNERGY_IS_PACKET("CINN")) + { + // Screen enter. Reply with CNOP + // kMsgCEnter = "CINN%2i%2i%4i%2i" + + // Obtain the Synergy sequence number + context->m_sequenceNumber = sNetToNative32(message + 12); + context->m_isCaptured = USYNERGY_TRUE; + + // Call callback + if (context->m_screenActiveCallback != 0L) + context->m_screenActiveCallback(context->m_cookie, USYNERGY_TRUE); + } + else if (USYNERGY_IS_PACKET("COUT")) + { + // Screen leave + // kMsgCLeave = "COUT" + context->m_isCaptured = USYNERGY_FALSE; + + // Call callback + if (context->m_screenActiveCallback != 0L) + context->m_screenActiveCallback(context->m_cookie, USYNERGY_FALSE); + } + else if (USYNERGY_IS_PACKET("DMDN")) + { + // Mouse down + // kMsgDMouseDown = "DMDN%1i" + char btn = message[8]-1; + if (btn==2) + context->m_mouseButtonRight = USYNERGY_TRUE; + else if (btn==1) + context->m_mouseButtonMiddle = USYNERGY_TRUE; + else + context->m_mouseButtonLeft = USYNERGY_TRUE; + sSendMouseCallback(context); + } + else if (USYNERGY_IS_PACKET("DMUP")) + { + // Mouse up + // kMsgDMouseUp = "DMUP%1i" + char btn = message[8]-1; + if (btn==2) + context->m_mouseButtonRight = USYNERGY_FALSE; + else if (btn==1) + context->m_mouseButtonMiddle = USYNERGY_FALSE; + else + context->m_mouseButtonLeft = USYNERGY_FALSE; + sSendMouseCallback(context); + } + else if (USYNERGY_IS_PACKET("DMMV")) + { + // Mouse move. Reply with CNOP + // kMsgDMouseMove = "DMMV%2i%2i" + context->m_mouseX = sNetToNative16(message+8); + context->m_mouseY = sNetToNative16(message+10); + sSendMouseCallback(context); + } + else if (USYNERGY_IS_PACKET("DMWM")) + { + // Mouse wheel + // kMsgDMouseWheel = "DMWM%2i%2i" + // kMsgDMouseWheel1_0 = "DMWM%2i" + context->m_mouseWheelX += sNetToNative16(message+8); + context->m_mouseWheelY += sNetToNative16(message+10); + sSendMouseCallback(context); + } + else if (USYNERGY_IS_PACKET("DKDN")) + { + // Key down + // kMsgDKeyDown = "DKDN%2i%2i%2i" + // kMsgDKeyDown1_0 = "DKDN%2i%2i" + //uint16_t id = sNetToNative16(message+8); + uint16_t mod = sNetToNative16(message+10); + uint16_t key = sNetToNative16(message+12); + sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_FALSE); + } + else if (USYNERGY_IS_PACKET("DKRP")) + { + // Key repeat + // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" + // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" + uint16_t mod = sNetToNative16(message+10); +// uint16_t count = sNetToNative16(message+12); + uint16_t key = sNetToNative16(message+14); + sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_TRUE); + } + else if (USYNERGY_IS_PACKET("DKUP")) + { + // Key up + // kMsgDKeyUp = "DKUP%2i%2i%2i" + // kMsgDKeyUp1_0 = "DKUP%2i%2i" + //uint16 id=Endian::sNetToNative(sbuf[4]); + uint16_t mod = sNetToNative16(message+10); + uint16_t key = sNetToNative16(message+12); + sSendKeyboardCallback(context, key, mod, USYNERGY_FALSE, USYNERGY_FALSE); + } + else if (USYNERGY_IS_PACKET("DGBT")) + { + // Joystick buttons + // kMsgDGameButtons = "DGBT%1i%2i"; + uint8_t joy_num = message[8]; + if (joy_numm_joystickButtons[joy_num] = (message[9] << 8) | message[10]; + sSendJoystickCallback(context, joy_num); + } + } + else if (USYNERGY_IS_PACKET("DGST")) + { + // Joystick sticks + // kMsgDGameSticks = "DGST%1i%1i%1i%1i%1i"; + uint8_t joy_num = message[8]; + if (joy_numm_joystickSticks[joy_num], message+9, 4); + sSendJoystickCallback(context, joy_num); + } + } + else if (USYNERGY_IS_PACKET("DSOP")) + { + // Set options + // kMsgDSetOptions = "DSOP%4I" + } + else if (USYNERGY_IS_PACKET("CALV")) + { + // Keepalive, reply with CALV and then CNOP + // kMsgCKeepAlive = "CALV" + sAddString(context, "CALV"); + sSendReply(context); + // now reply with CNOP + } + else if (USYNERGY_IS_PACKET("DCLP")) + { + // Clipboard message + // kMsgDClipboard = "DCLP%1i%4i%s" + // + // The clipboard message contains: + // 1 uint32: The size of the message + // 4 chars: The identifier ("DCLP") + // 1 uint8: The clipboard index + // 1 uint32: The sequence number. It's zero, because this message is always coming from the server? + // 1 uint32: The total size of the remaining 'string' (as per the Synergy %s string format (which is 1 uint32 for size followed by a char buffer (not necessarily null terminated)). + // 1 uint32: The number of formats present in the message + // And then 'number of formats' times the following: + // 1 uint32: The format of the clipboard data + // 1 uint32: The size n of the clipboard data + // n uint8: The clipboard data + const uint8_t * parse_msg = message+17; + uint32_t num_formats = sNetToNative32(parse_msg); + parse_msg += 4; + for (; num_formats; num_formats--) + { + // Parse clipboard format header + uint32_t format = sNetToNative32(parse_msg); + uint32_t size = sNetToNative32(parse_msg+4); + parse_msg += 8; + + // Call callback + if (context->m_clipboardCallback) + context->m_clipboardCallback(context->m_cookie, format, parse_msg, size); + + parse_msg += size; + } + } + else + { + // Unknown packet, could be any of these + // kMsgCNoop = "CNOP" + // kMsgCClose = "CBYE" + // kMsgCClipboard = "CCLP%1i%4i" + // kMsgCScreenSaver = "CSEC%1i" + // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" + // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" + // kMsgDMouseRelMove = "DMRM%2i%2i" + // kMsgEIncompatible = "EICV%2i%2i" + // kMsgEBusy = "EBSY" + // kMsgEUnknown = "EUNK" + // kMsgEBad = "EBAD" + char buffer[64]; + sprintf(buffer, "Unknown packet '%c%c%c%c'", message[4], message[5], message[6], message[7]); + sTrace(context, buffer); + return; + } + + // Reply with CNOP maybe? + sAddString(context, "CNOP"); + sSendReply(context); +} +#undef USYNERGY_IS_PACKET + + + +/** +@brief Mark context as being disconnected +**/ +static void sSetDisconnected(uSynergyContext *context) +{ + context->m_connected = USYNERGY_FALSE; + context->m_hasReceivedHello = USYNERGY_FALSE; + context->m_isCaptured = USYNERGY_FALSE; + context->m_replyCur = context->m_replyBuffer + 4; + context->m_sequenceNumber = 0; +} + + + +/** +@brief Update a connected context +**/ +static void sUpdateContext(uSynergyContext *context) +{ + /* Receive data (blocking) */ + int receive_size = USYNERGY_RECEIVE_BUFFER_SIZE - context->m_receiveOfs; + int num_received = 0; + int packlen = 0; + if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer + context->m_receiveOfs, receive_size, &num_received) == USYNERGY_FALSE) + { + /* Receive failed, let's try to reconnect */ + char buffer[128]; + sprintf(buffer, "Receive failed (%d bytes asked, %d bytes received), trying to reconnect in a second", receive_size, num_received); + sTrace(context, buffer); + sSetDisconnected(context); + context->m_sleepFunc(context->m_cookie, 1000); + return; + } + context->m_receiveOfs += num_received; + + /* If we didn't receive any data then we're probably still polling to get connected and + therefore not getting any data back. To avoid overloading the system with a Synergy + thread that would hammer on polling, we let it rest for a bit if there's no data. */ + if (num_received == 0) + context->m_sleepFunc(context->m_cookie, 500); + + /* Check for timeouts */ + if (context->m_hasReceivedHello) + { + uint32_t cur_time = context->m_getTimeFunc(); + if (num_received == 0) + { + /* Timeout after 2 secs of inactivity (we received no CALV) */ + if ((cur_time - context->m_lastMessageTime) > USYNERGY_IDLE_TIMEOUT) + sSetDisconnected(context); + } + else + context->m_lastMessageTime = cur_time; + } + + /* Eat packets */ + for (;;) + { + /* Grab packet length and bail out if the packet goes beyond the end of the buffer */ + packlen = sNetToNative32(context->m_receiveBuffer); + if (packlen+4 > context->m_receiveOfs) + break; + + /* Process message */ + sProcessMessage(context, context->m_receiveBuffer); + + /* Move packet to front of buffer */ + memmove(context->m_receiveBuffer, context->m_receiveBuffer+packlen+4, context->m_receiveOfs-packlen-4); + context->m_receiveOfs -= packlen+4; + } + + /* Throw away over-sized packets */ + if (packlen > USYNERGY_RECEIVE_BUFFER_SIZE) + { + /* Oversized packet, ditch tail end */ + char buffer[128]; + sprintf(buffer, "Oversized packet: '%c%c%c%c' (length %d)", context->m_receiveBuffer[4], context->m_receiveBuffer[5], context->m_receiveBuffer[6], context->m_receiveBuffer[7], packlen); + sTrace(context, buffer); + num_received = context->m_receiveOfs-4; // 4 bytes for the size field + while (num_received != packlen) + { + int buffer_left = packlen - num_received; + int to_receive = buffer_left < USYNERGY_RECEIVE_BUFFER_SIZE ? buffer_left : USYNERGY_RECEIVE_BUFFER_SIZE; + int ditch_received = 0; + if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer, to_receive, &ditch_received) == USYNERGY_FALSE) + { + /* Receive failed, let's try to reconnect */ + sTrace(context, "Receive failed, trying to reconnect in a second"); + sSetDisconnected(context); + context->m_sleepFunc(context->m_cookie, 1000); + break; + } + else + { + num_received += ditch_received; + } + } + context->m_receiveOfs = 0; + } +} + + +//--------------------------------------------------------------------------------------------------------------------- +// Public interface +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Initialize uSynergy context +**/ +void uSynergyInit(uSynergyContext *context) +{ + /* Zero memory */ + memset(context, 0, sizeof(uSynergyContext)); + + /* Initialize to default state */ + sSetDisconnected(context); +} + + +/** +@brief Update uSynergy +**/ +void uSynergyUpdate(uSynergyContext *context) +{ + if (context->m_connected) + { + /* Update context, receive data, call callbacks */ + sUpdateContext(context); + } + else + { + /* Try to connect */ + if (context->m_connectFunc(context->m_cookie)) + context->m_connected = USYNERGY_TRUE; + } +} + + + +/** +@brief Send clipboard data +**/ +void uSynergySendClipboard(uSynergyContext *context, const char *text) +{ + // Calculate maximum size that will fit in a reply packet + uint32_t overhead_size = 4 + /* Message size */ + 4 + /* Message ID */ + 1 + /* Clipboard index */ + 4 + /* Sequence number */ + 4 + /* Rest of message size (because it's a Synergy string from here on) */ + 4 + /* Number of clipboard formats */ + 4 + /* Clipboard format */ + 4; /* Clipboard data length */ + uint32_t max_length = USYNERGY_REPLY_BUFFER_SIZE - overhead_size; + + // Clip text to max length + uint32_t text_length = (uint32_t)strlen(text); + if (text_length > max_length) + { + char buffer[128]; + sprintf(buffer, "Clipboard buffer too small, clipboard truncated at %d characters", max_length); + sTrace(context, buffer); + text_length = max_length; + } + + // Assemble packet + sAddString(context, "DCLP"); + sAddUInt8(context, 0); /* Clipboard index */ + sAddUInt32(context, context->m_sequenceNumber); + sAddUInt32(context, 4+4+4+text_length); /* Rest of message size: numFormats, format, length, data */ + sAddUInt32(context, 1); /* Number of formats (only text for now) */ + sAddUInt32(context, USYNERGY_CLIPBOARD_FORMAT_TEXT); + sAddUInt32(context, text_length); + sAddString(context, text); + sSendReply(context); +} diff --git a/examples/libs/usynergy/uSynergy.h b/examples/libs/usynergy/uSynergy.h new file mode 100644 index 000000000..cedc38783 --- /dev/null +++ b/examples/libs/usynergy/uSynergy.h @@ -0,0 +1,420 @@ +/* +uSynergy client -- Interface for the embedded Synergy client library + version 1.0.0, July 7th, 2012 + +Copyright (C) 2012 Synergy Si Ltd. +Copyright (c) 2012 Alex Evans + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + +//--------------------------------------------------------------------------------------------------------------------- +// Configuration +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Determine endianness +**/ +#if defined(USYNERGY_LITTLE_ENDIAN) && defined(USYNERGY_BIG_ENDIAN) + /* Ambiguous: both endians specified */ + #error "Can't define both USYNERGY_LITTLE_ENDIAN and USYNERGY_BIG_ENDIAN" +#elif !defined(USYNERGY_LITTLE_ENDIAN) && !defined(USYNERGY_BIG_ENDIAN) + /* Attempt to auto detect */ + #if defined(__LITTLE_ENDIAN__) || defined(LITTLE_ENDIAN) || (_BYTE_ORDER == _LITTLE_ENDIAN) + #define USYNERGY_LITTLE_ENDIAN + #elif defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN) || (_BYTE_ORDER == _BIG_ENDIAN) + #define USYNERGY_BIG_ENDIAN + #else + #error "Can't detect endian-nes, please defined either USYNERGY_LITTLE_ENDIAN or USYNERGY_BIG_ENDIAN"; + #endif +#else + /* User-specified endian-nes, nothing to do for us */ +#endif + + + +//--------------------------------------------------------------------------------------------------------------------- +// Types and Constants +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Boolean type +**/ +typedef int uSynergyBool; +#define USYNERGY_FALSE 0 /* False value */ +#define USYNERGY_TRUE 1 /* True value */ + + +/** +@brief User context type + +The uSynergyCookie type is an opaque type that is used by uSynergy to communicate to the client. It is passed along to +callback functions as context. +**/ +typedef struct { int ignored; } * uSynergyCookie; + + + +/** +@brief Clipboard types +**/ +enum uSynergyClipboardFormat +{ + USYNERGY_CLIPBOARD_FORMAT_TEXT = 0, /* Text format, UTF-8, newline is LF */ + USYNERGY_CLIPBOARD_FORMAT_BITMAP = 1, /* Bitmap format, BMP 24/32bpp, BI_RGB */ + USYNERGY_CLIPBOARD_FORMAT_HTML = 2, /* HTML format, HTML fragment, UTF-8, newline is LF */ +}; + + + +/** +@brief Constants and limits +**/ +#define USYNERGY_NUM_JOYSTICKS 4 /* Maximum number of supported joysticks */ + +#define USYNERGY_PROTOCOL_MAJOR 1 /* Major protocol version */ +#define USYNERGY_PROTOCOL_MINOR 4 /* Minor protocol version */ + +#define USYNERGY_IDLE_TIMEOUT 2000 /* Timeout in milliseconds before reconnecting */ + +#define USYNERGY_TRACE_BUFFER_SIZE 1024 /* Maximum length of traced message */ +#define USYNERGY_REPLY_BUFFER_SIZE 1024 /* Maximum size of a reply packet */ +#define USYNERGY_RECEIVE_BUFFER_SIZE 4096 /* Maximum size of an incoming packet */ + + + +/** +@brief Keyboard constants +**/ +#define USYNERGY_MODIFIER_SHIFT 0x0001 /* Shift key modifier */ +#define USYNERGY_MODIFIER_CTRL 0x0002 /* Ctrl key modifier */ +#define USYNERGY_MODIFIER_ALT 0x0004 /* Alt key modifier */ +#define USYNERGY_MODIFIER_META 0x0008 /* Meta key modifier */ +#define USYNERGY_MODIFIER_WIN 0x0010 /* Windows key modifier */ +#define USYNERGY_MODIFIER_ALT_GR 0x0020 /* AltGr key modifier */ +#define USYNERGY_MODIFIER_LEVEL5LOCK 0x0040 /* Level5Lock key modifier */ +#define USYNERGY_MODIFIER_CAPSLOCK 0x1000 /* CapsLock key modifier */ +#define USYNERGY_MODIFIER_NUMLOCK 0x2000 /* NumLock key modifier */ +#define USYNERGY_MODIFIER_SCROLLOCK 0x4000 /* ScrollLock key modifier */ + + + + +//--------------------------------------------------------------------------------------------------------------------- +// Functions and Callbacks +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Connect function + +This function is called when uSynergy needs to connect to the host. It doesn't imply a network implementation or +destination address, that must all be handled on the user side. The function should return USYNERGY_TRUE if a +connection was established or USYNERGY_FALSE if it could not connect. + +When network errors occur (e.g. uSynergySend or uSynergyReceive fail) then the connect call will be called again +so the implementation of the function must close any old connections and clean up resources before retrying. + +@param cookie Cookie supplied in the Synergy context +**/ +typedef uSynergyBool (*uSynergyConnectFunc)(uSynergyCookie cookie); + + + +/** +@brief Send function + +This function is called when uSynergy needs to send something over the default connection. It should return +USYNERGY_TRUE if sending succeeded and USYNERGY_FALSE otherwise. This function should block until the send +operation is completed. + +@param cookie Cookie supplied in the Synergy context +@param buffer Address of buffer to send +@param length Length of buffer to send +**/ +typedef uSynergyBool (*uSynergySendFunc)(uSynergyCookie cookie, const uint8_t *buffer, int length); + + + +/** +@brief Receive function + +This function is called when uSynergy needs to receive data from the default connection. It should return +USYNERGY_TRUE if receiving data succeeded and USYNERGY_FALSE otherwise. This function should block until data +has been received and wait for data to become available. If @a outLength is set to 0 upon completion it is +assumed that the connection is alive, but still in a connecting state and needs time to settle. + +@param cookie Cookie supplied in the Synergy context +@param buffer Address of buffer to receive data into +@param maxLength Maximum amount of bytes to write into the receive buffer +@param outLength Address of integer that receives the actual amount of bytes written into @a buffer +**/ +typedef uSynergyBool (*uSynergyReceiveFunc)(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength); + + + +/** +@brief Thread sleep function + +This function is called when uSynergy wants to suspend operation for a while before retrying an operation. It +is mostly used when a socket times out or disconnect occurs to prevent uSynergy from continuously hammering a +network connection in case the network is down. + +@param cookie Cookie supplied in the Synergy context +@param timeMs Time to sleep the current thread (in milliseconds) +**/ +typedef void (*uSynergySleepFunc)(uSynergyCookie cookie, int timeMs); + + + +/** +@brief Get time function + +This function is called when uSynergy needs to know the current time. This is used to determine when timeouts +have occured. The time base should be a cyclic millisecond time value. + +@returns Time value in milliseconds +**/ +typedef uint32_t (*uSynergyGetTimeFunc)(); + + + +/** +@brief Trace function + +This function is called when uSynergy wants to trace something. It is optional to show these messages, but they +are often useful when debugging. uSynergy only traces major events like connecting and disconnecting. Usually +only a single trace is shown when the connection is established and no more trace are called. + +@param cookie Cookie supplied in the Synergy context +@param text Text to be traced +**/ +typedef void (*uSynergyTraceFunc)(uSynergyCookie cookie, const char *text); + + + +/** +@brief Screen active callback + +This callback is called when Synergy makes the screen active or inactive. This +callback is usually sent when the mouse enters or leaves the screen. + +@param cookie Cookie supplied in the Synergy context +@param active Activation flag, 1 if the screen has become active, 0 if the screen has become inactive +**/ +typedef void (*uSynergyScreenActiveCallback)(uSynergyCookie cookie, uSynergyBool active); + + + +/** +@brief Mouse callback + +This callback is called when a mouse events happens. The mouse X and Y position, +wheel and button state is communicated in the message. It's up to the user to +interpret if this is a mouse up, down, double-click or other message. + +@param cookie Cookie supplied in the Synergy context +@param x Mouse X position +@param y Mouse Y position +@param wheelX Mouse wheel X position +@param wheelY Mouse wheel Y position +@param buttonLeft Left button pressed status, 0 for released, 1 for pressed +@param buttonMiddle Middle button pressed status, 0 for released, 1 for pressed +@param buttonRight Right button pressed status, 0 for released, 1 for pressed +**/ +typedef void (*uSynergyMouseCallback)(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle); + + + +/** +@brief Key event callback + +This callback is called when a key is pressed or released. + +@param cookie Cookie supplied in the Synergy context +@param key Key code of key that was pressed or released +@param modifiers Status of modifier keys (alt, shift, etc.) +@param down Down or up status, 1 is key is pressed down, 0 if key is released (up) +@param repeat Repeat flag, 1 if the key is down because the key is repeating, 0 if the key is initially pressed by the user +**/ +typedef void (*uSynergyKeyboardCallback)(uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat); + + + +/** +@brief Joystick event callback + +This callback is called when a joystick stick or button changes. It is possible that multiple callbacks are +fired when different sticks or buttons change as these are individual messages in the packet stream. Each +callback will contain all the valid state for the different axes and buttons. The last callback received will +represent the most current joystick state. + +@param cookie Cookie supplied in the Synergy context +@param joyNum Joystick number, always in the range [0 ... USYNERGY_NUM_JOYSTICKS> +@param buttons Button pressed mask +@param leftStickX Left stick X position, in range [-127 ... 127] +@param leftStickY Left stick Y position, in range [-127 ... 127] +@param rightStickX Right stick X position, in range [-127 ... 127] +@param rightStickY Right stick Y position, in range [-127 ... 127] +**/ +typedef void (*uSynergyJoystickCallback)(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY); + + + +/** +@brief Clipboard event callback + +This callback is called when something is placed on the clipboard. Multiple callbacks may be fired for +multiple clipboard formats if they are supported. The data provided is read-only and may not be modified +by the application. + +@param cookie Cookie supplied in the Synergy context +@param format Clipboard format +@param data Memory area containing the clipboard raw data +@param size Size of clipboard data +**/ +typedef void (*uSynergyClipboardCallback)(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size); + + + +//--------------------------------------------------------------------------------------------------------------------- +// Context +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief uSynergy context +**/ +typedef struct +{ + /* Mandatory configuration data, filled in by client */ + uSynergyConnectFunc m_connectFunc; /* Connect function */ + uSynergySendFunc m_sendFunc; /* Send data function */ + uSynergyReceiveFunc m_receiveFunc; /* Receive data function */ + uSynergySleepFunc m_sleepFunc; /* Thread sleep function */ + uSynergyGetTimeFunc m_getTimeFunc; /* Get current time function */ + const char* m_clientName; /* Name of Synergy Screen / Client */ + uint16_t m_clientWidth; /* Width of screen */ + uint16_t m_clientHeight; /* Height of screen */ + + /* Optional configuration data, filled in by client */ + uSynergyCookie m_cookie; /* Cookie pointer passed to callback functions (can be NULL) */ + uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */ + uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */ + uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */ + uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */ + uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */ + uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */ + + /* State data, used internall by client, initialized by uSynergyInit() */ + uSynergyBool m_connected; /* Is our socket connected? */ + uSynergyBool m_hasReceivedHello; /* Have we received a 'Hello' from the server? */ + uSynergyBool m_isCaptured; /* Is Synergy active (i.e. this client is receiving input messages?) */ + uint32_t m_lastMessageTime; /* Time at which last message was received */ + uint32_t m_sequenceNumber; /* Packet sequence number */ + uint8_t m_receiveBuffer[USYNERGY_RECEIVE_BUFFER_SIZE]; /* Receive buffer */ + int m_receiveOfs; /* Receive buffer offset */ + uint8_t m_replyBuffer[USYNERGY_REPLY_BUFFER_SIZE]; /* Reply buffer */ + uint8_t* m_replyCur; /* Write offset into reply buffer */ + uint16_t m_mouseX; /* Mouse X position */ + uint16_t m_mouseY; /* Mouse Y position */ + int16_t m_mouseWheelX; /* Mouse wheel X position */ + int16_t m_mouseWheelY; /* Mouse wheel Y position */ + uSynergyBool m_mouseButtonLeft; /* Mouse left button */ + uSynergyBool m_mouseButtonRight; /* Mouse right button */ + uSynergyBool m_mouseButtonMiddle; /* Mouse middle button */ + int8_t m_joystickSticks[USYNERGY_NUM_JOYSTICKS][4]; /* Joystick stick position in 2 axes for 2 sticks */ + uint16_t m_joystickButtons[USYNERGY_NUM_JOYSTICKS]; /* Joystick button state */ +} uSynergyContext; + + + +//--------------------------------------------------------------------------------------------------------------------- +// Interface +//--------------------------------------------------------------------------------------------------------------------- + + + +/** +@brief Initialize uSynergy context + +This function initializes @a context for use. Call this function directly after +creating the context, before filling in any configuration data in it. Not calling +this function will cause undefined behavior. + +@param context Context to be initialized +**/ +extern void uSynergyInit(uSynergyContext *context); + + + +/** +@brief Update uSynergy + +This function updates uSynergy and does the bulk of the work. It does connection management, +receiving data, reconnecting after errors or timeouts and so on. It assumes that networking +operations are blocking and it can suspend the current thread if it needs to wait. It is +best practice to call uSynergyUpdate from a background thread so it is responsive. + +Because uSynergy relies mostly on blocking calls it will mostly stay in thread sleep state +waiting for system mutexes and won't eat much memory. + +uSynergyUpdate doesn't do any memory allocations or have any side effects beyond those of +the callbacks it calls. + +@param context Context to be updated +**/ +extern void uSynergyUpdate(uSynergyContext *context); + + + +/** +@brief Send clipboard data + +This function sets new clipboard data and sends it to the server. Use this function if +your client cuts or copies data onto the clipboard that it needs to share with the +server. + +Currently there is only support for plaintext, but HTML and image data could be +supported with some effort. + +@param context Context to send clipboard data to +@param text Text to set to the clipboard +**/ +extern void uSynergySendClipboard(uSynergyContext *context, const char *text); + + + +#ifdef __cplusplus +}; +#endif