Skip to content

Commit

Permalink
grund-shell: Barebone implementation of a karm-ui host.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Dec 27, 2024
1 parent d91b68c commit 4e75ffd
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 125 deletions.
8 changes: 8 additions & 0 deletions src/libs/karm-app/inputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ struct MouseEvent {
MouseButton buttons{};
KeyMod mods{};
MouseButton button{};

bool pressed(MouseButton button) const {
return (bool)(buttons & button);
}

bool released(MouseButton button) const {
return not pressed(button);
}
};

struct MouseLeaveEvent {
Expand Down
17 changes: 17 additions & 0 deletions src/libs/karm-gfx/cpu/surface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "../buffer.h"

namespace Karm::Gfx {

struct CpuSurface {
virtual ~CpuSurface() = default;

virtual Math::Recti bound() {
return mutPixels().bound();
}

virtual MutPixels mutPixels() = 0;
};

} // namespace Karm::Gfx
2 changes: 1 addition & 1 deletion src/libs/karm-sys/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct Rpc : Meta::Pinned {

Rpc(Sys::IpcConnection con)
: _con(std::move(con)) {
// FIXME: Fid a way to do proper cleanup
// FIXME: Find a way to do proper cleanup
Async::detach(_receiverTask(*this), [](Res<> res) {
logError("receiver task exited: {}", res);
panic("receiver task exited");
Expand Down
8 changes: 7 additions & 1 deletion src/srvs/grund-device/ps2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,17 @@ Res<> Mouse::decode() {
if (_buf[0] & 0x20)
offy -= 0x100;

App::MouseButton buttons = App::MouseButton::NONE;

buttons |= ((_buf[0] >> 0) & 1) ? App::MouseButton::LEFT : App::MouseButton::NONE;
buttons |= ((_buf[0] >> 1) & 1) ? App::MouseButton::RIGHT : App::MouseButton::NONE;
buttons |= ((_buf[0] >> 2) & 1) ? App::MouseButton::MIDDLE : App::MouseButton::NONE;

int scroll = 0;
if (_hasWheel)
scroll = (i8)_buf[3];

auto event = App::makeEvent<App::MouseEvent>(App::MouseEvent::MOVE, 0, scroll, Math::Vec2i{offx, -offy});
auto event = App::makeEvent<App::MouseEvent>(App::MouseEvent::MOVE, 0, scroll, Math::Vec2i{offx, -offy}, buttons);
logInfo("ps2: mouse move {} {} {}", offx, offy, scroll);
try$(bubble(*event));

Expand Down
36 changes: 0 additions & 36 deletions src/srvs/grund-shell/host.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions src/srvs/grund-shell/host.h

This file was deleted.

Loading

0 comments on commit 4e75ffd

Please sign in to comment.