Updated show-logo and start reviewing RPI inputs
This commit is contained in:
parent
30fafb77db
commit
0018522031
3 changed files with 17 additions and 47 deletions
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* raylib [shapes] example - raylib logo animation
|
* raylib [shapes] example - raylib logo animation
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.1 (www.raylib.com)
|
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||||
|
@ -32,8 +32,6 @@ int main()
|
||||||
int bottomSideRecWidth = 16;
|
int bottomSideRecWidth = 16;
|
||||||
int rightSideRecHeight = 16;
|
int rightSideRecHeight = 16;
|
||||||
|
|
||||||
char raylib[8] = " \0"; // raylib text array, max 8 letters
|
|
||||||
|
|
||||||
int state = 0; // Tracking animation states (State Machine)
|
int state = 0; // Tracking animation states (State Machine)
|
||||||
float alpha = 1.0f; // Useful for fading
|
float alpha = 1.0f; // Useful for fading
|
||||||
|
|
||||||
|
@ -79,24 +77,13 @@ int main()
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lettersCount)
|
|
||||||
{
|
|
||||||
case 1: raylib[0] = 'r'; break;
|
|
||||||
case 2: raylib[1] = 'a'; break;
|
|
||||||
case 3: raylib[2] = 'y'; break;
|
|
||||||
case 4: raylib[3] = 'l'; break;
|
|
||||||
case 5: raylib[4] = 'i'; break;
|
|
||||||
case 6: raylib[5] = 'b'; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lettersCount >= 10) // When all letters have appeared, just fade out everything
|
if (lettersCount >= 10) // When all letters have appeared, just fade out everything
|
||||||
{
|
{
|
||||||
alpha -= 0.02;
|
alpha -= 0.02f;
|
||||||
|
|
||||||
if (alpha <= 0)
|
if (alpha <= 0.0f)
|
||||||
{
|
{
|
||||||
alpha = 0;
|
alpha = 0.0f;
|
||||||
state = 4;
|
state = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,12 +101,7 @@ int main()
|
||||||
bottomSideRecWidth = 16;
|
bottomSideRecWidth = 16;
|
||||||
rightSideRecHeight = 16;
|
rightSideRecHeight = 16;
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) raylib[i] = ' ';
|
alpha = 1.0f;
|
||||||
|
|
||||||
raylib[7] = '\0'; // Last character is end-of-line
|
|
||||||
|
|
||||||
alpha = 1.0;
|
|
||||||
|
|
||||||
state = 0; // Return to State 0
|
state = 0; // Return to State 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +140,7 @@ int main()
|
||||||
|
|
||||||
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
|
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
|
||||||
|
|
||||||
DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
DrawText(SubText("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
||||||
}
|
}
|
||||||
else if (state == 4)
|
else if (state == 4)
|
||||||
{
|
{
|
||||||
|
|
32
src/core.c
32
src/core.c
|
@ -151,7 +151,7 @@ pthread_t mouseThreadId; // Mouse reading thread id
|
||||||
static int defaultKeyboardMode; // Used to store default keyboard mode
|
static int defaultKeyboardMode; // Used to store default keyboard mode
|
||||||
static struct termios defaultKeyboardSettings; // Used to staore default keyboard settings
|
static struct termios defaultKeyboardSettings; // Used to staore default keyboard settings
|
||||||
|
|
||||||
static int keyboardMode = 0; // Keyboard mode: 1 (KEYCODES), 2 (ASCII)
|
static int keyboardMode = 0; // Keyboard mode: 1 - KEYCODES, 2 - ASCII
|
||||||
|
|
||||||
// This array maps Unix keycodes to ASCII equivalent and to GLFW3 equivalent for special function keys (>256)
|
// This array maps Unix keycodes to ASCII equivalent and to GLFW3 equivalent for special function keys (>256)
|
||||||
const short UnixKeycodeToASCII[128] = { 256, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 259, 9, 81, 87, 69, 82, 84, 89, 85, 73, 79, 80, 91, 93, 257, 341, 65, 83, 68,
|
const short UnixKeycodeToASCII[128] = { 256, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 259, 9, 81, 87, 69, 82, 84, 89, 85, 73, 79, 80, 91, 93, 257, 341, 65, 83, 68,
|
||||||
|
@ -1128,7 +1128,7 @@ bool IsCursorHidden()
|
||||||
{
|
{
|
||||||
return cursorHidden;
|
return cursorHidden;
|
||||||
}
|
}
|
||||||
#endif
|
#endif //defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
|
|
||||||
// TODO: Enable gamepad usage on Rapsberry Pi
|
// TODO: Enable gamepad usage on Rapsberry Pi
|
||||||
// NOTE: emscripten not implemented
|
// NOTE: emscripten not implemented
|
||||||
|
@ -2077,7 +2077,7 @@ static bool GetMouseButtonStatus(int button)
|
||||||
// TODO: Check for virtual keyboard
|
// TODO: Check for virtual keyboard
|
||||||
return false;
|
return false;
|
||||||
#elif defined(PLATFORM_RPI)
|
#elif defined(PLATFORM_RPI)
|
||||||
// NOTE: mouse buttons array is filled on PollInputEvents()
|
// NOTE: Mouse buttons states are filled in PollInputEvents()
|
||||||
return currentMouseState[button];
|
return currentMouseState[button];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2099,8 +2099,7 @@ static void PollInputEvents(void)
|
||||||
mousePosition.x = (float)mouseX;
|
mousePosition.x = (float)mouseX;
|
||||||
mousePosition.y = (float)mouseY;
|
mousePosition.y = (float)mouseY;
|
||||||
|
|
||||||
// Keyboard polling
|
// Keyboard input polling (automatically managed by GLFW3 through callback)
|
||||||
// Automatically managed by GLFW3 through callback
|
|
||||||
lastKeyPressed = -1;
|
lastKeyPressed = -1;
|
||||||
|
|
||||||
// Register previous keys states
|
// Register previous keys states
|
||||||
|
@ -2157,7 +2156,7 @@ static void PollInputEvents(void)
|
||||||
|
|
||||||
int key = keysBuffer[i];
|
int key = keysBuffer[i];
|
||||||
|
|
||||||
if (keyboardMode == 2) // scancodes
|
if (keyboardMode == 2) // ASCII chars (K_XLATE mode)
|
||||||
{
|
{
|
||||||
// NOTE: If (key == 0x1b), depending on next key, it could be a special keymap code!
|
// NOTE: If (key == 0x1b), depending on next key, it could be a special keymap code!
|
||||||
// Up -> 1b 5b 41 / Left -> 1b 5b 44 / Right -> 1b 5b 43 / Down -> 1b 5b 42
|
// Up -> 1b 5b 41 / Left -> 1b 5b 44 / Right -> 1b 5b 43 / Down -> 1b 5b 42
|
||||||
|
@ -2215,8 +2214,7 @@ static void PollInputEvents(void)
|
||||||
if (key == 0x01) windowShouldClose = true;
|
if (key == 0x01) windowShouldClose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same functionality as GLFW3 KeyCallback()
|
||||||
// Same fucnionality as GLFW3 KeyCallback()
|
|
||||||
/*
|
/*
|
||||||
if (asciiKey == exitKey) windowShouldClose = true;
|
if (asciiKey == exitKey) windowShouldClose = true;
|
||||||
else if (key == GLFW_KEY_F12 && action == GLFW_PRESS)
|
else if (key == GLFW_KEY_F12 && action == GLFW_PRESS)
|
||||||
|
@ -2356,7 +2354,7 @@ static void InitKeyboard(void)
|
||||||
// Set new keyboard settings (change occurs immediately)
|
// Set new keyboard settings (change occurs immediately)
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &keyboardNewSettings);
|
tcsetattr(STDIN_FILENO, TCSANOW, &keyboardNewSettings);
|
||||||
|
|
||||||
// NOTE: Reading directly from stdin will give chars already key-mapped by kernel to ASCII or UNICODE, we change that!
|
// NOTE: Reading directly from stdin will give chars already key-mapped by kernel to ASCII or UNICODE, we change that! -> WHY???
|
||||||
|
|
||||||
// Save old keyboard mode to restore it at the end
|
// Save old keyboard mode to restore it at the end
|
||||||
if (ioctl(STDIN_FILENO, KDGKBMODE, &defaultKeyboardMode) < 0)
|
if (ioctl(STDIN_FILENO, KDGKBMODE, &defaultKeyboardMode) < 0)
|
||||||
|
@ -2374,6 +2372,8 @@ static void InitKeyboard(void)
|
||||||
// - ASCII chars (K_XLATE)
|
// - ASCII chars (K_XLATE)
|
||||||
// - UNICODE chars (K_UNICODE)
|
// - UNICODE chars (K_UNICODE)
|
||||||
ioctl(STDIN_FILENO, KDSKBMODE, K_MEDIUMRAW);
|
ioctl(STDIN_FILENO, KDSKBMODE, K_MEDIUMRAW);
|
||||||
|
|
||||||
|
//http://lct.sourceforge.net/lct/x60.html
|
||||||
|
|
||||||
keyboardMode = 1; // keycodes
|
keyboardMode = 1; // keycodes
|
||||||
}
|
}
|
||||||
|
@ -2587,7 +2587,6 @@ static void LogoAnimation(void)
|
||||||
int bottomSideRecWidth = 16;
|
int bottomSideRecWidth = 16;
|
||||||
int rightSideRecHeight = 16;
|
int rightSideRecHeight = 16;
|
||||||
|
|
||||||
char raylib[8] = " "; // raylib text array, max 8 letters
|
|
||||||
int state = 0; // Tracking animation states (State Machine)
|
int state = 0; // Tracking animation states (State Machine)
|
||||||
float alpha = 1.0f; // Useful for fading
|
float alpha = 1.0f; // Useful for fading
|
||||||
|
|
||||||
|
@ -2629,17 +2628,6 @@ static void LogoAnimation(void)
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lettersCount)
|
|
||||||
{
|
|
||||||
case 1: raylib[0] = 'r'; break;
|
|
||||||
case 2: raylib[1] = 'a'; break;
|
|
||||||
case 3: raylib[2] = 'y'; break;
|
|
||||||
case 4: raylib[3] = 'l'; break;
|
|
||||||
case 5: raylib[4] = 'i'; break;
|
|
||||||
case 6: raylib[5] = 'b'; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lettersCount >= 10) // When all letters have appeared, just fade out everything
|
if (lettersCount >= 10) // When all letters have appeared, just fade out everything
|
||||||
{
|
{
|
||||||
alpha -= 0.02f;
|
alpha -= 0.02f;
|
||||||
|
@ -2686,7 +2674,7 @@ static void LogoAnimation(void)
|
||||||
|
|
||||||
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
|
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
|
||||||
|
|
||||||
DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
DrawText(SubText("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
#define KEY_RIGHT_CONTROL 345
|
#define KEY_RIGHT_CONTROL 345
|
||||||
#define KEY_RIGHT_ALT 346
|
#define KEY_RIGHT_ALT 346
|
||||||
|
|
||||||
// Keyboard Alhpa Numeric Keys
|
// Keyboard Alpha Numeric Keys
|
||||||
#define KEY_ZERO 48
|
#define KEY_ZERO 48
|
||||||
#define KEY_ONE 49
|
#define KEY_ONE 49
|
||||||
#define KEY_TWO 50
|
#define KEY_TWO 50
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue