mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-08 04:57:32 -04:00
basic add and del mousemaps work, drag is yet to be implemented
This commit is contained in:
parent
64dccb248d
commit
9d8463255c
5 changed files with 81 additions and 112 deletions
|
|
@ -12,20 +12,19 @@ const RemoteLua = @import("../RemoteLua.zig");
|
|||
const Lua = &@import("../main.zig").lua;
|
||||
|
||||
modifier: wlr.Keyboard.ModifierMask,
|
||||
keycode: xkb.Keysym,
|
||||
event_code: i32,
|
||||
options: struct {
|
||||
/// This is the location of the on press lua function in the lua registry
|
||||
lua_press_ref_idx: i32,
|
||||
/// This is the location of the on release lua function in the lua registry
|
||||
lua_release_ref_idx: i32,
|
||||
/// THis is the location of the on drag lua function in the lua registry
|
||||
/// This is the location of the on drag lua function in the lua registry
|
||||
lua_drag_ref_idx: i32,
|
||||
},
|
||||
|
||||
pub const MousemapState = enum { press, drag, release };
|
||||
|
||||
pub fn callback(self: *const Mousemap, state: MousemapState) void {
|
||||
const lua_ref_idx = if (release) self.options.lua_release_ref_idx else self.options.lua_press_ref_idx;
|
||||
const lua_ref_idx = switch(state) {
|
||||
.press => self.options.lua_press_ref_idx,
|
||||
.release => self.options.lua_release_ref_idx,
|
||||
|
|
@ -45,8 +44,8 @@ pub fn callback(self: *const Mousemap, state: MousemapState) void {
|
|||
Lua.state.pop(-1);
|
||||
}
|
||||
|
||||
pub fn hash(modifier: wlr.Keyboard.ModifierMask, keycode: xkb.Keysym) u64 {
|
||||
pub fn hash(modifier: wlr.Keyboard.ModifierMask, event_code: i32) u64 {
|
||||
const mod_val: u32 = @bitCast(modifier);
|
||||
const key_val: u32 = @intFromEnum(keycode);
|
||||
return (@as(u64, mod_val) << 32) | @as(u64, key_val);
|
||||
const button_val: u32 = @bitCast(event_code);
|
||||
return (@as(u64, mod_val) << 32) | @as(u64, button_val);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue