pad.h

00001 /*    
00002         This file is part of ps2padlib.
00003 
00004         Copyright 2003, Alex Mole
00005 
00006     ps2padlib is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     ps2padlib is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with ps2padlib; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 #ifndef __PAD_H_INCLUDED__
00022 #define __PAD_H_INCLUDED__
00023 
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #include <linux/ps2/pad.h>
00030         
00031 
00032 //bitmasks for digital button presses   
00033 #define PAD_SELECT      (1 << 0)
00034 #define PAD_L3          (1 << 1)
00035 #define PAD_R3          (1 << 2)
00036 #define PAD_START       (1 << 3)
00037 #define PAD_UP          (1 << 4)
00038 #define PAD_RIGHT       (1 << 5)
00039 #define PAD_DOWN        (1 << 6)
00040 #define PAD_LEFT        (1 << 7)
00041 #define PAD_L2          (1 << 8)
00042 #define PAD_R2          (1 << 9)
00043 #define PAD_L1          (1 << 10)
00044 #define PAD_R1          (1 << 11)
00045 #define PAD_TRI         (1 << 12)
00046 #define PAD_CIRCLE      (1 << 13)
00047 #define PAD_CROSS       (1 << 14)
00048 #define PAD_SQUARE      (1 << 15)
00049 
00050 //indices into axes     
00051 #define PAD_AXIS_LX     0
00052 #define PAD_AXIS_LY     1
00053 #define PAD_AXIS_RX     2
00054 #define PAD_AXIS_RY     3
00055         
00056 //indices into pressures
00057 #define PAD_PLEFT       0
00058 #define PAD_PRIGHT      1
00059 #define PAD_PUP         2
00060 #define PAD_PDOWN       3
00061 #define PAD_PTRI        4
00062 #define PAD_PCIRCLE     5
00063 #define PAD_PCROSS      6
00064 #define PAD_PSQUARE     7
00065 #define PAD_PL1         8
00066 #define PAD_PR1         9
00067 #define PAD_PL2         10
00068 #define PAD_PR2         11
00069         
00070 //use these with the pad_* functions
00071 #define PAD_0           1
00072 #define PAD_1           2
00073 
00074 //pad init flags        
00075 #define PAD_INIT_DIGITAL        0x00    //select digital mode (default)
00076 #define PAD_INIT_ANALOGUE       0x01    //select analogue mode
00077 #define PAD_INIT_UNLOCK         0x00    //do not lock the pad mode
00078 #define PAD_INIT_LOCK           0x02    //lock the pad mode
00079 #define PAD_INIT_PRESSURE       0x04    //enable button pressure sensing
00080         
00081 
00082 //the structure used to describe the state of a pad     
00083 typedef struct
00084 {
00085         int initflags;                  //flags used to initialise the pad state
00086         int actuator;                   //=1 if actuator supported otherwise 0
00087         int buttons;                    //a bitfield describing which buttons are
00088                                                         //currently pressed
00089         
00090         float axes[4];                  //these values are mapped from -1 -> +1 
00091         float pressures[12];    //these values are mapped from 0 -> 1
00092 
00093         //state change info
00094         int pressed;                    //like buttons, but contains buttons 
00095                                                         //pressed since the last update
00096         int released;                   //like buttons, but contains buttons
00097                                                         //released since the last update
00098 } padinfo_t;
00099 
00100 
00101 //pad info for both pads
00102 extern padinfo_t pad[2];
00103 
00104 
00105 //pads should be PAD_0 and/or PAD_1, or'd together
00106 //pad_init returns zero on failure
00107 //actuator_supported returns 1 if supported otherwise 0
00108 int pad_init (int pads, int initflags);
00109 void pad_update (int pads);
00110 void pad_cleanup (int pads);
00111 //int actuator_supported (int padnum);
00112 void enable_actuator(int padnum, int enable_small, int enable_big);
00113 void set_actuator(int padnum, unsigned char small_intensity, unsigned char big_intensity);
00114 
00115 
00116 #ifdef __cplusplus
00117 };
00118 #endif
00119 
00120 #endif
00121 

Generated on Sun May 18 21:45:08 2008 for PS2X by  doxygen 1.5.4