Mercurial > hg > Members > kono > Cerium
diff TaskManager/Test/test_render/Joystick.cpp @ 191:5e3b0405a44b
fix Joystick Button
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 12 Jan 2009 10:32:25 +0900 |
parents | 861271089c43 |
children | d61fded0729e |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Joystick.cpp Thu Jan 08 19:07:52 2009 +0900 +++ b/TaskManager/Test/test_render/Joystick.cpp Mon Jan 12 10:32:25 2009 +0900 @@ -1,6 +1,28 @@ #include <SDL.h> #include "Joystick.h" +/** + * PS3 コントローラの配置 + */ +static const int SELECT = 0; +static const int L3 = 1; +static const int R3 = 2; +static const int START = 3; +static const int UP = 4; +static const int RIGHT = 5; +static const int DOWN = 6; +static const int LEFT = 7; +static const int L2 = 8; +static const int R2 = 9; +static const int L1 = 10; +static const int R1 = 11; +static const int TRIANGLE = 12; +static const int CIRCLE = 13; +static const int CROSS = 14; +static const int SQUARE = 15; +static const int PS = 16; + +#if 0 static const int CROSS = 0; static const int CIRCLE = 1; static const int SQUARE = 2; @@ -19,6 +41,7 @@ static const int LEFT = 15; static const int ESCAPE = 16; static const int SPACE = 17; +#endif Joystick::Joystick(SDL_Joystick *j) { @@ -102,6 +125,28 @@ r3.release_work(); } + if (SDL_JoystickGetButton(joy,UP)==SDL_PRESSED) { + up.push_work(); + } else { + up.release_work(); + } + + if (SDL_JoystickGetButton(joy,DOWN)==SDL_PRESSED) { + down.push_work(); + } else { + down.release_work(); + } + if (SDL_JoystickGetButton(joy,RIGHT)==SDL_PRESSED) { + right.push_work(); + } else { + right.release_work(); + } + if (SDL_JoystickGetButton(joy,LEFT)==SDL_PRESSED) { + left.push_work(); + } else { + left.release_work(); + } + axis = SDL_JoystickGetAxis(joy,0); if (axis >= 3200) { left.release_work();