src/haptic/linux/SDL_syshaptic.c
author Edgar Simo <bobbens@gmail.com>
Tue, 01 Jul 2008 10:44:42 +0000
branchgsoc2008_force_feedback
changeset 2481 5d0ea4576f20
parent 2480 b883974445fc
child 2482 b51ad78812d5
permissions -rw-r--r--
More comments.
Clamped values in struct ff_effect.
Added waveforms.
bobbens@2472
     1
/*
bobbens@2472
     2
    SDL - Simple DirectMedia Layer
bobbens@2472
     3
    Copyright (C) 2008 Edgar Simo
bobbens@2472
     4
bobbens@2472
     5
    This library is free software; you can redistribute it and/or
bobbens@2472
     6
    modify it under the terms of the GNU Lesser General Public
bobbens@2472
     7
    License as published by the Free Software Foundation; either
bobbens@2472
     8
    version 2.1 of the License, or (at your option) any later version.
bobbens@2472
     9
bobbens@2472
    10
    This library is distributed in the hope that it will be useful,
bobbens@2472
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
bobbens@2472
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bobbens@2472
    13
    Lesser General Public License for more details.
bobbens@2472
    14
bobbens@2472
    15
    You should have received a copy of the GNU Lesser General Public
bobbens@2472
    16
    License along with this library; if not, write to the Free Software
bobbens@2472
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
bobbens@2472
    18
bobbens@2472
    19
    Sam Lantinga
bobbens@2472
    20
    slouken@libsdl.org
bobbens@2472
    21
*/
bobbens@2472
    22
#include "SDL_config.h"
bobbens@2472
    23
bobbens@2472
    24
#ifdef SDL_JOYSTICK_LINUX
bobbens@2472
    25
bobbens@2472
    26
#include "SDL_haptic.h"
bobbens@2472
    27
#include "../SDL_haptic_c.h"
bobbens@2472
    28
#include "../SDL_syshaptic.h"
bobbens@2472
    29
bobbens@2472
    30
#include <unistd.h> /* close */
bobbens@2472
    31
#include <linux/input.h>
bobbens@2472
    32
#include <sys/ioctl.h>
bobbens@2472
    33
#include <sys/types.h>
bobbens@2472
    34
#include <sys/stat.h>
bobbens@2472
    35
#include <fcntl.h>
bobbens@2472
    36
#include <linux/limits.h>
bobbens@2472
    37
#include <string.h>
bobbens@2480
    38
#include <errno.h>
bobbens@2472
    39
bobbens@2472
    40
bobbens@2472
    41
#define MAX_HAPTICS  32
bobbens@2472
    42
bobbens@2472
    43
bobbens@2475
    44
/*
bobbens@2475
    45
 * List of available haptic devices.
bobbens@2475
    46
 */
bobbens@2472
    47
static struct
bobbens@2472
    48
{
bobbens@2472
    49
   char *fname;
bobbens@2472
    50
   SDL_Haptic *haptic;
bobbens@2472
    51
} SDL_hapticlist[MAX_HAPTICS];
bobbens@2472
    52
bobbens@2475
    53
bobbens@2475
    54
/*
bobbens@2475
    55
 * Haptic system hardware data.
bobbens@2475
    56
 */
bobbens@2472
    57
struct haptic_hwdata
bobbens@2472
    58
{
bobbens@2472
    59
   int fd;
bobbens@2472
    60
};
bobbens@2472
    61
bobbens@2472
    62
bobbens@2477
    63
/*
bobbens@2477
    64
 * Haptic system effect data.
bobbens@2477
    65
 */
bobbens@2477
    66
struct haptic_hweffect
bobbens@2477
    67
{
bobbens@2479
    68
   struct ff_effect effect;
bobbens@2477
    69
};
bobbens@2477
    70
bobbens@2477
    71
bobbens@2475
    72
bobbens@2472
    73
