package game import ( "sync" "gitea.boner.be/bdnugget/goonscape/game/mock" rl "github.com/gen2brain/raylib-go/raylib" ) var ( mockInput struct { sync.Mutex keyPressed map[int32]bool keyDown map[int32]bool mousePressed map[int32]bool mousePosition rl.Vector2 mouseRay rl.Ray mouseWheel float32 charPressed rune } ) func init() { resetMockInput() setupMockFunctions() } func setupMockFunctions() { mock.IsKeyPressed = mockIsKeyPressed mock.IsKeyDown = mockIsKeyDown mock.IsMouseButtonPressed = mockIsMouseButtonPressed mock.GetMousePosition = mockGetMousePosition mock.GetMouseRay = mockGetMouseRay mock.GetMouseWheelMove = mockGetMouseWheelMove mock.GetCharPressed = mockGetCharPressed } func resetMockInput() { mockInput.Lock() defer mockInput.Unlock() mockInput.keyPressed = make(map[int32]bool) mockInput.keyDown = make(map[int32]bool) mockInput.mousePressed = make(map[int32]bool) mockInput.mousePosition = rl.Vector2{} mockInput.mouseRay = rl.Ray{} mockInput.mouseWheel = 0 mockInput.charPressed = 0 } // Mock input simulation functions func simulateKeyPress(key int32) { mockInput.Lock() mockInput.keyPressed[key] = true mockInput.Unlock() } func simulateKeyDown(key int32, isDown bool) { mockInput.Lock() mockInput.keyDown[key] = isDown mockInput.Unlock() } func simulateMouseButton(button int32, isPressed bool) { mockInput.Lock() mockInput.mousePressed[button] = isPressed mockInput.Unlock() } func simulateMousePosition(x, y float32) { mockInput.Lock() mockInput.mousePosition = rl.Vector2{X: x, Y: y} mockInput.Unlock() } func simulateMouseRay(ray rl.Ray) { mockInput.Lock() mockInput.mouseRay = ray mockInput.Unlock() } func simulateMouseWheel(move float32) { mockInput.Lock() mockInput.mouseWheel = move mockInput.Unlock() } func simulateCharInput(char rune) { mockInput.Lock() mockInput.charPressed = char mockInput.Unlock() } // Mock raylib functions func mockIsKeyPressed(key int32) bool { mockInput.Lock() defer mockInput.Unlock() return mockInput.keyPressed[key] } func mockIsKeyDown(key int32) bool { mockInput.Lock() defer mockInput.Unlock() return mockInput.keyDown[key] } func mockIsMouseButtonPressed(button int32) bool { mockInput.Lock() defer mockInput.Unlock() return mockInput.mousePressed[button] } func mockGetMousePosition() rl.Vector2 { mockInput.Lock() defer mockInput.Unlock() return mockInput.mousePosition } func mockGetMouseRay(mousePos rl.Vector2, camera rl.Camera3D) rl.Ray { mockInput.Lock() defer mockInput.Unlock() return mockInput.mouseRay } func mockGetMouseWheelMove() float32 { mockInput.Lock() defer mockInput.Unlock() return mockInput.mouseWheel } func mockGetCharPressed() rune { mockInput.Lock() defer mockInput.Unlock() return mockInput.charPressed } // Add more mock implementations... // Add this helper function func toInt32(button rl.MouseButton) int32 { return int32(button) }