Search
lxdream.org :: lxdream/src/maple/controller.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/controller.c
changeset 31:495e480360d7
prev2:42349f6ea216
next144:7f0714e89aaa
author nkeynes
date Sun Dec 25 08:24:11 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Finish adding header blocks to all files
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@31
     2
 * $Id: controller.c,v 1.2 2005-12-25 08:24:11 nkeynes Exp $
nkeynes@31
     3
 *
nkeynes@31
     4
 * Implements the standard dreamcast controller
nkeynes@31
     5
 *
nkeynes@31
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@31
     7
 *
nkeynes@31
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@31
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@31
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@31
    11
 * (at your option) any later version.
nkeynes@31
    12
 *
nkeynes@31
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@31
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@31
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@31
    16
 * GNU General Public License for more details.
nkeynes@31
    17
 */
nkeynes@31
    18
nkeynes@2
    19
#include <stdlib.h>
nkeynes@2
    20
#include "dream.h"
nkeynes@2
    21
#include "maple.h"
nkeynes@2
    22
#include "maple/controller.h"
nkeynes@2
    23
nkeynes@2
    24
void controller_attach( maple_device_t dev );
nkeynes@2
    25
void controller_detach( maple_device_t dev );
nkeynes@2
    26
int controller_get_cond( maple_device_t dev, int function, char *outbuf,
nkeynes@2
    27
                         int *outlen );
nkeynes@2
    28
nkeynes@2
    29
static struct maple_device base_controller = {
nkeynes@2
    30
    MAPLE_DEVICE_TAG, CONTROLLER_IDENT, CONTROLLER_VERSION, NULL, NULL,
nkeynes@2
    31
    controller_get_cond, NULL, NULL, NULL,
nkeynes@2
    32
    controller_attach, controller_detach };
nkeynes@2
    33
nkeynes@2
    34
typedef struct controller_device {
nkeynes@2
    35
    struct maple_device dev;
nkeynes@2
    36
    uint32_t condition[2];
nkeynes@2
    37
} *controller_device_t;
nkeynes@2
    38
nkeynes@2
    39
nkeynes@2
    40
nkeynes@2
    41
maple_device_t controller_new( )
nkeynes@2
    42
{
nkeynes@2
    43
    controller_device_t dev = malloc( sizeof(struct controller_device) );
nkeynes@2
    44
    memcpy( dev, &base_controller, sizeof(base_controller) );
nkeynes@2
    45
    memset( dev->condition, 0, 8 );
nkeynes@2
    46
    dev->condition[0] = 0x0000FFFF;
nkeynes@2
    47
    return MAPLE_DEVICE(dev);
nkeynes@2
    48
}
nkeynes@2
    49
nkeynes@2
    50
nkeynes@2
    51
void controller_attach( maple_device_t dev )
nkeynes@2
    52
{
nkeynes@2
    53
nkeynes@2
    54
}
nkeynes@2
    55
nkeynes@2
    56
void controller_detach( maple_device_t dev )
nkeynes@2
    57
{
nkeynes@2
    58
nkeynes@2
    59
}
nkeynes@2
    60
nkeynes@2
    61
nkeynes@2
    62
int controller_get_cond( maple_device_t mdev, int function, char *outbuf,
nkeynes@2
    63
                         int *outlen )
nkeynes@2
    64
{
nkeynes@2
    65
    controller_device_t dev = (controller_device_t)mdev;
nkeynes@2
    66
    if( function == MAPLE_FUNC_CONTROLLER ) {
nkeynes@2
    67
        *outlen = 2;
nkeynes@2
    68
        memcpy( outbuf, dev->condition, 8 );
nkeynes@2
    69
        return 0;
nkeynes@2
    70
    } else {
nkeynes@2
    71
        return MAPLE_ERR_FUNC_UNSUP;
nkeynes@2
    72
    }
nkeynes@2
    73
}
nkeynes@2
    74
.