#define test_bit(nr, addr) \
bobbens@2472
    74
   (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
bobbens@2472
    75
#define EV_TEST(ev,f) \
bobbens@2472
    76
   if (test_bit((ev), features)) ret |= (f);
bobbens@2475
    77
/*
bobbens@2475
    78
 * Test whether a device has haptic properties.
bobbens@2475
    79
 * Returns available properties or 0 if there are none.
bobbens@2475
    80
 */
bobbens@2472
    81
static int
bobbens@2472
    82
EV_IsHaptic(int fd)
bobbens@2472
    83
{
bobbens@2472
    84
   unsigned int ret;
bobbens@2472
    85
   unsigned long features[1 + FF_MAX/sizeof(unsigned long)];
bobbens@2472
    86
bobbens@2472
    87
   ret = 0;
bobbens@2472
    88
bobbens@2472
    89
   ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features);
bobbens@2472
    90
bobbens@2472
    91
   EV_TEST(FF_CONSTANT,   SDL_HAPTIC_CONSTANT);
bobbens@2472
    92
   EV_TEST(FF_PERIODIC,   SDL_HAPTIC_PERIODIC);
bobbens@2472
    93
   EV_TEST(FF_RAMP,       SDL_HAPTIC_RAMP);
bobbens@2472
    94
   EV_TEST(FF_SPRING,     SDL_HAPTIC_SPRING);
bobbens@2472
    95
   EV_TEST(FF_FRICTION,   SDL_HAPTIC_FRICTION);
bobbens@2472
    96
   EV_TEST(FF_DAMPER,     SDL_HAPTIC_DAMPER);
bobbens@2472
    97
   EV_TEST(FF_RUMBLE,     SDL_HAPTIC_RUMBLE);
bobbens@2472
    98
   EV_TEST(FF_INERTIA,    SDL_HAPTIC_INERTIA);
bobbens@2472
    99
   EV_TEST(FF_GAIN,       SDL_HAPTIC_GAIN);
bobbens@2472
   100
   EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER);
bobbens@2472
   101
bobbens@2472
   102
   return ret;
bobbens@2472
   103
}
bobbens@2472
   104
bobbens@2472
   105
int
bobbens@2472
   106
SDL_SYS_HapticInit(void)
bobbens@2472
   107
{
bobbens@2472
   108
   const char joydev_pattern[] = "/dev/input/event%d";
bobbens@2472
   109
   dev_t dev_nums[MAX_HAPTICS];
bobbens@2472
   110
   char path[PATH_MAX];
bobbens@2472
   111
   struct stat sb;
bobbens@2472
   112
   int fd;
bobbens@2472
   113
   int i, j, k;
bobbens@2472
   114
   int duplicate;
bobbens@2472
   115
   int numhaptics;
bobbens@2472
   116
bobbens@2472
   117
   numhaptics = 0;
bobbens@2472
   118
bobbens@2472
   119
   i = 0;
bobbens@2472
   120
   for (j = 0; j < MAX_HAPTICS; ++j) {
bobbens@2472
   121
bobbens@2472
   122
      snprintf(path, PATH_MAX, joydev_pattern, i++);
bobbens@2472
   123
bobbens@2472
   124
      /* check to see if file exists */
bobbens@2472
   125
      if (stat(path,&sb) != 0)
bobbens@2472
   126
         break;
bobbens@2472
   127
bobbens@2472
   128
      /* check for duplicates */
bobbens@2472
   129
      duplicate = 0;
bobbens@2472
   130
      for (k = 0; (k < numhaptics) && !duplicate; ++k) {
bobbens@2472
   131
         if (sb.st_rdev == dev_nums[k]) {
bobbens@2472
   132
            duplicate = 1;
bobbens@2472
   133
         }                                                     
bobbens@2472
   134
      }                                                         
bobbens@2472
   135
      if (duplicate) {
bobbens@2472
   136
         continue;
bobbens@2472
   137
      }
bobbens@2472
   138
bobbens@2472
   139
      /* try to open */
bobbens@2472
   140
      fd = open(path, O_RDWR, 0);
bobbens@2472
   141
      if (fd < 0) continue;
bobbens@2472
   142
bobbens@2472
   143
#ifdef DEBUG_INPUT_EVENTS
bobbens@2472
   144
      printf("Checking %s\n", path);
bobbens@2472
   145
#endif          
bobbens@2472
   146
bobbens@2472
   147
      /* see if it works */
bobbens@2472
   148
      if (EV_IsHaptic(fd)!=0) {
bobbens@2472
   149
         SDL_hapticlist[numhaptics].fname = SDL_strdup(path);
bobbens@2472
   150
         SDL_hapticlist[numhaptics].haptic = NULL;
bobbens@2472
   151
         dev_nums[numhaptics] = sb.st_rdev;
bobbens@2472
   152
         ++numhaptics;
bobbens@2472
   153
      }
bobbens@2472
   154
      close(fd);
bobbens@2472
   155
   }
bobbens@2472
   156
bobbens@2472
   157
   return numhaptics;
bobbens@2472
   158
}
bobbens@2472
   159
bobbens@2472
   160
bobbens@2475
   161
/*
bobbens@2475
   162
 * Return the name of a haptic device, does not need to be opened.
bobbens@2475
   163
 */
bobbens@2472
   164
const char *
bobbens@2472
   165
SDL_SYS_HapticName(int index)
bobbens@2472
   166
{
bobbens@2472
   167
   int fd;
bobbens@2472
   168
   static char namebuf[128];
bobbens@2472
   169
   char *name;
bobbens@2472
   170
bobbens@2472
   171
   name = NULL;
bobbens@2472
   172
   fd = open(SDL_hapticlist[index].fname, O_RDONLY, 0);
bobbens@2472
   173
   if (fd >= 0) {
bobbens@2472
   174
      if (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) {
bobbens@2472
   175
         name = SDL_hapticlist[index].fname;
bobbens@2472
   176
      }
bobbens@2472
   177
      else {
bobbens@2472
   178
         name = namebuf;
bobbens@2472
   179
      }
bobbens@2472
   180
   }
bobbens@2472
   181
   close(fd);
bobbens@2472
   182
bobbens@2472
   183
   return name;
bobbens@2472
   184
}
bobbens@2472
   185
bobbens@2472
   186
bobbens@2475
   187
/*
bobbens@2475
   188
 * Opens a haptic device for usage.
bobbens@2475
   189
 */
bobbens@2472
   190
int
bobbens@2472
   191
SDL_SYS_HapticOpen(SDL_Haptic * haptic)
bobbens@2472
   192
{
bobbens@2477
   193
   int i;
bobbens@2472
   194
   int fd;
bobbens@2472
   195
bobbens@2476
   196
   /* Open the character device */
bobbens@2472
   197
   fd = open(SDL_hapticlist[haptic->index].fname, O_RDWR, 0);
bobbens@2472
   198
   if (fd < 0) {
bobbens@2472
   199
      SDL_SetError("Unable to open %s\n", SDL_hapticlist[haptic->index]);
bobbens@2477
   200
      return -1;
bobbens@2472
   201
   }
bobbens@2472
   202
bobbens@2476
   203
   /* Allocate the hwdata */
bobbens@2476
   204
   haptic->hwdata = (struct haptic_hwdata *)
bobbens@2477
   205
         SDL_malloc(sizeof(*haptic->hwdata));
bobbens@2476
   206
   if (haptic->hwdata == NULL) {
bobbens@2476
   207
      SDL_OutOfMemory();
bobbens@2477
   208
      goto open_err;
bobbens@2476
   209
   }
bobbens@2476
   210
   SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
bobbens@2478
   211
   /* Set the data */
bobbens@2476
   212
   haptic->hwdata->fd = fd;
bobbens@2478
   213
   haptic->supported = EV_IsHaptic(fd);
bobbens@2472
   214
bobbens@2477
   215
   /* Set the effects */
bobbens@2477
   216
   if (ioctl(fd, EVIOCGEFFECTS, &haptic->neffects) < 0) {
bobbens@2477
   217
      SDL_SetError("Unable to query haptic device memory.");
bobbens@2477
   218
      goto open_err;
bobbens@2477
   219
   }
bobbens@2477
   220
   haptic->effects = (struct haptic_effect *)
bobbens@2477
   221
         SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
bobbens@2477
   222
   if (haptic->effects == NULL) {
bobbens@2477
   223
      SDL_OutOfMemory();
bobbens@2477
   224
      goto open_err;
bobbens@2477
   225
   }
bobbens@2477
   226
bobbens@2472
   227
   return 0;
bobbens@2477
   228
bobbens@2477
   229
   /* Error handling */
bobbens@2477
   230
open_err:
bobbens@2477
   231
   close(fd);
bobbens@2477
   232
   if (haptic->hwdata != NULL) {
bobbens@2477
   233
      free(haptic->hwdata);
bobbens@2477
   234
      haptic->hwdata = NULL;
bobbens@2477
   235
   }
bobbens@2477
   236
   return -1;
bobbens@2472
   237
}
bobbens@2472
   238
