src/events/SDL_gesture.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 10126 d2686deec646
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9791
diff changeset
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
7252
8ecb54eeaeec Corrected indentation of license.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
    14
     claim that you wrote the original software. If you use this software
8ecb54eeaeec Corrected indentation of license.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
8ecb54eeaeec Corrected indentation of license.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
    16
     appreciated but is not required.
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
7252
8ecb54eeaeec Corrected indentation of license.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
    18
     misrepresented as being the original software.
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    20
*/
4865
fff50e86c891 Update VS2010 project to add new files; update new files so code builds on Win32/Win64
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 4689
diff changeset
    21
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7900
diff changeset
    22
#include "../SDL_internal.h"
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    23
10126
d2686deec646 Fixed comment in gesture source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9998
diff changeset
    24
/* General gesture handling code for SDL */
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    25
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    26
#include "SDL_events.h"
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
    27
#include "SDL_endian.h"
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    28
#include "SDL_events_c.h"
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    29
#include "SDL_gesture_c.h"
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    30
8775
047537a5a114 Removed unused standard library includes from gesture source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8726
diff changeset
    31
/*
4865
fff50e86c891 Update VS2010 project to add new files; update new files so code builds on Win32/Win64
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 4689
diff changeset
    32
#include <stdio.h>
8775
047537a5a114 Removed unused standard library includes from gesture source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8726
diff changeset
    33
*/
4865
fff50e86c891 Update VS2010 project to add new files; update new files so code builds on Win32/Win64
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 4689
diff changeset
    34
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    35
/* TODO: Replace with malloc */
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    36
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    37
#define MAXPATHSIZE 1024
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    38
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    39
#define DOLLARNPOINTS 64
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    40
#define DOLLARSIZE 256
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    41
4684
f47c2640c667 Re-enabled dollar gesture
Jim Grandpre <jim.tla@gmail.com>
parents: 4683
diff changeset
    42
#define ENABLE_DOLLAR
f47c2640c667 Re-enabled dollar gesture
Jim Grandpre <jim.tla@gmail.com>
parents: 4683
diff changeset
    43
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    44
#define PHI 0.618033989
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    45
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    46
typedef struct {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    47
    float x,y;
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    48
} SDL_FloatPoint;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    49
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    50
typedef struct {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    51
    float length;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    52
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    53
    int numPoints;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    54
    SDL_FloatPoint p[MAXPATHSIZE];
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    55
} SDL_DollarPath;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    56
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    57
typedef struct {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    58
    SDL_FloatPoint path[DOLLARNPOINTS];
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    59
    unsigned long hash;
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    60
} SDL_DollarTemplate;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    61
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    62
typedef struct {
6069
fbb37897c788 Type of SDL_GestureTouch.id is SDL_TouchID (only for SDL_gesture.c internal)
Kees Bakker <kees@ijzerbout.nl>
parents: 6068
diff changeset
    63
    SDL_TouchID id;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    64
    SDL_FloatPoint centroid;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    65
    SDL_DollarPath dollarPath;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    66
    Uint16 numDownFingers;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
    67
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    68
    int numDollarTemplates;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    69
    SDL_DollarTemplate *dollarTemplate;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
    70
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    71
    SDL_bool recording;
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    72
} SDL_GestureTouch;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
    73
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    74
SDL_GestureTouch *SDL_gestureTouch;
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
    75
int SDL_numGestureTouches = 0;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
    76
SDL_bool recordAll;
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
    77
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4865
diff changeset
    78
#if 0
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    79
static void PrintPath(SDL_FloatPoint *path)
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    80
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    81
    int i;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    82
    printf("Path:");
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
    83
    for (i=0; i<DOLLARNPOINTS; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    84
        printf(" (%f,%f)",path[i].x,path[i].y);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    85
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    86
    printf("\n");
4685
e0c3b09368a6 Fixed Dollar Recognition.
Jim Grandpre <jim.tla@gmail.com>
parents: 4684
diff changeset
    87
}
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4865
diff changeset
    88
#endif
4685
e0c3b09368a6 Fixed Dollar Recognition.
Jim Grandpre <jim.tla@gmail.com>
parents: 4684
diff changeset
    89
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    90
int SDL_RecordGesture(SDL_TouchID touchId)
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    91
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    92
    int i;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
    93
    if (touchId < 0) recordAll = SDL_TRUE;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
    94
    for (i = 0; i < SDL_numGestureTouches; i++) {
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
    95
        if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    96
            SDL_gestureTouch[i].recording = SDL_TRUE;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
    97
            if (touchId >= 0)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    98
                return 1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
    99
        }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   100
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   101
    return (touchId < 0);
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   102
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   103
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   104
static unsigned long SDL_HashDollar(SDL_FloatPoint* points)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   105
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   106
    unsigned long hash = 5381;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   107
    int i;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   108
    for (i = 0; i < DOLLARNPOINTS; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   109
        hash = ((hash<<5) + hash) + (unsigned long)points[i].x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   110
        hash = ((hash<<5) + hash) + (unsigned long)points[i].y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   111
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   112
    return hash;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   113
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   114
4665
c2493813a2f4 Merged changes
Jim Grandpre <jim.tla@gmail.com>
parents: 4664 4663
diff changeset
   115
7900
cc2289c332eb Changed parameter name for gesture template save functions from "src" to "dst".
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7899
diff changeset
   116
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   117
{
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   118
    if (dst == NULL) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   119
        return 0;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   120
    }
4665
c2493813a2f4 Merged changes
Jim Grandpre <jim.tla@gmail.com>
parents: 4664 4663
diff changeset
   121
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   122
    /* No Longer storing the Hash, rehash on load */
7900
cc2289c332eb Changed parameter name for gesture template save functions from "src" to "dst".
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7899
diff changeset
   123
    /* if (SDL_RWops.write(dst, &(templ->hash), sizeof(templ->hash), 1) != 1) return 0; */
4682
4ba1048a324c Minimized functionality of gestureSDLTest.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
   124
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   125
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
7900
cc2289c332eb Changed parameter name for gesture template save functions from "src" to "dst".
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7899
diff changeset
   126
    if (SDL_RWwrite(dst, templ->path,
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   127
                    sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   128
        return 0;
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   129
    }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   130
#else
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   131
    {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   132
        SDL_DollarTemplate copy = *templ;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   133
        SDL_FloatPoint *p = copy.path;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   134
        int i;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   135
        for (i = 0; i < DOLLARNPOINTS; i++, p++) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   136
            p->x = SDL_SwapFloatLE(p->x);
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   137
            p->y = SDL_SwapFloatLE(p->y);
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   138
        }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   139
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   140
        if (SDL_RWwrite(dst, copy.path,
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   141
                        sizeof(copy.path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   142
            return 0;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   143
        }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   144
    }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   145
#endif
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   146
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   147
    return 1;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   148
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   149
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   150
7900
cc2289c332eb Changed parameter name for gesture template save functions from "src" to "dst".
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7899
diff changeset
   151
int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   152
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   153
    int i,j,rtrn = 0;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   154
    for (i = 0; i < SDL_numGestureTouches; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   155
        SDL_GestureTouch* touch = &SDL_gestureTouch[i];
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   156
        for (j = 0; j < touch->numDollarTemplates; j++) {
8705
fee2f7e242a1 Fixed bug 2503 - Loop indexing and event union errors in SDL_gesture.c
Sam Lantinga <slouken@libsdl.org>
parents: 8296
diff changeset
   157
            rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   158
        }
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   159
    }
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   160
    return rtrn;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   161
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   162
7900
cc2289c332eb Changed parameter name for gesture template save functions from "src" to "dst".
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7899
diff changeset
   163
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   164
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   165
    int i,j;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   166
    for (i = 0; i < SDL_numGestureTouches; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   167
        SDL_GestureTouch* touch = &SDL_gestureTouch[i];
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   168
        for (j = 0; j < touch->numDollarTemplates; j++) {
8726
9a5a5808aa14 Fixed missing j
Sam Lantinga <slouken@libsdl.org>
parents: 8705
diff changeset
   169
            if (touch->dollarTemplate[j].hash == gestureId) {
8705
fee2f7e242a1 Fixed bug 2503 - Loop indexing and event union errors in SDL_gesture.c
Sam Lantinga <slouken@libsdl.org>
parents: 8296
diff changeset
   170
                return SaveTemplate(&touch->dollarTemplate[j], dst);
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   171
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   172
        }
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   173
    }
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 7009
diff changeset
   174
    return SDL_SetError("Unknown gestureId");
4663
56a2d70de945 Started trying to build gesture code for iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 4659
diff changeset
   175
}
56a2d70de945 Started trying to build gesture code for iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 4659
diff changeset
   176
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   177
/* path is an already sampled set of points
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   178
Returns the index of the gesture on success, or -1 */
6067
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   179
static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   180
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   181
    SDL_DollarTemplate* dollarTemplate;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   182
    SDL_DollarTemplate *templ;
6067
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   183
    int index;
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   184
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   185
    index = inTouch->numDollarTemplates;
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   186
    dollarTemplate =
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   187
        (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   188
                                          (index + 1) *
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   189
                                          sizeof(SDL_DollarTemplate));
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   190
    if (!dollarTemplate) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 7009
diff changeset
   191
        return SDL_OutOfMemory();
6067
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   192
    }
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   193
    inTouch->dollarTemplate = dollarTemplate;
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   194
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   195
    templ = &inTouch->dollarTemplate[index];
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   196
    SDL_memcpy(templ->path, path, DOLLARNPOINTS*sizeof(SDL_FloatPoint));
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   197
    templ->hash = SDL_HashDollar(templ->path);
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   198
    inTouch->numDollarTemplates++;
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   199
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   200
    return index;
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   201
}
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   202
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   203
static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   204
{
6071
72f06ae88e7e Fixed uninitialized variable.
Ryan C. Gordon <icculus@icculus.org>
parents: 6070
diff changeset
   205
    int index = -1;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   206
    int i = 0;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   207
    if (inTouch == NULL) {
9456
2d6ec08030a0 Add some SDL_SetError() calls to the dollar gesture code (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8910
diff changeset
   208
        if (SDL_numGestureTouches == 0) return SDL_SetError("no gesture touch devices registered");
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   209
        for (i = 0; i < SDL_numGestureTouches; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   210
            inTouch = &SDL_gestureTouch[i];
6067
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   211
            index = SDL_AddDollarGesture_one(inTouch, path);
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   212
            if (index < 0)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   213
                return -1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   214
        }
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   215
        /* Use the index of the last one added. */
6067
9a8faef6fdbe Refactor SDL_AddDollarGesture
Kees Bakker <kees@ijzerbout.nl>
parents: 6066
diff changeset
   216
        return index;
4663
56a2d70de945 Started trying to build gesture code for iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 4659
diff changeset
   217
    }
7899
e94abe9c40ca Removed unreachable return statement in gesture source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7678
diff changeset
   218
    return SDL_AddDollarGesture_one(inTouch, path);
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   219
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   220
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   221
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   222
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   223
    int i,loaded = 0;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   224
    SDL_GestureTouch *touch = NULL;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   225
    if (src == NULL) return 0;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   226
    if (touchId >= 0) {
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   227
        for (i = 0; i < SDL_numGestureTouches; i++) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   228
            if (SDL_gestureTouch[i].id == touchId) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   229
                touch = &SDL_gestureTouch[i];
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   230
            }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   231
        }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   232
        if (touch == NULL) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   233
            return SDL_SetError("given touch id not found");
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   234
        }
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   235
    }
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   236
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   237
    while (1) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   238
        SDL_DollarTemplate templ;
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
   239
9457
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   240
        if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   241
            if (loaded == 0) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   242
                return SDL_SetError("could not read any dollar gesture from rwops");
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   243
            }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   244
            break;
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   245
        }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   246
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   247
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   248
        for (i = 0; i < DOLLARNPOINTS; i++) {
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   249
            SDL_FloatPoint *p = &templ.path[i];
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   250
            p->x = SDL_SwapFloatLE(p->x);
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   251
            p->y = SDL_SwapFloatLE(p->y);
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   252
        }
9f2beba999b8 Make loading/saving dollar gesture templates endian clean (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 9456
diff changeset
   253
#endif
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   254
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   255
        if (touchId >= 0) {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   256
            /* printf("Adding loaded gesture to 1 touch\n"); */
6068
c0a928f55a19 Correct usage of SDL_AddDollarGesture (return value >= 0 on success)
Kees Bakker <kees@ijzerbout.nl>
parents: 6067
diff changeset
   257
            if (SDL_AddDollarGesture(touch, templ.path) >= 0)
c0a928f55a19 Correct usage of SDL_AddDollarGesture (return value >= 0 on success)
Kees Bakker <kees@ijzerbout.nl>
parents: 6067
diff changeset
   258
                loaded++;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   259
        }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   260
        else {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   261
            /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   262
            for (i = 0; i < SDL_numGestureTouches; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   263
                touch = &SDL_gestureTouch[i];
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   264
                /* printf("Adding loaded gesture to + touches\n"); */
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   265
                /* TODO: What if this fails? */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   266
                SDL_AddDollarGesture(touch,templ.path);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   267
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   268
            loaded++;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   269
        }
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   270
    }
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   271
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   272
    return loaded;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   273
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   274
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   275
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   276
static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   277
{
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   278
    /*  SDL_FloatPoint p[DOLLARNPOINTS]; */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   279
    float dist = 0;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   280
    SDL_FloatPoint p;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   281
    int i;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   282
    for (i = 0; i < DOLLARNPOINTS; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   283
        p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang));
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   284
        p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang));
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   285
        dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   286
                                 (p.y-templ[i].y)*(p.y-templ[i].y)));
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   287
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   288
    return dist/DOLLARNPOINTS;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   289
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   290
}
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   291
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   292
static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   293
{
7662
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   294
    /*------------BEGIN DOLLAR BLACKBOX------------------
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   295
      -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   296
      -"http://depts.washington.edu/aimgroup/proj/dollar/"
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   297
    */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   298
    double ta = -M_PI/4;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   299
    double tb = M_PI/4;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   300
    double dt = M_PI/90;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   301
    float x1 = (float)(PHI*ta + (1-PHI)*tb);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   302
    float f1 = dollarDifference(points,templ,x1);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   303
    float x2 = (float)((1-PHI)*ta + PHI*tb);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   304
    float f2 = dollarDifference(points,templ,x2);
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   305
    while (SDL_fabs(ta-tb) > dt) {
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   306
        if (f1 < f2) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   307
            tb = x2;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   308
            x2 = x1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   309
            f2 = f1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   310
            x1 = (float)(PHI*ta + (1-PHI)*tb);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   311
            f1 = dollarDifference(points,templ,x1);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   312
        }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   313
        else {
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   314
            ta = x1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   315
            x1 = x2;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   316
            f1 = f2;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   317
            x2 = (float)((1-PHI)*ta + PHI*tb);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   318
            f2 = dollarDifference(points,templ,x2);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   319
        }
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   320
    }
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   321
    /*
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   322
      if (f1 <= f2)
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   323
          printf("Min angle (x1): %f\n",x1);
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   324
      else if (f1 >  f2)
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   325
          printf("Min angle (x2): %f\n",x2);
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   326
    */
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   327
    return SDL_min(f1,f2);
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   328
}
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   329
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   330
/* DollarPath contains raw points, plus (possibly) the calculated length */
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   331
static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   332
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   333
    int i;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   334
    float interval;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   335
    float dist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   336
    int numPoints = 0;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   337
    SDL_FloatPoint centroid;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   338
    float xmin,xmax,ymin,ymax;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   339
    float ang;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   340
    float w,h;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   341
    float length = path->length;
4865
fff50e86c891 Update VS2010 project to add new files; update new files so code builds on Win32/Win64
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 4689
diff changeset
   342
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   343
    /* Calculate length if it hasn't already been done */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   344
    if (length <= 0) {
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   345
        for (i=1;i < path->numPoints; i++) {
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   346
            float dx = path->p[i  ].x - path->p[i-1].x;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   347
            float dy = path->p[i  ].y - path->p[i-1].y;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   348
            length += (float)(SDL_sqrt(dx*dx+dy*dy));
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   349
        }
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   350
    }
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   351
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   352
    /* Resample */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   353
    interval = length/(DOLLARNPOINTS - 1);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   354
    dist = interval;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   355
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   356
    centroid.x = 0;centroid.y = 0;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   357
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   358
    /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   359
    for (i = 1; i < path->numPoints; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   360
        float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   361
                                   (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y)));
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   362
        /* printf("d = %f dist = %f/%f\n",d,dist,interval); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   363
        while (dist + d > interval) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   364
            points[numPoints].x = path->p[i-1].x +
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   365
                ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   366
            points[numPoints].y = path->p[i-1].y +
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   367
                ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   368
            centroid.x += points[numPoints].x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   369
            centroid.y += points[numPoints].y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   370
            numPoints++;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   371
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   372
            dist -= interval;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   373
        }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   374
        dist += d;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   375
    }
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   376
    if (numPoints < DOLLARNPOINTS-1) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   377
        SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   378
        return 0;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   379
    }
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   380
    /* copy the last point */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   381
    points[DOLLARNPOINTS-1] = path->p[path->numPoints-1];
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   382
    numPoints = DOLLARNPOINTS;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   383
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   384
    centroid.x /= numPoints;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   385
    centroid.y /= numPoints;
4685
e0c3b09368a6 Fixed Dollar Recognition.
Jim Grandpre <jim.tla@gmail.com>
parents: 4684
diff changeset
   386
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   387
    /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   388
    /* Rotate Points so point 0 is left of centroid and solve for the bounding box */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   389
    xmin = centroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   390
    xmax = centroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   391
    ymin = centroid.y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   392
    ymax = centroid.y;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   393
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   394
    ang = (float)(SDL_atan2(centroid.y - points[0].y,
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   395
                            centroid.x - points[0].x));
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   396
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   397
    for (i = 0; i<numPoints; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   398
        float px = points[i].x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   399
        float py = points[i].y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   400
        points[i].x = (float)((px - centroid.x)*SDL_cos(ang) -
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   401
                              (py - centroid.y)*SDL_sin(ang) + centroid.x);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   402
        points[i].y = (float)((px - centroid.x)*SDL_sin(ang) +
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   403
                              (py - centroid.y)*SDL_cos(ang) + centroid.y);
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   404
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   405
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   406
        if (points[i].x < xmin) xmin = points[i].x;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   407
        if (points[i].x > xmax) xmax = points[i].x;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   408
        if (points[i].y < ymin) ymin = points[i].y;
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   409
        if (points[i].y > ymax) ymax = points[i].y;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   410
    }
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   411
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   412
    /* Scale points to DOLLARSIZE, and translate to the origin */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   413
    w = xmax-xmin;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   414
    h = ymax-ymin;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   415
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   416
    for (i=0; i<numPoints; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   417
        points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   418
        points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   419
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   420
    return numPoints;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   421
}
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   422
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   423
static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   424
{
7510
dbba26bab0f8 = {{0}} generates a memset() in MSVC, which isn't linked. Whoops!
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7509
diff changeset
   425
    SDL_FloatPoint points[DOLLARNPOINTS];
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   426
    int i;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   427
    float bestDiff = 10000;
5981
75caa8a7d559 Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   428
7510
dbba26bab0f8 = {{0}} generates a memset() in MSVC, which isn't linked. Whoops!
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7509
diff changeset
   429
    SDL_memset(points, 0, sizeof(points));
dbba26bab0f8 = {{0}} generates a memset() in MSVC, which isn't linked. Whoops!
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7509
diff changeset
   430
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   431
    dollarNormalize(path,points);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   432
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   433
    /* PrintPath(points); */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   434
    *bestTempl = -1;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   435
    for (i = 0; i < touch->numDollarTemplates; i++) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   436
        float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   437
        if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   438
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   439
    return bestDiff;
4663
56a2d70de945 Started trying to build gesture code for iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 4659
diff changeset
   440
}
56a2d70de945 Started trying to build gesture code for iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 4659
diff changeset
   441
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   442
int SDL_GestureAddTouch(SDL_TouchID touchId)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   443
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   444
    SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   445
                                                                     (SDL_numGestureTouches + 1) *
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   446
                                                                     sizeof(SDL_GestureTouch));
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
   447
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   448
    if (!gestureTouch) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 7009
