static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) { bSensor *sens = (bSensor *)ptr->data; bKeyboardSensor *ks = (bKeyboardSensor *)sens->data; if (ISKEYBOARD(value)) ks->qual2 = value; else ks->qual2 = 0; }
static wmEvent *rna_Window_event_add_simulate(wmWindow *win, ReportList *reports, int type, int value, const char *unicode, int x, int y, bool shift, bool ctrl, bool alt, bool oskey) { if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) { BKE_report(reports, RPT_ERROR, "Not running with '--enable-event-simulate' enabled"); return NULL; } if (!ELEM(value, KM_PRESS, KM_RELEASE, KM_NOTHING)) { BKE_report(reports, RPT_ERROR, "value: only 'PRESS/RELEASE/NOTHING' are supported"); return NULL; } if (ISKEYBOARD(type) || ISMOUSE_BUTTON(type)) { if (!ELEM(value, KM_PRESS, KM_RELEASE)) { BKE_report(reports, RPT_ERROR, "value: must be 'PRESS/RELEASE' for keyboard/buttons"); return NULL; } } if (ELEM(type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (value != KM_NOTHING) { BKE_report(reports, RPT_ERROR, "value: must be 'NOTHING' for motion"); return NULL; } } if (unicode != NULL) { if (value != KM_PRESS) { BKE_report(reports, RPT_ERROR, "value: must be 'PRESS' when unicode is set"); return NULL; } } /* TODO: validate NDOF. */ char ascii = 0; if (unicode != NULL) { int len = BLI_str_utf8_size(unicode); if (len == -1 || unicode[len] != '\0') { BKE_report(reports, RPT_ERROR, "Only a single character supported"); return NULL; } if (len == 1 && isascii(unicode[0])) { ascii = unicode[0]; } } wmEvent e = *win->eventstate; e.type = type; e.val = value; e.x = x; e.y = y; /* Note: KM_MOD_FIRST, KM_MOD_SECOND aren't used anywhere, set as bools */ e.shift = shift; e.ctrl = ctrl; e.alt = alt; e.oskey = oskey; e.prevx = win->eventstate->x; e.prevy = win->eventstate->y; e.prevval = win->eventstate->val; e.prevtype = win->eventstate->type; e.ascii = '\0'; e.utf8_buf[0] = '\0'; if (unicode != NULL) { e.ascii = ascii; STRNCPY(e.utf8_buf, unicode); } return WM_event_add_simulate(win, &e); }