bool QikFlat::getStartupData() { bool rc1 = getFirmwareVersion(); bool rc2 = getBrightness(); return (rc1 && rc2); }
bool FlipFlat::getStartupData() { bool rc1 = getFirmwareVersion(); bool rc2 = getStatus(); bool rc3 = getBrightness(); return (rc1 && rc2 && rc3); }
float VideoInput::setBrightness(float brightness) { //HERE; if ( brightness > 1 ) brightness = 1; else if ( brightness < 0 ) brightness = 0; m_brightness = brightness; return getBrightness(); }
double Scene::getBrightness(int U,int D,int L,int R,Vec3f& p,bools& Done,bools& Reach) const{ // qDebug() << U << D << L << R; Vec3f a,b,c; Material d; Vec3f UL = _Light[U][L] - p; Vec3f UR = _Light[U][R] - p; Vec3f DL = _Light[D][L] - p; Vec3f DR = _Light[D][R] - p; bool ul = Done[U][L]?Reach[U][L]:getIntersection(Line(p,UL),a,b,c,d,Len(UL)- EPS); if (!Done[U][L]){ Reach[U][L] = ul; Done[U][L] = true; } bool ur = Done[U][R]?Reach[U][R]:getIntersection(Line(p,UR),a,b,c,d,Len(UR)- EPS); if (!Done[U][R]){ Reach[U][R] = ur; Done[U][R] = true; } bool dl = Done[D][L]?Reach[D][L]:getIntersection(Line(p,DL),a,b,c,d,Len(DL)- EPS); if (!Done[D][L]){ Reach[D][L] = dl; Done[D][L] = true; } bool dr = Done[D][R]?Reach[D][R]:getIntersection(Line(p,DR),a,b,c,d,Len(DR)- EPS); if (!Done[D][R]){ Reach[D][R] = dr; Done[D][R] = true; } if (ul && ur && dr && dl) return 0; if (!(ul || ur || dr || dl)) return 1; if (D <= U + 1) return 0.5; return 0.25*( getBrightness(U,(U + D)/2,L,(L + R)/2,p,Done,Reach) + getBrightness((U + D)/2,D,(L + R)/2,R,p,Done,Reach) + getBrightness(U,(U + D)/2,(L + R)/2,R,p,Done,Reach) + getBrightness((U + D)/2,D,L,(L + R)/2,p,Done,Reach) ); }
// advanced functions void StairvilleLEDParSpot::fadeBrightness(unsigned char endValue, float timeSeconds){ // if(!fading) // { if(timeSeconds > 0) fadeDelta = (endValue - getBrightness()) / timeSeconds; else return; fadeEndTime = timeSeconds + ofGetElapsedTimef(); fadeEndValue = endValue; fading = true; // } }
void applyXPro(Bitmap* bitmap) { //Cache to local variables unsigned char* red = (*bitmap).red; unsigned char* green = (*bitmap).green; unsigned char* blue = (*bitmap).blue; unsigned int length = (*bitmap).width * (*bitmap).height; register unsigned int i; short int overlayLut[256][256]; int j; for (i = 256; i--;) { for (j = 256; j--;) { overlayLut[i][j] = -1; } } for (i = length; i--;) { HSBColour hsb; //rgbToHsb(red[i], green[i], blue[i], &hsb); //float value = hsb.b; float value; getBrightness(red[i], green[i], blue[i], &value); unsigned char r = xproRedCurveLut[red[i]]; unsigned char g = xproGreenCurveLut[green[i]]; unsigned char b = xproBlueCurveLut[blue[i]]; rgbToHsb(r, g, b, &hsb); hsb.b = value; hsbToRgb(&hsb, &r, &g, &b); if (overlayLut[red[i]][r] == -1) { overlayLut[red[i]][r] = overlayPixelComponents(red[i], r, 1.0f); } red[i] = overlayLut[red[i]][r]; //overlayPixelComponents(red[i], r, 1.0f); if (overlayLut[green[i]][g] == -1) { overlayLut[green[i]][g] = overlayPixelComponents(green[i], g, 1.0f); } green[i] = overlayLut[green[i]][g]; //overlayPixelComponents(green[i], g, 1.0f); if (overlayLut[blue[i]][b] == -1) { overlayLut[blue[i]][b] = overlayPixelComponents(blue[i], b, 1.0f); } blue[i] = overlayLut[blue[i]][b]; //overlayPixelComponents(blue[i], b, 1.0f); } }
/** * @brief Show the pixels on an APA102 device. * The pixels that have been set are pushed to the APA102 devices. */ void Apa102::show() { // We follow the data sheet for the APA102. To signify a new stream of data // we send 32bits of 0 value. Following that are 4 bytes of color data. The // data is 0b111 nnnnn where `nnnnn` is the brightness of the pixels. // The following data is 8 bits for blue, 8 bits for green and 8 bits for red. // Send APA102 start. mySPI.transferByte(0x0); mySPI.transferByte(0x0); mySPI.transferByte(0x0); mySPI.transferByte(0x0); double brigthnessScale = getBrightness() / 100.0; // Loop over all the pixels in the pixels array to set the colors. for (int i=0; i<m_pixelCount; i++) { mySPI.transferByte(0xff); // Maximum brightness mySPI.transferByte(m_pixels[i].blue * brigthnessScale); mySPI.transferByte(m_pixels[i].green * brigthnessScale); mySPI.transferByte(m_pixels[i].red * brigthnessScale); } // End loop over all the pixels. } // show
void ConnectionTracerRenderer ::drawTracer(const AbstractConnection& connection, std::shared_ptr<ofBaseRenderer>& renderer) { if (!connection.visible()) { return; } auto ratio = ofWrap(_rawRatio + static_cast<float>(connection.entityId() % 12) / 12.0f, 0, 1); auto tracerPos = connection.evaluatePosition(ratio); const auto& entityA = connection.sourceEntity(); const auto& entityB = connection.targetEntity(); auto color = getInterpolated(entityA.color(), entityB.color(), ratio); color.setBrightness(color.getBrightness() * 1.2); color.a *= getInterpolated(entityA.alpha(), entityB.alpha(), ratio); color.a *= _params.alphaFade.evaluate(ratio); renderer->setColor(color); renderer->drawBox(tracerPos, _params.drawRadius.get()); }
void loop () { // event interface int fd = -1; /* the file descriptor for the device */ int i; /* loop counter */ size_t read_bytes; /* how many bytes were read */ struct input_event ev[64]; /* the events (up to 64 at once) */ int key; /*key code */ /* used if event hit fn */ int hasSomething; #ifdef HAVE_LIBXOSD // prepare queue handling int flag = 0, brightness = 0, sound = 0; createqueue (); #endif if (strcasecmp(devinput,"AUTO")==0) { // try to figure out rigth event value for keyboard snprintf(devinput,MAX_DEVINPUT_SIZE,"/dev/input/event%d",getItemEvent(DEFAULT_KEYBOARD_NAME)); syslog(LOG_INFO,"autodevice determines %s as keyboard event",devinput); } if ((fd = open (devinput, O_RDONLY)) < 0) { syslog (LOG_CRIT,"event interface (%s) open failed: %m",devinput); // shoot auto as LAST chance snprintf(devinput,MAX_DEVINPUT_SIZE,"/dev/input/event%d",getItemEvent(DEFAULT_KEYBOARD_NAME)); syslog(LOG_CRIT,"autodevice determines %s as a last chance keyboard event",devinput); if ((fd = open (devinput, O_RDONLY)) < 0) { syslog(LOG_CRIT,"Event interface (%s) open failed: %m",devinput); cleanExit(EXIT_FAILURE); } } /* handle important signal */ if (signal(SIGTERM,signal_handler) < 0) { perror("signal"); exit(EXIT_FAILURE); } if (signal(SIGHUP,signal_handler) < 0) { perror("signal"); exit(EXIT_FAILURE); } syslog(LOG_INFO,"fsfn loaded"); while (1) { /* loop */ hasSomething = 0; /* nothing yet */ /* * read the event interface */ if ( (read_bytes = read (fd, ev, sizeof (struct input_event) * 64))==-1) { //fprintf(stderr,"Error: %d\n",errno); if (errno==ENODEV) { // event is now invalid ? must be back from sleep... syslog(LOG_NOTICE,"Start sleeping..."); sleep(10); syslog(LOG_NOTICE,"End sleeping..."); close(fd); // is this needed ?? syslog(LOG_NOTICE,"Input device changed, back from suspend ?: %m"); // get new event snprintf(devinput,MAX_DEVINPUT_SIZE,"/dev/input/event%d",getItemEvent(DEFAULT_KEYBOARD_NAME)); syslog(LOG_NOTICE,"autodevice determines %s as new event",devinput); // reopen - seems to be problems after a hibernate :( if ((fd = open (devinput, O_RDONLY)) < 0) { syslog(LOG_CRIT,"New event interface (%s) open failed: %m",devinput); cleanExit(EXIT_FAILURE); } // read it if ((read_bytes = read (fd, ev, sizeof (struct input_event) * 64))==-1) { syslog(LOG_CRIT,"Reading new device (%s) failed: %m",devinput); cleanExit(EXIT_FAILURE); } } else { syslog(LOG_CRIT,"Input device reading failed: %m"); cleanExit(EXIT_FAILURE); } } if (read_bytes < (int) sizeof (struct input_event)) { syslog (LOG_CRIT,"short read: %m"); cleanExit(EXIT_FAILURE); } /* * Loop for all readed events until we have something * interesting.. */ for (i = 0; !hasSomething && (i < (int) (read_bytes / sizeof (struct input_event))); i++) { hasSomething = (ev[i].type == FN_INPUT_TYPE) && (ev[i].code == FN_INPUT_CODE) && (ev[i].value == FN_INPUT_VALUE); } /* * If we got a FN event, plz do something... */ if (hasSomething && (key = getCodes ())) { if ((key & FN_F5) == FN_F5) { // check config if (!checkConfig("F5_CMD")) { // lower brightness #ifdef HAVE_LIBXOSD flag = MOD_BRIGHTNESS; brightness = setBrightness (getBrightness () - 1); sendmsg (flag, brightness, sound); sendcmd (FN_F5); #else setBrightness (getBrightness () - 1); #endif } } if ((key & FN_F6) == FN_F6) { // check config if (!checkConfig("F6_CMD")) { // higher brightness #ifdef HAVE_LIBXOSD flag = MOD_BRIGHTNESS; brightness = setBrightness (getBrightness () + 1); sendmsg (flag, brightness, sound); sendcmd (FN_F6); #else setBrightness (getBrightness () + 1); #endif } } if ((key & FN_F2) == FN_F2) { // check config if (!checkConfig("F2_CMD")) { #ifdef HAVE_LIBXOSD flag = MOD_SOUND; sound = mute (SOUND_STEP); sendmsg (flag, brightness, sound); sendcmd(FN_F2); #else mute (SOUND_STEP); #endif } } if ((key & FN_F3) == FN_F3) { if (!checkConfig("F3_CMD")) { #ifdef HAVE_LIBXOSD flag = MOD_SOUND; sound = volume_down (SOUND_STEP); //mod by SilSha sendmsg (flag, brightness, sound); sendcmd(FN_F3); #else volume_down (SOUND_STEP); #endif } } if ((key & FN_F4) == FN_F4) { if (!checkConfig("F4_CMD")) { #ifdef HAVE_LIBXOSD flag = MOD_SOUND; sound = volume_up (SOUND_STEP); //mod by SilSha sendmsg (flag, brightness, sound); sendcmd(FN_F4); #else volume_up (SOUND_STEP); #endif } } /* NO built in commands */ if ((key & FN_F7) == FN_F7) { #ifdef HAVE_LIBXOSD if (!checkConfig("F7_CMD")) sendcmd(FN_F7); #else sendcmd(FN_F7); #endif } if ((key & FN_F10) == FN_F10) { #ifdef HAVE_LIBXOSD if(!checkConfig("F10_CMD")) sendcmd(FN_F10); #else sendcmd(FN_F10); #endif } if ((key & FN_F12) == FN_F12) { #ifdef HAVE_LIBXOSD if (!checkConfig("F12_CMD")) sendcmd(FN_F12); #else checkConfig("F12_CMD"); #endif } if (( key & S1_BTN) == S1_BTN) { #ifdef HAVE_LIBXOSD if (!checkConfig("S1_CMD")) sendcmd(S1_BTN); #else checkConfig("S1_CMD"); #endif } if (( key & S2_BTN) == S2_BTN) { #ifdef HAVE_LIBXOSD if (!checkConfig("S2_CMD")) sendcmd(S2_BTN); #else checkConfig("S2_CMD"); #endif } } }// while }
//[20091123 exif Ratnesh void CameraHal::CreateExif(unsigned char* pInThumbnailData,int Inthumbsize,unsigned char* pOutExifBuf,int& OutExifSize,int flag) { int w =0, h = 0; int orientationValue = getOrientation(); HAL_PRINT("CreateExif orientationValue = %d \n", orientationValue); ExifCreator* mExifCreator = new ExifCreator(); unsigned int ExifSize = 0; ExifInfoStructure ExifInfo; char ver_date[5] = {NULL,}; unsigned short tempISO = 0; struct v4l2_exif exifobj; // To read values from driver if(mCameraIndex==MAIN_CAMERA) { getExifInfoFromDriver(&exifobj); } memset(&ExifInfo, NULL, sizeof(ExifInfoStructure)); strcpy( (char *)&ExifInfo.maker, "SAMSUNG"); strcpy( (char *)&ExifInfo.model, "GT-I9003"); mParameters.getPreviewSize(&w, &h); mParameters.getPictureSize((int*)&ExifInfo.imageWidth , (int*)&ExifInfo.imageHeight); mParameters.getPictureSize((int*)&ExifInfo.pixelXDimension, (int*)&ExifInfo.pixelYDimension); struct tm *t = NULL; time_t nTime; time(&nTime); t = localtime(&nTime); if(t != NULL) { sprintf((char *)&ExifInfo.dateTimeOriginal, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); sprintf((char *)&ExifInfo.dateTimeDigitized, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); sprintf((char *)&ExifInfo.dateTime, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); } if(mCameraIndex==MAIN_CAMERA) { int cam_ver = GetCamera_version(); ExifInfo.Camversion[0] = (cam_ver & 0xFF); ExifInfo.Camversion[1] = ((cam_ver >> 8) & 0xFF); ExifInfo.Camversion[2] = ((cam_ver >> 16) & 0xFF); ExifInfo.Camversion[3] = ((cam_ver >> 24) & 0xFF); HAL_PRINT("CreateExif GetCamera_version =[%x][%x][%x][%x]\n", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]); sprintf((char *)&ExifInfo.software, "fw %02d.%02d prm %02d.%02d", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]); if(mThumbnailWidth > 0 && mThumbnailHeight > 0) { ExifInfo.hasThumbnail = true; ExifInfo.thumbStream = pInThumbnailData; ExifInfo.thumbSize = Inthumbsize; ExifInfo.thumbImageWidth = mThumbnailWidth; ExifInfo.thumbImageHeight = mThumbnailHeight; } else { ExifInfo.hasThumbnail = false; } ExifInfo.exposureProgram = 3; ExifInfo.exposureMode = 0; ExifInfo.contrast = convertToExifLMH(getContrast(), 2); ExifInfo.fNumber.numerator = 26; ExifInfo.fNumber.denominator = 10; ExifInfo.aperture.numerator = 26; ExifInfo.aperture.denominator = 10; ExifInfo.maxAperture.numerator = 26; ExifInfo.maxAperture.denominator = 10; ExifInfo.focalLength.numerator = 3430; ExifInfo.focalLength.denominator = 1000; //[ 2010 05 01 exif ExifInfo.shutterSpeed.numerator = exifobj.TV_Value; ExifInfo.shutterSpeed.denominator = 100; ExifInfo.exposureTime.numerator = 1; ExifInfo.exposureTime.denominator = (unsigned int)pow(2.0, ((double)exifobj.TV_Value/100.0)); //] ExifInfo.brightness.numerator = 5; ExifInfo.brightness.denominator = 9; ExifInfo.iso = 1; ExifInfo.flash = 0; // default value // Flash // bit 0 -whether the flash fired // bit 1,2 -status of returned light // bit 3,4 - indicating the camera's flash mode // bit 5 -presence of a flash function // bit 6 - red-eye mode // refer to flash_mode[] at CameraHal.cpp // off = 1 // on = 2 // auto = 3 // Todo : Need to implement how HAL can recognize existance of flash // if( ! isFlashExist ) // pseudo code // ExifInfo.flash = 32; // bit 5 - No flash function. // else { LOGD("createExif - flashmode = %d flash result = %d", mPreviousFlashMode, ExifInfo.flash); // bit 0 ExifInfo.flash = ExifInfo.flash | exifobj.flash; // bit 3,4 if(mPreviousFlashMode == 3) // Flashmode auto ExifInfo.flash = ExifInfo.flash |24; // bit 6 // Todo : Need to implement about red-eye // if(mPreviousFlashMode == ??) // Flashmode red-eye // ExifInfo.flash = ExifInfo.flash | 64; } HAL_PRINT("Main Orientation = %d\n",orientationValue); switch(orientationValue) { case 0: ExifInfo.orientation = 1 ; break; case 90: ExifInfo.orientation = 6 ; break; case 180: ExifInfo.orientation = 3 ; break; case 270: ExifInfo.orientation = 8 ; break; default: ExifInfo.orientation = 1 ; break; } //[ 2010 05 01 exif double calIsoValue = 0; calIsoValue = pow(2.0,((double)exifobj.SV_Value/100.0))*3.125; //] if(calIsoValue < 8.909) { tempISO = 0; } else if(calIsoValue >=8.909 && calIsoValue < 11.22) { tempISO = 10; } else if(calIsoValue >=11.22 && calIsoValue < 14.14) { tempISO = 12; } else if(calIsoValue >=14.14 && calIsoValue < 17.82) { tempISO = 16; } else if(calIsoValue >=17.82 && calIsoValue < 22.45) { tempISO = 20; } else if(calIsoValue >=22.45 && calIsoValue < 28.28) { tempISO = 25; } else if(calIsoValue >=28.28 && calIsoValue < 35.64) { tempISO = 32; } else if(calIsoValue >=35.64 && calIsoValue < 44.90) { tempISO = 40; } else if(calIsoValue >=44.90 && calIsoValue < 56.57) { tempISO = 50; } else if(calIsoValue >=56.57 && calIsoValue < 71.27) { tempISO = 64; } else if(calIsoValue >=71.27 && calIsoValue < 89.09) { tempISO = 80; } else if(calIsoValue >=89.09 && calIsoValue < 112.2) { tempISO = 100; } else if(calIsoValue >=112.2 && calIsoValue < 141.4) { tempISO = 125; } else if(calIsoValue >=141.4 && calIsoValue < 178.2) { tempISO = 160; } else if(calIsoValue >=178.2 && calIsoValue < 224.5) { tempISO = 200; } else if(calIsoValue >=224.5 && calIsoValue < 282.8) { tempISO = 250; } else if(calIsoValue >=282.8 && calIsoValue < 356.4) { tempISO = 320; } else if(calIsoValue >=356.4 && calIsoValue < 449.0) { tempISO = 400; } else if(calIsoValue >=449.0 && calIsoValue < 565.7) { tempISO = 500; } else if(calIsoValue >=565.7 && calIsoValue < 712.7) { tempISO = 640; } else if(calIsoValue >=712.7 && calIsoValue < 890.9) { tempISO = 800; } else if(calIsoValue >=890.9 && calIsoValue < 1122) { tempISO = 1000; } else if(calIsoValue >=1122 && calIsoValue < 1414) { tempISO = 1250; } else if(calIsoValue >=1414 && calIsoValue < 1782) { tempISO = 160; } else if(calIsoValue >=1782 && calIsoValue < 2245) { tempISO = 2000; } else if(calIsoValue >=2245 && calIsoValue < 2828) { tempISO = 2500; } else if(calIsoValue >=2828 && calIsoValue < 3564) { tempISO = 3200; } else if(calIsoValue >=3564 && calIsoValue < 4490) { tempISO = 4000; } else if(calIsoValue >=4490 && calIsoValue < 5657) { tempISO = 5000; } else if(calIsoValue >=5657 && calIsoValue < 7127) { tempISO = 6400; } else { tempISO = 8000; } if(mPreviousSceneMode <= 1) { ExifInfo.meteringMode = mPreviousMetering; if(mPreviousWB <= 1) { ExifInfo.whiteBalance = 0; } else { ExifInfo.whiteBalance = 1; } ExifInfo.saturation = convertToExifLMH(getSaturation(), 2); ExifInfo.sharpness = convertToExifLMH(getSharpness(), 2); switch(mPreviousISO) { case 2: ExifInfo.isoSpeedRating = 50; break; case 3: ExifInfo.isoSpeedRating = 100; break; case 4: ExifInfo.isoSpeedRating = 200; break; case 5: ExifInfo.isoSpeedRating = 400; break; case 6: ExifInfo.isoSpeedRating = 800; break; default: ExifInfo.isoSpeedRating = tempISO; break; } switch(getBrightness()) { case 0: ExifInfo.exposureBias.numerator = -20; break; case 1: ExifInfo.exposureBias.numerator = -15; break; case 2: ExifInfo.exposureBias.numerator = -10; break; case 3: ExifInfo.exposureBias.numerator = -5; break; case 4: ExifInfo.exposureBias.numerator = 0; break; case 5: ExifInfo.exposureBias.numerator = 5; break; case 6: ExifInfo.exposureBias.numerator = 10; break; case 7: ExifInfo.exposureBias.numerator = 15; break; case 8: ExifInfo.exposureBias.numerator = 20; break; default: ExifInfo.exposureBias.numerator = 0; break; } ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 0; } else { switch(mPreviousSceneMode) { case 3://sunset ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 1; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 4://dawn ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 1; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 5://candlelight ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 1; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 6://beach & snow ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 2; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = 50; ExifInfo.exposureBias.numerator = 10; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 1; break; case 7://againstlight ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; if(mPreviousFlashMode <= 1) { ExifInfo.meteringMode = 3; } else { ExifInfo.meteringMode = 2; } ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 8://text ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 2; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 9://night ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 3; break; case 10://landscape ExifInfo.meteringMode = 5; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 2; ExifInfo.sharpness = 2; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 1; break; case 11://fireworks ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = 50; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 12://portrait ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 1; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 2; break; case 13://fallcolor ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 2; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 14://indoors ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 2; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = 200; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; case 15://sports ExifInfo.meteringMode = 2; ExifInfo.whiteBalance = 0; ExifInfo.saturation = 0; ExifInfo.sharpness = 0; ExifInfo.isoSpeedRating = tempISO; ExifInfo.exposureBias.numerator = 0; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = 4; break; } } }
Vec3f Scene::RayTracer(Line l,Vec3f& IntersectPoint,double strength) const{ if (strength < 0.01) return Vec3f(0,0,0); Vec3f N; Material material; Vec3f Color; if (getIntersection(l,N,IntersectPoint,Color,material)){ double len = (IntersectPoint - l.start_point).Len(); if ((l.start_point + l.dir * len - IntersectPoint).Len() > EPS){ qDebug() << "f**k" << (l.start_point + l.dir * len - IntersectPoint).Len(); l.start_point.debug(); l.dir.debug(); IntersectPoint.debug(); } if (material.refract_n > 1) strength *= exp(0.05 -len * material.absorptivity); double I = 0; /*for (unsigned i = 0; i < _lightsources.size();i++){ Line light(IntersectPoint,_lightsources[i] - IntersectPoint); if (!getIntersection(light,a,b,c,d,Len(_lightsources[i] - IntersectPoint)- EPS)){ Vec3f Ref = light.dir - N * 2 * (light.dir * N); double Ii = material.Kd * abs(N * light.dir); if (Ref * l.dir > EPS) Ii += material.Ks * pow(Ref * l.dir,material.Ksn); I += Ii * Ii/_lightsources.size(); } }*/ Line light(IntersectPoint,_lightsources[0] - IntersectPoint); Vec3f Ref = light.dir - N * 2 * (light.dir * N); double Ii = material.Kd * abs(N * light.dir); if (Ref * l.dir > EPS) Ii += material.Ks * pow(Ref * l.dir,material.Ksn); double Brightness; if (softshape){ bools Done,Reach; memset(Done,0,sizeof(Done)); //Brightness = getBrightness(LightUL,LightUR,LightDR,LightDL,IntersectPoint); Brightness = getBrightness(0,LightNum,0,LightNum,IntersectPoint,Done,Reach); } else{ Vec3f a,b,c; Material d; Brightness = getIntersection(light,a,b,c,d,Len(_lightsources[0] - IntersectPoint)- EPS)?0:1; } I = Ii * Brightness + material.Ka; if (I > 1 - EPS){ I = 1 - EPS; } I = I * strength; double Cosi = l.dir * N; double Sini = abs(Cosi) < 1 - EPS?sqrt(1 - Cosi * Cosi):0; double Sinr = Sini * material.refract_n; Line reflect(IntersectPoint,l.dir - N * 2 * Cosi); Line refract = reflect; if (Sinr < 1 - EPS){ double Cosr = sqrt(1 - Sinr * Sinr); Vec3f tmp = l.dir - N * Cosi; tmp.Normalize(); Vec3f rf = N * Cosr + tmp * Sinr; refract = Line(IntersectPoint,rf); } if (REF){ Vec3f iii; Color = Color * I * material.diffuse_reflectance + Color.mul(RayTracer(reflect,iii,material.reflect_rate * strength)) + Color.mul(RayTracer(refract,iii,material.refract_rate * strength)); } else Color = Color * I * material.diffuse_reflectance; Color.Fix255(); return Color; } else{ double I = 1; for (unsigned i = 0; i < _lightsources.size();i++){ } return Vec3f(0,0,0) * I * strength; } }
// main and loop int main(int argc, char **argv) { // event interface int fd = -1; /* the file descriptor for the device */ int i; /* loop counter */ size_t read_bytes; /* how many bytes were read */ struct input_event ev[64]; /* the events (up to 64 at once) */ /* key code */ int key; /* used if event hit fn */ int hasSomething; /* Volume */ int value = 0; fileops(0, 0); /* open event interface*/ if (argc != 2) { /* i don't like outputs... fprintf(stderr, "Using /dev/input/event1 for input\n"); fprintf(stderr, "Overide with %s event-device\n", argv[0]); */ if ((fd = open("/dev/input/event1", O_RDONLY)) < 0) { perror("event interface open failed"); exit(1); } } else { if ((fd = open(argv[1], O_RDONLY)) < 0) { perror("event interface open failed"); exit(1); } } nice(10); // be a nice dirty code (less dirty but keep nice) while(1) { /* loop */ hasSomething=0; /* nothing yet */ /* read the event interface */ read_bytes = read(fd, ev, sizeof(struct input_event) * 64); if (read_bytes < (int) sizeof(struct input_event)) { perror("sonyfn: short read"); exit (1); } /* Loop for all readed events until we have something interesting.. */ for (i = 0;! hasSomething && ( i < (int) (read_bytes / sizeof(struct input_event)) ); i++) { hasSomething= (ev[i].type == FN_INPUT_TYPE) && (ev[i].code == FN_INPUT_CODE) && (ev[i].value == FN_INPUT_VALUE); } /* If we got a FN event, plz do something...*/ if ( hasSomething && (key=getCodes()) ) { if ((key & FN_F5)==FN_F5) { // lower brightness setBrightness(getBrightness()-1); fileops(FN_F5, getBrightness()); } if ((key & FN_F6)==FN_F6) { // higher brightness setBrightness(getBrightness()+1); fileops(FN_F6, getBrightness()); } if ((key & FN_F2)==FN_F2){ mute(); fileops(FN_F2, 0); } if ((key & FN_F3)==FN_F3) { volume_down(); get_volume(&value); fileops(FN_F3, value); } if ((key & FN_F4)==FN_F4) { volume_up(); get_volume(&value); fileops(FN_F4, value); } if ((key & FN_F7)==FN_F7) { fileops(FN_F7, 0); usleep(100000); fileops(0, 0); } if ((key & FN_F10)==FN_F10) { fileops(FN_F10, 0); usleep(100000); fileops(0, 0); } if ((key & FN_F12)==FN_F12) { fileops(FN_F12, 0); usleep(100000); fileops(0, 0); } } }// while close(fd); return 0; }
//[20091123 exif Ratnesh void CameraHal::CreateExif(unsigned char* pInThumbnailData, int Inthumbsize, unsigned char* pOutExifBuf, int& OutExifSize, int flag) { // 0 90 180 270 360 const int MAIN_ORIENTATION[] = { 1, 6, 3, 8, 1}; const int FRONT_ORIENTATION[] = { 3, 6, 1, 8, 3}; ExifCreator* mExifCreator = new ExifCreator(); unsigned int ExifSize = 0; ExifInfoStructure ExifInfo; char ver_date[5] = {NULL,}; unsigned short tempISO = 0; struct v4l2_exif exifobj; int orientationValue = getOrientation(); LOGV("CreateExif orientationValue = %d \n", orientationValue); memset(&ExifInfo, NULL, sizeof(ExifInfoStructure)); strcpy( (char *)&ExifInfo.maker, "SAMSUNG"); mParameters.getPictureSize((int*)&ExifInfo.imageWidth , (int*)&ExifInfo.imageHeight); mParameters.getPictureSize((int*)&ExifInfo.pixelXDimension, (int*)&ExifInfo.pixelYDimension); struct tm *t = NULL; time_t nTime; time(&nTime); t = localtime(&nTime); if(t != NULL) { sprintf((char *)&ExifInfo.dateTimeOriginal, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); sprintf((char *)&ExifInfo.dateTimeDigitized, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); sprintf((char *)&ExifInfo.dateTime, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); } if(mCameraIndex==MAIN_CAMERA) { if(orientationValue<=360) ExifInfo.orientation = MAIN_ORIENTATION[orientationValue/90]; else ExifInfo.orientation = 0; getExifInfoFromDriver(&exifobj); strcpy( (char *)&ExifInfo.model, "GT-I8320 M4MO"); int cam_ver = GetCamera_version(); ExifInfo.Camversion[0] = (cam_ver & 0xFF); ExifInfo.Camversion[1] = ((cam_ver >> 8) & 0xFF); //HAL_PRINT("CreateExif GetCamera_version =[%x][%x][%x][%x]\n", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]); sprintf((char *)&ExifInfo.software, "%02X%02X", ExifInfo.Camversion[1], ExifInfo.Camversion[0]); // TODO: get thumbnail offset of m4mo jpeg data // if(mThumbnailWidth > 0 && mThumbnailHeight > 0) // { // ExifInfo.hasThumbnail = true; // ExifInfo.thumbStream = pInThumbnailData; // ExifInfo.thumbSize = Inthumbsize; // ExifInfo.thumbImageWidth = mThumbnailWidth; // ExifInfo.thumbImageHeight = mThumbnailHeight; // } // else { ExifInfo.hasThumbnail = false; } ExifInfo.exposureProgram = 3; ExifInfo.exposureMode = 0; ExifInfo.contrast = convertToExifLMH(getContrast(), 2); ExifInfo.fNumber.numerator = 26; ExifInfo.fNumber.denominator = 10; ExifInfo.aperture.numerator = 26; ExifInfo.aperture.denominator = 10; ExifInfo.maxAperture.numerator = 26; ExifInfo.maxAperture.denominator = 10; ExifInfo.focalLength.numerator = 4610; ExifInfo.focalLength.denominator = 1000; //[ 2010 05 01 exif ExifInfo.shutterSpeed.numerator = exifobj.shutter_speed_numerator; ExifInfo.shutterSpeed.denominator = exifobj.shutter_speed_denominator; ExifInfo.exposureTime.numerator = exifobj.exposure_time_numerator; ExifInfo.exposureTime.denominator = exifobj.exposure_time_denominator; //] ExifInfo.brightness.numerator = exifobj.brigtness_numerator; ExifInfo.brightness.denominator = exifobj.brightness_denominator; ExifInfo.iso = 1; ExifInfo.isoSpeedRating = roundIso(exifobj.iso); // Flash // bit 0 -whether the flash fired // bit 1,2 -status of returned light // bit 3,4 - indicating the camera's flash mode // bit 5 -presence of a flash function // bit 6 - red-eye mode // refer to flash_mode[] at CameraHal.cpp // off = 1 // on = 2 // auto = 3 ExifInfo.flash = exifobj.flash | (mPreviousFlashMode == 3)?(3<<4):0; // default value ExifInfo.whiteBalance = (mPreviousWB <= 1)?0:1; ExifInfo.meteringMode = mPreviousMetering; ExifInfo.saturation = convertToExifLMH(getSaturation(), 2); ExifInfo.sharpness = convertToExifLMH(getSharpness(), 2); ExifInfo.exposureBias.numerator = (getBrightness()-4)*5; ExifInfo.exposureBias.denominator = 10; ExifInfo.sceneCaptureType = mPreviousSceneMode; // ExifInfo.meteringMode = 2; // ExifInfo.whiteBalance = 1; // ExifInfo.saturation = 0; // ExifInfo.sharpness = 0; // ExifInfo.isoSpeedRating = tempISO; // ExifInfo.exposureBias.numerator = 0; // ExifInfo.exposureBias.denominator = 10; // ExifInfo.sceneCaptureType = 4; } else // VGA Camera { if(orientationValue<=360)
int Light::getBrightnessPercent() { return int(getBrightness() / 255.0 * 100); }
int main( int argc, char ** argv ) { struct pci_device * dev; uint8_t val; int newval; int mode; int argp; setuid(0); if( pci_system_init() ) { fprintf( stderr, "ERROR: PCI bus init failed. No root?\n" ); exit( 1 ); } dev = pci_device_find_by_slot( 0, 0, 2, 1 ); if( !isNc10( dev ) ) { fprintf( stderr, "ERROR: This device does not look not like a Samsung NC10.\n" ); exit( 1 ); } mode = 0; argp = 1; switch( argc ) { case 1: mode = 0; break; case 2: if( !strcmp( "-get", argv[argp] ) ) { mode=0; argp++; } else { usage(); exit( 1 ); } break; case 3: if( !strcmp( "-set", argv[argp] ) || !strcmp( "=", argv[argp] ) ) { mode = 1; argp++; } else if( !strcmp( "-inc", argv[argp] ) || !strcmp( "+", argv[argp] ) ) { mode = 2; argp++; } else if( !strcmp( "-dec", argv[argp] ) || !strcmp( "-", argv[argp] ) ) { mode = 3; argp++; } else { usage(); exit( 1 ); } break; default: usage(); exit( 1 ); } switch( mode ) { case 0: /* get */ val = getBrightness( dev ); printf("%d\n", val); break; case 1: /* set */ val = (uint8_t) atoi( argv[argp] ); setBrightness( dev, val ); break; case 2: /* inc */ val = getBrightness( dev ); newval = val + atoi( argv[argp] ); if( newval > 255 ) newval = 255; setBrightness( dev, (uint8_t) newval ); break; case 3: /* dec */ val = getBrightness( dev ); newval = val - atoi( argv[argp] ); if( newval < 0 ) newval = 0; setBrightness( dev, (uint8_t) newval ); break; } pci_system_cleanup(); return 0; }
static void fadeLED(void) { if (_fullLEDMode == 1) { if (pwmDir == 0) setPWM((uint8_t) (getBrightness(pwmCounter / PWM_SPEED))); else if (pwmDir == 2) setPWM((uint8_t) (getBrightness(PWM_MAX - pwmCounter / PWM_SPEED))); else if (pwmDir == 1 || pwmDir == 3) pwmCounter++; // pwmDir 0~3 : idle if (pwmCounter >= PWM_MAX * PWM_SPEED) { pwmCounter = 0; pwmDir = (pwmDir + 1) % 4; } pwmCounter++; } else if (_fullLEDMode == 3) { // 일정시간 유지 if (downLevelStay > 0) { downLevelStay--; } else { // 시간이 흐르면 레벨을 감소 시킨다. if (downLevelLife > 0) { pwmCounter++; if (pwmCounter >= PWM_SPEED) { pwmCounter = 0; downLevelLife--; downLevel = downLevelMax - (PWM_MAX - downLevelLife) / (PWM_MAX / downLevelMax); } } else { downLevel = 0; pwmCounter = 0; } } setPWM((uint8_t) (getBrightness(downLevelLife))); } else if (_fullLEDMode == 4) { // 일정시간 유지 if (downLevelStay > 0) { downLevelStay--; } else { // 시간이 흐르면 레벨을 증가 시킨다. if (downLevelLife < PWM_MAX) { pwmCounter++; if (pwmCounter >= PWM_SPEED) { pwmCounter = 0; downLevelLife++; downLevel = downLevelMax - (PWM_MAX - downLevelLife) / (PWM_MAX / downLevelMax); } } else { downLevel = downLevelMax; pwmCounter = 0; } } setPWM((uint8_t) (getBrightness(downLevelLife))); } else { pwmCounter = 0; pwmDir = 3; } }
bool LEDControl::toggleState() { if (m_useGStreamer) { if ( m_isOn ) { // turn off gst_element_set_state(pipeline, GST_STATE_NULL); setOnBool(!m_isOn); } else { // turn on gst_element_set_state(pipeline, GST_STATE_PLAYING); setOnBool(!m_isOn); } } else { if ( !m_isValid ) return 1; QString data; if ( m_isOn ) { // turn off data = QString::number(0); } else { // turn on data = getBrightness(); } if ( !file.exists() ) { qDebug() << "file does not exist"; return 1; } QFile ledFile(file.fileName()); if ( !ledFile.open(QFile::WriteOnly) ) { qDebug() << "can not open file"; return 1; } QTextStream stream(&ledFile); stream << data; stream.flush(); QTextStream::Status status = stream.status(); ledFile.close(); // check that the write succeeded before changing the state of led boolean if ( status != QTextStream::Ok ) { qDebug() << "error writing to file"; return 1; } // toggle the boolean using the setOnBool method, which will emit a signal and change the qml property setOnBool(!m_isOn); } return 0; }
bool MMSLabelWidget::draw(bool *backgroundFilled) { int width, height, x, y; bool myBackgroundFilled = false; if(!surface) return false; if (backgroundFilled) { if (this->has_own_surface) *backgroundFilled = false; } else backgroundFilled = &myBackgroundFilled; // lock this->surface->lock(); // draw widget basics if (MMSWidget::draw(backgroundFilled)) { // draw my things if (prepareText(&width, &height)) { // text is translated and font is set MMSFBRectangle surfaceGeom = getSurfaceGeometry(); // save the width of the text this->slide_width = width; switch ((!this->swap_left_right) ? getAlignment() : swapAlignmentHorizontal(getAlignment())) { case MMSALIGNMENT_LEFT: x = surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; case MMSALIGNMENT_TOP_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = surfaceGeom.y; break; case MMSALIGNMENT_TOP_LEFT: x = surfaceGeom.x; y = surfaceGeom.y; break; case MMSALIGNMENT_TOP_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = surfaceGeom.y; break; case MMSALIGNMENT_BOTTOM_CENTER: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = surfaceGeom.y + surfaceGeom.h - height; break; case MMSALIGNMENT_BOTTOM_LEFT: x = surfaceGeom.x; y = surfaceGeom.y + surfaceGeom.h - height; break; case MMSALIGNMENT_BOTTOM_RIGHT: x = surfaceGeom.x + surfaceGeom.w - width; y = surfaceGeom.y + surfaceGeom.h - height; break; default: x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x; y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y; break; } // get color MMSFBColor color; getForeground(&color); this->current_fgcolor = color; this->current_fgset = true; if (color.a) { // prepare for drawing this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity( color, (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM), (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT), (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT), (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT), getBrightness(), getOpacity()); // draw the text this->surface->drawString(this->translated_text, -1, x - this->slide_offset, y); } } // update window surface with an area of surface updateWindowSurfaceWithSurface(!*backgroundFilled); } // unlock this->surface->unlock(); // draw widgets debug frame return MMSWidget::drawDebug(); }
// enable/disable segment void SEVENSEGHW::setSegmentStatus(unsigned int enabled) { REGISTER( IO_SLOT(wishboneSlot), 0 ) = enabled & 0xF | (getBrightness() << 4); }
void Mushroom::lowerHealth() { m_health--; //decrement health setBrightness(getBrightness()-0.25); //decrement brightness accordingly }
bool Menu::handleEvent(StartMenuAction action, Common::EventType type) { bool clicked = (type == Common::EVENT_LBUTTONUP); switch(action) { default: hideOverlays(); break; ////////////////////////////////////////////////////////////////////////// case kMenuCredits: if (hasTimeDelta()) { hideOverlays(); break; } if (clicked) { showFrame(kOverlayEggButtons, kButtonCreditsPushed, true); showFrame(kOverlayTooltip, -1, true); getSound()->playSound(kEntityPlayer, "LIB046"); hideOverlays(); _isShowingCredits = true; _creditsSequenceIndex = 0; showFrame(kOverlayCredits, 0, true); } else { // TODO check flags ? showFrame(kOverlayEggButtons, kButtonCredits, true); showFrame(kOverlayTooltip, kTooltipCredits, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuQuitGame: showFrame(kOverlayTooltip, kTooltipQuit, true); if (clicked) { showFrame(kOverlayButtons, kButtonQuitPushed, true); getSound()->clearStatus(); getSound()->updateQueue(); getSound()->playSound(kEntityPlayer, "LIB046"); // FIXME uncomment when sound queue is properly implemented /*while (getSound()->isBuffered("LIB046")) getSound()->updateQueue();*/ getFlags()->shouldRedraw = false; Engine::quitGame(); return false; } else { showFrame(kOverlayButtons, kButtonQuit, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuCase4: if (clicked) _index = 0; // fall down to kMenuContinue ////////////////////////////////////////////////////////////////////////// case kMenuContinue: { if (hasTimeDelta()) { hideOverlays(); break; } // Determine the proper CD archive ArchiveIndex cd = kArchiveCd1; if (getProgress().chapter > kChapter1) cd = (getProgress().chapter > kChapter3) ? kArchiveCd3 : kArchiveCd2; // Show tooltips & buttons to start a game, continue a game or load the proper cd if (ResourceManager::isArchivePresent(cd)) { if (_isGameStarted) { showFrame(kOverlayEggButtons, kButtonContinue, true); if (_lastIndex == _index) { showFrame(kOverlayTooltip, getSaveLoad()->isGameFinished(_index, _lastIndex) ? kTooltipViewGameEnding : kTooltipContinueGame, true); } else { showFrame(kOverlayTooltip, kTooltipContinueRewoundGame, true); } } else { showFrame(kOverlayEggButtons, kButtonShield, true); showFrame(kOverlayTooltip, kTooltipPlayNewGame, true); } } else { showFrame(kOverlayEggButtons, -1, true); showFrame(kOverlayTooltip, cd - 1, true); } if (!clicked) break; // Try loading the archive file if (!_engine->getResourceManager()->loadArchive(cd)) break; // Load the train data file and setup game getScenes()->loadSceneDataFile(cd); showFrame(kOverlayTooltip, -1, true); getSound()->playSound(kEntityPlayer, "LIB046"); // Setup new game getSavePoints()->reset(); setLogicEventHandlers(); if (_index) { getSound()->processEntry(SoundManager::kSoundType11); } else { if (!getFlags()->mouseRightClick) { getScenes()->loadScene((SceneIndex)(5 * _gameId + 3)); if (!getFlags()->mouseRightClick) { getScenes()->loadScene((SceneIndex)(5 * _gameId + 4)); if (!getFlags()->mouseRightClick) { getScenes()->loadScene((SceneIndex)(5 * _gameId + 5)); if (!getFlags()->mouseRightClick) { getSound()->processEntry(SoundManager::kSoundType11); // Show intro Animation animation; if (animation.load(getArchive("1601.nis"))) animation.play(); getEvent(kEventIntro) = 1; } } } } if (!getEvent(kEventIntro)) { getEvent(kEventIntro) = 1; getSound()->processEntry(SoundManager::kSoundType11); } } // Setup game getFlags()->isGameRunning = true; startGame(); if (!_isShowingMenu) getInventory()->show(); return false; } ////////////////////////////////////////////////////////////////////////// case kMenuSwitchSaveGame: if (hasTimeDelta()) { hideOverlays(); break; } if (clicked) { showFrame(kOverlayAcorn, 1, true); showFrame(kOverlayTooltip, -1, true); getSound()->playSound(kEntityPlayer, "LIB047"); // Setup new menu screen switchGame(); setup(); // Set fight state to 0 getFight()->resetState(); return true; } // TODO Check for flag showFrame(kOverlayAcorn, 0, true); if (_isGameStarted) { showFrame(kOverlayTooltip, kTooltipSwitchBlueGame, true); break; } if (_gameId == kGameGold) { showFrame(kOverlayTooltip, kTooltipSwitchBlueGame, true); break; } if (!SaveLoad::isSavegameValid(getNextGameId())) { showFrame(kOverlayTooltip, kTooltipStartAnotherGame, true); break; } // Stupid tooltips ids are not in order, so we can't just increment them... switch(_gameId) { default: break; case kGameBlue: showFrame(kOverlayTooltip, kTooltipSwitchRedGame, true); break; case kGameRed: showFrame(kOverlayTooltip, kTooltipSwitchGreenGame, true); break; case kGameGreen: showFrame(kOverlayTooltip, kTooltipSwitchPurpleGame, true); break; case kGamePurple: showFrame(kOverlayTooltip, kTooltipSwitchTealGame, true); break; case kGameTeal: showFrame(kOverlayTooltip, kTooltipSwitchGoldGame, true); break; } break; ////////////////////////////////////////////////////////////////////////// case kMenuRewindGame: if (!_index || _currentTime < _time) { hideOverlays(); break; } if (clicked) { if (hasTimeDelta()) _handleTimeDelta = false; showFrame(kOverlayEggButtons, kButtonRewindPushed, true); showFrame(kOverlayTooltip, -1, true); getSound()->playSound(kEntityPlayer, "LIB046"); rewindTime(); _handleTimeDelta = false; } else { showFrame(kOverlayEggButtons, kButtonRewind, true); showFrame(kOverlayTooltip, kTooltipRewind, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuForwardGame: if (_lastIndex <= _index || _currentTime > _time) { hideOverlays(); break; } if (clicked) { if (hasTimeDelta()) _handleTimeDelta = false; showFrame(kOverlayEggButtons, kButtonForwardPushed, true); showFrame(kOverlayTooltip, -1, true); getSound()->playSound(kEntityPlayer, "LIB046"); forwardTime(); _handleTimeDelta = false; } else { showFrame(kOverlayEggButtons, kButtonForward, true); showFrame(kOverlayTooltip, kTooltipFastForward, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuParis: moveToCity(kParis, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuStrasBourg: moveToCity(kStrasbourg, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuMunich: moveToCity(kMunich, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuVienna: moveToCity(kVienna, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuBudapest: moveToCity(kBudapest, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuBelgrade: moveToCity(kBelgrade, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuConstantinople: moveToCity(kConstantinople, clicked); break; ////////////////////////////////////////////////////////////////////////// case kMenuDecreaseVolume: if (hasTimeDelta()) { hideOverlays(); break; } // Cannot decrease volume further if (getVolume() == 0) { showFrame(kOverlayButtons, kButtonVolume, true); showFrame(kOverlayTooltip, -1, true); break; } showFrame(kOverlayTooltip, kTooltipVolumeDown, true); // Show highlight on button & adjust volume if needed if (clicked) { showFrame(kOverlayButtons, kButtonVolumeDownPushed, true); getSound()->playSound(kEntityPlayer, "LIB046"); setVolume(getVolume() - 1); getSaveLoad()->saveVolumeBrightness(); uint32 nextFrameCount = getFrameCount() + 15; while (nextFrameCount > getFrameCount()) { _engine->pollEvents(); getSound()->updateQueue(); } } else { showFrame(kOverlayButtons, kButtonVolumeDown, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuIncreaseVolume: if (hasTimeDelta()) { hideOverlays(); break; } // Cannot increase volume further if (getVolume() >= 7) { showFrame(kOverlayButtons, kButtonVolume, true); showFrame(kOverlayTooltip, -1, true); break; } showFrame(kOverlayTooltip, kTooltipVolumeUp, true); // Show highlight on button & adjust volume if needed if (clicked) { showFrame(kOverlayButtons, kButtonVolumeUpPushed, true); getSound()->playSound(kEntityPlayer, "LIB046"); setVolume(getVolume() + 1); getSaveLoad()->saveVolumeBrightness(); uint32 nextFrameCount = getFrameCount() + 15; while (nextFrameCount > getFrameCount()) { _engine->pollEvents(); getSound()->updateQueue(); } } else { showFrame(kOverlayButtons, kButtonVolumeUp, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuDecreaseBrightness: if (hasTimeDelta()) { hideOverlays(); break; } // Cannot increase brightness further if (getBrightness() == 0) { showFrame(kOverlayButtons, kButtonBrightness, true); showFrame(kOverlayTooltip, -1, true); break; } showFrame(kOverlayTooltip, kTooltipBrightnessDown, true); // Show highlight on button & adjust brightness if needed if (clicked) { showFrame(kOverlayButtons, kButtonBrightnessDownPushed, true); getSound()->playSound(kEntityPlayer, "LIB046"); setBrightness(getBrightness() - 1); getSaveLoad()->saveVolumeBrightness(); // Reshow the background and frames (they will pick up the new brightness through the GraphicsManager) _engine->getGraphicsManager()->draw(getScenes()->get((SceneIndex)(_isGameStarted ? _gameId * 5 + 1 : _gameId * 5 + 2)), GraphicsManager::kBackgroundC, true); showFrame(kOverlayTooltip, kTooltipBrightnessDown, false); showFrame(kOverlayButtons, kButtonBrightnessDownPushed, false); } else { showFrame(kOverlayButtons, kButtonBrightnessDown, true); } break; ////////////////////////////////////////////////////////////////////////// case kMenuIncreaseBrightness: if (hasTimeDelta()) { hideOverlays(); break; } // Cannot increase brightness further if (getBrightness() >= 6) { showFrame(kOverlayButtons, kButtonBrightness, true); showFrame(kOverlayTooltip, -1, true); break; } showFrame(kOverlayTooltip, kTooltipBrightnessUp, true); // Show highlight on button & adjust brightness if needed if (clicked) { showFrame(kOverlayButtons, kButtonBrightnessUpPushed, true); getSound()->playSound(kEntityPlayer, "LIB046"); setBrightness(getBrightness() + 1); getSaveLoad()->saveVolumeBrightness(); // Reshow the background and frames (they will pick up the new brightness through the GraphicsManager) _engine->getGraphicsManager()->draw(getScenes()->get((SceneIndex)(_isGameStarted ? _gameId * 5 + 1 : _gameId * 5 + 2)), GraphicsManager::kBackgroundC, true); showFrame(kOverlayTooltip, kTooltipBrightnessUp, false); showFrame(kOverlayButtons, kButtonBrightnessUpPushed, false); } else { showFrame(kOverlayButtons, kButtonBrightnessUp, true); } break; } return true; }
int GStreamerPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 13) qt_static_metacall(this, _c, _id, _a); _id -= 13; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 13) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 13; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getBrightness(); break; case 1: *reinterpret_cast< int*>(_v) = getContrast(); break; case 2: *reinterpret_cast< int*>(_v) = getHue(); break; case 3: *reinterpret_cast< int*>(_v) = getSaturation(); break; case 4: *reinterpret_cast< bool*>(_v) = getPlaying(); break; case 5: *reinterpret_cast< bool*>(_v) = getPaused(); break; case 6: *reinterpret_cast< bool*>(_v) = getStopped(); break; default: break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setBrightness(*reinterpret_cast< int*>(_v)); break; case 1: setContrast(*reinterpret_cast< int*>(_v)); break; case 2: setHue(*reinterpret_cast< int*>(_v)); break; case 3: setSaturation(*reinterpret_cast< int*>(_v)); break; case 4: setPlaying(*reinterpret_cast< bool*>(_v)); break; case 5: setPaused(*reinterpret_cast< bool*>(_v)); break; case 6: setStopped(*reinterpret_cast< bool*>(_v)); break; default: break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 7) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
bool Light::isOn() { return getBrightness() == 255; }
BOOLEAN setupDevice(Device device) { BOOLEAN change; fprintf(stdout, "- Seting up device %p\n", device); /* check (again) for a valid device */ if (!(device->vcapability.type & VID_TYPE_CAPTURE)) { fprintf(stdout, " * The device can't capture video\n"); return FALSE; } if (device->vcapability.channels == 0) { fprintf(stdout, " * The device hasn't inputs\n"); return FALSE; } /* ---------------------------------------------------------------------- */ /* let's try to change the capture width & height */ change = FALSE; if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) { perror("VIDIOCGWIN1"); return FALSE; } if (device->desiredWidth && (device->vwindow.width != device->desiredWidth)) { fprintf(stdout, " - Changing the width from %d to %d\n", device->vwindow.width, device->desiredWidth); device->vwindow.width = device->desiredWidth; change = TRUE; } if (device->desiredHeight && (device->vwindow.height != device->desiredHeight)) { fprintf(stdout, " - Changing the height from %d to %d\n", device->vwindow.height, device->desiredHeight); device->vwindow.height = device->desiredHeight; change = TRUE; } if (change) { if (EINTR_RETRY(xioctl(device->fd, VIDIOCSWIN, &device->vwindow)) < 0) { perror("VIDIOCGWIN2"); return FALSE; } if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) { perror("VIDIOCGWIN3"); return FALSE; } if (device->desiredWidth != device->vwindow.width) { fprintf(stdout, " * The device can't change the capture width (now=%d)\n", device->vwindow.width); return FALSE; } if (device->desiredHeight != device->vwindow.height) { fprintf(stdout, " * The device can't change the capture height (now=%d)\n", device->vwindow.height); return FALSE; } } fprintf(stdout, " - Extent=%d@%d\n", device->vwindow.width, device->vwindow.height); if (EINTR_RETRY(xioctl(device->fd, VIDIOCGPICT, &device->vpicture)) < 0) { perror("VIDIOCGPICT"); return FALSE; } fprintf(stdout, " - Brightness=%d, Contrast=%d, Saturation=%d, Hue=%d\n", getBrightness(device), getContrast(device), getSaturation(device), getHue(device)); /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ if (!setupPalette(device)) { return FALSE; } /* ---------------------------------------------------------------------- */ device->imageSize = (int) device->vwindow.width * device->vwindow.height * (paletteBytesPerPixel(device->vpicture.palette)); device->buffer24 = (char*) malloc(device->vwindow.width * device->vwindow.height * 3); if (device->forceRead) { fprintf(stdout, " - Capturing using (forced) read()\n"); if (!switchToRead(device)) { return FALSE; } } else { setupMMap(device); if (device->usingMMap) { fprintf(stdout, " - Capturing using mmap()\n"); if (!startCaptureInBuffers(device)) { fprintf(stdout, " * Falling back to read()\n"); if (!switchToRead(device)) { return FALSE; } } } else { fprintf(stdout, " - Capturing using read()\n"); if (!switchToRead(device)) { return FALSE; } } } return TRUE; }
bool Light::isOff() { return getBrightness() == 0; }