Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
14 KB
Referenced Files
None
Subscribers
None
diff --git a/util/input/psp/joystick.cpp b/util/input/psp/joystick.cpp
index 95f11418..d5e5e206 100644
--- a/util/input/psp/joystick.cpp
+++ b/util/input/psp/joystick.cpp
@@ -1,305 +1,305 @@
#ifdef MINPSPW
// Assumes SDL
#include <SDL.h>
#include "joystick.h"
#include "util/debug.h"
void PSPJoystick::poll(){
events.clear();
sceCtrlPeekBufferPositive(&joystick, 1);
doKeys();
}
int PSPJoystick::getDeviceId() const {
/* Only one available on psp, return that */
return 0;
}
JoystickInput PSPJoystick::readAll(){
return buffer;
}
void PSPJoystick::pressButton(int button){
/* NOTE This can easily be done in doKeys instead of feeding it back into SDL to run this */
- Event event = Invalid;
+ Event event = Event(Joystick::Invalid, false);
switch (button){
- case 0: event = Button1; break;
- case 1: event = Button2; break;
- case 2: event = Button3; break;
- case 3: event = Button4; break;
- case 4: event = Quit; break;
+ case 0: event = Event(Joystick::Button1, true); break;
+ case 1: event = Event(Joystick::Button2, true); break;
+ case 2: event = Event(Joystick::Button3, true); break;
+ case 3: event = Event(Joystick::Button4, true); break;
+ case 4: event = Event(Joystick::Quit, true); break;
}
events.push_back(event);
}
void PSPJoystick::releaseButton(int button){
}
void PSPJoystick::axisMotion(int axis, int motion){
if (axis == 0){
if (motion < 0){
- events.push_back(Left);
+ events.push_back(Event(Joystick::Left, true));
} else if (motion > 0){
- events.push_back(Right);
+ events.push_back(Event(Joystick::Right, true));
}
} else if (axis == 1){
if (motion < 0){
- events.push_back(Up);
+ events.push_back(Event(Joystick::Up, true));
} else if (motion > 0){
- events.push_back(Down);
+ events.push_back(Event(Joystick::Down, true));
}
}
}
void PSPJoystick::doKeys(){
if(joystick.Buttons != 0){
/*
if(!(buffer.button7) && (joystick.Buttons & PSP_CTRL_START)){
} else if((buffer.button7) && !(joystick.Buttons & PSP_CTRL_START)){
} */
if(!(buffer.quit) && (joystick.Buttons & PSP_CTRL_SELECT)){
buffer.quit = true;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 4;
event.jbutton.type = SDL_JOYBUTTONDOWN;
event.jbutton.state = SDL_PRESSED;
SDL_PushEvent(&event);
} else if((buffer.quit) && !(joystick.Buttons & PSP_CTRL_SELECT)){
buffer.quit = false;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 4;
event.jbutton.type = SDL_JOYBUTTONUP;
event.jbutton.state = SDL_RELEASED;
SDL_PushEvent(&event);
}
if(!(buffer.button1) && (joystick.Buttons & PSP_CTRL_SQUARE)){
buffer.button1 = true;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 0;
event.jbutton.type = SDL_JOYBUTTONDOWN;
event.jbutton.state = SDL_PRESSED;
SDL_PushEvent(&event);
} else if((buffer.button1) && !(joystick.Buttons & PSP_CTRL_SQUARE)){
buffer.button1 = false;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 0;
event.jbutton.type = SDL_JOYBUTTONUP;
event.jbutton.state = SDL_RELEASED;
SDL_PushEvent(&event);
}
if(!(buffer.button2) && (joystick.Buttons & PSP_CTRL_CROSS)){
buffer.button2 = true;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 1;
event.jbutton.type = SDL_JOYBUTTONDOWN;
event.jbutton.state = SDL_PRESSED;
SDL_PushEvent(&event);
} else if((buffer.button2) && !(joystick.Buttons & PSP_CTRL_CROSS)){
buffer.button2 = false;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 1;
event.jbutton.type = SDL_JOYBUTTONUP;
event.jbutton.state = SDL_RELEASED;
SDL_PushEvent(&event);
}
if(!(buffer.button3) && (joystick.Buttons & PSP_CTRL_TRIANGLE)){
buffer.button3 = true;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 2;
event.jbutton.type = SDL_JOYBUTTONDOWN;
event.jbutton.state = SDL_PRESSED;
SDL_PushEvent(&event);
} else if((buffer.button3) && !(joystick.Buttons & PSP_CTRL_TRIANGLE)){
buffer.button3 = false;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 2;
event.jbutton.type = SDL_JOYBUTTONUP;
event.jbutton.state = SDL_RELEASED;
SDL_PushEvent(&event);
}
if(!(buffer.button4) && (joystick.Buttons & PSP_CTRL_CIRCLE)){
buffer.button4 = true;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 3;
event.jbutton.type = SDL_JOYBUTTONDOWN;
event.jbutton.state = SDL_PRESSED;
SDL_PushEvent(&event);
} else if((buffer.button4) && !(joystick.Buttons & PSP_CTRL_CIRCLE)){
buffer.button4 = false;
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jbutton.which = 0;
event.jbutton.button = 3;
event.jbutton.type = SDL_JOYBUTTONUP;
event.jbutton.state = SDL_RELEASED;
SDL_PushEvent(&event);
}
/*
if(!(buffer.button5) && (joystick.Buttons & PSP_CTRL_RTRIGGER)){
} else if((buffer.button5) && !(joystick.Buttons & PSP_CTRL_RTRIGGER)){
}
if(!(buffer.button6) && (joystick.Buttons & PSP_CTRL_LTRIGGER)){
} else if((buffer.button6) && !(joystick.Buttons & PSP_CTRL_LTRIGGER)){
}
*/
if(!(buffer.left) && (joystick.Buttons & PSP_CTRL_LEFT)){
buffer.left = true;
- events.push_back(Left);
+ events.push_back(Event(Joystick::Left, true));
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 0;
event.jaxis.value = -1;
SDL_PushEvent(&event);
#endif
} else if((buffer.left) && !(joystick.Buttons & PSP_CTRL_LEFT)){
buffer.left = false;
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 0;
event.jaxis.value = 0;
SDL_PushEvent(&event);
#endif
}
if(!(buffer.right) && (joystick.Buttons & PSP_CTRL_RIGHT)){
buffer.right = true;
- events.push_back(Right);
+ events.push_back(Event(Joystick::Right, true));
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 0;
event.jaxis.value = 1;
SDL_PushEvent(&event);
#endif
} else if((buffer.right) && !(joystick.Buttons & PSP_CTRL_RIGHT)){
buffer.right = false;
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 0;
event.jaxis.value = 0;
SDL_PushEvent(&event);
#endif
}
if(!(buffer.down) && (joystick.Buttons & PSP_CTRL_DOWN)){
buffer.down = true;
- events.push_back(Down);
+ events.push_back(Event(Joystick::Down, true));
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 1;
event.jaxis.value = -1;
SDL_PushEvent(&event);
#endif
} else if((buffer.down) && !(joystick.Buttons & PSP_CTRL_DOWN)){
buffer.down = false;
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 1;
event.jaxis.value = 0;
SDL_PushEvent(&event);
#endif
}
if(!(buffer.up) && (joystick.Buttons & PSP_CTRL_UP)){
buffer.up = true;
- events.push_back(Up);
+ events.push_back(Event(Joystick::Up, true));
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 1;
event.jaxis.value = 1;
SDL_PushEvent(&event);
#endif
} else if((buffer.up) && !(joystick.Buttons & PSP_CTRL_UP)){
buffer.up = false;
#if 0
// Create SDL joy button event
SDL_Event event;
// Default to 0
event.jaxis.which = 0;
event.jaxis.type = SDL_JOYAXISMOTION;
event.jaxis.axis = 1;
event.jaxis.value = 0;
SDL_PushEvent(&event);
#endif
}
}
}
PSPJoystick::~PSPJoystick(){
// no cleanup required
}
PSPJoystick::PSPJoystick(){
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
#endif
diff --git a/util/music-player.h b/util/music-player.h
index 0315fd0a..bf7d0af3 100644
--- a/util/music-player.h
+++ b/util/music-player.h
@@ -1,189 +1,198 @@
#ifndef _paintown_music_player_h
#define _paintown_music_player_h
#include <string>
#include <stdio.h>
#ifdef USE_SDL
/* for Uint8 */
#include <SDL.h>
#include "sdl/mixer/SDL_mixer.h"
#endif
#ifdef HAVE_MP3_MPG123
#include <mpg123.h>
#endif
#ifdef HAVE_OGG
#include <vorbis/vorbisfile.h>
#endif
#ifdef HAVE_MP3_MAD
#include <mad.h>
#endif
#include "pointer.h"
struct DUH;
struct DUH_SIGRENDERER;
#ifdef USE_ALLEGRO
struct AUDIOSTREAM;
#endif
struct LOGG_Stream;
class Music_Emu;
#ifdef USE_ALLEGRO5
struct ALLEGRO_AUDIO_STREAM;
struct ALLEGRO_EVENT_QUEUE;
#endif
namespace Util{
class MusicPlayer;
/* implemented by some backend: allegro4/sdl/allergo5 */
class MusicRenderer{
public:
MusicRenderer();
MusicRenderer(int frequency, int channels);
virtual ~MusicRenderer();
void poll(MusicPlayer & player);
void play(MusicPlayer & player);
void pause();
protected:
void create(int frequency, int channels);
#ifdef USE_SDL
static void mixer(void * arg, Uint8 * stream, int length);
void fill(MusicPlayer * player);
void read(MusicPlayer * player, Uint8 * stream, int bytes);
SDL_AudioCVT convert;
Uint8 * data;
int position;
int converted;
#endif
#ifdef USE_ALLEGRO
AUDIOSTREAM * stream;
#endif
#ifdef USE_ALLEGRO5
ALLEGRO_AUDIO_STREAM * stream;
ALLEGRO_EVENT_QUEUE * queue;
#endif
};
class MusicPlayer{
public:
MusicPlayer();
virtual void play();
virtual void poll();
virtual void pause();
virtual void setVolume(double volume) = 0;
virtual ~MusicPlayer();
- /* length is in samples not bytes */
+ /* length is in samples not bytes.
+ * this function must produce samples that are
+ * signed
+ * 16-bit
+ * use the native endian of the machine
+ * dual-channel
+ *
+ * Which means each sample should be 4 bytes
+ * 2 bytes * 2 channels
+ */
virtual void render(void * stream, int length) = 0;
virtual inline double getVolume() const {
return volume;
}
virtual const ReferenceCount<MusicRenderer> & getRenderer() const {
return out;
}
virtual void setRenderer(const ReferenceCount<MusicRenderer> & what);
protected:
double volume;
ReferenceCount<MusicRenderer> out;
};
/* uses the GME library, plays nintendo music files and others */
class GMEPlayer: public MusicPlayer {
public:
GMEPlayer(std::string path);
virtual void setVolume(double volume);
virtual ~GMEPlayer();
virtual void render(void * stream, int length);
protected:
Music_Emu * emulator;
};
#ifdef HAVE_OGG
struct OggPage{
struct Page{
int position;
int max;
char * buffer;
~Page(){
delete[] buffer;
}
};
Page buffer1;
// Page buffer2;
// int use;
};
/* Maybe have some common sdl mixer class that this can inherit? */
class OggPlayer: public MusicPlayer {
public:
OggPlayer(std::string path);
virtual void setVolume(double volume);
virtual void render(void * stream, int length);
virtual ~OggPlayer();
protected:
void fillPage(OggPage::Page * page);
void doRender(char * data, int bytes);
FILE* file;
std::string path;
OggVorbis_File ogg;
ReferenceCount<OggPage> buffer;
int frequency;
int channels;
int bits;
ogg_int64_t length;
};
#endif
#if defined (HAVE_MP3_MPG123) || defined (HAVE_MP3_MAD)
/* Interface for mp3s */
class Mp3Player: public MusicPlayer {
public:
Mp3Player(std::string path);
virtual void setVolume(double volume);
virtual void render(void * data, int length);
virtual ~Mp3Player();
protected:
#ifdef HAVE_MP3_MPG123
mpg123_handle * mp3;
double base_volume;
#elif HAVE_MP3_MAD
#endif
};
#endif
/* interface to DUMB, plays mod/s3m/xm/it */
class DumbPlayer: public MusicPlayer {
public:
DumbPlayer(std::string path);
virtual void setVolume(double volume);
virtual void render(void * data, int samples);
virtual ~DumbPlayer();
protected:
DUH * loadDumbFile(std::string path);
protected:
DUH * music_file;
DUH_SIGRENDERER * renderer;
};
}
#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 10:14 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68332
Default Alt Text
(14 KB)

Event Timeline