static Bool mateInit (CompPlugin *p) { if (getCoreABI() != CORE_ABIVERSION) { compLogMessage ("matecompat", CompLogLevelError, "ABI mismatch\n" "\tPlugin was compiled with ABI: %d\n" "\tFusilli Core was compiled with ABI: %d\n", CORE_ABIVERSION, getCoreABI()); return FALSE; } displayPrivateIndex = allocateDisplayPrivateIndex (); if (displayPrivateIndex < 0) return FALSE; bananaIndex = bananaLoadPlugin ("matecompat"); if (bananaIndex == -1) return FALSE; bananaAddChangeNotifyCallBack (bananaIndex, mateChangeNotify); const BananaValue * option_main_menu_key = bananaGetOption (bananaIndex, "main_menu_key", -1); const BananaValue * option_run_key = bananaGetOption (bananaIndex, "run_key", -1); const BananaValue * option_run_command_screenshot_key = bananaGetOption (bananaIndex, "run_command_screenshot_key", -1); const BananaValue * option_run_command_window_screenshot_key = bananaGetOption (bananaIndex, "run_command_window_screenshot_key", -1); const BananaValue * option_run_command_terminal_key = bananaGetOption (bananaIndex, "run_command_terminal_key", -1); registerKey (option_main_menu_key->s, &main_menu_key); registerKey (option_run_key->s, &run_key); registerKey (option_run_command_screenshot_key->s, &run_command_screenshot_key); registerKey (option_run_command_window_screenshot_key->s, &run_command_window_screenshot_key); registerKey (option_run_command_terminal_key->s, &run_command_terminal_key); return TRUE; }
static Bool snowInitDisplay (CompPlugin *p, CompDisplay *d) { SnowDisplay *sd; sd = malloc (sizeof (SnowDisplay)); if (!sd) return FALSE; sd->screenPrivateIndex = allocateScreenPrivateIndex (); if (sd->screenPrivateIndex < 0) { free (sd); return FALSE; } const BananaValue * option_toggle_key = bananaGetOption (bananaIndex, "toggle_key", -1); registerKey (option_toggle_key->s, &sd->toggle_key); WRAP (sd, d, handleEvent, snowHandleEvent); d->privates[displayPrivateIndex].ptr = sd; return TRUE; }
static Bool colorFilterInitDisplay (CompPlugin *p, CompDisplay *d) { ColorFilterDisplay *cfd; cfd = malloc (sizeof (ColorFilterDisplay)); if (!cfd) return FALSE; cfd->screenPrivateIndex = allocateScreenPrivateIndex (); if (cfd->screenPrivateIndex < 0) { free (cfd); return FALSE; } WRAP (cfd, d, handleEvent, colorFilterHandleEvent); const BananaValue * option_toggle_window_key = bananaGetOption (bananaIndex, "toggle_window_key", -1); registerKey (option_toggle_window_key->s, &cfd->toggle_window_key); const BananaValue * option_toggle_screen_key = bananaGetOption (bananaIndex, "toggle_screen_key", -1); registerKey (option_toggle_screen_key->s, &cfd->toggle_screen_key); const BananaValue * option_switch_filter_key = bananaGetOption (bananaIndex, "switch_filter_key", -1); registerKey (option_switch_filter_key->s, &cfd->switch_filter_key); d->privates[displayPrivateIndex].ptr = cfd; return TRUE; }
int main(int argc, char *args[]) { int eaten = 0; srand (time(NULL)); printf("Start test...\n"); initEngine(0, 0, boardwidth, boardlength, color(255,255,255), fps, &renderBoard); init_snake(); newapple(); registerKey(&keydown); while(stepEngine() && end == false){ for(int i = 1; i < snake.digit+1; i++){ snake.xpos[i] = snake.xpos[i - 1]-(snake.xdir[i - 1]) * blockwidth; snake.ypos[i] = snake.ypos[i - 1]-(snake.ydir[i - 1]) * blocklength; } if(snake.xdir[head] != snake.xdir[head+1] || snake.ydir[head] != snake.ydir[head+1]){ for(int i = 1; i < snake.digit+1; i++){ snake.xdir[i] = snake.xdir[i - 1]; snake.ydir[i] = snake.ydir[i - 1]; } } snake.xpos[head] = snake.xpos[head] + (snake.xdir[head])*vel; snake.ypos[head] = snake.ypos[head] + (snake.ydir[head])*vel; if(iswall()){ stop(); } if(eatapple()){ newapple(); addtosnake(); eaten++; } // printf("snake.digit:%d\n",snake.digit); printf("head.xpos %d head.ypos: %d\n",snake.xpos[head],snake.ypos[head]); for(int i = 1; i < snake.digit+1; i++){ printf("digit(%d).xpos: %d digit(%d).ypos: %d xdir: %d ydir: %d\n",i,snake.xpos[i],i,snake.ypos[i],snake.xdir[i],snake.ydir[i]); } } printf("Eaten: %d\n", eaten); printf("Closing program...\n"); obliterate(); return 0; }
int main(int argc, char *args[]) { printf("Start test...\n"); initEngine(0, 0, boardwidth, boardlength, color(255,255,255), fps, &renderBoard); registerKey(&keydown); while(stepEngine()){ time += 1; // time = time/60; printf("time: %1d xpos: %1d ypos: %1d velocity: %1d\n",time,xpos,ypos,velocity); } printf("Closing program...\n"); obliterate(); return 0; }
static Bool opacifyInitDisplay (CompPlugin *p, CompDisplay *d) { OpacifyDisplay *od; od = malloc (sizeof (OpacifyDisplay)); if (!od) return FALSE; od->screenPrivateIndex = allocateScreenPrivateIndex (); if (od->screenPrivateIndex < 0) { free (od); return FALSE; } d->privates[displayPrivateIndex].ptr = od; od->timeoutHandle = 0; od->activeScreen = d->screens->screenNum; const BananaValue * option_init_toggle = bananaGetOption (bananaIndex, "init_toggle", -1); od->toggle = option_init_toggle->b; const BananaValue * option_toggle_key = bananaGetOption (bananaIndex, "toggle_key", -1); registerKey (option_toggle_key->s, &od->toggle_key); WRAP (od, d, handleEvent, opacifyHandleEvent); return TRUE; }
/* * groupInitDisplay * */ static Bool groupInitDisplay (CompPlugin *p, CompDisplay *d) { GroupDisplay *gd; gd = malloc (sizeof (GroupDisplay)); if (!gd) return FALSE; gd->screenPrivateIndex = allocateScreenPrivateIndex (); if (gd->screenPrivateIndex < 0) { free (gd); return FALSE; } gd->glowTextureProperties = (GlowTextureProperties*) glowTextureProperties; gd->ignoreMode = FALSE; gd->lastRestackedGroup = NULL; gd->resizeInfo = NULL; gd->groupWinPropertyAtom = XInternAtom (d->display, "_COMPIZ_GROUP", 0); gd->resizeNotifyAtom = XInternAtom (d->display, "_COMPIZ_RESIZE_NOTIFY", 0); WRAP (gd, d, handleEvent, groupHandleEvent); const BananaValue * option_select_button = bananaGetOption (bananaIndex, "select_button", -1); registerButton (option_select_button->s, &gd->select_button); const BananaValue * option_select_single_key = bananaGetOption (bananaIndex, "select_single_key", -1); registerKey (option_select_single_key->s, &gd->select_single_key); const BananaValue * option_group_key = bananaGetOption (bananaIndex, "group_key", -1); registerKey (option_group_key->s, &gd->group_key); const BananaValue * option_ungroup_key = bananaGetOption (bananaIndex, "ungroup_key", -1); registerKey (option_ungroup_key->s, &gd->ungroup_key); const BananaValue * option_remove_key = bananaGetOption (bananaIndex, "remove_key", -1); registerKey (option_remove_key->s, &gd->remove_key); const BananaValue * option_close_key = bananaGetOption (bananaIndex, "close_key", -1); registerKey (option_close_key->s, &gd->close_key); const BananaValue * option_ignore_key = bananaGetOption (bananaIndex, "ignore_key", -1); registerKey (option_ignore_key->s, &gd->ignore_key); const BananaValue * option_tabmode_key = bananaGetOption (bananaIndex, "tabmode_key", -1); registerKey (option_tabmode_key->s, &gd->tabmode_key); const BananaValue * option_change_tab_left_key = bananaGetOption (bananaIndex, "change_tab_left_key", -1); registerKey (option_change_tab_left_key->s, &gd->change_tab_left_key); const BananaValue * option_change_tab_right_key = bananaGetOption (bananaIndex, "change_tab_right_key", -1); registerKey (option_change_tab_right_key->s, &gd->change_tab_right_key); const BananaValue * option_change_color_key = bananaGetOption (bananaIndex, "change_color_key", -1); registerKey (option_change_color_key->s, &gd->change_color_key); d->privates[displayPrivateIndex].ptr = gd; srand (time (NULL)); return TRUE; }
static Bool gridInitDisplay (CompPlugin *p, CompDisplay *d) { GridDisplay *gd; gd = malloc (sizeof (GridDisplay)); if (!gd) return FALSE; WRAP (gd, d, handleEvent, gridHandleEvent); const BananaValue * option_put_center_key = bananaGetOption (bananaIndex, "put_center_key", -1); registerKey (option_put_center_key->s, &gd->put_center_key); const BananaValue * option_put_left_key = bananaGetOption (bananaIndex, "put_left_key", -1); registerKey (option_put_left_key->s, &gd->put_left_key); const BananaValue * option_put_right_key = bananaGetOption (bananaIndex, "put_right_key", -1); registerKey (option_put_right_key->s, &gd->put_right_key); const BananaValue * option_put_top_key = bananaGetOption (bananaIndex, "put_top_key", -1); registerKey (option_put_top_key->s, &gd->put_top_key); const BananaValue * option_put_bottom_key = bananaGetOption (bananaIndex, "put_bottom_key", -1); registerKey (option_put_bottom_key->s, &gd->put_bottom_key); const BananaValue * option_put_topleft_key = bananaGetOption (bananaIndex, "put_topleft_key", -1); registerKey (option_put_topleft_key->s, &gd->put_topleft_key); const BananaValue * option_put_topright_key = bananaGetOption (bananaIndex, "put_topright_key", -1); registerKey (option_put_topright_key->s, &gd->put_topright_key); const BananaValue * option_put_bottomleft_key = bananaGetOption (bananaIndex, "put_bottomleft_key", -1); registerKey (option_put_bottomleft_key->s, &gd->put_bottomleft_key); const BananaValue * option_put_bottomright_key = bananaGetOption (bananaIndex, "put_bottomright_key", -1); registerKey (option_put_bottomright_key->s, &gd->put_bottomright_key); d->privates[displayPrivateIndex].ptr = gd; return TRUE; }
void createKeyboardMap() { startKeyboardMap(); { startKeyboardGroup(KEYBOARD_GROUP_PRESETS); { registerKey('`', getPresetName(0), setPreset, 0); registerKey('1', getPresetName(1), setPreset, 1); registerKey('2', getPresetName(2), setPreset, 2); registerKey('3', getPresetName(3), setPreset, 3); registerKey('4', getPresetName(4), setPreset, 4); registerKey('5', getPresetName(5), setPreset, 5); registerKey('6', getPresetName(6), setPreset, 6); registerKey('7', getPresetName(7), setPreset, 7); registerKey('8', getPresetName(8), setPreset, 8); registerKey('9', getPresetName(9), setPreset, 9); registerKey('0', getPresetName(10), setPreset, 10); registerKey('-', getPresetName(11), setPreset, 11); registerKey('=', getPresetName(12), setPreset, 12); } endKeyboardGroup(); startKeyboardGroup(KEYBOARD_GROUP_DEVICE); { registerKey('m', "Mirror on/off", toggleMirror, 0); registerKey('/', "Reset all croppings", resetAllCropping, 0); } endKeyboardGroup(); startKeyboardGroup(KEYBOARD_GROUP_CAPTURE); { registerKey('s', "Start", startCapture, 0); registerKey('d', "Start (5 sec delay)", startCapture, 5); registerKey('x', "Stop", captureStop, 0); registerKey('c', "Capture current frame only", captureSingleFrame, 0); } endKeyboardGroup(); startKeyboardGroup(KEYBOARD_GROUP_DISPLAY); { registerKey('p', "Pointer Mode On/Off", togglePointerMode, 0); registerKey('f', "Full Screen On/Off", toggleFullScreen, 0); registerKey('?', "Show/Hide Help screen", toggleHelpScreen, 0); } endKeyboardGroup(); startKeyboardGroup(KEYBOARD_GROUP_GENERAL); { registerKey('z', "Start/Stop Collecting Statistics", toggleStatistics, 0); registerKey('?', "Show/Hide help screen", toggleHelpScreen, 0); registerKey(27, "Exit", closeSample, ERR_OK); } endKeyboardGroup(); startKeyboardGroup(KEYBOARD_GROUP_PLAYER); { registerKey('o', "Pause/Resume", togglePause, 0); registerKey('l', "Jump 1 frame forward", seek, 1); registerKey('L', "Jump 10 frames forward", seek, 10); registerKey('k', "Jump 1 frame backwards", seek, -1); registerKey('K', "Jump 10 frames backwards", seek, -10); registerKey(';', "Read one frame", step, 0); registerKey('[', "Decrease playback speed", setPlaybackSpeed, -1); registerKey(']', "Increase playback speed", setPlaybackSpeed, 1); } endKeyboardGroup(); } endKeyboardMap(); }
RaspiLcdWidget::RaspiLcdWidget( QWidget *parent ) : QWidget(parent) , m_image(128,64,QImage::Format_Mono) , m_keyPressed(eKeyNone) { QRgb value; value = m_background.rgb(); m_image.setColor(0, value); value = QColor(Qt::black).rgb(); m_image.setColor(1, value); QRadioButton *butA = new QRadioButton(this); butA->move(24+marginx,160+marginy); butA->setCheckable(false); registerKey(butA,eKeyA); QRadioButton *butB = new QRadioButton(this); butB->move(120+marginx,160+marginy); butB->setCheckable(false); registerKey(butB,eKeyB); QRadioButton *butC = new QRadioButton(this); butC->move(216+marginx,160+marginy); butC->setCheckable(false); registerKey(butC,eKeyC); QRadioButton *butD = new QRadioButton(this); butD->move(300+marginx,160+marginy); butD->setCheckable(false); registerKey(butD,eKeyD); QRadioButton *butUp = new QRadioButton(this); butUp->move(300+marginx,10+marginy); butUp->setCheckable(false); registerKey(butUp,eKeyUp); QRadioButton *butDown = new QRadioButton(this); butDown->move(300+marginx,96+marginy); butDown->setCheckable(false); registerKey(butDown,eKeyDown); resize(350+2*marginx,200+2*marginy); startTimer(100); }