void draw_line(struct razer_keys *keys,struct razer_pos *a,struct razer_pos *b,struct razer_rgb *color) { int dx = abs(b->x-a->x); int dy = -abs(b->y-a->y); int sx = 1; int sy = 1; if(a->x>b->x) sx=-1; if(a->y>b->y) sy=-1; int e = dx+dy; int e2; struct razer_pos pos; pos.x = a->x; pos.y = a->y; while(1) { razer_set_key_pos(keys,&pos,color); if(pos.x == b->x && pos.y == b->y) break; e2 = 2*e; if(e2>dy) { e += dy; pos.x += sx; } if(e2<dx) { e += dx; pos.y += sy; } } }
void effect(struct razer_chroma *chroma) { int r = 128, g = 0, b = 0; int count = 1; int count_dir = 1; int x,y; int span = 20; double c = 0; struct razer_rgb col; struct razer_rgb green = {.r=0,.g=255,.b=0}; //define a green color struct razer_pos pos; col.r = 0; col.g = 255; col.b = 0; while(running){ //r += rand_span(span); r = count; r = fixed_range(r, 255); g += rand_span(span); g = fixed_range(g, 255); g = 0; b += rand_span(span); b = fixed_range(b, 255); b = 0; for(x=0;x<22;x++){ for(y=0;y<6;y++){ g = fixed_range(r - (x * 10), 255); chroma->keys->rows[y].column[x].r = (unsigned char)r; chroma->keys->rows[y].column[x].g = (unsigned char)g; chroma->keys->rows[y].column[x].b = (unsigned char)b; chroma->keys->update_mask |= 1<<y; } } col.g = (sin(c) + 1)/2 * 225; col.b = 255 - col.g; c += 0.05; pos.x = 2; pos.y = 3; razer_set_key_pos(chroma->keys,&pos,&green); pos.x += 1; razer_set_key_pos(chroma->keys,&pos,&green); pos.y -= 1; razer_set_key_pos(chroma->keys,&pos,&green); pos.y += 1; pos.x += 1; razer_set_key_pos(chroma->keys,&pos,&green); for(int i=0;i<keys_max;i++) if(keys_history[i]!=-1){ razer_convert_keycode_to_pos(keys_history[i],&pos); razer_set_key_pos(chroma->keys,&pos,&col); if(pos.x == 17 && pos.y == 0){ for(int i=0;i<keys_max;i++){ keys_history[i] = -1; } } } razer_update_keys(chroma,chroma->keys); count+=count_dir; if(count<=0 || count>255){ count_dir=-count_dir; } razer_update(chroma); razer_frame_limiter(chroma,13); } } #pragma GCC diagnostic pop #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" void stop(int sig) { #ifdef USE_DEBUGGING printf("Stopping input example\n"); #endif running = 0; }