コード例 #1
0
// Adjusts the report for any settings speciified by the user
void Xbox360Peripheral::fiddleReport(IOBufferMemoryDescriptor *buffer)
{
    XBOX360_IN_REPORT *report=(XBOX360_IN_REPORT*)buffer->getBytesNoCopy();
    if(invertLeftX) report->left.x=~report->left.x;
    if(!invertLeftY) report->left.y=~report->left.y;
    if(invertRightX) report->right.x=~report->right.x;
    if(!invertRightY) report->right.y=~report->right.y;
    if(deadzoneLeft!=0) {
        if(relativeLeft) {
            if((getAbsolute(report->left.x)<deadzoneLeft)&&(getAbsolute(report->left.y)<deadzoneLeft)) {
                report->left.x=0;
                report->left.y=0;
            }
        } else {
            if(getAbsolute(report->left.x)<deadzoneLeft) report->left.x=0;
            if(getAbsolute(report->left.y)<deadzoneLeft) report->left.y=0;
        }
    }
    if(deadzoneRight!=0) {
        if(relativeRight) {
            if((getAbsolute(report->right.x)<deadzoneRight)&&(getAbsolute(report->right.y)<deadzoneRight)) {
                report->right.x=0;
                report->right.y=0;
            }
        } else {
            if(getAbsolute(report->right.x)<deadzoneRight) report->right.x=0;
            if(getAbsolute(report->right.y)<deadzoneRight) report->right.y=0;
        }
    }
}
コード例 #2
0
ファイル: LuaPath.cpp プロジェクト: carlsonp/vr-jugglua
    void LuaPath::_init(std::string const &arg0,
                        std::string const &vrjlua_base) {
        _valid = true;

        _initialPath = fs::initial_path().string();
        std::vector<std::string> startingPlaces;
        startingPlaces.push_back(_initialPath);
        if (!vrjlua_base.empty()) {
            startingPlaces.push_back(getAbsolute(vrjlua_base).string());
        }

        if (!arg0.empty()) {
            _exeDir = getAbsolute(arg0).remove_filename().string();
            startingPlaces.push_back(_exeDir);
        }

        _root = _findFilePath(startingPlaces,
                              "share/vrjugglua/lua/vrjlua-init.lua");
        if (!_root.empty()) {
            _luaDir = (fs::path(_root) / "share/vrjugglua/lua/").string();
            startingPlaces.push_back(
                (fs::path(_root) / "share/vrjugglua/").string());
        } else {
            _root = _findFilePath(startingPlaces, "vrjlua-init.lua");
            _luaDir = _root;
        }
        std::string sourceTreeIndicator =
            (fs::path(_luaDir) / "vrjlua-sourcetreeloc.lua").string();
        if (fs::exists(sourceTreeIndicator)) {
            std::ifstream df(sourceTreeIndicator.c_str());
            if (df.is_open()) {
                std::string line;
                std::getline(df, line);
                boost::algorithm::trim(line);
                if (!line.empty()) {
                    VRJLUA_MSG_START(dbgVRJLUA, MSG_STATUS)
                        << "LuaPath: Presence of file " << sourceTreeIndicator
                        << " indicated we are running from a build tree, "
                           "adding extra path hint " << line
                        << VRJLUA_MSG_END(dbgVRJLUA, MSG_STATUS);
                    startingPlaces.push_back(line);
                }
            }
        }
        _shareDir = _findFilePath(startingPlaces,
                                  "assets/fonts/droid-fonts/DroidSans.ttf");
        _jugglerRoot = _findJuggler();
        _setJugglerEnvironment();
    }
コード例 #3
0
ファイル: ofApp.cpp プロジェクト: danzeeeman/ofxXwax
void ofApp::audioOut(float* output, int bufferSize, int nChannels) {
	float sum = 0;
	for (int i = 0; i < bufferSize; i++){
		output[i * nChannels] = floatBuffer[bufferPosition * nChannels];
		output[i * nChannels + 1] = floatBuffer[bufferPosition * nChannels + 1];
		
		curBuffer[i * nChannels] = output[i * nChannels] * (1<<15);
		curBuffer[i * nChannels + 1] = output[i * nChannels + 1] * (1<<15);
	
		if(i % 2 == 0) { // drop 96khz to 48khz
			bufferPosition++;
			if(bufferPosition == bufferFrames) {
				bufferPosition = 0;
				relativePosition = 0;
				exportXml();
			}
		}
	}
	
	timecoder_submit(&timecoder, &curBuffer[0], bufferSize);
	relativeTtm[ttmPosition] = getRelative();
	absoluteTtm[ttmPosition] = getAbsolute();
	if(exporting) {
		wholeBuffer.push_back(absoluteTtm[ttmPosition] );
	}
	pitchTtm[ttmPosition] = getPitch();
	ttmPosition++;
	if(ttmPosition == relativeTtm.size()) {
		ttmPosition = 0;
	}
}
コード例 #4
0
ファイル: LuaPath.cpp プロジェクト: carlsonp/vr-jugglua
    std::string LuaPath::_findJuggler() {
#if __VJ_version >= 2003000
        static const fs::path jugglerTest = "share/vrjuggler-3.0/data/"
                                            "definitions/"
                                            "simulated_positional_device.jdef";
#else
        static const fs::path jugglerTest = "share/vrjuggler-2.2/data/"
                                            "definitions/"
                                            "simulated_positional_device.jdef";
#endif
        static const fs::path jugglerTestFallback =
            "share/vrjuggler/data/definitions/simulated_positional_device.jdef";

        if (fs::exists(_root / jugglerTest) ||
            fs::exists(_root / jugglerTestFallback)) {
            return _root;
        }

        std::string vprLibraryPath = findVPRDLL();
        if (!vprLibraryPath.empty()) {
            try {
                return _findFilePath(
                    getAbsolute(vprLibraryPath).remove_filename().string(),
                    jugglerTest.string());
            }
            catch (std::runtime_error &) {
                // nothing
            }
        }
        std::string ret;
        vpr::System::getenv("VJ_BASE_DIR", ret);
        return ret;
    }
コード例 #5
0
void Xbox360Peripheral::fiddleReport(XBOX360_HAT& left, XBOX360_HAT& right)
{
    // deadOff - Normalize checkbox is checked if true
    // relative - Linked checkbox is checked if true
    
    if(invertLeftX) left.x=~left.x;
    if(!invertLeftY) left.y=~left.y;
    if(invertRightX) right.x=~right.x;
    if(!invertRightY) right.y=~right.y;
    
    if(deadzoneLeft!=0) {
        if(relativeLeft) {
            if((getAbsolute(left.x)<deadzoneLeft)&&(getAbsolute(left.y)<deadzoneLeft)) {
                left.x=0;
                left.y=0;
            }
            else if(deadOffLeft) {
                normalizeAxis(left.x, deadzoneLeft);
                normalizeAxis(left.y, deadzoneLeft);
            }
        } else { // Linked checkbox has no check
            if(getAbsolute(left.x)<deadzoneLeft)
                left.x=0;
            else if (deadOffLeft)
                normalizeAxis(left.x, deadzoneLeft);
            
            if(getAbsolute(left.y)<deadzoneLeft)
                left.y=0;
            else if (deadOffLeft)
                normalizeAxis(left.y, deadzoneLeft);
        }
    }
    if(deadzoneRight!=0) {
        if(relativeRight) {
            if((getAbsolute(right.x)<deadzoneRight)&&(getAbsolute(right.y)<deadzoneRight)) {
                right.x=0;
                right.y=0;
            }
            else if(deadOffRight) {
                normalizeAxis(left.x, deadzoneRight);
                normalizeAxis(left.y, deadzoneRight);
            }
        } else {
            if(getAbsolute(right.x)<deadzoneRight)
                right.x=0;
            else if (deadOffRight)
                normalizeAxis(right.x, deadzoneRight);
            if(getAbsolute(right.y)<deadzoneRight)
                right.y=0;
            else if (deadOffRight)
                normalizeAxis(right.y, deadzoneRight);
        }
    }
}
コード例 #6
0
void Xbox360Peripheral::normalizeAxis(SInt16& axis, short deadzone)
{
    static const UInt16 max16=32767;
    const float current=getAbsolute(axis);
    const float maxVal=max16-deadzone;
    
    if (current>deadzone) {
        if (axis<0) {
            axis=max16*(current-deadzone)/maxVal;
            axis=~axis;
        } else {
            axis=max16*(current-deadzone)/maxVal;
        }
    } else {
        axis=0;
    }
}
コード例 #7
0
ファイル: tp.c プロジェクト: Xero-Hige/lg-at-compus
/**
 * Devuelve el brillo de un pixel que se recibe por parámetro.
 */