bobbens@2472
   239
bobbens@2475
   240
/*
bobbens@2475
   241
 * Closes the haptic device.
bobbens@2475
   242
 */
bobbens@2475
   243
void
bobbens@2475
   244
SDL_SYS_HapticClose(SDL_Haptic * haptic)
bobbens@2475
   245
{
bobbens@2476
   246
   if (haptic->hwdata) {
bobbens@2476
   247
bobbens@2476
   248
      /* Clean up */
bobbens@2476
   249
      close(haptic->hwdata->fd);
bobbens@2476
   250
bobbens@2476
   251
      /* Free */
bobbens@2476
   252
      SDL_free(haptic->hwdata);
bobbens@2476
   253
      haptic->hwdata = NULL;
bobbens@2477
   254
      SDL_free(haptic->effects);
bobbens@2477
   255
      haptic->neffects = 0;
bobbens@2476
   256
   }
bobbens@2475
   257
}
bobbens@2475
   258
bobbens@2475
   259
bobbens@2477
   260
/* 
bobbens@2477
   261
 * Clean up after system specific haptic stuff
bobbens@2477
   262
 */
bobbens@2474
   263
void
bobbens@2474
   264
SDL_SYS_HapticQuit(void)
bobbens@2474
   265
{
bobbens@2474
   266
   int i;
bobbens@2474
   267
bobbens@2474
   268
   for (i=0; SDL_hapticlist[i].fname != NULL; i++) {
bobbens@2474
   269
      SDL_free(SDL_hapticlist[i].fname);
bobbens@2474
   270
   }
bobbens@2474
   271
   SDL_hapticlist[0].fname = NULL;
bobbens@2474
   272
}
bobbens@2474
   273
bobbens@2481
   274
#define  CLAMP(x)    (((x) > 32767) ? 32767 : x)
bobbens@2477
   275
/*
bobbens@2479
   276
 * Initializes the linux effect struct from a haptic_effect.
bobbens@2481
   277
 * Values above 32767 (for unsigned) are unspecified so we must clamp.
bobbens@2479
   278
 */
bobbens@2479
   279
static int
bobbens@2480
   280
