1 // Copyright (c) 2012- PPSSPP Project. 2 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, version 2.0 or later versions. 6 7 // This program is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 // GNU General Public License 2.0 for more details. 11 12 // A copy of the GPL 2.0 should have been included with the program. 13 // If not, see http://www.gnu.org/licenses/ 14 15 // Official git repository and contact information can be found at 16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. 17 18 #pragma once 19 20 #include "Common/CommonTypes.h" 21 22 class PointerWrap; 23 24 void Register_sceCtrl(); 25 26 const int CTRL_STICK_LEFT = 0; 27 // The actual PSP only has one, but HD remasters expose this, maybe also the emulator on the PSP/Vita. 28 const int CTRL_STICK_RIGHT = 1; 29 30 #define CTRL_SQUARE 0x8000 31 #define CTRL_TRIANGLE 0x1000 32 #define CTRL_CIRCLE 0x2000 33 #define CTRL_CROSS 0x4000 34 #define CTRL_UP 0x0010 35 #define CTRL_DOWN 0x0040 36 #define CTRL_LEFT 0x0080 37 #define CTRL_RIGHT 0x0020 38 #define CTRL_START 0x0008 39 #define CTRL_SELECT 0x0001 40 #define CTRL_LTRIGGER 0x0100 41 #define CTRL_RTRIGGER 0x0200 42 43 // System-ish buttons. Not generally used by games. 44 #define CTRL_HOME 0x00010000 45 #define CTRL_HOLD 0x00020000 46 #define CTRL_WLAN 0x00040000 47 #define CTRL_REMOTE_HOLD 0x00080000 48 #define CTRL_VOL_UP 0x00100000 49 #define CTRL_VOL_DOWN 0x00200000 50 #define CTRL_SCREEN 0x00400000 51 #define CTRL_NOTE 0x00800000 52 #define CTRL_DISC 0x01000000 53 #define CTRL_MEMSTICK 0x02000000 54 #define CTRL_FORWARD 0x10000000 55 #define CTRL_BACK 0x20000000 56 #define CTRL_PLAYPAUSE 0x40000000 57 58 #define CTRL_MASK_DPAD (CTRL_UP | CTRL_DOWN | CTRL_LEFT | CTRL_RIGHT) 59 #define CTRL_MASK_ACTION (CTRL_SQUARE | CTRL_TRIANGLE | CTRL_CIRCLE | CTRL_CROSS) 60 #define CTRL_MASK_TRIGGER (CTRL_LTRIGGER | CTRL_RTRIGGER) 61 #define CTRL_MASK_USER (CTRL_MASK_DPAD | CTRL_MASK_ACTION | CTRL_START | CTRL_SELECT | CTRL_MASK_TRIGGER | CTRL_HOME | CTRL_HOLD | CTRL_WLAN | CTRL_REMOTE_HOLD | CTRL_VOL_UP | CTRL_VOL_DOWN | CTRL_SCREEN | CTRL_NOTE) 62 63 void __CtrlInit(); 64 void __CtrlDoState(PointerWrap &p); 65 void __CtrlShutdown(); 66 67 // Call this whenever a button is pressed, using the above CTRL_ constants. 68 // Multiple buttons may be sent in one call OR'd together. 69 // Resending a currently pressed button is fine but not required. 70 void __CtrlButtonDown(u32 buttonBit); 71 // Call this whenever a button is released. Similar to __CtrlButtonDown(). 72 void __CtrlButtonUp(u32 buttonBit); 73 74 // Call this to set the position of an analog stick, ideally when it changes. 75 // X and Y values should be from -1 to 1, inclusive, in a square (no need to force to a circle.) 76 // No deadzone filtering is done (but note that this applies to the actual PSP as well.) 77 void __CtrlSetAnalogXY(int stick, float x, float y); 78 79 // Call this to enable rapid-fire. This will cause buttons other than arrows to alternate. 80 void __CtrlSetRapidFire(bool state); 81 bool __CtrlGetRapidFire(); 82 83 // For use by internal UI like MsgDialog 84 u32 __CtrlPeekButtons(); 85 void __CtrlPeekAnalog(int stick, float *x, float *y); 86 u32 __CtrlReadLatch(); 87 88 void Register_sceCtrl_driver(); 89 90 u16 sceCtrlGetRightVibration(); 91 u16 sceCtrlGetLeftVibration(); 92 93 namespace SceCtrl { 94 void SetLeftVibration(u16 lVibration); 95 void SetRightVibration(u16 rVibration); 96 void SetVibrationLeftDropout(u8 vibrationLDropout); 97 void SetVibrationRightDropout(u8 vibrationRDropout); 98 }; 99