src/events/SDL_touch.c
author Jim Grandpre <jim.tla@gmail.com>
Mon, 31 May 2010 00:24:37 -0400
changeset 4645 0375d020e7e3
parent 4644 fb500b3e1717
child 4646 eea1bf53effa
permissions -rw-r--r--
Auto-detects Wacom touch devices.
jim@4640
     1
/*
jim@4640
     2
    SDL - Simple DirectMedia Layer
jim@4640
     3
    Copyright (C) 1997-2010 Sam Lantinga
jim@4640
     4
jim@4640
     5
    This library is free software; you can redistribute it and/or
jim@4640
     6
    modify it under the terms of the GNU Lesser General Public
jim@4640
     7
    License as published by the Free Software Foundation; either
jim@4640
     8
    version 2.1 of the License, or (at your option) any later version.
jim@4640
     9
jim@4640
    10
    This library is distributed in the hope that it will be useful,
jim@4640
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
jim@4640
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
jim@4640
    13
    Lesser General Public License for more details.
jim@4640
    14
jim@4640
    15
    You should have received a copy of the GNU Lesser General Public
jim@4640
    16
    License along with this library; if not, write to the Free Software
jim@4640
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
jim@4640
    18
jim@4640
    19
    Sam Lantinga
jim@4640
    20
    slouken@libsdl.org
jim@4640
    21
*/
jim@4640
    22
#include "SDL_config.h"
jim@4640
    23
jim@4640
    24
/* General touch handling code for SDL */
jim@4640
    25
jim@4640
    26
#include "SDL_events.h"
jim@4640
    27
#include "SDL_events_c.h"
jim@4640
    28
#include "../video/SDL_sysvideo.h"
jim@4640
    29
jim@4640
    30
jim@4640
    31
static int SDL_num_touch = 0;
jim@4641
    32
static SDL_Touch **SDL_touchPads = NULL;
jim@4640
    33
jim@4640
    34
jim@4640
    35
/* Public functions */
jim@4640
    36
int
jim@4640
    37
SDL_TouchInit(void)
jim@4640
    38
{
jim@4642
    39
    
jim@4640
    40
    return (0);
jim@4640
    41
}
jim@4642
    42
jim@4640
    43
SDL_Touch *
jim@4641
    44
SDL_GetTouch(int id)
jim@4640
    45
{
jim@4641
    46
    int index = SDL_GetTouchIndexId(id);
jim@4640
    47
    if (index < 0 || index >= SDL_num_touch) {
jim@4640
    48
        return NULL;
jim@4640
    49
    }
jim@4641
    50
    return SDL_touchPads[index];
jim@4640
    51
}
jim@4640
    52
jim@4642
    53
SDL_Touch *
jim@4642
    54
SDL_GetTouchIndex(int index)
jim@4641
    55
{
jim@4642
    56
    if (index < 0 || index >= SDL_num_touch) {
jim@4642
    57
        return NULL;
jim@4642
    58
    }
jim@4642
    59
    return SDL_touchPads[index];
jim@4641
    60
}
jim@4641
    61
jim@4641
    62
int
jim@4641
    63
SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid)
jim@4641
    64
{
jim@4641
    65
    int i;
jim@4641
    66
    for(i = 0;i < touch->num_fingers;i++)
jim@4641
    67
	if(touch->fingers[i]->id == fingerid)
jim@4641
    68
	    return i;
jim@4641
    69
    return -1;
jim@4641
    70
}
jim@4641
    71
jim@4642
    72
jim@4642
    73
SDL_Finger *
jim@4642
    74
SDL_GetFinger(SDL_Touch* touch,int id)
jim@4642
    75
{
jim@4642
    76
    int index = SDL_GetFingerIndexId(touch,id);
jim@4642
    77
    if(index < 0 || index >= touch->num_fingers)
jim@4642
    78
	return NULL;
jim@4642
    79
    return touch->fingers[index];
jim@4642
    80
}
jim@4642
    81
jim@4642
    82
jim@4641
    83
int
jim@4640
    84
SDL_GetTouchIndexId(int id)
jim@4640
    85
{
jim@4640
    86
    int index;
jim@4640
    87
    SDL_Touch *touch;
jim@4640
    88
jim@4640
    89
    for (index = 0; index < SDL_num_touch; ++index) {
jim@4641
    90
        touch = SDL_touchPads[index];
jim@4640
    91
        if (touch->id == id) {
jim@4640
    92
            return index;
jim@4640
    93
        }
jim@4640
    94
    }
jim@4640
    95
    return -1;
jim@4640
    96
}
jim@4640
    97
jim@4640
    98
int
jim@4642
    99
SDL_AddTouch(const SDL_Touch * touch, char *name)
jim@4640
   100
{
jim@4641
   101
    SDL_Touch **touchPads;
jim@4640
   102
    int selected_touch;
jim@4640
   103
    int index;
jim@4640
   104
    size_t length;
jim@4640
   105
jim@4640
   106
    if (SDL_GetTouchIndexId(touch->id) != -1) {
jim@4640
   107
        SDL_SetError("Touch ID already in use");
jim@4640
   108
    }
jim@4640
   109
jim@4640
   110
    /* Add the touch to the list of touch */
jim@4641
   111
    touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads,
jim@4640
   112
                                      (SDL_num_touch + 1) * sizeof(*touch));
jim@4641
   113
    if (!touchPads) {
jim@4640
   114
        SDL_OutOfMemory();
jim@4640
   115
        return -1;
jim@4640
   116
    }
jim@4640
   117
jim@4641
   118
    SDL_touchPads = touchPads;
jim@4640
   119
    index = SDL_num_touch++;
jim@4640
   120
jim@4641
   121
    SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index]));
jim@4641
   122
    if (!SDL_touchPads[index]) {
jim@4640
   123
        SDL_OutOfMemory();
jim@4640
   124
        return -1;
jim@4640
   125
    }
jim@4641
   126
    *SDL_touchPads[index] = *touch;
jim@4640
   127
jim@4640
   128
    /* we're setting the touch properties */
jim@4640
   129
    length = 0;
jim@4640
   130
    length = SDL_strlen(name);
jim@4641
   131
    SDL_touchPads[index]->focus = 0;
jim@4641
   132
    SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
jim@4642
   133
    SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);   
jim@4642
   134
jim@4642
   135
    SDL_touchPads[index]->num_fingers = 0;
jim@4645
   136
    SDL_touchPads[index]->max_fingers = 0;
jim@4645
   137
    SDL_touchPads[index]->fingers = NULL;
jim@4645
   138
    
jim@4642
   139
    SDL_touchPads[index]->buttonstate = 0;
jim@4642
   140
    SDL_touchPads[index]->relative_mode = SDL_FALSE;
jim@4642
   141
    SDL_touchPads[index]->flush_motion = SDL_FALSE;
jim@4641
   142
    
jim@4640
   143
    return index;
jim@4640
   144
}
jim@4640
   145
jim@4640
   146
void
jim@4641
   147
SDL_DelTouch(int id)
jim@4640
   148
{
jim@4641
   149
    int index = SDL_GetTouchIndexId(id);
jim@4641
   150
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4640
   151
jim@4640
   152
    if (!touch) {
jim@4640
   153
        return;
jim@4640
   154
    }
jim@4640
   155
jim@4641
   156
    
jim@4640
   157
    SDL_free(touch->name);
jim@4640
   158
 
jim@4640
   159
    if (touch->FreeTouch) {
jim@4640
   160
        touch->FreeTouch(touch);
jim@4640
   161
    }
jim@4640
   162
    SDL_free(touch);
jim@4640
   163
jim@4641
   164
    SDL_num_touch--;
jim@4641
   165
    SDL_touchPads[index] = SDL_touchPads[SDL_num_touch];
jim@4640
   166
}
jim@4640
   167
jim@4640
   168
void
jim@4640
   169
SDL_TouchQuit(void)
jim@4640
   170
{
jim@4640
   171
    int i;
jim@4640
   172
jim@4641
   173
    for (i = SDL_num_touch-1; i > 0 ; --i) {
jim@4640
   174
        SDL_DelTouch(i);
jim@4640
   175
    }
jim@4640
   176
    SDL_num_touch = 0;
jim@4640
   177
jim@4641
   178
    if (SDL_touchPads) {
jim@4641
   179
        SDL_free(SDL_touchPads);
jim@4641
   180
        SDL_touchPads = NULL;
jim@4640
   181
    }
jim@4640
   182
}
jim@4640
   183
jim@4640
   184
int
jim@4640
   185
SDL_GetNumTouch(void)
jim@4640
   186
{
jim@4640
   187
    return SDL_num_touch;
jim@4640
   188
}
jim@4641
   189
SDL_Window *
jim@4641
   190
SDL_GetTouchFocusWindow(int id)
jim@4640
   191
{
jim@4641
   192
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4640
   193
jim@4640
   194
    if (!touch) {
jim@4640
   195
        return 0;
jim@4640
   196
    }
jim@4640
   197
    return touch->focus;
jim@4640
   198
}
jim@4640
   199
jim@4640
   200
void
jim@4640
   201
SDL_SetTouchFocus(int id, SDL_Window * window)
jim@4640
   202
{
jim@4640
   203
    int index = SDL_GetTouchIndexId(id);
jim@4641
   204
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4640
   205
    int i;
jim@4640
   206
    SDL_bool focus;
jim@4640
   207
jim@4640
   208
    if (!touch || (touch->focus == window)) {
jim@4640
   209
        return;
jim@4640
   210
    }
jim@4640
   211
jim@4640
   212
    /* See if the current window has lost focus */
jim@4640
   213
    if (touch->focus) {
jim@4640
   214
        focus = SDL_FALSE;
jim@4640
   215
        for (i = 0; i < SDL_num_touch; ++i) {
jim@4640
   216
            SDL_Touch *check;
jim@4640
   217
            if (i != index) {
jim@4641
   218
                check = SDL_touchPads[i];
jim@4640
   219
                if (check && check->focus == touch->focus) {
jim@4640
   220
                    focus = SDL_TRUE;
jim@4640
   221
                    break;
jim@4640
   222
                }
jim@4640
   223
            }
jim@4640
   224
        }
jim@4640
   225
        if (!focus) {
jim@4640
   226
            SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
jim@4640
   227
        }
jim@4640
   228
    }
jim@4640
   229
jim@4640
   230
    touch->focus = window;
jim@4640
   231
jim@4640
   232
    if (touch->focus) {
jim@4640
   233
        focus = SDL_FALSE;
jim@4640
   234
        for (i = 0; i < SDL_num_touch; ++i) {
jim@4640
   235
            SDL_Touch *check;
jim@4640
   236
            if (i != index) {
jim@4641
   237
                check = SDL_touchPads[i];
jim@4640
   238
                if (check && check->focus == touch->focus) {
jim@4640
   239
                    focus = SDL_TRUE;
jim@4640
   240
                    break;
jim@4640
   241
                }
jim@4640
   242
            }
jim@4640
   243
        }
jim@4640
   244
        if (!focus) {
jim@4640
   245
            SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
jim@4640
   246
        }
jim@4640
   247
    }
jim@4640
   248
}
jim@4640
   249
jim@4641
   250
int 
jim@4641
   251
SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
jim@4640
   252
{
jim@4641
   253
    int index;
jim@4641
   254
    SDL_Finger **fingers;
jim@4641
   255
    size_t length;
jim@4641
   256
    
jim@4641
   257
    if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
jim@4641
   258
        SDL_SetError("Finger ID already in use");
jim@4642
   259
	}
