-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmouse.go
71 lines (61 loc) · 2.06 KB
/
mouse.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2012-2014 by krepa098. All rights reserved.
// Use of this source code is governed by a zlib-style
// license that can be found in the license.txt file.
package gosfml2
// #include <SFML/Window/Mouse.h>
// #include <SFML/Window/Window.h>
// #include <SFML/Graphics/RenderWindow.h>
import "C"
/////////////////////////////////////
/// CONSTS
/////////////////////////////////////
const (
MouseLeft = iota ///< The left mouse button
MouseRight ///< The right mouse button
MouseMiddle ///< The middle (wheel) mouse button
MouseXButton1 ///< The first extra mouse button
MouseXButton2 ///< The second extra mouse button
MouseButtonCount ///< Keep last -- the total number of mouse buttons
)
type MouseButton int
/////////////////////////////////////
/// FUNCTIONS
/////////////////////////////////////
// Check if a mouse button is pressed
//
// button: Button to check
func IsMouseButtonPressed(button MouseButton) bool {
return sfBool2Go(C.sfMouse_isButtonPressed(C.sfMouseButton(button)))
}
// Set the current position of the mouse
//
// This function sets the current position of the mouse
// cursor relative to the given window, or desktop if nil is passed.
//
// position: New position of the mouse
// relativeTo: Reference window
func MouseSetPosition(position Vector2i, relativeTo SystemWindow) {
switch relativeTo.(type) {
case *RenderWindow:
C.sfMouse_setPositionRenderWindow(position.toC(), relativeTo.(*RenderWindow).cptr)
case *Window:
C.sfMouse_setPosition(position.toC(), relativeTo.(*Window).cptr)
default:
}
}
// Get the current position of the mouse
//
// This function returns the current position of the mouse
// cursor relative to the given window, or desktop if nil is passed.
//
// relativeTo: Reference window
func MouseGetPosition(relativeTo SystemWindow) (pos Vector2i) {
switch relativeTo.(type) {
case *RenderWindow:
pos.fromC(C.sfMouse_getPositionRenderWindow(relativeTo.(*RenderWindow).cptr))
case *Window:
pos.fromC(C.sfMouse_getPosition(relativeTo.(*Window).cptr))
default:
}
return
}