Skip to main content
Glama
scroll.go1.75 kB
package control import ( "log" ) // ScrollHandler handles scroll control events type ScrollHandler struct { controlService *ControlService } // NewScrollHandler creates a new scroll handler func NewScrollHandler(controlService *ControlService) *ScrollHandler { return &ScrollHandler{ controlService: controlService, } } // ProcessScrollEvent processes a scroll event func (h *ScrollHandler) ProcessScrollEvent(msg map[string]interface{}, deviceSerial string) error { x, _ := msg["x"].(float64) y, _ := msg["y"].(float64) hScroll, _ := msg["hScroll"].(float64) vScroll, _ := msg["vScroll"].(float64) log.Printf("[DEBUG] Scroll event: device=%s, x=%.3f, y=%.3f, hScroll=%.2f, vScroll=%.2f", deviceSerial, x, y, hScroll, vScroll) // TODO: Implement scroll event processing logic // This could include: // - Scroll amount validation // - Coordinate transformation // - Event queuing // - Bridge communication return nil } // ValidateScrollEvent validates scroll event data func (h *ScrollHandler) ValidateScrollEvent(msg map[string]interface{}) error { // Validate required fields if _, ok := msg["x"].(float64); !ok { return ErrMissingX } if _, ok := msg["y"].(float64); !ok { return ErrMissingY } if _, ok := msg["hScroll"].(float64); !ok { return ErrMissingHScroll } if _, ok := msg["vScroll"].(float64); !ok { return ErrMissingVScroll } // Validate coordinates x, _ := msg["x"].(float64) y, _ := msg["y"].(float64) if x < 0 || y < 0 { return ErrInvalidCoordinates } return nil } // Error definitions var ( ErrMissingHScroll = &ControlError{Code: "MISSING_HSCROLL", Message: "Missing hScroll field"} ErrMissingVScroll = &ControlError{Code: "MISSING_VSCROLL", Message: "Missing vScroll field"} )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/babelcloud/gru-sandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server