Skip to content

Commit

Permalink
Fix canvas key callback signature
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Mar 29, 2018
1 parent 7269957 commit b736e44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 3 additions & 7 deletions pixelnuke/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void glfw_error_callback(int error, const char* description) {

void (*canvas_on_close_cb)();
void (*canvas_on_resize_cb)();
void (*canvas_on_key_cb)();
void (*canvas_on_key_cb)(int, int, int);

static int canvas_do_layout = 0;

Expand Down Expand Up @@ -90,12 +90,8 @@ static void canvas_on_key(GLFWwindow* window, int key, int scancode, int action,

static void canvas_on_key(GLFWwindow* window, int key, int scancode, int action,
int mods) {
printf("KEY: %u %u %u %u\n", key, scancode, action, mods);
if (action != GLFW_PRESS) {
return;
}
if (canvas_on_key_cb)
(*canvas_on_key_cb)(key, scancode, action, mods);
if (action == GLFW_PRESS && canvas_on_key_cb)
(*canvas_on_key_cb)(key, scancode, mods);
}

static void canvas_on_resize(GLFWwindow* window, int w, int h) {
Expand Down
7 changes: 5 additions & 2 deletions pixelnuke/pixelnuke.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <errno.h>
#include <stdio.h> //sprintf

int px_width = 1024;
int px_height = 1024;
unsigned int px_width = 1024;
unsigned int px_height = 1024;

// Helper functions

Expand Down Expand Up @@ -103,6 +103,9 @@ void px_on_close(NetClient *client, int error) {
}

void px_on_key(int key, int scancode, int mods) {

printf("Key pressed: key:%d scancode:%d mods:%d\n", key, scancode, mods);

if (key == 300) { // F11
int display = canvas_get_display();
if (display < 0)
Expand Down

0 comments on commit b736e44

Please sign in to comment.