Merge branch 'stable' into 'master'

This commit is contained in:
Scott Mansell 2015-07-13 12:40:38 +12:00
commit dc25277a2f
3 changed files with 19 additions and 3 deletions

View File

@ -115,8 +115,10 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{ {
while (nbytes) while (nbytes)
{ {
u64 read_size = 0; u64 read_size;
File::IOFile& data_file = SeekToCluster(offset, &read_size); File::IOFile& data_file = SeekToCluster(offset, &read_size);
if (read_size == 0)
return false;
read_size = (read_size > nbytes) ? nbytes : read_size; read_size = (read_size > nbytes) ? nbytes : read_size;
if (!data_file.ReadBytes(out_ptr, read_size)) if (!data_file.ReadBytes(out_ptr, read_size))
@ -160,6 +162,8 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
} }
PanicAlert("Read beyond end of disc"); PanicAlert("Read beyond end of disc");
if (available)
*available = 0;
m_files[0]->file.Seek(0, SEEK_SET); m_files[0]->file.Seek(0, SEEK_SET);
return m_files[0]->file; return m_files[0]->file;
} }

View File

@ -217,6 +217,12 @@ void evdevDevice::ForceFeedback::SetState(ControlState state)
// libevdev doesn't have nice helpers for forcefeedback // libevdev doesn't have nice helpers for forcefeedback
// we will use the file descriptors directly. // we will use the file descriptors directly.
if (m_id != -1) // delete the previous effect (which also stops it)
{
ioctl(m_fd, EVIOCRMFF, m_id);
m_id = -1;
}
if (state > 0) // Upload and start an effect. if (state > 0) // Upload and start an effect.
{ {
ff_effect effect; ff_effect effect;
@ -261,9 +267,14 @@ void evdevDevice::ForceFeedback::SetState(ControlState state)
write(m_fd, (const void*) &play, sizeof(play)); write(m_fd, (const void*) &play, sizeof(play));
} }
else if (m_id != -1) // delete the effect (which also stops it) }
evdevDevice::ForceFeedback::~ForceFeedback()
{
// delete the uploaded effect, so we don't leak it.
if (m_id != -1)
{ {
ioctl(m_id, EVIOCRMFF, m_id); ioctl(m_fd, EVIOCRMFF, m_id);
} }
} }

View File

@ -52,6 +52,7 @@ private:
public: public:
std::string GetName() const override; std::string GetName() const override;
ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); } ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); }
~ForceFeedback();
void SetState(ControlState state) override; void SetState(ControlState state) override;
private: private:
const u16 m_type; const u16 m_type;