Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pirvi-public
glfw
Commits
3c901103
Commit
3c901103
authored
Feb 13, 2018
by
Camilla Löwy
Browse files
Cleanup
parent
2040309d
Changes
2
Show whitespace changes
Inline
Side-by-side
src/input.c
View file @
3c901103
...
...
@@ -62,11 +62,11 @@ static _GLFWmapping* findMapping(const char* guid)
static
GLFWbool
isValidElementForJoystick
(
const
_GLFWmapelement
*
e
,
const
_GLFWjoystick
*
js
)
{
if
(
e
->
type
==
_GLFW_JOYSTICK_HATBIT
&&
(
e
->
value
>>
4
)
>=
js
->
hatCount
)
if
(
e
->
type
==
_GLFW_JOYSTICK_HATBIT
&&
(
e
->
index
>>
4
)
>=
js
->
hatCount
)
return
GLFW_FALSE
;
else
if
(
e
->
type
==
_GLFW_JOYSTICK_BUTTON
&&
e
->
value
>=
js
->
buttonCount
)
else
if
(
e
->
type
==
_GLFW_JOYSTICK_BUTTON
&&
e
->
index
>=
js
->
buttonCount
)
return
GLFW_FALSE
;
else
if
(
e
->
type
==
_GLFW_JOYSTICK_AXIS
&&
e
->
value
>=
js
->
axisCount
)
else
if
(
e
->
type
==
_GLFW_JOYSTICK_AXIS
&&
e
->
index
>=
js
->
axisCount
)
return
GLFW_FALSE
;
return
GLFW_TRUE
;
...
...
@@ -209,10 +209,10 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
{
const
unsigned
long
hat
=
strtoul
(
c
+
1
,
(
char
**
)
&
c
,
10
);
const
unsigned
long
bit
=
strtoul
(
c
+
1
,
(
char
**
)
&
c
,
10
);
e
->
value
=
(
uint8_t
)
((
hat
<<
4
)
|
bit
);
e
->
index
=
(
uint8_t
)
((
hat
<<
4
)
|
bit
);
}
else
e
->
value
=
(
uint8_t
)
strtoul
(
c
+
1
,
(
char
**
)
&
c
,
10
);
e
->
index
=
(
uint8_t
)
strtoul
(
c
+
1
,
(
char
**
)
&
c
,
10
);
if
(
e
->
type
==
_GLFW_JOYSTICK_AXIS
)
{
...
...
@@ -1222,19 +1222,19 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
const
_GLFWmapelement
*
e
=
js
->
mapping
->
buttons
+
i
;
if
(
e
->
type
==
_GLFW_JOYSTICK_AXIS
)
{
const
float
value
=
js
->
axes
[
e
->
value
]
*
e
->
axisScale
+
e
->
axisOffset
;
const
float
value
=
js
->
axes
[
e
->
index
]
*
e
->
axisScale
+
e
->
axisOffset
;
if
(
value
>
0
.
f
)
state
->
buttons
[
i
]
=
GLFW_PRESS
;
}
else
if
(
e
->
type
==
_GLFW_JOYSTICK_HATBIT
)
{
const
unsigned
int
hat
=
e
->
value
>>
4
;
const
unsigned
int
bit
=
e
->
value
&
0xf
;
const
unsigned
int
hat
=
e
->
index
>>
4
;
const
unsigned
int
bit
=
e
->
index
&
0xf
;
if
(
js
->
hats
[
hat
]
&
bit
)
state
->
buttons
[
i
]
=
GLFW_PRESS
;
}
else
if
(
e
->
type
==
_GLFW_JOYSTICK_BUTTON
)
state
->
buttons
[
i
]
=
js
->
buttons
[
e
->
value
];
state
->
buttons
[
i
]
=
js
->
buttons
[
e
->
index
];
}
for
(
i
=
0
;
i
<=
GLFW_GAMEPAD_AXIS_LAST
;
i
++
)
...
...
@@ -1242,18 +1242,18 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
const
_GLFWmapelement
*
e
=
js
->
mapping
->
axes
+
i
;
if
(
e
->
type
==
_GLFW_JOYSTICK_AXIS
)
{
const
float
value
=
js
->
axes
[
e
->
value
]
*
e
->
axisScale
+
e
->
axisOffset
;
const
float
value
=
js
->
axes
[
e
->
index
]
*
e
->
axisScale
+
e
->
axisOffset
;
state
->
axes
[
i
]
=
fminf
(
fmaxf
(
value
,
-
1
.
f
),
1
.
f
);
}
else
if
(
e
->
type
==
_GLFW_JOYSTICK_HATBIT
)
{
const
unsigned
int
hat
=
e
->
value
>>
4
;
const
unsigned
int
bit
=
e
->
value
&
0xf
;
const
unsigned
int
hat
=
e
->
index
>>
4
;
const
unsigned
int
bit
=
e
->
index
&
0xf
;
if
(
js
->
hats
[
hat
]
&
bit
)
state
->
axes
[
i
]
=
1
.
f
;
}
else
if
(
e
->
type
==
_GLFW_JOYSTICK_BUTTON
)
state
->
axes
[
i
]
=
(
float
)
js
->
buttons
[
e
->
value
];
state
->
axes
[
i
]
=
(
float
)
js
->
buttons
[
e
->
index
];
}
return
GLFW_TRUE
;
...
...
src/internal.h
View file @
3c901103
...
...
@@ -456,7 +456,7 @@ struct _GLFWcursor
struct
_GLFWmapelement
{
uint8_t
type
;
uint8_t
value
;
uint8_t
index
;
int8_t
axisScale
;
int8_t
axisOffset
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment