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