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 Sun Dec 25 01:28:39 2005 +0000 (18 years ago)
permissions -rw-r--r--
last change Refactor all the GUI bits out of the main directory (except for a couple
lingering temporarily in loader.c
Fix a few timeslice issues
view annotate diff log raw
     1 #include <stdlib.h>
     2 #include "dream.h"
     3 #include "maple.h"
     4 #include "maple/controller.h"
     6 void controller_attach( maple_device_t dev );
     7 void controller_detach( maple_device_t dev );
     8 int controller_get_cond( maple_device_t dev, int function, char *outbuf,
     9                          int *outlen );
    11 static struct maple_device base_controller = {
    12     MAPLE_DEVICE_TAG, CONTROLLER_IDENT, CONTROLLER_VERSION, NULL, NULL,
    13     controller_get_cond, NULL, NULL, NULL,
    14     controller_attach, controller_detach };
    16 typedef struct controller_device {
    17     struct maple_device dev;
    18     uint32_t condition[2];
    19 } *controller_device_t;
    23 maple_device_t controller_new( )
    24 {
    25     controller_device_t dev = malloc( sizeof(struct controller_device) );
    26     memcpy( dev, &base_controller, sizeof(base_controller) );
    27     memset( dev->condition, 0, 8 );
    28     dev->condition[0] = 0x0000FFFF;
    29     return MAPLE_DEVICE(dev);
    30 }
    33 void controller_attach( maple_device_t dev )
    34 {
    36 }
    38 void controller_detach( maple_device_t dev )
    39 {
    41 }
    44 int controller_get_cond( maple_device_t mdev, int function, char *outbuf,
    45                          int *outlen )
    46 {
    47     controller_device_t dev = (controller_device_t)mdev;
    48     if( function == MAPLE_FUNC_CONTROLLER ) {
    49         *outlen = 2;
    50         memcpy( outbuf, dev->condition, 8 );
    51         return 0;
    52     } else {
    53         return MAPLE_ERR_FUNC_UNSUP;
    54     }
    55 }
.