src/joystick/dummy/SDL_sysjoystick.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 26 Nov 2012 23:58:53 -0800
changeset 6706 b9f5fb1e78b5
parent 6705 1075e5ff6de0
child 6707 70eeb7e3ec2f
permissions -rw-r--r--
This should really fix it..
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.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
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.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.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.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:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.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
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
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
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
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.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
    21
#include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    23
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    24
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    25
/* This is the system specific header for the SDL joystick API */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    27
#include "SDL_joystick.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    28
#include "../SDL_sysjoystick.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    29
#include "../SDL_joystick_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    31
/* Function to scan the system for joysticks.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    32
 * It should return 0, or -1 on an unrecoverable fatal error.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    33
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    34
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    35
SDL_SYS_JoystickInit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    36
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    37
    return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    38
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    39
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    40
/* Function to get the device-dependent name of a joystick */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    41
const char *
6706
b9f5fb1e78b5 This should really fix it..
Sam Lantinga <slouken@libsdl.org>
parents: 6705
diff changeset
    42
SDL_SYS_JoystickNameForIndex(int index)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    44
    SDL_SetError("Logic error: No joysticks available");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    45
    return (NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    46
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    47
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    48
/* Function to open a joystick for use.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
   The joystick to open is specified by the index field of the joystick.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    50
   This should fill the nbuttons and naxes fields of the joystick structure.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    51
   It returns 0, or -1 if there is an error.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    52
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    53
int
6698
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    54
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    55
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    56
    SDL_SetError("Logic error: No joysticks available");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    57
    return (-1);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    58
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    59
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    60
/* Function to update the state of a joystick - called as a device poll.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    61
 * This function shouldn't update the joystick structure directly,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    62
 * but instead should call SDL_PrivateJoystick*() to deliver events
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    63
 * and update joystick device state.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    64
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    65
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    66
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    67
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    68
    return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    69
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    70
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    71
/* Function to close a joystick after use */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    72
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    73
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    74
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    75
    return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    76
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    77
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    78
/* Function to perform any system-specific joystick related cleanup */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    79
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    80
SDL_SYS_JoystickQuit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    81
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    82
    return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    83
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    84
6698
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    85
/* Function to perform the mapping from device index to the instance id for this index */
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    86
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    87
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    88
    return index;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    89
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    90
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    91
/* Function to determine is this joystick is attached to the system right now */
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    92
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    93
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    94
    return 1;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    95
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    96
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    97
int SDL_SYS_NumJoysticks()
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    98
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    99
    return 0;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   100
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   101
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   102
int SDL_SYS_JoystickNeedsPolling()
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   103
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   104
    return 0;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   105
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   106
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   107
void SDL_SYS_JoystickDetect()
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   108
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   109
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   110
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   111
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   112
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   113
    JoystickGUID guid;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   114
    // the GUID is just the first 16 chars of the name for now
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   115
    const char *name = SDL_SYS_JoystickNameForIndex( device_index );
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   116
    SDL_zero( guid );
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   117
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   118
    return guid;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   119
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   120
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   121
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   122
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   123
{
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   124
    JoystickGUID guid;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   125
    // the GUID is just the first 16 chars of the name for now
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   126
    const char *name = joystick->name;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   127
    SDL_zero( guid );
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   128
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   129
    return guid;
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   130
}
28ab2ef7bfc9 Completed adding new hotplug stubs for the joystick implementations
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   131
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   132
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
3104
86ea6c073d87 Fixed undefined references to joystick code
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   133
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   134
/* vi: set ts=4 sw=4 expandtab: */