2 * $Id: controller.c,v 1.2 2005-12-25 08:24:11 nkeynes Exp $
4 * Implements the standard dreamcast controller
6 * Copyright (c) 2005 Nathan Keynes.
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.
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.
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,
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( )
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);
51 void controller_attach( maple_device_t dev )
56 void controller_detach( maple_device_t dev )
62 int controller_get_cond( maple_device_t mdev, int function, char *outbuf,
65 controller_device_t dev = (controller_device_t)mdev;
66 if( function == MAPLE_FUNC_CONTROLLER ) {
68 memcpy( outbuf, dev->condition, 8 );
71 return MAPLE_ERR_FUNC_UNSUP;
.