Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "joystick.h"
- JoyStick::Joystick(void)
- {
- for(int i=0; i<8; i++) keys[i] = 0;
- gamepad_x = gamepad_y = gamepad_z = gamepad_r = gamepad_u = gamepad_v = 0;
- }
- void JoyStick::OnDownKey(const int key)
- {
- keys[key] = 1;
- }
- void JoyStick::OnUpKey(const int key)
- {
- keys[key] = 3;
- }
- bool JoyStick::OnKeyDown(const int key)
- {
- return (keys[key] == 1);
- }
- bool JoyStick::OnKeyUp(const int key)
- {
- return (keys[key] == 3);
- }
- bool JoyStick::OnKeyPressed(const int key)
- {
- return ((keys[key] == 1) || (keys[key] == 2));
- }
- void JoyStick::flush(void)
- {
- for(int i=0; i<8; i++)
- {
- if(keys[i] == 1) keys[i] = 2;
- else if(keys[i] == 3) keys[i] = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement