erebus

diff liberebus/src/erebus.cc @ 9:d38e13d6063c

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 17:22:53 +0300
parents e2d9bf168a41
children 506e114b7ca2
line diff
     1.1 --- a/liberebus/src/erebus.cc	Sat May 24 06:12:57 2014 +0300
     1.2 +++ b/liberebus/src/erebus.cc	Sat May 24 17:22:53 2014 +0300
     1.3 @@ -34,6 +34,11 @@
     1.4  	int cur_pixel_x, cur_pixel_y;
     1.5  	Rect cur_rect;
     1.6  	int cur_sample;
     1.7 +
     1.8 +	// interactive input
     1.9 +	std::vector<bool> keystate;
    1.10 +	std::vector<bool> bnstate;
    1.11 +	int mouse_pos[2];
    1.12  };
    1.13  
    1.14  static void render_pixel(struct erebus *ctx, int x, int y, int sample);
    1.15 @@ -205,6 +210,30 @@
    1.16  	return 0;
    1.17  }
    1.18  
    1.19 +bool erb_input_keyboard(struct erebus *ctx, int key, bool pressed)
    1.20 +{
    1.21 +	if(!ctx) return false;
    1.22 +	if(ctx->keystate.size() <= key) ctx->keystate.resize(key < 256 ? 256 : key + 1);
    1.23 +
    1.24 +	ctx->keystate[key] = pressed;
    1.25 +	return false;
    1.26 +}
    1.27 +
    1.28 +bool erb_input_mouse_button(struct erebus *ctx, int bn, bool pressed, int x, int y)
    1.29 +{
    1.30 +	if(!ctx) return false;
    1.31 +	if(ctx->bnstate.size() <= bn) ctx->bnstate.resize(bn < 32 ? 32 : bn + 1);
    1.32 +
    1.33 +	ctx->bnstate[bn] = pressed;
    1.34 +	ctx->mouse_pos[0] = x;
    1.35 +	ctx->mouse_pos[1] = y;
    1.36 +}
    1.37 +
    1.38 +bool erb_input_mouse_motion(struct erebus *ctx, int x, int y);
    1.39 +bool erb_input_6dof_button(struct erebus *ctx, int bn, bool pressed);
    1.40 +bool erb_input_6dof_motion(struct erebus *ctx, float x, float y, float z);
    1.41 +
    1.42 +
    1.43  }	// extern "C"
    1.44  
    1.45  float randf(float low, float high)