{"id":15717623,"url":"https://github.com/mgood7123/multitouch","last_synced_at":"2026-05-06T13:35:11.403Z","repository":{"id":119196007,"uuid":"391008508","full_name":"mgood7123/MultiTouch","owner":"mgood7123","description":"a cross platform Multi-Touch library that aims to provide a unified Multi-Touch API","archived":false,"fork":false,"pushed_at":"2021-11-19T13:10:37.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-06T00:42:44.387Z","etag":null,"topics":["android","cross-platform","mac-os","mac-osx","macos","macosx","multi-touch"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgood7123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-30T09:30:50.000Z","updated_at":"2021-11-19T13:10:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b4b4dea-b937-4b7d-b7ec-e22957bd9fe5","html_url":"https://github.com/mgood7123/MultiTouch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2FMultiTouch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2FMultiTouch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2FMultiTouch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2FMultiTouch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgood7123","download_url":"https://codeload.github.com/mgood7123/MultiTouch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246380764,"owners_count":20767900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cross-platform","mac-os","mac-osx","macos","macosx","multi-touch"],"created_at":"2024-10-03T21:50:47.257Z","updated_at":"2026-05-06T13:35:11.371Z","avatar_url":"https://github.com/mgood7123.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MultiTouch\na cross platform MultiTouch library that aims to provide a unified MultiTouch API\n\n## now includes DiligentLog for stand-alone compilation\n\n# USAGE\n\n### Mac OS\n\nto add MultiTouch support to your application, adapt your source to the following\n\ninside `NSView` that subclasses a `NSResponder`, for example, `NSOpenGLView`\n\nimplementation (.mm)\n```ObjectiveC\n- (void)updateTrackingAreas {\n    [self initTrackingArea];\n}\n\n-(void) initTrackingArea {\n    NSTrackingAreaOptions options = (\n        NSTrackingActiveAlways |\n        NSTrackingInVisibleRect |\n        NSTrackingMouseMoved\n     );\n\n    NSTrackingArea *area = [\n        [NSTrackingArea alloc]\n        initWithRect:[self bounds]\n        options:options\n        owner:self\n        userInfo:nil\n    ];\n    [self addTrackingArea:area];\n}\n\n- (BOOL)acceptsFirstResponder {\n    return YES;\n}\n\n// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html#//apple_ref/doc/uid/10000060i-CH13-SW21\n\n- (NSPoint) getMouse {\n    NSPoint x = [[self window] mouseLocationOutsideOfEventStream];\n    // bottom is 0, top is height\n    // we need top is 0, bottom is height\n    x.y = [self bounds].size.height - x.y;\n    return x;\n}\n\n- (void)touchesBeganWithEvent:(NSEvent *)event {\n    NSSet * touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:self];\n    NSArray *array = [touches allObjects];\n    NSUInteger numberOfTouches = [array count];\n    for (unsigned long i = 0; i \u003c numberOfTouches; i++) {\n        NSTouch *touch = [array objectAtIndex:i];\n        [_renderer touchesBeganWithTouch:touch AndPoint:[self getMouse]];\n    }\n}\n\n- (void)touchesMovedWithEvent:(NSEvent *)event {\n    NSSet * touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:self];\n    NSArray *array = [touches allObjects];\n    NSUInteger numberOfTouches = [array count];\n    for (unsigned long i = 0; i \u003c numberOfTouches; i++) {\n        NSTouch *touch = [array objectAtIndex:i];\n        [_renderer touchesMovedWithTouch:touch AndPoint:[self getMouse]];\n    }\n}\n\n- (void)touchesEndedWithEvent:(NSEvent *)event {\n    NSSet * touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:self];\n    NSArray *array = [touches allObjects];\n    NSUInteger numberOfTouches = [array count];\n    for (unsigned long i = 0; i \u003c numberOfTouches; i++) {\n        NSTouch *touch = [array objectAtIndex:i];\n        [_renderer touchesEndedWithTouch:touch AndPoint:[self getMouse]];\n    }\n}\n\n- (void)touchesCancelledWithEvent:(NSEvent *)event {\n    NSSet * touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:self];\n    NSArray *array = [touches allObjects];\n    NSUInteger numberOfTouches = [array count];\n    for (unsigned long i = 0; i \u003c numberOfTouches; i++) {\n        NSTouch *touch = [array objectAtIndex:i];\n        [_renderer touchesCancelledWithTouch:touch AndPoint:[self getMouse]];\n    }\n}\n\n- (void) awakeFromNib\n\n{\n    [self setAcceptsTouchEvents:YES];\n    // ...\n}\n\n// ...\n```\n\ninside a callback class, eg `_renderer`\n\ninterface (.h)\n```ObjectiveC\n// include path/to/MultiTouch.h here\n\n@interface OpenGLRenderer : NSObject\n{\n    MultiTouch multiTouch;\n\n    // something that consumes MultiTouch objects\n    AppInstance appInstance;\n}\n\n- (instancetype) init;\n\n- (void) touchesBeganWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point;\n- (void) touchesMovedWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point;\n- (void) touchesEndedWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point;\n- (void) touchesCancelledWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point;\n\n// ...\n\n@end\n```\nimplementation (.mm)\n```ObjectiveC\n@implementation OpenGLRenderer\n\n- (instancetype) init {\n    multiTouch.setMaxSupportedTouches(10);\n    return self;\n}\n\n- (void)touchesBeganWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point {\n    multiTouch.addTouch(\n        ((NSInteger) touch.identity),\n        point.x,\n        point.y\n    );\n    appInstance.onTouchEvent(multiTouch);\n}\n\n- (void)touchesMovedWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point {\n    multiTouch.moveTouch(\n        ((NSInteger) touch.identity),\n        point.x,\n        point.y\n    );\n    appInstance.onTouchEvent(multiTouch);\n}\n\n- (void)touchesEndedWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point {\n    multiTouch.removeTouch(\n        ((NSInteger) touch.identity),\n        point.x,\n        point.y\n    );\n    appInstance.onTouchEvent(multiTouch);\n}\n\n- (void)touchesCancelledWithTouch:(NSTouch *)touch AndPoint:(NSPoint)point {\n    multiTouch.cancelTouch(\n        ((NSInteger) touch.identity),\n        point.x,\n        point.y\n    );\n    appInstance.onTouchEvent(multiTouch);\n}\n// ...\n```\n\n### Android\n\nto add MultiTouch support to android, adapt your views OnTouchEvent to the following\n\n```Java\n@Override\npublic boolean onTouchEvent(MotionEvent event) {\n    int action = event.getActionMasked();\n    int actionIndex = event.getActionIndex();\n    int id = 0;\n    boolean isUpDown = false;\n    switch (action) {\n        case MotionEvent.ACTION_DOWN:\n        case MotionEvent.ACTION_UP:\n        case MotionEvent.ACTION_POINTER_DOWN:\n        case MotionEvent.ACTION_POINTER_UP:\n            id = event.getPointerId(actionIndex);\n            isUpDown = true;\n            break;\n    }\n\n    int c = event.getPointerCount();\n    for (int i = 0; i \u003c c; i++) {\n        int pid = event.getPointerId(i);\n        if (isUpDown) {\n            if (actionIndex == i) {\n                switch (action) {\n                    case MotionEvent.ACTION_DOWN:\n                    case MotionEvent.ACTION_POINTER_DOWN:\n                        renderer.addTouch(\n                                id,\n                                event.getX(actionIndex),\n                                event.getY(actionIndex),\n                                event.getSize(actionIndex),\n                                event.getPressure(actionIndex)\n                        );\n                        break;\n                    case MotionEvent.ACTION_UP:\n                    case MotionEvent.ACTION_POINTER_UP:\n                        renderer.removeTouch(\n                                id,\n                                event.getX(actionIndex),\n                                event.getY(actionIndex),\n                                event.getSize(actionIndex),\n                                event.getPressure(actionIndex)\n                        );\n                        break;\n                }\n            }\n        }\n\n        if (actionIndex != i || !isUpDown) {\n            renderer.moveTouch(\n                    pid,\n                    event.getX(i),\n                    event.getY(i),\n                    event.getSize(i),\n                    event.getPressure(i)\n            );\n        }\n    }\n    return renderer.onTouchEvent(renderer.nativeInstance);\n}\n```\n\nand add the following native calls\n\n```Java\nnative void addTouch(long identity, float x, float y);\nnative void addTouch(long identity, float x, float y, float size);\nnative void addTouch(long identity, float x, float y, float size, float pressure);\nnative void moveTouch(long identity, float x, float y);\nnative void moveTouch(long identity, float x, float y, float size);\nnative void moveTouch(long identity, float x, float y, float size, float pressure);\nnative void removeTouch(long identity, float x, float y);\nnative void removeTouch(long identity, float x, float y, float size);\nnative void removeTouch(long identity, float x, float y, float size, float pressure);\nnative void cancelTouch(long identity, float x, float y);\nnative void cancelTouch(long identity, float x, float y, float size);\nnative void cancelTouch(long identity, float x, float y, float size, float pressure);\nnative boolean onTouchEvent(long instance);\n```\n\nfinally, add the native implementation\n\n```C++\n#include \u003cMultiTouch.h\u003e\nMultiTouch multiTouch;\n\n#define APP(jlong) reinterpret_cast\u003cYourNativeClassInstance*\u003e(jlong)\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_addTouch__JFF(\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y\n)\n{\n    multiTouch.addTouch(identifier, x, y);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_addTouch__JFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size\n)\n{\n    multiTouch.addTouch(identifier, x, y, size);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_addTouch__JFFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size, jfloat pressure\n)\n{\n    multiTouch.addTouch(identifier, x, y, size, pressure);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_moveTouch__JFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y\n)\n{\n    multiTouch.moveTouch(identifier, x, y);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_moveTouch__JFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size\n)\n{\n    multiTouch.moveTouch(identifier, x, y, size);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_moveTouch__JFFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size, jfloat pressure\n)\n{\n    multiTouch.moveTouch(identifier, x, y, size, pressure);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_removeTouch__JFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y\n)\n{\n    multiTouch.removeTouch(identifier, x, y);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_removeTouch__JFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size\n)\n{\n    multiTouch.removeTouch(identifier, x, y, size);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_removeTouch__JFFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size, jfloat pressure\n)\n{\n    multiTouch.removeTouch(identifier, x, y, size, pressure);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_cancelTouch__JFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y\n)\n{\n    multiTouch.cancelTouch(identifier, x, y);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_cancelTouch__JFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size\n)\n{\n    multiTouch.cancelTouch(identifier, x, y, size);\n}\n\nextern \"C\" JNIEXPORT void JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_cancelTouch__JFFFF (\n        JNIEnv * env, jobject thiz,\n        jlong identifier, jfloat x, jfloat y, jfloat size, jfloat pressure\n)\n{\n    multiTouch.cancelTouch(identifier, x, y, size, pressure);\n}\n\nextern \"C\" JNIEXPORT jboolean JNICALL\nJava_smallville7123_graphical_tool_kit_DiligentEngineView_00024DiligentEngineRenderer_onTouchEvent (\n        JNIEnv * env, jobject thiz, jlong instance\n)\n{\n    return APP(instance)-\u003eonTouchEvent(multiTouch);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgood7123%2Fmultitouch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgood7123%2Fmultitouch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgood7123%2Fmultitouch/lists"}