int getBrightness(double x, double y) {
	double varComplexPixelX = x;
	double varComplexPixelY = y;
	double previousComplexPixelX, previousComplexPixelY;
	int brightness;
	double limitation = 2;
	for (brightness = 0; brightness < MAX_ITERATIONS - 1; brightness++) {
		if (getAbsolute(varComplexPixelX, varComplexPixelY) > limitation) {
			break;
		}
		previousComplexPixelX = varComplexPixelX;
		previousComplexPixelY = varComplexPixelY;
		varComplexPixelX = getNewIterationX(previousComplexPixelX,
				previousComplexPixelY, x);
		varComplexPixelY = getNewIterationY(previousComplexPixelX,
				previousComplexPixelY, y);
	}
	return brightness;
}
コード例 #8
0
// Adjusts the report for any settings speciified by the user
void Xbox360Peripheral::fiddleReport(IOBufferMemoryDescriptor *buffer)
{
    XBOX360_IN_REPORT *report=(XBOX360_IN_REPORT*)buffer->getBytesNoCopy();
    if(invertLeftX) report->left.x=~report->left.x;
    if(!invertLeftY) report->left.y=~report->left.y;
    if(invertRightX) report->right.x=~report->right.x;
    if(!invertRightY) report->right.y=~report->right.y;
    if(deadzoneLeft!=0) {
        if(relativeLeft) {
            if((getAbsolute(report->left.x)<deadzoneLeft)&&(getAbsolute(report->left.y)<deadzoneLeft)) {
                report->left.x=0;
                report->left.y=0;
            }
            else if(deadOffLeft) {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneLeft;
                float valX=getAbsolute(report->left.x);
                if (valX>deadzoneLeft) {
                    if (report->left.x<0) {
                        report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                        report->left.x=~report->left.x;
                    } else {
                        report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                    }
                } else {
                    report->left.x=0;
                }
                float valY=getAbsolute(report->left.y);
                if (valY>deadzoneLeft) {
                    if (report->left.y<0) {
                        report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                        report->left.y=~report->left.y;
                    } else {
                        report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                    }
                } else {
                    report->left.y=0;
                }
            }
        } else {
            if(getAbsolute(report->left.x)<deadzoneLeft)
                report->left.x=0;
            else if (deadOffLeft)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneLeft;
                if (report->left.x<0) {
                    float valX=getAbsolute(report->left.x);
                    report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                    report->left.x=~report->left.x;
                } else {
                    float valX=getAbsolute(report->left.x);
                    report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                }
            }
            if(getAbsolute(report->left.y)<deadzoneLeft)
                report->left.y=0;
            else if (deadOffLeft)
            {
                const UInt16 max16=32767;
                float maxVal = max16-deadzoneLeft;
                if (report->left.y<0) {
                    float valY=getAbsolute(report->left.y);
                    report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                    report->left.y=~report->left.y;
                } else {
                    float valY=getAbsolute(report->left.y);
                    report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                }
            }
        }
    }
    if(deadzoneRight!=0) {
        if(relativeRight) {
            if((getAbsolute(report->right.x)<deadzoneRight)&&(getAbsolute(report->right.y)<deadzoneRight)) {
                report->right.x=0;
                report->right.y=0;
            }
            else if(deadOffRight) {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                float valX=getAbsolute(report->right.x);
                if (valX>deadzoneRight) {
                    if (report->right.x<0) {
                        report->right.x=max16*(valX-deadzoneRight)/maxVal;
                        report->right.x=~report->right.x;
                    } else {
                        report->right.x=max16*(valX-deadzoneRight)/maxVal;
                    }
                } else {
                    report->right.x = 0;
                }
                float valY=getAbsolute(report->right.y);
                if (valY>deadzoneRight) {
                    if (report->right.y<0) {
                        report->right.y=max16*(valY-deadzoneRight)/maxVal;
                        report->right.y=~report->right.y;
                    } else {
                        report->right.y=max16*(valY-deadzoneRight)/maxVal;
                    }
                } else {
                    report->right.y = 0;
                }
            }
        } else {
            if(getAbsolute(report->right.x)<deadzoneRight)
                report->right.x=0;
            else if (deadOffRight)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                if (report->right.x<0) {
                    float valX=getAbsolute(report->right.x);
                    report->right.x=max16*(valX-deadzoneRight)/maxVal;
                    report->right.x=~report->right.x;
                } else {
                    float valX=getAbsolute(report->right.x);
                    report->right.x=max16*(valX-deadzoneRight)/maxVal;
                }
            }
            if(getAbsolute(report->right.y)<deadzoneRight)
                report->right.y=0;
            else if (deadOffRight)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                if (report->right.y<0) {
                    float valY=getAbsolute(report->right.y);
                    report->right.y=max16*(valY-deadzoneRight)/maxVal;
                    report->right.y=~report->right.y;
                } else {
                    float valY=getAbsolute(report->right.y);
                    report->right.y=max16*(valY-deadzoneRight)/maxVal;
                }
            }
        }
    }
}
コード例 #9
0
int ConfigCtx::getAbsolutePath(char *dest, const char *path)
{
    return getAbsolute(dest, path, 1);
}
コード例 #10
0
int ConfigCtx::getAbsoluteFile(char *dest, const char *file)
{
    return getAbsolute(dest, file, 0);
}
コード例 #11
0
// Adjusts the report for any settings specified by the user
void Wireless360Controller::fiddleReport(unsigned char *data, int length)
{
    XBOX360_IN_REPORT *report=(XBOX360_IN_REPORT*)data;
    if(invertLeftX) report->left.x=~report->left.x;
    if(!invertLeftY) report->left.y=~report->left.y;
    if(invertRightX) report->right.x=~report->right.x;
    if(!invertRightY) report->right.y=~report->right.y;
    if(deadzoneLeft!=0) {
        if(relativeLeft) {
            if((getAbsolute(report->left.x)<deadzoneLeft)&&(getAbsolute(report->left.y)<deadzoneLeft)) {
                report->left.x=0;
                report->left.y=0;
            }
            else if(deadOffLeft) {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneLeft;
                float valX=getAbsolute(report->left.x);
                if (valX>deadzoneLeft) {
                    if (report->left.x<0) {
                        report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                        report->left.x=~report->left.x;
                    } else {
                        report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                    }
                } else {
                    report->left.x=0;
                }
                float valY=getAbsolute(report->left.y);
                if (valY>deadzoneLeft) {
                    if (report->left.y<0) {
                        report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                        report->left.y=~report->left.y;
                    } else {
                        report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                    }
                } else {
                    report->left.y=0;
                }
            }
        } else {
            if(getAbsolute(report->left.x)<deadzoneLeft)
                report->left.x=0;
            else if (deadOffLeft)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneLeft;
                if (report->left.x<0) {
                    float valX=getAbsolute(report->left.x);
                    report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                    report->left.x=~report->left.x;
                } else {
                    float valX=getAbsolute(report->left.x);
                    report->left.x=max16*(valX-deadzoneLeft)/maxVal;
                }
            }
            if(getAbsolute(report->left.y)<deadzoneLeft)
                report->left.y=0;
            else if (deadOffLeft)
            {
                const UInt16 max16=32767;
                float maxVal = max16-deadzoneLeft;
                if (report->left.y<0) {
                    float valY=getAbsolute(report->left.y);
                    report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                    report->left.y=~report->left.y;
                } else {
                    float valY=getAbsolute(report->left.y);
                    report->left.y=max16*(valY-deadzoneLeft)/maxVal;
                }
            }
        }
    }
    if(deadzoneRight!=0) {
        if(relativeRight) {
            if((getAbsolute(report->right.x)<deadzoneRight)&&(getAbsolute(report->right.y)<deadzoneRight)) {
                report->right.x=0;
                report->right.y=0;
            }
            else if(deadOffRight) {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                float valX=getAbsolute(report->right.x);
                if (valX>deadzoneRight) {
                    if (report->right.x<0) {
                        report->right.x=max16*(valX-deadzoneRight)/maxVal;
                        report->right.x=~report->right.x;
                    } else {
                        report->right.x=max16*(valX-deadzoneRight)/maxVal;
                    }
                } else {
                    report->right.x = 0;
                }
                float valY=getAbsolute(report->right.y);
                if (valY>deadzoneRight) {
                    if (report->right.y<0) {
                        report->right.y=max16*(valY-deadzoneRight)/maxVal;
                        report->right.y=~report->right.y;
                    } else {
                        report->right.y=max16*(valY-deadzoneRight)/maxVal;
                    }
                } else {
                    report->right.y = 0;
                }
            }
        } else {
            if(getAbsolute(report->right.x)<deadzoneRight)
                report->right.x=0;
            else if (deadOffRight)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                if (report->right.x<0) {
                    float valX=getAbsolute(report->right.x);
                    report->right.x=max16*(valX-deadzoneRight)/maxVal;
                    report->right.x=~report->right.x;
                } else {
                    float valX=getAbsolute(report->right.x);
                    report->right.x=max16*(valX-deadzoneRight)/maxVal;
                }
            }
            if(getAbsolute(report->right.y)<deadzoneRight)
                report->right.y=0;
            else if (deadOffRight)
            {
                const UInt16 max16=32767;
                float maxVal=max16-deadzoneRight;
                if (report->right.y<0) {
                    float valY=getAbsolute(report->right.y);
                    report->right.y=max16*(valY-deadzoneRight)/maxVal;
                    report->right.y=~report->right.y;
                } else {
                    float valY=getAbsolute(report->right.y);
                    report->right.y=max16*(valY-deadzoneRight)/maxVal;
                }
            }
        }
    }

    // hack for crimsonland.
    report->trigL = report->right.x/256 + 128;
    report->trigR = report->right.y/256 + 128;
}