SDL_SYS_ToFFEffect( struct ff_effect * dest, SDL_HapticEffect * src )
bobbens@2479
   281
{
bobbens@2480
   282
   SDL_HapticConstant *constant;
bobbens@2480
   283
   SDL_HapticPeriodic *periodic;
bobbens@2480
   284
bobbens@2480
   285
   /* Clear up */
bobbens@2479
   286
   SDL_memset(dest, 0, sizeof(struct ff_effect));
bobbens@2480
   287
bobbens@2480
   288
   switch (src->type) {
bobbens@2479
   289
      case SDL_HAPTIC_CONSTANT:
bobbens@2480
   290
         constant = &src->constant;
bobbens@2480
   291
bobbens@2480
   292
         /* Header */
bobbens@2479
   293
         dest->type = FF_CONSTANT;
bobbens@2481
   294
         dest->direction = CLAMP(constant->direction);
bobbens@2480
   295
bobbens@2480
   296
         /* Replay */
bobbens@2481
   297
         dest->replay.length = CLAMP(constant->length);
bobbens@2481
   298
         dest->replay.delay = CLAMP(constant->delay);
bobbens@2480
   299
bobbens@2480
   300
         /* Trigger */
bobbens@2481
   301
         dest->trigger.button = CLAMP(constant->button);
bobbens@2481
   302
         dest->trigger.interval = CLAMP(constant->interval);
bobbens@2480
   303
bobbens@2480
   304
         /* Constant */
bobbens@2480
   305
         dest->u.constant.level = constant->level;
bobbens@2480
   306
bobbens@2480
   307
         /* Envelope */
bobbens@2481
   308
         dest->u.constant.envelope.attack_length = CLAMP(constant->attack_length);
bobbens@2481
   309
         dest->u.constant.envelope.attack_level = CLAMP(constant->attack_level);
bobbens@2481
   310
         dest->u.constant.envelope.fade_length = CLAMP(constant->fade_length);
bobbens@2481
   311
         dest->u.constant.envelope.fade_level = CLAMP(constant->fade_level);
bobbens@2480
   312
bobbens@2480
   313
         break;
bobbens@2480
   314
bobbens@2480
   315
      case SDL_HAPTIC_PERIODIC:
bobbens@2480
   316
         periodic = &src->periodic;
bobbens@2480
   317
bobbens@2480
   318
         /* Header */
bobbens@2480
   319
         dest->type = FF_PERIODIC;
bobbens@2481
   320
         dest->direction = CLAMP(periodic->direction);
bobbens@2480
   321
         
bobbens@2480
   322
         /* Replay */
bobbens@2481
   323
         dest->replay.length = CLAMP(periodic->length);
bobbens@2481
   324
         dest->replay.delay = CLAMP(periodic->delay);
bobbens@2480
   325
         
bobbens@2480
   326
         /* Trigger */
bobbens@2481
   327
         dest->trigger.button = CLAMP(periodic->button);
bobbens@2481
   328
         dest->trigger.interval = CLAMP(periodic->interval);
bobbens@2480
   329
         
bobbens@2480
   330
         /* Constant */
bobbens@2481
   331
         switch (periodic->waveform) {
bobbens@2481
   332
            case SDL_WAVEFORM_SINE:
bobbens@2481
   333
               dest->u.periodic.waveform = FF_SINE;
bobbens@2481
   334
               break;
bobbens@2481
   335
            case SDL_WAVEFORM_SQUARE:
bobbens@2481
   336
               dest->u.periodic.waveform = FF_SQUARE;
bobbens@2481
   337
               break;
bobbens@2481
   338
            case SDL_WAVEFORM_TRIANGLE:
bobbens@2481
   339
               dest->u.periodic.waveform = FF_TRIANGLE;
bobbens@2481
   340
               break;
bobbens@2481
   341
            case SDL_WAVEFORM_SAWTOOTHUP:
bobbens@2481
   342
               dest->u.periodic.waveform = FF_SAW_UP;
bobbens@2481
   343
               break;
bobbens@2481
   344
            case SDL_WAVEFORM_SAWTOOTHDOWN:
bobbens@2481
   345
               dest->u.periodic.waveform = FF_SAW_DOWN;
bobbens@2481
   346
               break;
bobbens@2481
   347
bobbens@2481
   348
            default:
bobbens@2481
   349
               SDL_SetError("Unknown waveform.");
bobbens@2481
   350
               return -1;
bobbens@2481
   351
         }
bobbens@2481
   352
         dest->u.periodic.period = CLAMP(periodic->period);
bobbens@2480
   353
         dest->u.periodic.magnitude = periodic->magnitude;
bobbens@2480
   354
         dest->u.periodic.offset = periodic->offset;
bobbens@2481
   355
         dest->u.periodic.phase = CLAMP(periodic->phase);
bobbens@2480
   356
         
bobbens@2480
   357
         /* Envelope */
bobbens@2481
   358
         dest->u.periodic.envelope.attack_length = CLAMP(periodic->attack_length);
bobbens@2481
   359
         dest->u.periodic.envelope.attack_level = CLAMP(periodic->attack_level);
bobbens@2481
   360
         dest->u.periodic.envelope.fade_length = CLAMP(periodic->fade_length);
bobbens@2481
   361
         dest->u.periodic.envelope.fade_level = CLAMP(periodic->fade_level);
bobbens@2479
   362
bobbens@2479
   363
         break;
bobbens@2479
   364
bobbens@2479
   365
      default:
bobbens@2479
   366
         SDL_SetError("Unknown haptic effect type.");
bobbens@2479
   367
         return -1;
bobbens@2479
   368
   }
bobbens@2479
   369
bobbens@2479
   370
   return 0;
bobbens@2479
   371
}
bobbens@2479
   372
bobbens@2479
   373
/*
bobbens@2477
   374
 * Creates a new haptic effect.
bobbens@2477
   375
 */
bobbens@2477
   376
int
bobbens@2480
   377
SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect * effect,
bobbens@2480
   378
      SDL_HapticEffect * base)
bobbens@2477
   379
{
bobbens@2480
   380
   struct ff_effect * linux_effect;
bobbens@2480
   381
bobbens@2479
   382
   /* Allocate the hardware effect */
bobbens@2479
   383
   effect->hweffect = (struct haptic_hweffect *) 
bobbens@2479
   384
         SDL_malloc(sizeof(struct haptic_hweffect));
bobbens@2479
   385
   if (effect->hweffect == NULL) {
bobbens@2479
   386
      SDL_OutOfMemory();
bobbens@2479
   387
      return -1;
bobbens@2479
   388
   }
bobbens@2479
   389
bobbens@2479
   390
   /* Prepare the ff_effect */
bobbens@2480
   391
   linux_effect = &effect->hweffect->effect;
bobbens@2480
   392
   if (SDL_SYS_ToFFEffect( linux_effect, base ) != 0) {
bobbens@2479
   393
      return -1;
bobbens@2479
   394
   }
bobbens@2480
   395
   linux_effect->id = -1; /* Have the kernel give it an id */
bobbens@2479
   396
bobbens@2479
   397
   /* Upload the effect */
bobbens@2480
   398
   if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) {
bobbens@2480
   399
      SDL_SetError("Error uploading effect to the haptic device: %s",
bobbens@2480
   400
            strerror(errno));
bobbens@2479
   401
      return -1;
bobbens@2479
   402
   }
bobbens@2479
   403
bobbens@2479
   404
   return 0;
bobbens@2477
   405
}
bobbens@2477
   406
bobbens@2474
   407
bobbens@2479
   408
/*
bobbens@2479
   409
 * Runs an effect.
bobbens@2479
   410
 */
bobbens@2479
   411
int
bobbens@2479
   412
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect * effect)
bobbens@2479
   413
{
bobbens@2479
   414
   struct input_event run;
bobbens@2479
   415
bobbens@2479
   416
   /* Prepare to run the effect */
bobbens@2479
   417
   run.type = EV_FF;
bobbens@2479
   418
   run.code = effect->hweffect->effect.id;
bobbens@2479
   419
   run.value = 1;
bobbens@2479
   420
bobbens@2479
   421
   if (write(haptic->hwdata->fd, (const void*) &run, sizeof(run)) < 0) {
bobbens@2479
   422
      SDL_SetError("Unable to run the haptic effect.");
bobbens@2479
   423
      return -1;
bobbens@2479
   424
   }
bobbens@2479
   425
bobbens@2479
   426
   return 0;
bobbens@2479
   427
}
bobbens@2479
   428
bobbens@2479
   429
bobbens@2479
   430
/*
bobbens@2479
   431
 * Frees the effect
bobbens@2479
   432
 */
bobbens@2479
   433
void
bobbens@2479
   434
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect)
bobbens@2479
   435
{
bobbens@2479
   436
   if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) {
bobbens@2479
   437
      SDL_SetError("Error removing the effect from the haptic device.");
bobbens@2479
   438
   }
bobbens@2479
   439
   SDL_free(effect->hweffect);
bobbens@2479
   440
   effect->hweffect = NULL;
bobbens@2479
   441
}
bobbens@2479
   442
bobbens@2479
   443
bobbens@2472
   444
#endif /* SDL_HAPTIC_LINUX */