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
|
||||
- Debugger: Add CLI functions for writing to memory
|
||||
- Better audio resampling via blip-buf
|
||||
- Game Pak overrides dialog for setting savetype and sensor values
|
||||
Bugfixes:
|
||||
- Qt: Fix issue with set frame sizes being the wrong height
|
||||
- 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.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) {
|
||||
GameController* controller = static_cast<GameController*>(context->userData);
|
||||
controller->m_audioProcessor->setInput(context);
|
||||
context->gba->luminanceSource = &controller->m_lux;
|
||||
controller->gameStarted(context);
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QString>
|
||||
|
||||
extern "C" {
|
||||
#include "gba-sensors.h"
|
||||
#include "gba-thread.h"
|
||||
#ifdef BUILD_SDL
|
||||
#include "sdl-events.h"
|
||||
|
@ -91,6 +92,7 @@ public slots:
|
|||
void setTurbo(bool, bool forced = true);
|
||||
void setAVStream(GBAAVStream*);
|
||||
void clearAVStream();
|
||||
void setLuminanceValue(uint8_t value) { m_luxValue = value; }
|
||||
|
||||
void setLogLevel(int);
|
||||
void enableLogLevel(int);
|
||||
|
@ -136,6 +138,12 @@ private:
|
|||
bool m_turboForced;
|
||||
|
||||
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(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()) {
|
||||
gameStarted(controller->thread());
|
||||
|
@ -61,3 +63,18 @@ void GamePakView::gameStopped() {
|
|||
m_ui.sensorGyro->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:
|
||||
void gameStarted(GBAThread*);
|
||||
void gameStopped();
|
||||
void setLuminanceValue(int);
|
||||
|
||||
private:
|
||||
Ui::GamePakView m_ui;
|
||||
|
|
Loading…
Reference in New Issue