[mednaffe] 74/99: Add deadzones for analog axis
Stephen Kitt
skitt at moszumanska.debian.org
Tue Aug 2 21:00:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
skitt pushed a commit to branch master
in repository mednaffe.
commit ab1bbc646a0b6191624bbbd7a985894d9f879f18
Author: AmatCoder <amatcoder at gmail.com>
Date: Sat Jul 18 15:17:06 2015 +0200
Add deadzones for analog axis
---
src/input.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/input.c b/src/input.c
index c4bac7e..61ec629 100644
--- a/src/input.c
+++ b/src/input.c
@@ -39,6 +39,8 @@
static GMutex mutex;
#endif
+#define DEADZONE 16384
+
void close_channels(guidata *gui)
{
#ifdef G_OS_UNIX
@@ -167,7 +169,9 @@ gboolean joy_watch( GIOChannel *channel, GIOCondition cond, guidata *gui)
if (gui->inputedited == TRUE)
return TRUE;
- if ((e.type == JS_EVENT_BUTTON) || (e.type == JS_EVENT_AXIS))
+ if ((e.type == JS_EVENT_BUTTON) ||
+ ((e.type == JS_EVENT_AXIS) &&
+ ((e.value < -DEADZONE) || (e.value > DEADZONE))))
{
GtkTreeIter iter;
gchar *command;
@@ -466,10 +470,10 @@ DWORD WINAPI joy_thread(LPVOID lpParam)
//printf("Unhandled Event: %i\n", event.type);
if ((event.type == SDL_JOYBUTTONDOWN) ||
- (event.type == SDL_JOYAXISMOTION) ||
- (event.type == SDL_JOYHATMOTION))
+ (event.type == SDL_JOYHATMOTION) ||
+ ((event.type == SDL_JOYAXISMOTION) &&
+ ((event.jaxis.value < -DEADZONE) || (event.jaxis.value > DEADZONE))))
{
-
unsigned int b;
int a;
@@ -531,8 +535,9 @@ DWORD WINAPI joy_thread(LPVOID lpParam)
}
}
else
- if (event.type == SDL_JOYAXISMOTION) {
- a = GetControllerIndex(event.jaxis.which, gui);
+ if (event.type == SDL_JOYAXISMOTION)
+ {
+ a = GetControllerIndex(event.jaxis.which, gui);
if (a>-1)
{
printf("Value: %i\n", event.jaxis.value);
@@ -541,7 +546,7 @@ DWORD WINAPI joy_thread(LPVOID lpParam)
{
if (gui->joy[a].xinput==TRUE)
{
- if (event.jaxis.value>0) on = g_strdup_printf("Axis %i Up", event.jaxis.axis);
+ if (event.jaxis.value<0) on = g_strdup_printf("Axis %i Up", event.jaxis.axis);
else on = g_strdup_printf("Axis %i Down", event.jaxis.axis);
if (event.jaxis.axis==5)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mednaffe.git
More information about the Pkg-games-commits
mailing list