mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	input: use button mapping from configuration
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									567b81ea10
								
							
						
					
					
						commit
						5a93aa3a78
					
				
					 1 changed files with 22 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -11,8 +11,6 @@
 | 
			
		|||
#include "input/cursor.h"
 | 
			
		||||
#include "input/drawing_tablet.h"
 | 
			
		||||
 | 
			
		||||
#include "config/rcxml.h"
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
handle_axis(struct wl_listener *listener, void *data)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -33,14 +31,33 @@ handle_axis(struct wl_listener *listener, void *data)
 | 
			
		|||
	// Ignore other events
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t
 | 
			
		||||
get_mapped_button(uint32_t src_button)
 | 
			
		||||
{
 | 
			
		||||
	struct button_map_entry *map_entry;
 | 
			
		||||
	for (size_t i = 0; i < rc.tablet.button_map_count; i++) {
 | 
			
		||||
		map_entry = &rc.tablet.button_map[i];
 | 
			
		||||
		if (map_entry->from == src_button) {
 | 
			
		||||
			return map_entry->to;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	wlr_log(WLR_DEBUG, "no button map target for 0x%x", src_button);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
handle_tip(struct wl_listener *listener, void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct wlr_tablet_tool_tip_event *ev = data;
 | 
			
		||||
	struct drawing_tablet *tablet = ev->tablet->data;
 | 
			
		||||
 | 
			
		||||
	uint32_t button = get_mapped_button(BTN_TOOL_PEN);
 | 
			
		||||
	if (!button) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cursor_emulate_button(tablet->seat,
 | 
			
		||||
		BTN_LEFT,
 | 
			
		||||
		button,
 | 
			
		||||
		ev->state == WLR_TABLET_TOOL_TIP_DOWN
 | 
			
		||||
			? WLR_BUTTON_PRESSED
 | 
			
		||||
			: WLR_BUTTON_RELEASED,
 | 
			
		||||
| 
						 | 
				
			
			@ -53,16 +70,8 @@ handle_button(struct wl_listener *listener, void *data)
 | 
			
		|||
	struct wlr_tablet_tool_button_event *ev = data;
 | 
			
		||||
	struct drawing_tablet *tablet = ev->tablet->data;
 | 
			
		||||
 | 
			
		||||
	uint32_t button;
 | 
			
		||||
	switch (ev->button) {
 | 
			
		||||
	case BTN_STYLUS:
 | 
			
		||||
		button = BTN_RIGHT;
 | 
			
		||||
		break;
 | 
			
		||||
	case BTN_STYLUS2:
 | 
			
		||||
		button = BTN_MIDDLE;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		wlr_log(WLR_DEBUG, "no button map target");
 | 
			
		||||
	uint32_t button = get_mapped_button(ev->button);
 | 
			
		||||
	if (!button) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue