Прекрасное вращение
This commit is contained in:
@@ -95,7 +95,8 @@ figure_handle_collision:
|
|||||||
; Вызов place_points_on_circle
|
; Вызов place_points_on_circle
|
||||||
movss xmm0, [r12 + WDI_FIGURE + FIG_POSITION]
|
movss xmm0, [r12 + WDI_FIGURE + FIG_POSITION]
|
||||||
movss xmm1, [r12 + WDI_FIGURE + FIG_POSITION + 4]
|
movss xmm1, [r12 + WDI_FIGURE + FIG_POSITION + 4]
|
||||||
movss xmm2, [rel ZERO_CONST] ; смещение угла = 0
|
movss xmm2, [r12 + WDI_FIGURE + FIG_ANGLE] ; смещение угла = 0
|
||||||
|
mulss xmm2, [rel NEG_ONE_CONST]
|
||||||
|
|
||||||
; Установка правильного количества точек
|
; Установка правильного количества точек
|
||||||
mov eax, dword [r12 + WDI_FIGURE + FIG_TYPE]
|
mov eax, dword [r12 + WDI_FIGURE + FIG_TYPE]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "input-handle.h"
|
#include "input-handle.h"
|
||||||
#include "wayland-runtime.h"
|
#include "wayland-runtime.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
void keyboard_key_handle(xkb_keycode_t kc, xkb_keysym_t ks, enum keyboard_key_state state, struct wayland_window *window)
|
void keyboard_key_handle(xkb_keycode_t kc, xkb_keysym_t ks, enum keyboard_key_state state, struct wayland_window *window)
|
||||||
{
|
{
|
||||||
@@ -13,7 +14,7 @@ void keyboard_key_handle(xkb_keycode_t kc, xkb_keysym_t ks, enum keyboard_key_st
|
|||||||
else
|
else
|
||||||
printf("keyboard: keysym 0x%x (no UTF-8 representation)\n", ks);
|
printf("keyboard: keysym 0x%x (no UTF-8 representation)\n", ks);
|
||||||
|
|
||||||
if(state == KEYBOARD_KEY_STATE_PRESSED)
|
if(state != KEYBOARD_KEY_STATE_RELEASED)
|
||||||
{
|
{
|
||||||
switch (ks)
|
switch (ks)
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,48 @@ void keyboard_key_handle(xkb_keycode_t kc, xkb_keysym_t ks, enum keyboard_key_st
|
|||||||
case '3':
|
case '3':
|
||||||
window->draw_info.figure.type = FIGURE_SQUARE;
|
window->draw_info.figure.type = FIGURE_SQUARE;
|
||||||
break;
|
break;
|
||||||
|
case '-':
|
||||||
|
/* decrease animation speed (multiplicative delta, clamped) */
|
||||||
|
pthread_mutex_lock(&window->draw_info.figure_mutex);
|
||||||
|
window->draw_info.figure.speed -= 0.5f;
|
||||||
|
if (window->draw_info.figure.speed < 1)
|
||||||
|
window->draw_info.figure.speed = 1;
|
||||||
|
printf("keyboard: speed decreased to %.2f\n", window->draw_info.figure.speed);
|
||||||
|
pthread_mutex_unlock(&window->draw_info.figure_mutex);
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
case '=': /* some layouts may emit '=' for unshifted, handle + via keysym */
|
||||||
|
/* increase animation speed (multiplicative delta, clamped) */
|
||||||
|
pthread_mutex_lock(&window->draw_info.figure_mutex);
|
||||||
|
window->draw_info.figure.speed += 0.5f;
|
||||||
|
if (window->draw_info.figure.speed > 30.0f)
|
||||||
|
window->draw_info.figure.speed = 30.0f;
|
||||||
|
printf("keyboard: speed increased to %.2f\n", window->draw_info.figure.speed);
|
||||||
|
pthread_mutex_unlock(&window->draw_info.figure_mutex);
|
||||||
|
break;
|
||||||
|
case XKB_KEY_Up:
|
||||||
|
/* increase figure radius */
|
||||||
|
pthread_mutex_lock(&window->draw_info.figure_mutex);
|
||||||
|
{
|
||||||
|
float maxr = fminf(window->draw_info.width, window->draw_info.height) / 2.0f - 1.0f;
|
||||||
|
window->draw_info.figure.radius += 2.0f;
|
||||||
|
if (window->draw_info.figure.radius > maxr)
|
||||||
|
window->draw_info.figure.radius = maxr;
|
||||||
|
}
|
||||||
|
printf("keyboard: radius increased to %.2f\n", window->draw_info.figure.radius);
|
||||||
|
pthread_mutex_unlock(&window->draw_info.figure_mutex);
|
||||||
|
break;
|
||||||
|
case XKB_KEY_Down:
|
||||||
|
/* decrease figure radius */
|
||||||
|
pthread_mutex_lock(&window->draw_info.figure_mutex);
|
||||||
|
{
|
||||||
|
window->draw_info.figure.radius -= 2.0f;
|
||||||
|
if (window->draw_info.figure.radius < 1.0f)
|
||||||
|
window->draw_info.figure.radius = 1.0f;
|
||||||
|
}
|
||||||
|
printf("keyboard: radius decreased to %.2f\n", window->draw_info.figure.radius);
|
||||||
|
pthread_mutex_unlock(&window->draw_info.figure_mutex);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user