Compare commits

...

2 Commits

Author SHA1 Message Date
Bananymous d4903caafa Kernel: Combine consecutive mouse move and scroll events
This makes mouse work much smoother when running without kvm.
2024-06-11 00:07:31 +03:00
Bananymous caa0111c79 BAN: Implement back() for CircularQueue 2024-06-11 00:05:11 +03:00
2 changed files with 33 additions and 0 deletions

View File

@ -31,6 +31,9 @@ namespace BAN
const T& front() const;
T& front();
const T& back() const;
T& back();
size_type size() const { return m_size; }
bool empty() const { return size() == 0; }
bool full() const { return size() == capacity(); }
@ -98,6 +101,20 @@ namespace BAN
return *element_at(m_first);
}
template<typename T, size_t S>
const T& CircularQueue<T, S>::back() const
{
ASSERT(!empty());
return *element_at((m_first + m_size - 1) % capacity());
}
template<typename T, size_t S>
T& CircularQueue<T, S>::back()
{
ASSERT(!empty());
return *element_at((m_first + m_size - 1) % capacity());
}
template<typename T, size_t S>
const T* CircularQueue<T, S>::element_at(size_type index) const
{

View File

@ -165,6 +165,22 @@ namespace Kernel::Input
for (int i = 0; i < event_count; i++)
{
if (!m_event_queue.empty() && m_event_queue.back().type == events[i].type)
{
if (events[i].type == MouseEventType::MouseMoveEvent)
{
m_event_queue.back().move_event.rel_x += events[i].move_event.rel_x;
m_event_queue.back().move_event.rel_y += events[i].move_event.rel_y;
continue;
}
if (events[i].type == MouseEventType::MouseScrollEvent)
{
m_event_queue.back().scroll_event.scroll += events[i].scroll_event.scroll;
continue;
}
}
if (m_event_queue.full())
{
dwarnln("PS/2 event queue full");