aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp2
-rw-r--r--src/utils.cpp3
-rw-r--r--src/window.cpp14
3 files changed, 11 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 774429d..a91e9e5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -81,7 +81,7 @@ int main() {
}
case EVENT_TYPES::KEY_PRESS: {
auto move_speed = 0.01f * delta_time;
- if (wnd.keyboard[KEYS::SHIFT]) {
+ if (wnd.keyboard[KEYS::LSHIFT] || wnd.keyboard[KEYS::RSHIFT]) {
move_speed *= 2.f;
}
diff --git a/src/utils.cpp b/src/utils.cpp
index 1c6fac1..3416714 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -91,8 +91,7 @@ void random_scene(sphere *world) {
struct input_data create_inputs(uint32_t width, uint32_t height) {
// Image dimensions
- // const float aspect_ratio = 16.0 / 9.0;
- const float aspect_ratio = 1;
+ const float aspect_ratio = (float)width / (float) height;
const uint32_t samples_per_pixel = 1;
const uint32_t max_depth = 2;
diff --git a/src/window.cpp b/src/window.cpp
index 840d570..a353809 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -119,12 +119,16 @@ void window::poll_events() {
}
case XCB_KEY_RELEASE:
case XCB_KEY_PRESS: {
- auto key_press_event = (xcb_key_press_event_t*)event;
- auto keysym = xkb_state_key_get_one_sym(keyboard_state, key_press_event->detail);
+ auto key_press_event = (xcb_key_press_event_t*)event;
+ auto keysym = xkb_state_key_get_one_sym(keyboard_state, key_press_event->detail);
+ auto isKeyPress = event->response_type == XCB_KEY_PRESS;
+ auto key = (KEYS)keysym;
+
+ keyboard[key] = isKeyPress;
+
struct event new_event = {
- .type = event->response_type == XCB_KEY_PRESS ? EVENT_TYPES::KEY_PRESS :EVENT_TYPES::KEY_RELEASE
- .modifiers = key_press_event->state;
- .keycode = keysym;
+ .key = key,
+ .type = isKeyPress ? EVENT_TYPES::KEY_PRESS :EVENT_TYPES::KEY_RELEASE
};
events.push_back(new_event);