CommonHostInterface: Reimplement controller rumble support

Even better than before, supports separate motor control.
This commit is contained in:
Connor McLaughlin
2020-04-14 16:34:39 +10:00
parent 7677c95fa7
commit d9ebb975b2
16 changed files with 242 additions and 38 deletions

View File

@ -436,3 +436,8 @@ Controller::ButtonList AnalogController::StaticGetButtonNames()
B(Square), B(L1), B(L2), B(R1), B(R2), B(L3), B(R3)};
#undef B
}
u32 AnalogController::StaticGetVibrationMotorCount()
{
return NUM_MOTORS;
}

View File

@ -48,6 +48,7 @@ public:
static std::optional<s32> StaticGetButtonCodeByName(std::string_view button_name);
static AxisList StaticGetAxisNames();
static ButtonList StaticGetButtonNames();
static u32 StaticGetVibrationMotorCount();
ControllerType GetType() const override;
std::optional<s32> GetAxisCodeByName(std::string_view axis_name) const override;

View File

@ -94,6 +94,22 @@ Controller::ButtonList Controller::GetButtonNames(ControllerType type)
}
}
u32 Controller::GetVibrationMotorCount(ControllerType type)
{
switch (type)
{
case ControllerType::DigitalController:
return DigitalController::StaticGetVibrationMotorCount();
case ControllerType::AnalogController:
return AnalogController::StaticGetVibrationMotorCount();
case ControllerType::None:
default:
return 0;
}
}
std::optional<s32> Controller::GetAxisCodeByName(ControllerType type, std::string_view axis_name)
{
switch (type)

View File

@ -61,4 +61,7 @@ public:
/// Returns a list of buttons for the specified controller type.
static ButtonList GetButtonNames(ControllerType type);
/// Returns the number of vibration motors.
static u32 GetVibrationMotorCount(ControllerType type);
};

View File

@ -147,3 +147,8 @@ Controller::ButtonList DigitalController::StaticGetButtonNames()
B(Cross), B(Circle), B(Square), B(L1), B(L2), B(R1), B(R2)};
#undef B
}
u32 DigitalController::StaticGetVibrationMotorCount()
{
return 0;
}

View File

@ -36,6 +36,7 @@ public:
static std::optional<s32> StaticGetButtonCodeByName(std::string_view button_name);
static AxisList StaticGetAxisNames();
static ButtonList StaticGetButtonNames();
static u32 StaticGetVibrationMotorCount();
ControllerType GetType() const override;
std::optional<s32> GetAxisCodeByName(std::string_view axis_name) const override;

View File

@ -163,6 +163,7 @@ void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display)
Log_WarningPrintf("GL_EXT_copy_image missing, this may affect performance.");
m_supports_texture_buffer = (GLAD_GL_VERSION_3_1 || GLAD_GL_ES_VERSION_3_2);
m_supports_texture_buffer = false;
if (m_supports_texture_buffer)
{
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, reinterpret_cast<GLint*>(&m_max_texture_buffer_size));
@ -766,7 +767,7 @@ void GPU_HW_OpenGL::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 wid
src_y = m_vram_texture.GetHeight() - src_y - height;
dst_y = m_vram_texture.GetHeight() - dst_y - height;
if (GLAD_GL_VERSION_4_3)
/*if (GLAD_GL_VERSION_4_3)
{
glCopyImageSubData(m_vram_texture.GetGLId(), GL_TEXTURE_2D, 0, src_x, src_y, 0, m_vram_texture.GetGLId(),
GL_TEXTURE_2D, 0, dst_x, dst_y, 0, width, height, 1);
@ -776,7 +777,7 @@ void GPU_HW_OpenGL::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 wid
glCopyImageSubDataEXT(m_vram_texture.GetGLId(), GL_TEXTURE_2D, 0, src_x, src_y, 0, m_vram_texture.GetGLId(),
GL_TEXTURE_2D, 0, dst_x, dst_y, 0, width, height, 1);
}
else
else*/
{
glDisable(GL_SCISSOR_TEST);
m_vram_texture.BindFramebuffer(GL_READ_FRAMEBUFFER);
@ -794,7 +795,7 @@ void GPU_HW_OpenGL::UpdateVRAMReadTexture()
const u32 x = scaled_rect.left;
const u32 y = m_vram_texture.GetHeight() - scaled_rect.top - height;
if (GLAD_GL_VERSION_4_3)
/*if (GLAD_GL_VERSION_4_3)
{
glCopyImageSubData(m_vram_texture.GetGLId(), GL_TEXTURE_2D, 0, x, y, 0, m_vram_read_texture.GetGLId(),
GL_TEXTURE_2D, 0, x, y, 0, width, height, 1);
@ -804,7 +805,7 @@ void GPU_HW_OpenGL::UpdateVRAMReadTexture()
glCopyImageSubDataEXT(m_vram_texture.GetGLId(), GL_TEXTURE_2D, 0, x, y, 0, m_vram_read_texture.GetGLId(),
GL_TEXTURE_2D, 0, x, y, 0, width, height, 1);
}
else
else*/
{
m_vram_read_texture.BindFramebuffer(GL_DRAW_FRAMEBUFFER);
m_vram_texture.BindFramebuffer(GL_READ_FRAMEBUFFER);

View File

@ -547,7 +547,7 @@ float4 SampleFromVRAM(int4 texpage, int2 icoord)
texcol.rgb /= float3(ialpha, ialpha, ialpha);
semitransparent = (texcol.a != 0.0);
#else
float4 texcol = SampleFromVRAM(v_texpage, int2(v_tex0));
float4 texcol = SampleFromVRAM(v_texpage, int2(floor(v_tex0)));
if (VECTOR_EQ(texcol, TRANSPARENT_PIXEL_COLOR))
discard;