diff changeset
   449
        return SDL_OutOfMemory();
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   450
    }
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
   451
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   452
    SDL_gestureTouch = gestureTouch;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   453
8296
cb13016bf07b Fixed bug 2430 - Missing initialization of the variable 'centroid' inside SDL_GestureAddTouch
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   454
    SDL_zero(SDL_gestureTouch[SDL_numGestureTouches]);
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   455
    SDL_gestureTouch[SDL_numGestureTouches].id = touchId;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   456
    SDL_numGestureTouches++;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   457
    return 0;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   458
}
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   459
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   460
static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   461
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   462
    int i;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   463
    for (i = 0; i < SDL_numGestureTouches; i++) {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   464
        /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   465
        if (SDL_gestureTouch[i].id == id)
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   466
            return &SDL_gestureTouch[i];
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   467
    }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   468
    return NULL;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   469
}
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   470
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   471
int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist)
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   472
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   473
    SDL_Event event;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   474
    event.mgesture.type = SDL_MULTIGESTURE;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   475
    event.mgesture.touchId = touch->id;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   476
    event.mgesture.x = touch->centroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   477
    event.mgesture.y = touch->centroid.y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   478
    event.mgesture.dTheta = dTheta;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   479
    event.mgesture.dDist = dDist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   480
    event.mgesture.numFingers = touch->numDownFingers;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   481
    return SDL_PushEvent(&event) > 0;
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   482
}
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   483
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5981
diff changeset
   484
static int SDL_SendGestureDollar(SDL_GestureTouch* touch,
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   485
                          SDL_GestureID gestureId,float error)
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   486
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   487
    SDL_Event event;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   488
    event.dgesture.type = SDL_DOLLARGESTURE;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   489
    event.dgesture.touchId = touch->id;
8705
fee2f7e242a1 Fixed bug 2503 - Loop indexing and event union errors in SDL_gesture.c
Sam Lantinga <slouken@libsdl.org>
parents: 8296
diff changeset
   490
    event.dgesture.x = touch->centroid.x;
fee2f7e242a1 Fixed bug 2503 - Loop indexing and event union errors in SDL_gesture.c
Sam Lantinga <slouken@libsdl.org>
parents: 8296
diff changeset
   491
    event.dgesture.y = touch->centroid.y;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   492
    event.dgesture.gestureId = gestureId;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   493
    event.dgesture.error = error;
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   494
    /* A finger came up to trigger this event. */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   495
    event.dgesture.numFingers = touch->numDownFingers + 1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   496
    return SDL_PushEvent(&event) > 0;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   497
}
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   498
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   499
6070
69b6275bb5dc Merge from https://bitbucket.org/keestux/sdl ... SDL_gesture code cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044 6069
diff changeset
   500
static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   501
{
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   502
    SDL_Event event;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   503
    event.dgesture.type = SDL_DOLLARRECORD;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   504
    event.dgesture.touchId = touch->id;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   505
    event.dgesture.gestureId = gestureId;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   506
    return SDL_PushEvent(&event) > 0;
4659
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   507
}
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   508
063b9455bd1a Added some files I had previosuly missed
Jim Grandpre <jim.tla@gmail.com>
parents: 4658
diff changeset
   509
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   510
void SDL_GestureProcessEvent(SDL_Event* event)
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   511
{
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   512
    float x,y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   513
    int index;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   514
    int i;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   515
    float pathDx, pathDy;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   516
    SDL_FloatPoint lastP;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   517
    SDL_FloatPoint lastCentroid;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   518
    float lDist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   519
    float Dist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   520
    float dtheta;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   521
    float dDist;
4865
fff50e86c891 Update VS2010 project to add new files; update new files so code builds on Win32/Win64
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 4689
diff changeset
   522
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   523
    if (event->type == SDL_FINGERMOTION ||
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   524
        event->type == SDL_FINGERDOWN ||
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   525
        event->type == SDL_FINGERUP) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   526
        SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   527
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   528
        /* Shouldn't be possible */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   529
        if (inTouch == NULL) return;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   530
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   531
        x = event->tfinger.x;
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   532
        y = event->tfinger.y;
4658
454385d76845 Moved $1 Gestures into the SDL Library
Jim Grandpre <jim.tla@gmail.com>
parents: 4657
diff changeset
   533
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   534
        /* Finger Up */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   535
        if (event->type == SDL_FINGERUP) {
8910
c23ffe72934c Partial fix for bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8775
diff changeset
   536
            SDL_FloatPoint path[DOLLARNPOINTS];
c23ffe72934c Partial fix for bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8775
diff changeset
   537
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   538
            inTouch->numDownFingers--;
4688
494f71f57a80 Fixed bugs related to keyboard handling in gestureSDLTest. Fixed gesture code (dynamic memory allocation). Cleaned up gesture and test code.
Jim Grandpre <jim.tla@gmail.com>
parents: 4686
diff changeset
   539
4684
f47c2640c667 Re-enabled dollar gesture
Jim Grandpre <jim.tla@gmail.com>
parents: 4683
diff changeset
   540
#ifdef ENABLE_DOLLAR
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   541
            if (inTouch->recording) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   542
                inTouch->recording = SDL_FALSE;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   543
                dollarNormalize(&inTouch->dollarPath,path);
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   544
                /* PrintPath(path); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   545
                if (recordAll) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   546
                    index = SDL_AddDollarGesture(NULL,path);
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   547
                    for (i = 0; i < SDL_numGestureTouches; i++)
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   548
                        SDL_gestureTouch[i].recording = SDL_FALSE;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   549
                }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   550
                else {
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   551
                    index = SDL_AddDollarGesture(inTouch,path);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   552
                }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   553
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   554
                if (index >= 0) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   555
                    SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   556
                }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   557
                else {
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   558
                    SDL_SendDollarRecord(inTouch,-1);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   559
                }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   560
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   561
            else {
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   562
                int bestTempl;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   563
                float error;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   564
                error = dollarRecognize(&inTouch->dollarPath,
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   565
                                        &bestTempl,inTouch);
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   566
                if (bestTempl >= 0){
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   567
                    /* Send Event */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   568
                    unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   569
                    SDL_SendGestureDollar(inTouch,gestureId,error);
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   570
                    /* printf ("%s\n",);("Dollar error: %f\n",error); */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   571
                }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   572
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   573
#endif
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   574
            /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   575
            if (inTouch->numDownFingers > 0) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   576
                inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   577
                                       x)/inTouch->numDownFingers;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   578
                inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)-
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   579
                                       y)/inTouch->numDownFingers;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   580
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   581
        }
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   582
        else if (event->type == SDL_FINGERMOTION) {
6951
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   583
            float dx = event->tfinger.dx;
7833f01322b3 Updated touch API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   584
            float dy = event->tfinger.dy;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   585
#ifdef ENABLE_DOLLAR
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   586
            SDL_DollarPath* path = &inTouch->dollarPath;
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   587
            if (path->numPoints < MAXPATHSIZE) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   588
                path->p[path->numPoints].x = inTouch->centroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   589
                path->p[path->numPoints].y = inTouch->centroid.y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   590
                pathDx =
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   591
                    (path->p[path->numPoints].x-path->p[path->numPoints-1].x);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   592
                pathDy =
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   593
                    (path->p[path->numPoints].y-path->p[path->numPoints-1].y);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   594
                path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   595
                path->numPoints++;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   596
            }
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4682
diff changeset
   597
#endif
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   598
            lastP.x = x - dx;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   599
            lastP.y = y - dy;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   600
            lastCentroid = inTouch->centroid;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   601
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   602
            inTouch->centroid.x += dx/inTouch->numDownFingers;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   603
            inTouch->centroid.y += dy/inTouch->numDownFingers;
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   604
            /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */
6066
1d66a8dce3ef Reformat SDL_gesture.c (part 2, space after keywords)
Kees Bakker <kees@ijzerbout.nl>
parents: 6065
diff changeset
   605
            if (inTouch->numDownFingers > 1) {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   606
                SDL_FloatPoint lv; /* Vector from centroid to last x,y position */
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   607
                SDL_FloatPoint v; /* Vector from centroid to current x,y position */
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   608
                /* lv = inTouch->gestureLast[j].cv; */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   609
                lv.x = lastP.x - lastCentroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   610
                lv.y = lastP.y - lastCentroid.y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   611
                lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   612
                /* printf("lDist = %f\n",lDist); */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   613
                v.x = x - inTouch->centroid.x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   614
                v.y = y - inTouch->centroid.y;
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   615
                /* inTouch->gestureLast[j].cv = v; */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   616
                Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   617
                /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   618
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   619
                /* Normalize Vectors to simplify angle calculation */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   620
                lv.x/=lDist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   621
                lv.y/=lDist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   622
                v.x/=Dist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   623
                v.y/=Dist;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   624
                dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   625
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   626
                dDist = (Dist - lDist);
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   627
                if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   628
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   629
                /* inTouch->gestureLast[j].dDist = dDist;
7662
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   630
                inTouch->gestureLast[j].dtheta = dtheta;
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   631
7662
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   632
                printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   633
                gdtheta = gdtheta*.9 + dtheta*.1;
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   634
                gdDist  =  gdDist*.9 +  dDist*.1
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   635
                knob.r += dDist/numDownFingers;
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   636
                knob.ang += dtheta;
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   637
                printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   638
                printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   639
                SDL_SendGestureMulti(inTouch,dtheta,dDist);
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   640
            }
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   641
            else {
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   642
                /* inTouch->gestureLast[j].dDist = 0;
7662
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   643
                inTouch->gestureLast[j].dtheta = 0;
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   644
                inTouch->gestureLast[j].cv.x = 0;
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   645
                inTouch->gestureLast[j].cv.y = 0; */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   646
            }
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   647
            /* inTouch->gestureLast[j].f.p.x = x;
7662
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   648
            inTouch->gestureLast[j].f.p.y = y;
d31efd717578 Fixes a few non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7510
diff changeset
   649
            break;
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   650
            pressure? */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   651
        }
9791
bf1504455f2a Removed redundant variable check when processing gestures.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9619
diff changeset
   652
        else if (event->type == SDL_FINGERDOWN) {
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   653
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   654
            inTouch->numDownFingers++;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   655
            inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   656
                                   x)/inTouch->numDownFingers;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   657
            inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   658
                                   y)/inTouch->numDownFingers;
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   659
            /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7662
diff changeset
   660
                 inTouch->centroid.x,inTouch->centroid.y); */
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   661
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   662
#ifdef ENABLE_DOLLAR
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   663
            inTouch->dollarPath.length = 0;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   664
            inTouch->dollarPath.p[0].x = x;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   665
            inTouch->dollarPath.p[0].y = y;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   666
            inTouch->dollarPath.numPoints = 1;
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   667
#endif
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   668
        }
4657
eed063a0bf5b Moved Multi finger gesture recognition into the library.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
   669
    }
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4682
diff changeset
   670
}
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4682
diff changeset
   671
6065
fcd144b830ce Reformat SDL_gesture.c (part 1, reindent using Emacs, c-basic-offset 4)
Kees Bakker <kees@ijzerbout.nl>
parents: 5981
diff changeset
   672
/* vi: set ts=4 sw=4 expandtab: */