mirror of https://github.com/mgba-emu/mgba.git
Add missing changes
This commit is contained in:
parent
ba0596da07
commit
da38027654
|
@ -4,16 +4,17 @@
|
||||||
#include "gba-io.h"
|
#include "gba-io.h"
|
||||||
#include "gba-video.h"
|
#include "gba-video.h"
|
||||||
|
|
||||||
int GBASDLInitEvents() {
|
int GBASDLInitEvents(struct GBASDLEvents* context) {
|
||||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
|
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
SDL_JoystickOpen(0);
|
context->joystick = SDL_JoystickOpen(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBASDLDeinitEvents() {
|
void GBASDLDeinitEvents(struct GBASDLEvents* context) {
|
||||||
|
SDL_JoystickClose(context->joystick);
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,12 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
int GBASDLInitEvents(void);
|
struct GBASDLEvents {
|
||||||
void GBASDLDeinitEvents(void);
|
SDL_Joystick* joystick;
|
||||||
|
};
|
||||||
|
|
||||||
|
int GBASDLInitEvents(struct GBASDLEvents*);
|
||||||
|
void GBASDLDeinitEvents(struct GBASDLEvents*);
|
||||||
|
|
||||||
void GBASDLHandleEvent(struct GBAThread* context, const union SDL_Event* event);
|
void GBASDLHandleEvent(struct GBAThread* context, const union SDL_Event* event);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,24 @@ int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value) {
|
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value) {
|
||||||
uint32_t* data = buffer->readPtr;
|
int8_t* data = buffer->readPtr;
|
||||||
|
if (buffer->readPtr == buffer->writePtr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*value = *data;
|
||||||
|
++data;
|
||||||
|
ptrdiff_t size = (int8_t*) data - (int8_t*) buffer->data;
|
||||||
|
if (size < buffer->capacity) {
|
||||||
|
buffer->readPtr = data;
|
||||||
|
} else {
|
||||||
|
buffer->readPtr = buffer->data;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value) {
|
||||||
|
int32_t* data = buffer->readPtr;
|
||||||
if (buffer->readPtr == buffer->writePtr) {
|
if (buffer->readPtr == buffer->writePtr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
|
||||||
void CircleBufferDeinit(struct CircleBuffer* buffer);
|
void CircleBufferDeinit(struct CircleBuffer* buffer);
|
||||||
unsigned CircleBufferSize(const struct CircleBuffer* buffer);
|
unsigned CircleBufferSize(const struct CircleBuffer* buffer);
|
||||||
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
|
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
|
||||||
|
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
|
||||||
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
|
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue