00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "LampBasic.h"
00026 #include "Input/Joystick/Joystick.h"
00027
00028 namespace Lamp{
00029
00030
00031
00032 Joystick::Joystick(JoystickDevice* device) : device_(device){
00033 }
00034
00035
00036 Joystick::~Joystick(){
00037 }
00038
00039
00040 void Joystick::setNextState(const JoystickState& state){
00041 preState_ = state_;
00042 state_ = state;
00043 }
00044
00045
00046 String Joystick::toString() const{
00047 String result, temp;
00048 result = getName();
00049 result += " (";
00050 if(isAttached()){ result += " Attached"; }
00051 if(isPolled()){ result += " NeedPolling"; }
00052 result += " )\n";
00053
00054 temp.format("Axes %d ( Slider %d )\n", getAxisCount(), getSliderCount());
00055 result += temp;
00056 if(hasXAxis()){
00057 temp.format(" XAxis %.3f\n", getXAxis());
00058 result += temp;
00059 }
00060 if(hasYAxis()){
00061 temp.format(" YAxis %.3f\n", getYAxis());
00062 result += temp;
00063 }
00064 if(hasZAxis()){
00065 temp.format(" ZAxis %.3f\n", getZAxis());
00066 result += temp;
00067 }
00068 if(hasXRotation()){
00069 temp.format(" XRotation %.3f\n", getXRotation());
00070 result += temp;
00071 }
00072 if(hasYRotation()){
00073 temp.format(" YRotation %.3f\n", getYRotation());
00074 result += temp;
00075 }
00076 if(hasZRotation()){
00077 temp.format(" ZRotation %.3f\n", getZRotation());
00078 result += temp;
00079 }
00080 int sliderCount = getSliderCount();
00081 for(int i = 0; i < sliderCount; i++){
00082 temp.format(" Slider%d %.3f\n", i, getSlider(i));
00083 result += temp;
00084 }
00085
00086
00087 int povCount = getPOVCount();
00088 temp.format("POVs %d", povCount);
00089 result += temp;
00090 if(povCount != 0){
00091 result += " (";
00092 for(int i = 0; i < povCount; i++){
00093 if(isPOVCenter(i)){
00094 result += " C";
00095 }else{
00096 temp.format(" %5d", getPOV(i));
00097 result += temp;
00098 }
00099 }
00100 result += " )";
00101 }
00102 result += "\n";
00103
00104
00105 int buttonCount = getButtonCount();
00106 temp.format("Buttons %d\n", getButtonCount());
00107 result += temp;
00108 result += " Press";
00109 for(int i = 0; i < buttonCount; i++){
00110 if(buttonPressed(i)){ result += " O"; }
00111 else{ result += " X"; }
00112 }
00113 result += "\n";
00114 result += " Down ";
00115 for(int i = 0; i < buttonCount; i++){
00116 if(buttonDown(i)){ result += " O"; }
00117 else{ result += " X"; }
00118 }
00119 result += "\n";
00120 result += " Up ";
00121 for(int i = 0; i < buttonCount; i++){
00122 if(buttonUp(i)){ result += " O"; }
00123 else{ result += " X"; }
00124 }
00125 result += "\n";
00126 return result;
00127 }
00128
00129
00130 }
00131