1 /* 2 Copyright 1999, Be Incorporated. All Rights Reserved. 3 This file may be used under the terms of the Be Sample Code License. 4 */ 5 6 #include "cm_private.h" 7 #include <string.h> 8 9 #if !defined(_KERNEL_EXPORT_H) 10 #include <KernelExport.h> 11 #endif /* _KERNEL_EXPORT_H */ 12 13 14 static status_t joy_open(const char *name, uint32 flags, void **cookie); 15 static status_t joy_close(void *cookie); 16 static status_t joy_free(void *cookie); 17 static status_t joy_control(void *cookie, uint32 op, void *data, size_t len); 18 static status_t joy_read(void *cookie, off_t pos, void *data, size_t *len); 19 static status_t joy_write(void *cookie, off_t pos, const void *data, size_t *len); 20 21 22 #define MIN_COMP -7 23 #define MAX_COMP 8 24 25 26 device_hooks joy_hooks = { 27 &joy_open, 28 &joy_close, 29 &joy_free, 30 &joy_control, 31 &joy_read, 32 &joy_write, 33 NULL, /* select */ 34 NULL, /* deselect */ 35 NULL, /* readv */ 36 NULL /* writev */ 37 }; 38 39 40 static status_t 41 joy_open( 42 const char * name, 43 uint32 flags, 44 void ** cookie) 45 { 46 int ix; 47 int offset = -1; 48 49 ddprintf(("cmedia_pci: joy_open()\n")); 50 51 *cookie = NULL; 52 for (ix=0; ix<num_cards; ix++) { 53 if (!strcmp(name, cards[ix].joy.name1)) { 54 offset = 0; 55 break; 56 } 57 } 58 if (offset < 0) { 59 return ENODEV; 60 } 61 return (*gameport->open_hook)(cards[ix].joy.driver, flags, cookie); 62 } 63 64 65 static status_t 66 joy_close( 67 void * cookie) 68 { 69 return (*gameport->close_hook)(cookie); 70 } 71 72 73 static status_t 74 joy_free( 75 void * cookie) 76 { 77 return (*gameport->free_hook)(cookie); 78 } 79 80 81 static status_t 82 joy_control( 83 void * cookie, 84 uint32 iop, 85 void * data, 86 size_t len) 87 { 88 return (*gameport->control_hook)(cookie, iop, data, len); 89 } 90 91 92 static status_t 93 joy_read( 94 void * cookie, 95 off_t pos, 96 void * data, 97 size_t * nread) 98 { 99 return (*gameport->read_hook)(cookie, pos, data, nread); 100 } 101 102 103 static status_t 104 joy_write( 105 void * cookie, 106 off_t pos, 107 const void * data, 108 size_t * nwritten) 109 { 110 return (*gameport->write_hook)(cookie, pos, data, nwritten); 111 } 112 113