void buttonUp(int buttonNo, int modifiers) { ButtonEvent evt; evt.button = buttonNo; evt.position = Point(mLastX, mLastY); setModifiers(evt.modifiers, modifiers); mApp.buttonUp(evt); }
void KeySequence::loadSettings(QSettings& settings) { sequence().clear(); int num = settings.beginReadArray("keys"); for (int i = 0; i < num; i++) { settings.setArrayIndex(i); sequence().append(settings.value("key", 0).toInt()); } settings.endArray(); setModifiers(0); setValid(true); }
void KeyTracker::keyEvent(QKeyEvent *event) { switch (event->type()) { case QEvent::KeyPress: pressKey(event->key()); setModifiers(event->modifiers()); break; case QEvent::KeyRelease: releaseKey(event->key()); break; default: break; } }
int main(int argc, char *argv[]) { struttura str; str.display = XOpenDisplay(0); int i; int keycodemap[LENB*7+LENB1+LENB5+LENB0]={ XK_1,XK_quoteright,XK_period,XK_question,XK_exclam,XK_comma,XK_colon, XK_semicolon,34,XK_asciicircum,XK_underscore,XK_bar,XK_percent, XK_ampersand,64,35,XK_dollar,/*1.?!,:;"^_|%&@#$*/ XK_a,XK_b,XK_c,XK_agrave,XK_2,/* a,b,c,à,2*/ XK_d,XK_e,XK_f,XK_egrave,XK_3,/* d,e,f,è,3*/ XK_g,XK_h,XK_i,XK_igrave,XK_4,/* g,h,i,ì,4*/ XK_j,XK_k,XK_l,XK_5, /* j,j,l,5 */ XK_m,XK_n,XK_o,XK_ograve,XK_6,/* m,n,o,ò,6*/ XK_p,XK_q,XK_r,XK_s,XK_7, /* p,q,r,s,7*/ XK_t,XK_u,XK_v,XK_ugrave,XK_8,/* t,u,v,ù,8*/ XK_w,XK_x,XK_y,XK_z,XK_9, /* w,x,y,z,9*/ XK_0,XK_equal,XK_asterisk,XK_plus,XK_minus,XK_slash,XK_backslash,XK_less, XK_greater,XK_parenleft,XK_parenright,91,93, 123,125/*0=*+-/\<>()[]{}*/ }; int sup,rest; str.indexSimbol=0;//semplice inizzializzazione str.modifier=0;//semplice inizzializzazione str.specialKey=0;//semplice inizzializzazione str.listButton[1].simbol=setListButton(LENB1,keycodemap,str.listButton[1]); for(i=2,sup=LENB1;i<=4;i++,sup+=LENB) str.listButton[i].simbol=setListButton(LENB,keycodemap+sup,str.listButton[i]); str.listButton[5].simbol=setListButton(LENB5,keycodemap+sup,str.listButton[5]); for(i++,sup+=LENB5;i<=9;i++,sup+=LENB) str.listButton[i].simbol=setListButton(LENB,keycodemap+sup,str.listButton[i]); str.listButton[0].simbol=setListButton(LENB0,keycodemap+sup,str.listButton[0]); setModifiers(str.modifiers); //t9 pthread_t t9_thread; str.tp.flagcaricat9=0; rest = pthread_create(&t9_thread, NULL, thfilet9,(void *)&str); if (rest != 0) { printf("\nerrore partenza thread del T9"); exit(EXIT_FAILURE); } str.tp.luncodicet9=0; str.tp.statot9=0; str.tp.codicet9[0]=0; str.move.position_height=0; str.move.position_width=0; str.ins.on=0; str.ins.index=0; str.ins.key_numbers[0]=0; // Get the root window for the current display. str.winRoot = XDefaultRootWindow(str.display); //system("export MALLOC_CHECK_=0"); gtk_init (NULL,NULL); finestra(&str); finestra2(&str); gtk_main(); XCloseDisplay(str.display); return 0; }
GoIntegralType::GoIntegralType(uint type) : IntegralType(createData<GoIntegralType>()) { setDataType(type); setModifiers(ConstModifier); }
PuglStatus puglProcessEvents(PuglView* view) { XEvent event; while (XPending(view->impl->display) > 0) { XNextEvent(view->impl->display, &event); if (x_fib_handle_events(view->impl->display, &event)) { const int status = x_fib_status(); if (status > 0) { char* const filename = x_fib_filename(); x_fib_close(view->impl->display); if (view->fileSelectedFunc) { view->fileSelectedFunc(view, filename); } free(filename); } else if (status < 0) { x_fib_close(view->impl->display); if (view->fileSelectedFunc) { view->fileSelectedFunc(view, NULL); } } break; } if (event.xany.window != view->impl->win) { continue; } switch (event.type) { case MapNotify: puglReshape(view, view->width, view->height); break; case ConfigureNotify: if ((event.xconfigure.width != view->width) || (event.xconfigure.height != view->height)) { puglReshape(view, event.xconfigure.width, event.xconfigure.height); } break; case Expose: if (event.xexpose.count != 0) { break; } puglDisplay(view); break; case MotionNotify: setModifiers(view, event.xmotion.state, event.xmotion.time); if (view->motionFunc) { view->motionFunc(view, event.xmotion.x, event.xmotion.y); } break; case ButtonPress: setModifiers(view, event.xbutton.state, event.xbutton.time); if (event.xbutton.button >= 4 && event.xbutton.button <= 7) { if (view->scrollFunc) { float dx = 0, dy = 0; switch (event.xbutton.button) { case 4: dy = 1.0f; break; case 5: dy = -1.0f; break; case 6: dx = -1.0f; break; case 7: dx = 1.0f; break; } view->scrollFunc(view, event.xbutton.x, event.xbutton.y, dx, dy); } break; } // nobreak case ButtonRelease: setModifiers(view, event.xbutton.state, event.xbutton.time); if (view->mouseFunc && (event.xbutton.button < 4 || event.xbutton.button > 7)) { view->mouseFunc(view, event.xbutton.button, event.type == ButtonPress, event.xbutton.x, event.xbutton.y); } break; case KeyPress: setModifiers(view, event.xkey.state, event.xkey.time); dispatchKey(view, &event, true); break; case KeyRelease: { setModifiers(view, event.xkey.state, event.xkey.time); bool repeated = false; if (view->ignoreKeyRepeat && XEventsQueued(view->impl->display, QueuedAfterReading)) { XEvent next; XPeekEvent(view->impl->display, &next); if (next.type == KeyPress && next.xkey.time == event.xkey.time && next.xkey.keycode == event.xkey.keycode) { XNextEvent(view->impl->display, &event); repeated = true; } } if (!repeated) { dispatchKey(view, &event, false); } } break; case ClientMessage: { char* type = XGetAtomName(view->impl->display, event.xclient.message_type); if (!strcmp(type, "WM_PROTOCOLS")) { if (view->closeFunc) { view->closeFunc(view); view->redisplay = false; } } XFree(type); } break; #ifdef PUGL_GRAB_FOCUS case EnterNotify: XSetInputFocus(view->impl->display, view->impl->win, RevertToPointerRoot, CurrentTime); break; #endif default: break; } } if (view->redisplay) { puglDisplay(view); } return PUGL_SUCCESS; }
PuglStatus puglProcessEvents(PuglView* view) { XEvent event; while (XPending(view->impl->display) > 0) { XNextEvent(view->impl->display, &event); switch (event.type) { case MapNotify: puglReshape(view, view->width, view->height); break; case ConfigureNotify: if ((event.xconfigure.width != view->width) || (event.xconfigure.height != view->height)) { puglReshape(view, event.xconfigure.width, event.xconfigure.height); } break; case Expose: if (event.xexpose.count != 0) { break; } puglDisplay(view); view->redisplay = false; break; case MotionNotify: setModifiers(view, event.xmotion.state); if (view->motionFunc) { view->motionFunc(view, event.xmotion.x, event.xmotion.y); } break; case ButtonPress: setModifiers(view, event.xbutton.state); if (event.xbutton.button >= 4 && event.xbutton.button <= 7) { if (view->scrollFunc) { float dx = 0, dy = 0; switch (event.xbutton.button) { case 4: dy = 1.0f; break; case 5: dy = -1.0f; break; case 6: dx = -1.0f; break; case 7: dx = 1.0f; break; } view->scrollFunc(view, dx, dy); } break; } // nobreak case ButtonRelease: setModifiers(view, event.xbutton.state); if (view->mouseFunc && (event.xbutton.button < 4 || event.xbutton.button > 7)) { view->mouseFunc(view, event.xbutton.button, event.type == ButtonPress, event.xbutton.x, event.xbutton.y); } break; case KeyPress: { setModifiers(view, event.xkey.state); KeySym sym; char str[5]; int n = XLookupString(&event.xkey, str, 4, &sym, NULL); PuglKey key = keySymToSpecial(sym); if (!key && view->keyboardFunc) { if (n == 1) { view->keyboardFunc(view, true, str[0]); } else { fprintf(stderr, "warning: Unknown key %X\n", (int)sym); } } else if (view->specialFunc) { view->specialFunc(view, true, key); } } break; case KeyRelease: { setModifiers(view, event.xkey.state); bool repeated = false; if (view->ignoreKeyRepeat && XEventsQueued(view->impl->display, QueuedAfterReading)) { XEvent next; XPeekEvent(view->impl->display, &next); if (next.type == KeyPress && next.xkey.time == event.xkey.time && next.xkey.keycode == event.xkey.keycode) { XNextEvent(view->impl->display, &event); repeated = true; } } if (!repeated && view->keyboardFunc) { KeySym sym = XKeycodeToKeysym( view->impl->display, event.xkey.keycode, 0); PuglKey special = keySymToSpecial(sym); if (!special) { view->keyboardFunc(view, false, sym); } else if (view->specialFunc) { view->specialFunc(view, false, special); } } } break; case ClientMessage: if (!strcmp(XGetAtomName(view->impl->display, event.xclient.message_type), "WM_PROTOCOLS")) { if (view->closeFunc) { view->closeFunc(view); } } break; default: break; } } if (view->redisplay) { puglDisplay(view); } return PUGL_SUCCESS; }
static LRESULT handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) { MSG msg; PAINTSTRUCT ps; PuglKey key; setModifiers(view); switch (message) { case WM_CREATE: case WM_SHOWWINDOW: case WM_SIZE: puglReshape(view, view->width, view->height); break; case WM_PAINT: BeginPaint(view->impl->hwnd, &ps); puglDisplay(view); EndPaint(view->impl->hwnd, &ps); break; case WM_MOUSEMOVE: if (view->motionFunc) { view->motionFunc( view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } break; case WM_LBUTTONDOWN: processMouseEvent(view, 1, true, lParam); break; case WM_MBUTTONDOWN: processMouseEvent(view, 2, true, lParam); break; case WM_RBUTTONDOWN: processMouseEvent(view, 3, true, lParam); break; case WM_LBUTTONUP: processMouseEvent(view, 1, false, lParam); break; case WM_MBUTTONUP: processMouseEvent(view, 2, false, lParam); break; case WM_RBUTTONUP: processMouseEvent(view, 3, false, lParam); break; case WM_MOUSEWHEEL: if (view->scrollFunc) { view->scrollFunc( view, 0, (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA); } break; case WM_MOUSEHWHEEL: if (view->scrollFunc) { view->scrollFunc( view, (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0); } break; case WM_KEYDOWN: if (view->ignoreKeyRepeat && (lParam & (1 << 30))) { break; } // else nobreak case WM_KEYUP: if (key = keySymToSpecial(wParam)) { if (view->specialFunc) { view->specialFunc(view, message == WM_KEYDOWN, key); } } else if (view->keyboardFunc) { view->keyboardFunc(view, message == WM_KEYDOWN, wParam); } break; case WM_QUIT: if (view->closeFunc) { view->closeFunc(view); } break; default: return DefWindowProc( view->impl->hwnd, message, wParam, lParam); } return 0; }
static LRESULT handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; PuglKey key; setModifiers(view); switch (message) { case WM_CREATE: case WM_SHOWWINDOW: case WM_SIZE: RECT rect; GetClientRect(view->impl->hwnd, &rect); puglReshape(view, rect.right, rect.bottom); view->width = rect.right; view->height = rect.bottom; break; case WM_PAINT: BeginPaint(view->impl->hwnd, &ps); puglDisplay(view); EndPaint(view->impl->hwnd, &ps); break; case WM_MOUSEMOVE: if (view->motionFunc) { view->event_timestamp_ms = GetMessageTime(); view->motionFunc(view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } break; case WM_LBUTTONDOWN: processMouseEvent(view, 1, true, lParam); break; case WM_MBUTTONDOWN: processMouseEvent(view, 2, true, lParam); break; case WM_RBUTTONDOWN: processMouseEvent(view, 3, true, lParam); break; case WM_LBUTTONUP: processMouseEvent(view, 1, false, lParam); break; case WM_MBUTTONUP: processMouseEvent(view, 2, false, lParam); break; case WM_RBUTTONUP: processMouseEvent(view, 3, false, lParam); break; case WM_MOUSEWHEEL: if (view->scrollFunc) { view->event_timestamp_ms = GetMessageTime(); view->scrollFunc( view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0.0f, (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA); } break; case WM_MOUSEHWHEEL: if (view->scrollFunc) { view->event_timestamp_ms = GetMessageTime(); view->scrollFunc( view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0.0f); } break; case WM_KEYDOWN: if (view->ignoreKeyRepeat && (lParam & (1 << 30))) { break; } // else nobreak case WM_KEYUP: view->event_timestamp_ms = GetMessageTime(); if ((key = keySymToSpecial(wParam))) { if (view->specialFunc) { view->specialFunc(view, message == WM_KEYDOWN, key); } } else if (view->keyboardFunc) { view->keyboardFunc(view, message == WM_KEYDOWN, wParam); } break; case WM_QUIT: case PUGL_LOCAL_CLOSE_MSG: if (view->closeFunc) { view->closeFunc(view); } break; default: return DefWindowProc( view->impl->hwnd, message, wParam, lParam); } return 0; }
int ConsumableImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) { if (!isASubChildOf(player)) return 0; if (selectedID != 20) { return TangibleObjectImplementation::handleObjectMenuSelect(player, selectedID); } if (speciesRestriction == "pets") { player->sendSystemMessage("@error_message:pets_only"); //That food is only suitable for pets. return 0; } PlayerObject* ghost = player->getPlayerObject(); String raceName = player->getSpeciesName(); if ((speciesRestriction == "2" && raceName != "trandoshan") || (speciesRestriction == "4" && raceName != "wookiee")) { player->sendSystemMessage("@error_message:race_restriction"); //That food isn't edible by your species. return 0; } if (isSpice() && player->hasSpice()) { player->sendSystemMessage("@spice/spice:sys_already_spiced"); //You are already under the influence of spices. return 0; } if (player->hasBuff(buffCRC) && (!isAttributeEffect() || isForagedFood())) { player->sendSystemMessage("@combat_effects:already_affected"); //You are already under the influence of that food. Eating more won't enhance the effect. return 0; } if (player->isDead() || player->isIncapacitated()) return 0; int availfill = 0; if (ghost == NULL) return 1; if (isFood()) availfill = ghost->getFoodFillingMax() - ghost->getFoodFilling(); if (isDrink()) availfill = ghost->getDrinkFillingMax() - ghost->getDrinkFilling(); if (filling > availfill) { if (isFood()) player->sendSystemMessage("@error_message:full_food"); //You are too full to eat that. if (isDrink()) player->sendSystemMessage("@error_message:full_drink"); //You are too full to drink that. return 1; } ManagedReference<Buff*> buff = NULL; switch (effectType) { case EFFECT_ATTRIBUTE: { buff = new Buff(player, buffName.hashCode(), duration, BuffType::FOOD); setModifiers(buff, false); break; } case EFFECT_SKILL: { buff = new Buff(player, buffName.hashCode(), duration, BuffType::FOOD); setModifiers(buff, true); break; } case EFFECT_SPICE: { buff = new SpiceBuff(player, buffName, String("spice." + buffName + ".up").hashCode(), duration); setModifiers(buff, false); //buff->parseAttributeModifierString(modifierString); player->addBuff(buff); //useCharge(player); decreaseUseCount(); return 1; } case EFFECT_HEALING: { int dmghealed = player->healDamage(player, 6, nutrition); if (dmghealed <= 0) { player->sendSystemMessage("@healing:no_mind_to_heal_self"); //You have no mind to heal. return 0; } StringIdChatParameter stringId("combat_effects", "food_mind_heal"); stringId.setDI(dmghealed); player->sendSystemMessage(stringId); break; } case EFFECT_DURATION: { buff = new DurationBuff(player, buffName.hashCode(), duration); setModifiers(buff, true); //buff->parseSkillModifierString(generateModifierString()); break; } case EFFECT_DELAYED: { buff = new DelayedBuff(player, buffName.hashCode(), duration); setModifiers(buff, true); DelayedBuff* delayedBuff = cast<DelayedBuff*>(buff.get()); delayedBuff->init(&eventTypes); break; } case EFFECT_INSTANT: { if (modifiers.isEmpty()) return 0; //TODO: Handle each instant effect on its own... String effect = modifiers.elementAt(0).getKey(); if (effect == "burst_run") { //We need to reduce the cooldown and efficiency. player->executeObjectControllerAction(String("burstrun").hashCode()); if (player->hasBuff(String("burstrun").hashCode())) { float reduction = 1.f - ((float)nutrition / 100.f); player->updateCooldownTimer("burstrun", ((300 * reduction) + duration) * 1000); player->sendSystemMessage("@combat_effects:instant_burst_run"); //You instantly burst run at increased efficiency! Reference<Task*> task = player->getPendingTask("burst_run_notify"); if (task != NULL) task->reschedule(((300 * reduction) + duration) * 1000); else { task = new BurstRunNotifyAvailableEvent(player); player->addPendingTask("burst_run_notify", task, ((300 * reduction) + duration) * 1000); } } else { //Couldnt burst run yet. return 0; } } else if (effect == "food_reduce") { //Tilla till reduces food stomach filling by a percentage int currentfilling = ghost->getFoodFilling(); ghost->setFoodFilling(round(currentfilling * (100 - nutrition) / 100.0f), true); } } } if (buff != NULL) player->addBuff(buff); if (isFood()) ghost->setFoodFilling(ghost->getFoodFilling() + filling, true); if (isDrink()) ghost->setDrinkFilling(ghost->getDrinkFilling() + filling, true); StringIdChatParameter stringId("base_player", "prose_consume_item"); stringId.setTT(getObjectID()); player->sendSystemMessage(stringId);//player->sendSystemMessage("base_player", "prose_consume_item", objectID);; // Play the client effect sound depending on species/gender. // Get the species. int species = player->getSpecies(); switch (species) { case 0: // Human if (player->getGender() == 0) player->playEffect("clienteffect/human_male_eat.cef"); else if (player->getGender() == 1) player->playEffect("clienteffect/human_female_eat.cef"); break; case 2: // Trandoshan if (player->getGender() == 0) player->playEffect("clienteffect/reptile_male_eat.cef"); else if (player->getGender() == 1) player->playEffect("clienteffect/reptile_female_eat.cef"); break; case 4: // Wookiee if (player->getGender() == 0) player->playEffect("clienteffect/wookiee_male_eat.cef"); else if (player->getGender() == 1) player->playEffect("clienteffect/wookiee_female_eat.cef"); break; default: break; } //Consume a charge from the item, destroy it if it reaches 0 charges remaining. //useCharge(player); decreaseUseCount(); return 0; }