SDL: Added CD-ROM and Joystick stubs for easer porting

git-svn-id: svn://kolibrios.org@9956 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2024-01-13 18:29:07 +00:00
parent 75cc884573
commit 9ab6a07ce2
4 changed files with 120 additions and 32 deletions

View File

@ -30,6 +30,8 @@ static char rcsid =
#ifndef _SDL_cdrom_h #ifndef _SDL_cdrom_h
#define _SDL_cdrom_h #define _SDL_cdrom_h
#include <stddef.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "begin_code.h" #include "begin_code.h"
@ -43,6 +45,8 @@ extern "C" {
for CD-ROM drives, and load appropriate drivers. for CD-ROM drives, and load appropriate drivers.
*/ */
#warning "CD-ROM support in SDL is not implemented for KolibriOS. All functions are stubs!"
/* The maximum number of CD-ROM tracks on a disk */ /* The maximum number of CD-ROM tracks on a disk */
#define SDL_MAX_TRACKS 99 #define SDL_MAX_TRACKS 99
@ -99,7 +103,10 @@ typedef struct SDL_CD {
/* Returns the number of CD-ROM drives on the system, or -1 if /* Returns the number of CD-ROM drives on the system, or -1 if
SDL_Init() has not been called with the SDL_INIT_CDROM flag. SDL_Init() has not been called with the SDL_INIT_CDROM flag.
*/ */
extern DECLSPEC int SDL_CDNumDrives(void); static inline DECLSPEC int SDL_CDNumDrives(void)
{
return -1;
}
/* Returns a human-readable, system-dependent identifier for the CD-ROM. /* Returns a human-readable, system-dependent identifier for the CD-ROM.
Example: Example:
@ -107,7 +114,10 @@ extern DECLSPEC int SDL_CDNumDrives(void);
"E:" "E:"
"/dev/disk/ide/1/master" "/dev/disk/ide/1/master"
*/ */
extern DECLSPEC const char * SDL_CDName(int drive); static inline DECLSPEC const char * SDL_CDName(int drive)
{
return NULL;
}
/* Opens a CD-ROM drive for access. It returns a drive handle on success, /* Opens a CD-ROM drive for access. It returns a drive handle on success,
or NULL if the drive was invalid or busy. This newly opened CD-ROM or NULL if the drive was invalid or busy. This newly opened CD-ROM
@ -115,13 +125,19 @@ extern DECLSPEC const char * SDL_CDName(int drive);
CD-ROM handle. CD-ROM handle.
Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.
*/ */
extern DECLSPEC SDL_CD * SDL_CDOpen(int drive); static inline DECLSPEC SDL_CD * SDL_CDOpen(int drive)
{
return NULL;
}
/* This function returns the current status of the given drive. /* This function returns the current status of the given drive.
If the drive has a CD in it, the table of contents of the CD and current If the drive has a CD in it, the table of contents of the CD and current
play position of the CD will be stored in the SDL_CD structure. play position of the CD will be stored in the SDL_CD structure.
*/ */
extern DECLSPEC CDstatus SDL_CDStatus(SDL_CD *cdrom); static inline DECLSPEC CDstatus SDL_CDStatus(SDL_CD *cdrom)
{
return CD_ERROR;
}
/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' /* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
@ -142,29 +158,49 @@ extern DECLSPEC CDstatus SDL_CDStatus(SDL_CD *cdrom);
This function returns 0, or -1 if there was an error. This function returns 0, or -1 if there was an error.
*/ */
extern DECLSPEC int SDL_CDPlayTracks(SDL_CD *cdrom, static inline DECLSPEC int SDL_CDPlayTracks(SDL_CD *cdrom,
int start_track, int start_frame, int ntracks, int nframes); int start_track, int start_frame, int ntracks, int nframes)
{
return CD_ERROR;
}
/* Play the given CD starting at 'start' frame for 'length' frames. /* Play the given CD starting at 'start' frame for 'length' frames.
It returns 0, or -1 if there was an error. It returns 0, or -1 if there was an error.
*/ */
extern DECLSPEC int SDL_CDPlay(SDL_CD *cdrom, int start, int length); static inline DECLSPEC int SDL_CDPlay(SDL_CD *cdrom, int start, int length)
{
return CD_ERROR;
}
/* Pause play -- returns 0, or -1 on error */ /* Pause play -- returns 0, or -1 on error */
extern DECLSPEC int SDL_CDPause(SDL_CD *cdrom); static inline DECLSPEC int SDL_CDPause(SDL_CD *cdrom)
{
return CD_ERROR;
}
/* Resume play -- returns 0, or -1 on error */ /* Resume play -- returns 0, or -1 on error */
extern DECLSPEC int SDL_CDResume(SDL_CD *cdrom); static inline DECLSPEC int SDL_CDResume(SDL_CD *cdrom)
{
return CD_ERROR;
}
/* Stop play -- returns 0, or -1 on error */ /* Stop play -- returns 0, or -1 on error */
extern DECLSPEC int SDL_CDStop(SDL_CD *cdrom); static inline DECLSPEC int SDL_CDStop(SDL_CD *cdrom)
{
return CD_ERROR;
}
/* Eject CD-ROM -- returns 0, or -1 on error */ /* Eject CD-ROM -- returns 0, or -1 on error */
extern DECLSPEC int SDL_CDEject(SDL_CD *cdrom); static inline DECLSPEC int SDL_CDEject(SDL_CD *cdrom)
{
return CD_ERROR;
}
/* Closes the handle for the CD-ROM drive */ /* Closes the handle for the CD-ROM drive */
extern DECLSPEC void SDL_CDClose(SDL_CD *cdrom); static inline DECLSPEC void SDL_CDClose(SDL_CD *cdrom)
{
/* STUB! */
}
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -43,11 +43,13 @@ extern DECLSPEC void SDL_ClearError(void);
/* Private error message function - used internally */ /* Private error message function - used internally */
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
typedef enum { typedef enum {
SDL_ENOMEM, SDL_ENOMEM,
SDL_EFREAD, SDL_EFREAD,
SDL_EFWRITE, SDL_EFWRITE,
SDL_EFSEEK, SDL_EFSEEK,
SDL_UNSUPPORTED,
SDL_LASTERROR SDL_LASTERROR
} SDL_errorcode; } SDL_errorcode;
extern void SDL_Error(SDL_errorcode code); extern void SDL_Error(SDL_errorcode code);

View File

@ -34,7 +34,6 @@ static char rcsid =
#include "SDL_active.h" #include "SDL_active.h"
#include "SDL_keyboard.h" #include "SDL_keyboard.h"
#include "SDL_mouse.h" #include "SDL_mouse.h"
#include "SDL_joystick.h"
#include "SDL_quit.h" #include "SDL_quit.h"
#include "begin_code.h" #include "begin_code.h"

View File

@ -30,7 +30,11 @@ static char rcsid =
#ifndef _SDL_joystick_h #ifndef _SDL_joystick_h
#define _SDL_joystick_h #define _SDL_joystick_h
#include <stddef.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -47,19 +51,26 @@ extern "C" {
struct _SDL_Joystick; struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick;
#warning "Joysticks are not supported in KolibriOS. All functions are stubs!"
/* Function prototypes */ /* Function prototypes */
/* /*
* Count the number of joysticks attached to the system * Count the number of joysticks attached to the system
*/ */
extern DECLSPEC int SDL_NumJoysticks(void); static inline DECLSPEC int SDL_NumJoysticks(void)
{
return 0;
}
/* /*
* Get the implementation dependent name of a joystick. * Get the implementation dependent name of a joystick.
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* If no name can be found, this function returns NULL. * If no name can be found, this function returns NULL.
*/ */
extern DECLSPEC const char *SDL_JoystickName(int device_index); static inline DECLSPEC const char *SDL_JoystickName(int device_index)
{
return NULL;
}
/* /*
* Open a joystick for use - the index passed as an argument refers to * Open a joystick for use - the index passed as an argument refers to
@ -68,46 +79,70 @@ extern DECLSPEC const char *SDL_JoystickName(int device_index);
* *
* This function returns a joystick identifier, or NULL if an error occurred. * This function returns a joystick identifier, or NULL if an error occurred.
*/ */
extern DECLSPEC SDL_Joystick *SDL_JoystickOpen(int device_index); static inline DECLSPEC SDL_Joystick *SDL_JoystickOpen(int device_index)
{
return NULL;
}
/* /*
* Returns 1 if the joystick has been opened, or 0 if it has not. * Returns 1 if the joystick has been opened, or 0 if it has not.
*/ */
extern DECLSPEC int SDL_JoystickOpened(int device_index); static inline DECLSPEC int SDL_JoystickOpened(int device_index)
{
return 0;
}
/* /*
* Get the device index of an opened joystick. * Get the device index of an opened joystick.
*/ */
extern DECLSPEC int SDL_JoystickIndex(SDL_Joystick *joystick); static inline DECLSPEC int SDL_JoystickIndex(SDL_Joystick *joystick)
{
return -1;
}
/* /*
* Get the number of general axis controls on a joystick * Get the number of general axis controls on a joystick
*/ */
extern DECLSPEC int SDL_JoystickNumAxes(SDL_Joystick *joystick); static inline DECLSPEC int SDL_JoystickNumAxes(SDL_Joystick *joystick)
{
return -1;
}
/* /*
* Get the number of trackballs on a joystick * Get the number of trackballs on a joystick
* Joystick trackballs have only relative motion events associated * Joystick trackballs have only relative motion events associated
* with them and their state cannot be polled. * with them and their state cannot be polled.
*/ */
extern DECLSPEC int SDL_JoystickNumBalls(SDL_Joystick *joystick); static inline DECLSPEC int SDL_JoystickNumBalls(SDL_Joystick *joystick)
{
return -1;
}
/* /*
* Get the number of POV hats on a joystick * Get the number of POV hats on a joystick
*/ */
extern DECLSPEC int SDL_JoystickNumHats(SDL_Joystick *joystick); static inline DECLSPEC int SDL_JoystickNumHats(SDL_Joystick *joystick)
{
return -1;
}
/* /*
* Get the number of buttons on a joystick * Get the number of buttons on a joystick
*/ */
extern DECLSPEC int SDL_JoystickNumButtons(SDL_Joystick *joystick); static inline DECLSPEC int SDL_JoystickNumButtons(SDL_Joystick *joystick)
{
return -1;
}
/* /*
* Update the current state of the open joysticks. * Update the current state of the open joysticks.
* This is called automatically by the event loop if any joystick * This is called automatically by the event loop if any joystick
* events are enabled. * events are enabled.
*/ */
extern DECLSPEC void SDL_JoystickUpdate(void); static inline DECLSPEC void SDL_JoystickUpdate(void)
{
/* STUB! */
}
/* /*
* Enable/disable joystick event polling. * Enable/disable joystick event polling.
@ -116,14 +151,20 @@ extern DECLSPEC void SDL_JoystickUpdate(void);
* information. * information.
* The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
*/ */
extern DECLSPEC int SDL_JoystickEventState(int state); static inline DECLSPEC int SDL_JoystickEventState(int state)
{
return SDL_IGNORE;
}
/* /*
* Get the current state of an axis control on a joystick * Get the current state of an axis control on a joystick
* The state is a value ranging from -32768 to 32767. * The state is a value ranging from -32768 to 32767.
* The axis indices start at index 0. * The axis indices start at index 0.
*/ */
extern DECLSPEC Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); static inline DECLSPEC Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
{
return -1;
}
/* /*
* Get the current state of a POV hat on a joystick * Get the current state of a POV hat on a joystick
@ -141,26 +182,36 @@ extern DECLSPEC Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
/* /*
* The hat indices start at index 0. * The hat indices start at index 0.
*/ */
extern DECLSPEC Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); static inline DECLSPEC Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
{
return 0;
}
/* /*
* Get the ball axis change since the last poll * Get the ball axis change since the last poll
* This returns 0, or -1 if you passed it invalid parameters. * This returns 0, or -1 if you passed it invalid parameters.
* The ball indices start at index 0. * The ball indices start at index 0.
*/ */
extern DECLSPEC int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); static inline DECLSPEC int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
{
return -1;
}
/* /*
* Get the current state of a button on a joystick * Get the current state of a button on a joystick
* The button indices start at index 0. * The button indices start at index 0.
*/ */
extern DECLSPEC Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button); static inline DECLSPEC Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
{
return 0;
}
/* /*
* Close a joystick previously opened with SDL_JoystickOpen() * Close a joystick previously opened with SDL_JoystickOpen()
*/ */
extern DECLSPEC void SDL_JoystickClose(SDL_Joystick *joystick); static inline DECLSPEC void SDL_JoystickClose(SDL_Joystick *joystick)
{
/* STUB! */
}
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus