Frontend: emulate motion sensor
This commit is contained in:
parent
6479f63091
commit
bcf9d20d57
9 changed files with 239 additions and 16 deletions
|
@ -19,16 +19,22 @@
|
|||
|
||||
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
|
||||
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
||||
motion_emu->Tilt(x, y);
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
|
||||
if (button != SDL_BUTTON_LEFT)
|
||||
return;
|
||||
|
||||
if (state == SDL_PRESSED) {
|
||||
TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
||||
} else {
|
||||
TouchReleased();
|
||||
if (button == SDL_BUTTON_LEFT) {
|
||||
if (state == SDL_PRESSED) {
|
||||
TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
||||
} else {
|
||||
TouchReleased();
|
||||
}
|
||||
} else if (button == SDL_BUTTON_RIGHT) {
|
||||
if (state == SDL_PRESSED) {
|
||||
motion_emu->BeginTilt(x, y);
|
||||
} else {
|
||||
motion_emu->EndTilt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +60,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
|
|||
keyboard_id = KeyMap::NewDeviceId();
|
||||
|
||||
ReloadSetKeymaps();
|
||||
motion_emu = std::make_unique<Motion::MotionEmu>(*this);
|
||||
|
||||
SDL_SetMainReady();
|
||||
|
||||
|
@ -109,6 +116,7 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
|
|||
EmuWindow_SDL2::~EmuWindow_SDL2() {
|
||||
SDL_GL_DeleteContext(gl_context);
|
||||
SDL_Quit();
|
||||
motion_emu = nullptr;
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::SwapBuffers() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue