mirror of https://github.com/mgba-emu/mgba.git
Qt: Light sensor setting from GUI
This commit is contained in:
parent
d759305e23
commit
7935d58eac
1
CHANGES
1
CHANGES
|
@ -10,6 +10,7 @@ Features:
|
||||||
- Support for games using the Solar Sensor
|
- Support for games using the Solar Sensor
|
||||||
- Debugger: Add CLI functions for writing to memory
|
- Debugger: Add CLI functions for writing to memory
|
||||||
- Better audio resampling via blip-buf
|
- Better audio resampling via blip-buf
|
||||||
|
- Game Pak overrides dialog for setting savetype and sensor values
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- Qt: Fix issue with set frame sizes being the wrong height
|
- Qt: Fix issue with set frame sizes being the wrong height
|
||||||
- Qt: Fix emulator crashing when full screen if a game is not running
|
- Qt: Fix emulator crashing when full screen if a game is not running
|
||||||
|
|
|
@ -48,9 +48,21 @@ GameController::GameController(QObject* parent)
|
||||||
m_threadContext.rewindBufferCapacity = 0;
|
m_threadContext.rewindBufferCapacity = 0;
|
||||||
m_threadContext.logLevel = -1;
|
m_threadContext.logLevel = -1;
|
||||||
|
|
||||||
|
m_lux.p = this;
|
||||||
|
m_lux.sample = [] (GBALuminanceSource* context) {
|
||||||
|
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
|
||||||
|
lux->value = 0xFF - lux->p->m_luxValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
m_lux.readLuminance = [] (GBALuminanceSource* context) {
|
||||||
|
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
|
||||||
|
return lux->value;
|
||||||
|
};
|
||||||
|
|
||||||
m_threadContext.startCallback = [] (GBAThread* context) {
|
m_threadContext.startCallback = [] (GBAThread* context) {
|
||||||
GameController* controller = static_cast<GameController*>(context->userData);
|
GameController* controller = static_cast<GameController*>(context->userData);
|
||||||
controller->m_audioProcessor->setInput(context);
|
controller->m_audioProcessor->setInput(context);
|
||||||
|
context->gba->luminanceSource = &controller->m_lux;
|
||||||
controller->gameStarted(context);
|
controller->gameStarted(context);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include "gba-sensors.h"
|
||||||
#include "gba-thread.h"
|
#include "gba-thread.h"
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
#include "sdl-events.h"
|
#include "sdl-events.h"
|
||||||
|
@ -91,6 +92,7 @@ public slots:
|
||||||
void setTurbo(bool, bool forced = true);
|
void setTurbo(bool, bool forced = true);
|
||||||
void setAVStream(GBAAVStream*);
|
void setAVStream(GBAAVStream*);
|
||||||
void clearAVStream();
|
void clearAVStream();
|
||||||
|
void setLuminanceValue(uint8_t value) { m_luxValue = value; }
|
||||||
|
|
||||||
void setLogLevel(int);
|
void setLogLevel(int);
|
||||||
void enableLogLevel(int);
|
void enableLogLevel(int);
|
||||||
|
@ -136,6 +138,12 @@ private:
|
||||||
bool m_turboForced;
|
bool m_turboForced;
|
||||||
|
|
||||||
InputController* m_inputController;
|
InputController* m_inputController;
|
||||||
|
|
||||||
|
struct GameControllerLux : GBALuminanceSource {
|
||||||
|
GameController* p;
|
||||||
|
uint8_t value;
|
||||||
|
} m_lux;
|
||||||
|
uint8_t m_luxValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ GamePakView::GamePakView(GameController* controller, QWidget* parent)
|
||||||
|
|
||||||
connect(controller, SIGNAL(gameStarted(GBAThread*)), this, SLOT(gameStarted(GBAThread*)));
|
connect(controller, SIGNAL(gameStarted(GBAThread*)), this, SLOT(gameStarted(GBAThread*)));
|
||||||
connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped()));
|
connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped()));
|
||||||
|
connect(m_ui.lightSpin, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int)));
|
||||||
|
connect(m_ui.lightSlide, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int)));
|
||||||
|
|
||||||
if (controller->isLoaded()) {
|
if (controller->isLoaded()) {
|
||||||
gameStarted(controller->thread());
|
gameStarted(controller->thread());
|
||||||
|
@ -61,3 +63,18 @@ void GamePakView::gameStopped() {
|
||||||
m_ui.sensorGyro->setChecked(false);
|
m_ui.sensorGyro->setChecked(false);
|
||||||
m_ui.sensorLight->setChecked(false);
|
m_ui.sensorLight->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GamePakView::setLuminanceValue(int value) {
|
||||||
|
bool oldState;
|
||||||
|
value = std::max(0, std::min(value, 255));
|
||||||
|
|
||||||
|
oldState = m_ui.lightSpin->blockSignals(true);
|
||||||
|
m_ui.lightSpin->setValue(value);
|
||||||
|
m_ui.lightSpin->blockSignals(oldState);
|
||||||
|
|
||||||
|
oldState = m_ui.lightSlide->blockSignals(true);
|
||||||
|
m_ui.lightSlide->setValue(value);
|
||||||
|
m_ui.lightSlide->blockSignals(oldState);
|
||||||
|
|
||||||
|
m_controller->setLuminanceValue(value);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void gameStarted(GBAThread*);
|
void gameStarted(GBAThread*);
|
||||||
void gameStopped();
|
void gameStopped();
|
||||||
|
void setLuminanceValue(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GamePakView m_ui;
|
Ui::GamePakView m_ui;
|
||||||
|
|
Loading…
Reference in New Issue