From 8e1c9a736b381f95b4f6ec04aabf830d1e257855 Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Mon, 24 Feb 2003 16:29:10 +0000 Subject: [PATCH] Added funcs to get joystick values Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@690 --- include/joystick.h | 7 +++++++ src/hardware/joystick.cpp | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/joystick.h b/include/joystick.h index aec0b477..6c14091c 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -24,3 +24,10 @@ void JOYSTICK_Move_X(Bitu which,float x); void JOYSTICK_Move_Y(Bitu which,float y); +bool JOYSTICK_IsEnabled(Bitu which); + +bool JOYSTICK_GetButton(Bitu which, Bitu num); + +float JOYSTICK_GetMove_X(Bitu which); + +float JOYSTICK_GetMove_Y(Bitu which); diff --git a/src/hardware/joystick.cpp b/src/hardware/joystick.cpp index f99aea0b..23536ff0 100644 --- a/src/hardware/joystick.cpp +++ b/src/hardware/joystick.cpp @@ -90,6 +90,29 @@ void JOYSTICK_Move_Y(Bitu which,float y) { } } +bool JOYSTICK_IsEnabled(Bitu which) +{ + if (which<2) return stick[which].enabled; + return false; +}; + +bool JOYSTICK_GetButton(Bitu which, Bitu num) +{ + if ((which<2) && (num<2)) return stick[which].button[num]; + return false; +} + +float JOYSTICK_GetMove_X(Bitu which) +{ + if (which<2) return stick[which].xpos; + return 0.0f; +} + +float JOYSTICK_GetMove_Y(Bitu which) +{ + if (which<2) return stick[which].ypos; + return 0.0f; +}; void JOYSTICK_Init(Section* sec) { IO_RegisterReadHandler(0x201,read_p201,"JOYSTICK");