jim@4640
   260
jim@4641
   261
    /* Add the touch to the list of touch */
jim@4645
   262
    if(touch->num_fingers >= touch->max_fingers){
jim@4645
   263
      if(fingers == NULL) {
jim@4645
   264
	touch->max_fingers = 1;
jim@4645
   265
	fingers = (SDL_Finger **) SDL_malloc(sizeof(finger));
jim@4645
   266
      }
jim@4645
   267
      else {
jim@4645
   268
	fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
jim@4645
   269
				     (touch->num_fingers + 1) * sizeof(finger));
jim@4645
   270
	touch->max_fingers = touch->num_fingers+1;
jim@4645
   271
      }
jim@4645
   272
jim@4645
   273
    }
jim@4645
   274
jim@4641
   275
    if (!fingers) {
jim@4641
   276
        SDL_OutOfMemory();
jim@4641
   277
        return -1;
jim@4640
   278
    }
jim@4641
   279
jim@4641
   280
    touch->fingers = fingers;
jim@4645
   281
    index = touch->num_fingers;
jim@4645
   282
    touch->num_fingers++;
jim@4641
   283
    touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index])));
jim@4641
   284
    if (!touch->fingers[index]) {
jim@4641
   285
        SDL_OutOfMemory();
jim@4641
   286
        return -1;
jim@4641
   287
    }
jim@4641
   288
    *touch->fingers[index] = *finger;    
jim@4641
   289
jim@4641
   290
    return index;
jim@4640
   291
}
jim@4640
   292
jim@4640
   293
int
jim@4641
   294
SDL_DelFinger(SDL_Touch* touch,int fingerid)
jim@4641
   295
{
jim@4642
   296
    int index = SDL_GetFingerIndexId(touch,fingerid);
jim@4641
   297
    SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
jim@4641
   298
jim@4641
   299
    if (!finger) {
jim@4641
   300
        return;
jim@4641
   301
    }
jim@4641
   302
 
jim@4641
   303
jim@4641
   304
    SDL_free(finger);
jim@4641
   305
    touch->num_fingers--;
jim@4641
   306
    touch->fingers[index] = touch->fingers[touch->num_fingers];
jim@4641
   307
}
jim@4641
   308
jim@4641
   309
jim@4641
   310
int
jim@4641
   311
SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
jim@4641
   312
{
jim@4643
   313
    int posted;
jim@4641
   314
    SDL_Touch* touch = SDL_GetTouch(id);
jim@4643
   315
jim@4641
   316
    if(down) {
jim@4641
   317
	SDL_Finger nf;
jim@4643
   318
	nf.id = fingerid;
jim@4641
   319
	nf.x = x;
jim@4641
   320
	nf.y = y;
jim@4641
   321
	nf.pressure = pressure;
jim@4641
   322
	nf.xdelta = 0;
jim@4641
   323
	nf.ydelta = 0;
jim@4641
   324
	nf.last_x = x;
jim@4641
   325
	nf.last_y = y;
jim@4641
   326
	SDL_AddFinger(touch,&nf);
jim@4641
   327
jim@4641
   328
	posted = 0;
jim@4641
   329
	if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
jim@4641
   330
	    SDL_Event event;
jim@4641
   331
	    event.tfinger.type = SDL_FINGERDOWN;
jim@4641
   332
	    event.tfinger.touchId = (Uint8) id;
jim@4642
   333
	    event.tfinger.x = x;
jim@4642
   334
	    event.tfinger.y = y;
jim@4641
   335
	    event.tfinger.state = touch->buttonstate;
jim@4641
   336
	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
jim@4643
   337
	    event.tfinger.fingerId = fingerid;
jim@4641
   338
	    posted = (SDL_PushEvent(&event) > 0);
jim@4641
   339
	}
jim@4641
   340
	return posted;
jim@4641
   341
    }
jim@4641
   342
    else {
jim@4643
   343
	SDL_DelFinger(touch,fingerid);
jim@4641
   344
	posted = 0;
jim@4641
   345
	if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
jim@4641
   346
	    SDL_Event event;
jim@4641
   347
	    event.tfinger.type = SDL_FINGERUP;
jim@4641
   348
	    event.tfinger.touchId = (Uint8) id;
jim@4641
   349
	    event.tfinger.state = touch->buttonstate;
jim@4641
   350
	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
jim@4643
   351
	    event.tfinger.fingerId = fingerid;
jim@4641
   352
	    posted = (SDL_PushEvent(&event) > 0);
jim@4641
   353
	}
jim@4641
   354
	return posted;
jim@4641
   355
    }
jim@4641
   356
}
jim@4641
   357
jim@4641
   358
int
jim@4641
   359
SDL_SendTouchMotion(int id, int fingerid, int relative, 
jim@4641
   360
		    int x, int y, int pressure)
jim@4640
   361
{
jim@4640
   362
    int index = SDL_GetTouchIndexId(id);
jim@4641
   363
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4641
   364
    SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
jim@4640
   365
    int posted;
jim@4640
   366
    int xrel;
jim@4640
   367
    int yrel;
jim@4640
   368
    int x_max = 0, y_max = 0;
jim@4640
   369
jim@4640
   370
    if (!touch || touch->flush_motion) {
jim@4640
   371
        return 0;
jim@4640
   372
    }
jim@4640
   373
jim@4642
   374
    if(finger == NULL)
jim@4642
   375
	SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
jim@4642
   376
    else {
jim@4642
   377
	/* the relative motion is calculated regarding the last position */
jim@4642
   378
	if (relative) {
jim@4642
   379
	    xrel = x;
jim@4642
   380
	    yrel = y;
jim@4642
   381
	    x = (finger->last_x + x);
jim@4642
   382
	    y = (finger->last_y + y);
jim@4642
   383
	} else {
jim@4642
   384
	    if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
jim@4642
   385
	    if(y < 0) y = finger->last_y; /*The other is marked as -1*/
jim@4642
   386
	    xrel = x - finger->last_x;
jim@4642
   387
	    yrel = y - finger->last_y;
jim@4642
   388
	}
jim@4642
   389
	
jim@4642
   390
	/* Drop events that don't change state */
jim@4642
   391
	if (!xrel && !yrel) {
jim@4642
   392
#if 0
jim@4642
   393
	    printf("Touch event didn't change state - dropped!\n");
jim@4642
   394
#endif
jim@4642
   395
	    return 0;
jim@4642
   396
	}
jim@4642
   397
	
jim@4642
   398
	/* Update internal touch coordinates */
jim@4642
   399
	
jim@4642
   400
	finger->x = x;
jim@4642
   401
	finger->y = y;
jim@4642
   402
	
jim@4642
   403
	/*Should scale to window? Normalize? Maintain Aspect?*/
jim@4642
   404
	//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
jim@4642
   405
	
jim@4642
   406
	/* make sure that the pointers find themselves inside the windows */
jim@4642
   407
	/* only check if touch->xmax is set ! */
jim@4642
   408
	/*
jim@4642
   409
	  if (x_max && touch->x > x_max) {
jim@4642
   410
	  touch->x = x_max;
jim@4642
   411
	  } else if (touch->x < 0) {
jim@4642
   412
	  touch->x = 0;
jim@4642
   413
	  }
jim@4642
   414
	  
jim@4642
   415
	  if (y_max && touch->y > y_max) {
jim@4642
   416
	  touch->y = y_max;
jim@4642
   417
	  } else if (touch->y < 0) {
jim@4642
   418
	  touch->y = 0;
jim@4642
   419
	  }
jim@4642
   420
	*/
jim@4642
   421
	finger->xdelta += xrel;
jim@4642
   422
	finger->ydelta += yrel;
jim@4642
   423
	finger->pressure = pressure;
jim@4642
   424
	
jim@4642
   425
	
jim@4642
   426
	
jim@4642
   427
	/* Post the event, if desired */
jim@4642
   428
	posted = 0;
jim@4642
   429
	if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
jim@4642
   430
	    SDL_Event event;
jim@4642
   431
	    event.tfinger.type = SDL_FINGERMOTION;
jim@4643
   432
	    event.tfinger.touchId = (Uint8) id;
jim@4643
   433
	    event.tfinger.fingerId = (Uint8) fingerid;
jim@4642
   434
	    event.tfinger.x = x;
jim@4642
   435
	    event.tfinger.y = y;
jim@4644
   436
	    event.tfinger.pressure = pressure;
jim@4642
   437
	    event.tfinger.state = touch->buttonstate;
jim@4642
   438
	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
jim@4642
   439
	    posted = (SDL_PushEvent(&event) > 0);
jim@4642
   440
	}
jim@4642
   441
	finger->last_x = finger->x;
jim@4642
   442
	finger->last_y = finger->y;
jim@4642
   443
	return posted;
jim@4640
   444
    }
