Search
lxdream.org :: lxdream/src/maple/controller.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/controller.c
changeset 2:42349f6ea216
next31:495e480360d7
author nkeynes
date Sat Aug 21 06:15:49 2004 +0000 (17 years ago)
permissions -rw-r--r--
last change Commit changes into cvs
file annotate diff log raw
nkeynes@2
     1
#include <stdlib.h>
nkeynes@2
     2
#include "dream.h"
nkeynes@2
     3
#include "maple.h"
nkeynes@2
     4
#include "maple/controller.h"
nkeynes@2
     5
nkeynes@2
     6
void controller_attach( maple_device_t dev );
nkeynes@2
     7
void controller_detach( maple_device_t dev );
nkeynes@2
     8
int controller_get_cond( maple_device_t dev, int function, char *outbuf,
nkeynes@2
     9
                         int *outlen );
nkeynes@2
    10
nkeynes@2
    11
static struct maple_device base_controller = {
nkeynes@2
    12
    MAPLE_DEVICE_TAG, CONTROLLER_IDENT, CONTROLLER_VERSION, NULL, NULL,
nkeynes@2
    13
    controller_get_cond, NULL, NULL, NULL,
nkeynes@2
    14
    controller_attach, controller_detach };
nkeynes@2
    15
nkeynes@2
    16
typedef struct controller_device {
nkeynes@2
    17
    struct maple_device dev;
nkeynes@2
    18
    uint32_t condition[2];
nkeynes@2
    19
} *controller_device_t;
nkeynes@2
    20
nkeynes@2
    21
nkeynes@2
    22
nkeynes@2
    23
maple_device_t controller_new( )
nkeynes@2
    24
{
nkeynes@2
    25
    controller_device_t dev = malloc( sizeof(struct controller_device) );
nkeynes@2
    26
    memcpy( dev, &base_controller, sizeof(base_controller) );
nkeynes@2
    27
    memset( dev->condition, 0, 8 );
nkeynes@2
    28
    dev->condition[0] = 0x0000FFFF;
nkeynes@2
    29
    return MAPLE_DEVICE(dev);
nkeynes@2
    30
}
nkeynes@2
    31
nkeynes@2
    32
nkeynes@2
    33
void controller_attach( maple_device_t dev )
nkeynes@2
    34
{
nkeynes@2
    35
nkeynes@2
    36
}
nkeynes@2
    37
nkeynes@2
    38
void controller_detach( maple_device_t dev )
nkeynes@2
    39
{
nkeynes@2
    40
nkeynes@2
    41
}
nkeynes@2
    42
nkeynes@2
    43
nkeynes@2
    44
int controller_get_cond( maple_device_t mdev, int function, char *outbuf,
nkeynes@2
    45
                         int *outlen )
nkeynes@2
    46
{
nkeynes@2
    47
    controller_device_t dev = (controller_device_t)mdev;
nkeynes@2
    48
    if( function == MAPLE_FUNC_CONTROLLER ) {
nkeynes@2
    49
        *outlen = 2;
nkeynes@2
    50
        memcpy( outbuf, dev->condition, 8 );
nkeynes@2
    51
        return 0;
nkeynes@2
    52
    } else {
nkeynes@2
    53
        return MAPLE_ERR_FUNC_UNSUP;
nkeynes@2
    54
    }
nkeynes@2
    55
}
nkeynes@2
    56
.