annotate src/cdrom/beos/SDL_syscdrom.cc @ 4170:092c0bc69155 SDL-1.2

Fixed bug #618 Description From Tim Angus 2008-08-30 12:23:56 (-) [reply] As we all know SDL 1.2 doesn't handle dead keys well since one key press potentially equals two (or more) characters. For example, on many layouts, keying <backquote>,<space> results in <no character>,<backquote><space>. Since the unicode member of the SDL_keysym struct only has room for one character, only one can be returned. On Linux, the first character is returned. On Windows however, unless the exact number of characters generated by the keypress is 1, nothing is returned. The following patch addresses this inconsistency. Updated patch which includes a further fix to the handling of the numpad when numlock is on. This further fix is courtesy Amanieu d'Antras.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 13 Apr 2009 08:42:09 +0000
parents a1b03ba2fcd0
children
rev   line source
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 153
diff changeset
20 slouken@libsdl.org
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1572
diff changeset
24 #ifdef SDL_CDROM_BEOS
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1572
diff changeset
25
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 /* Functions for system-level CD-ROM audio control on BeOS
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 (not completely implemented yet)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <sys/types.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <sys/stat.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <unistd.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include <scsi.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include <Directory.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include <Entry.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include <Path.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_cdrom.h"
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 extern "C" {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
41 #include "../SDL_syscdrom.h"
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 /* Constants to help us get at the SCSI table-of-contents info */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #define CD_NUMTRACKS(toc) toc.toc_data[3]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #define CD_TRACK(toc, track) (&toc.toc_data[6+(track)*8])
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 #define CD_TRACK_N(toc, track) CD_TRACK(toc, track)[0]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #define CD_TRACK_M(toc, track) CD_TRACK(toc, track)[3]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 #define CD_TRACK_S(toc, track) CD_TRACK(toc, track)[4]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 #define CD_TRACK_F(toc, track) CD_TRACK(toc, track)[5]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 /* Constants to help us get at the SCSI position info */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 #define POS_TRACK(pos) pos.position[6]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 #define POS_ABS_M(pos) pos.position[9]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 #define POS_ABS_S(pos) pos.position[10]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 #define POS_ABS_F(pos) pos.position[11]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 #define POS_REL_M(pos) pos.position[13]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 #define POS_REL_S(pos) pos.position[14]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 #define POS_REL_F(pos) pos.position[15]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 /* The maximum number of CD-ROM drives we'll detect */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 #define MAX_DRIVES 16
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* A list of available CD-ROM drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static char *SDL_cdlist[MAX_DRIVES];
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 /* The system-dependent CD control functions */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static const char *SDL_SYS_CDName(int drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static int SDL_SYS_CDOpen(int drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 static int SDL_SYS_CDPause(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static int SDL_SYS_CDResume(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 static int SDL_SYS_CDStop(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 static int SDL_SYS_CDEject(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 static void SDL_SYS_CDClose(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 int try_dir(const char *directory);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 /* Check a drive to see if it is a CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 static int CheckDrive(char *drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 struct stat stbuf;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 int is_cd, cdfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 device_geometry info;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* If it doesn't exist, return -1 */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 if ( stat(drive, &stbuf) < 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 return(-1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 /* If it does exist, verify that it's an available CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 is_cd = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 cdfd = open(drive, 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 if ( cdfd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 if ( ioctl(cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 if ( info.device_type == B_CD ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 is_cd = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 close(cdfd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /* This can happen when the drive is open .. (?) */;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 is_cd = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 return(is_cd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 /* Add a CD-ROM drive to our list of valid drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 static void AddDrive(char *drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 int i;
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
114 size_t len;
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if ( SDL_numcds < MAX_DRIVES ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 /* Add this drive to our list */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 i = SDL_numcds;
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
119 len = SDL_strlen(drive)+1;
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
120 SDL_cdlist[i] = (char *)SDL_malloc(len);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 if ( SDL_cdlist[i] == NULL ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 SDL_OutOfMemory();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 return;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
125 SDL_strlcpy(SDL_cdlist[i], drive, len);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 ++SDL_numcds;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 #ifdef CDROM_DEBUG
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 #endif
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 /* IDE bus scanning magic */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 enum {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 IDE_GET_DEVICES_INFO = B_DEVICE_OP_CODES_END + 50,
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 };
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 struct ide_ctrl_info {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 bool ide_0_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 bool ide_0_master_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 bool ide_0_slave_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 int ide_0_master_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 int ide_0_slave_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 bool ide_1_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 bool ide_1_master_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 bool ide_1_slave_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 int ide_1_master_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 int ide_1_slave_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 };
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 int SDL_SYS_CDInit(void)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 char *SDLcdrom;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 int raw_fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 struct ide_ctrl_info info;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 /* Fill in our driver capabilities */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 SDL_CDcaps.Name = SDL_SYS_CDName;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 SDL_CDcaps.Open = SDL_SYS_CDOpen;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 SDL_CDcaps.Status = SDL_SYS_CDStatus;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_CDcaps.Play = SDL_SYS_CDPlay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 SDL_CDcaps.Pause = SDL_SYS_CDPause;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 SDL_CDcaps.Resume = SDL_SYS_CDResume;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 SDL_CDcaps.Stop = SDL_SYS_CDStop;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 SDL_CDcaps.Eject = SDL_SYS_CDEject;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_CDcaps.Close = SDL_SYS_CDClose;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 /* Look in the environment for our CD-ROM drive list */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
169 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 if ( SDLcdrom != NULL ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 char *cdpath, *delim;
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
172 size_t len = SDL_strlen(SDLcdrom)+1;
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
173 cdpath = SDL_stack_alloc(char, len);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 if ( cdpath != NULL ) {
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
175 SDL_strlcpy(cdpath, SDLcdrom, len);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 SDLcdrom = cdpath;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 do {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
178 delim = SDL_strchr(SDLcdrom, ':');
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if ( delim ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 *delim++ = '\0';
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 if ( CheckDrive(SDLcdrom) > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 AddDrive(SDLcdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 if ( delim ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDLcdrom = delim;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 SDLcdrom = NULL;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 } while ( SDLcdrom );
1572
3a8920cc822b *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
191 SDL_stack_free(cdpath);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* If we found our drives, there's nothing left to do */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 if ( SDL_numcds > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 return(0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 /* Scan the system for CD-ROM drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 try_dir("/dev/disk");
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 return 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 int try_dir(const char *directory)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 BDirectory dir;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 dir.SetTo(directory);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if(dir.InitCheck() != B_NO_ERROR) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 return false;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 dir.Rewind();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 BEntry entry;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 while(dir.GetNextEntry(&entry) >= 0) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 BPath path;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 const char *name;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 entry_ref e;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 if(entry.GetPath(&path) != B_NO_ERROR)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 name = path.Path();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if(entry.GetRef(&e) != B_NO_ERROR)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 if(entry.IsDirectory()) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
228 if(SDL_strcmp(e.name, "floppy") == 0)
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 continue; /* ignore floppy (it is not silent) */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 int devfd = try_dir(name);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 if(devfd >= 0)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 return devfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 int devfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 device_geometry g;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
238 if(SDL_strcmp(e.name, "raw") != 0)
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 continue; /* ignore partitions */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 devfd = open(name, O_RDONLY);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 if(devfd < 0)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if(g.device_type == B_CD)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 AddDrive(strdup(name));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 close(devfd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 return B_ERROR;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 /* General ioctl() CD-ROM command function */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 static int SDL_SYS_CDioctl(int index, int command, void *arg)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 int okay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 okay = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 fd = open(SDL_cdlist[index], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 if ( ioctl(fd, command, arg) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 okay = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 return(okay ? 0 : -1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 static const char *SDL_SYS_CDName(int drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 return(SDL_cdlist[drive]);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 static int SDL_SYS_CDOpen(int drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 return(drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 int i;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 scsi_toc toc;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 if ( SDL_SYS_CDioctl(cdrom->id, B_SCSI_GET_TOC, &toc) == 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 cdrom->numtracks = CD_NUMTRACKS(toc);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 cdrom->numtracks = SDL_MAX_TRACKS;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 for ( i=0; i<=cdrom->numtracks; ++i ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 cdrom->track[i].id = CD_TRACK_N(toc, i);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 /* FIXME: How do we tell on BeOS? */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 cdrom->track[i].type = SDL_AUDIO_TRACK;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 cdrom->track[i].offset = MSF_TO_FRAMES(
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 CD_TRACK_M(toc, i),
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 CD_TRACK_S(toc, i),
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 CD_TRACK_F(toc, i));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 cdrom->track[i].length = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 if ( i > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 cdrom->track[i-1].length =
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 cdrom->track[i].offset-
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 cdrom->track[i-1].offset;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 return(0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 return(-1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 /* Get CD-ROM status */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 CDstatus status;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 int cur_frame;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 scsi_position pos;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 fd = open(SDL_cdlist[cdrom->id], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 cur_frame = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 if ( ioctl(fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 cur_frame = MSF_TO_FRAMES(
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 POS_ABS_M(pos), POS_ABS_S(pos), POS_ABS_F(pos));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 if ( ! pos.position[1] || (pos.position[1] >= 0x13) ||
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 ((pos.position[1] == 0x12) && (!pos.position[6])) ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 status = CD_STOPPED;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 } else
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 if ( pos.position[1] == 0x11 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 status = CD_PLAYING;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 status = CD_PAUSED;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 status = CD_TRAYEMPTY;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 if ( position ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 *position = cur_frame;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 return(status);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 /* Start play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 int okay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 scsi_play_position pos;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 okay = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 fd = open(SDL_cdlist[cdrom->id], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 FRAMES_TO_MSF(start, &pos.start_m, &pos.start_s, &pos.start_f);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 FRAMES_TO_MSF(start+length, &pos.end_m, &pos.end_s, &pos.end_f);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 if ( ioctl(fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 okay = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 return(okay ? 0 : -1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 /* Pause play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 static int SDL_SYS_CDPause(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_PAUSE_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 /* Resume play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 static int SDL_SYS_CDResume(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_RESUME_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 /* Stop play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 static int SDL_SYS_CDStop(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_STOP_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 /* Eject the CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 static int SDL_SYS_CDEject(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_EJECT, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 /* Close the CD-ROM handle */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 static void SDL_SYS_CDClose(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 close(cdrom->id);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 void SDL_SYS_CDQuit(void)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 int i;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 if ( SDL_numcds > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 for ( i=0; i<SDL_numcds; ++i ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
406 SDL_free(SDL_cdlist[i]);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 SDL_numcds = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1572
diff changeset
412 #endif /* SDL_CDROM_BEOS */