jim@4640
   445
}
jim@4640
   446
int
jim@4640
   447
SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
jim@4640
   448
{
jim@4641
   449
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4640
   450
    int posted;
jim@4640
   451
    Uint32 type;
jim@4640
   452
jim@4640
   453
    if (!touch) {
jim@4640
   454
        return 0;
jim@4640
   455
    }
jim@4640
   456
jim@4640
   457
    /* Figure out which event to perform */
jim@4640
   458
    switch (state) {
jim@4640
   459
    case SDL_PRESSED:
jim@4640
   460
        if (touch->buttonstate & SDL_BUTTON(button)) {
jim@4640
   461
            /* Ignore this event, no state change */
jim@4640
   462
            return 0;
jim@4640
   463
        }
jim@4640
   464
        type = SDL_TOUCHBUTTONDOWN;
jim@4640
   465
        touch->buttonstate |= SDL_BUTTON(button);
jim@4640
   466
        break;
jim@4640
   467
    case SDL_RELEASED:
jim@4640
   468
        if (!(touch->buttonstate & SDL_BUTTON(button))) {
jim@4640
   469
            /* Ignore this event, no state change */
jim@4640
   470
            return 0;
jim@4640
   471
        }
jim@4640
   472
        type = SDL_TOUCHBUTTONUP;
jim@4640
   473
        touch->buttonstate &= ~SDL_BUTTON(button);
jim@4640
   474
        break;
jim@4640
   475
    default:
jim@4640
   476
        /* Invalid state -- bail */
jim@4640
   477
        return 0;
jim@4640
   478
    }
jim@4640
   479
jim@4640
   480
    /* Post the event, if desired */
jim@4640
   481
    posted = 0;
jim@4640
   482
    if (SDL_GetEventState(type) == SDL_ENABLE) {
jim@4640
   483
        SDL_Event event;
jim@4640
   484
        event.type = type;
jim@4642
   485
        event.tbutton.touchId = (Uint8) index;
jim@4641
   486
        event.tbutton.state = state;
jim@4641
   487
        event.tbutton.button = button;
jim@4641
   488
        event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
jim@4640
   489
        posted = (SDL_PushEvent(&event) > 0);
jim@4640
   490
    }
jim@4640
   491
    return posted;
jim@4640
   492
}
jim@4640
   493
jim@4641
   494
char *
jim@4641
   495
SDL_GetTouchName(int id)
jim@4640
   496
{
jim@4641
   497
    SDL_Touch *touch = SDL_GetTouch(id);
jim@4640
   498
    if (!touch) {
jim@4640
   499
        return NULL;
jim@4640
   500
    }
jim@4640
   501
    return touch->name;
jim@4640
   502
}
jim@4640
   503
jim@4640
   504
/* vi: set ts=4 sw=4 expandtab: */