Skip to content

Commit

Permalink
Driver - PS2:
Browse files Browse the repository at this point in the history
 - Fix handling of key-presses, lock keys were not handled correctly. Removed dead VK_*. Optimized handling of key presses.
  • Loading branch information
Meulengracht committed Feb 10, 2021
1 parent f7647d3 commit f90cf19
Show file tree
Hide file tree
Showing 15 changed files with 380 additions and 335 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ add_custom_target (install_applications
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/tools/utils.py --cp --source ${VALI_PATH_APPLICATIONS}/bin --dest ${VALI_PATH_DEPLOY_SHARED_MAPS} --pattern *.map
#COMMAND ${CMAKE_COMMAND} -E copy_directory ${VALI_PATH_APPLICATIONS}/include/ ${VALI_PATH_DEPLOY_SHARED_INC}
#COMMAND ${CMAKE_COMMAND} -E copy_directory ${VALI_PATH_APPLICATIONS}/lib/ ${VALI_PATH_DEPLOY_SHARED_LIB}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${VALI_PATH_APPLICATIONS}/share/ ${VALI_PATH_DEPLOY_SHARED_SHARE}
#COMMAND ${CMAKE_COMMAND} -E copy_directory ${VALI_PATH_APPLICATIONS}/share/ ${VALI_PATH_DEPLOY_SHARED_SHARE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

Expand Down
4 changes: 2 additions & 2 deletions kernel/system_api/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ extern OsStatus_t ScCreateMemoryHandler(unsigned int Flags, size_t Length, UUId_
extern OsStatus_t ScDestroyMemoryHandler(UUId_t Handle);
extern OsStatus_t ScFlushHardwareCache(int Cache, void* Start, size_t Length);
extern OsStatus_t ScSystemQuery(SystemDescriptor_t* Descriptor);
extern OsStatus_t ScSystemTime(SystemTime_t* SystemTime);
extern OsStatus_t ScSystemTick(int TickBase, LargeUInteger_t* Tick);
extern OsStatus_t ScSystemTime(SystemTime_t* systemTime);
extern OsStatus_t ScSystemTick(int tickBase, LargeUInteger_t* tick);
extern OsStatus_t ScPerformanceFrequency(LargeInteger_t *Frequency);
extern OsStatus_t ScPerformanceTick(LargeInteger_t *Value);

Expand Down
24 changes: 12 additions & 12 deletions kernel/system_api/system_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,42 +98,42 @@ ScFlushHardwareCache(

OsStatus_t
ScSystemTime(
_In_ SystemTime_t* SystemTime)
_In_ SystemTime_t* systemTime)
{
if (SystemTime == NULL) {
if (systemTime == NULL) {
return OsError;
}
memcpy(SystemTime, &GetMachine()->SystemTime, sizeof(SystemTime_t));
memcpy(systemTime, &GetMachine()->SystemTime, sizeof(SystemTime_t));
return OsSuccess;
}

OsStatus_t
ScSystemTick(
_In_ int TickBase,
_In_ LargeUInteger_t* Tick)
_In_ int tickBase,
_In_ LargeUInteger_t* tick)
{
if (Tick == NULL) {
if (tick == NULL) {
return OsError;
}

if (TimersGetSystemTick((clock_t*)&Tick->QuadPart) == OsSuccess) {
if (TickBase == TIME_PROCESS) {
if (TimersGetSystemTick((clock_t*)&tick->QuadPart) == OsSuccess) {
if (tickBase == TIME_PROCESS) {
SystemModule_t* Module = GetCurrentModule();
if (Module != NULL) {
Tick->QuadPart -= Module->StartedAt;
tick->QuadPart -= Module->StartedAt;
}
}
else if (TickBase == TIME_THREAD) {
else if (tickBase == TIME_THREAD) {
Thread_t* Thread = ThreadCurrentForCore(ArchGetProcessorCoreId());
if (Thread != NULL) {
Tick->QuadPart -= ThreadStartTime(Thread);
tick->QuadPart -= ThreadStartTime(Thread);
}
}
return OsSuccess;
}

// Default the result to 0 to indicate unsupported
Tick->QuadPart = 0;
tick->QuadPart = 0;
return OsError;
}

Expand Down
190 changes: 95 additions & 95 deletions librt/libc/include/os/keycodes.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* MollenOS
/**
* MollenOS
*
* Copyright 2011, Philip Meulengracht
*
Expand All @@ -25,8 +26,9 @@
#define _KEYCODES_INTERFACE_H_

#include <crtdefs.h>
#include <stdint.h>

typedef enum KeyCode {
enum KeyCode {
VK_INVALID = 0x00,

// 0-9
Expand Down Expand Up @@ -84,103 +86,100 @@ typedef enum KeyCode {
VK_SEMICOLON = 0x31,
VK_CLEAR = 0x32,
VK_ENTER = 0x33,
VK_SHIFT = 0x34,
VK_CONTROL = 0x35,
VK_ALT = 0x36,
VK_PAUSE = 0x37,
VK_CAPSLOCK = 0x38,
VK_HYPHEN = 0x39,
VK_ESCAPE = 0x3A,
VK_SPACE = 0x3B,
VK_SLASH = 0x3C,
VK_BACKSLASH = 0x3D,
VK_APOSTROPHE = 0x3E,
VK_EQUAL = 0x3F,
VK_LBRACKET = 0x40,
VK_RBRACKET = 0x41,
VK_PAGEUP = 0x42,
VK_PAGEDOWN = 0x43,
VK_END = 0x44,
VK_HOME = 0x45,
VK_LEFT = 0x46,
VK_UP = 0x47,
VK_RIGHT = 0x48,
VK_DOWN = 0x49,
VK_SELECT = 0x4A,
VK_PRINT = 0x4B,
VK_EXECUTE = 0x4C,
VK_SNAPSHOT = 0x4D,
VK_INSERT = 0x4E,
VK_DELETE = 0x4F,
VK_HELP = 0x50,
VK_PAUSE = 0x34,
VK_CAPSLOCK = 0x35,
VK_HYPHEN = 0x36,
VK_ESCAPE = 0x37,
VK_SPACE = 0x38,
VK_SLASH = 0x39,
VK_BACKSLASH = 0x3A,
VK_APOSTROPHE = 0x3B,
VK_EQUAL = 0x3C,
VK_LBRACKET = 0x3D,
VK_RBRACKET = 0x3E,
VK_PAGEUP = 0x3F,
VK_PAGEDOWN = 0x40,
VK_END = 0x41,
VK_HOME = 0x42,
VK_LEFT = 0x43,
VK_UP = 0x44,
VK_RIGHT = 0x45,
VK_DOWN = 0x46,
VK_SELECT = 0x47,
VK_PRINT = 0x48,
VK_EXECUTE = 0x49,
VK_SNAPSHOT = 0x4A,
VK_INSERT = 0x4B,
VK_DELETE = 0x4C,
VK_HELP = 0x4D,

VK_NUMLOCK = 0x51,
VK_SCROLL = 0x52,
VK_NUMLOCK = 0x4E,
VK_SCROLL = 0x4F,

VK_LSHIFT = 0x53,
VK_RSHIFT = 0x54,
VK_LCONTROL = 0x55,
VK_RCONTROL = 0x56,
VK_LALT = 0x57,
VK_RALT = 0x58,
VK_LSHIFT = 0x50,
VK_RSHIFT = 0x51,
VK_LCONTROL = 0x52,
VK_RCONTROL = 0x53,
VK_LALT = 0x54,
VK_RALT = 0x55,

VK_LWIN = 0x59,
VK_RWIN = 0x5A,
VK_APPS = 0x5B,
VK_LWIN = 0x56,
VK_RWIN = 0x57,
VK_APPS = 0x58,

VK_F1 = 0x5C,
VK_F2 = 0x5D,
VK_F3 = 0x5E,
VK_F4 = 0x5F,
VK_F5 = 0x60,
VK_F6 = 0x61,
VK_F7 = 0x62,
VK_F8 = 0x63,
VK_F9 = 0x64,
VK_F10 = 0x65,
VK_F11 = 0x66,
VK_F12 = 0x67,
VK_F13 = 0x68,
VK_F14 = 0x69,
VK_F15 = 0x70,
VK_F16 = 0x71,
VK_F17 = 0x72,
VK_F18 = 0x73,
VK_F19 = 0x74,
VK_F20 = 0x75,
VK_F21 = 0x76,
VK_F22 = 0x77,
VK_F23 = 0x78,
VK_F24 = 0x79,
VK_F1 = 0x59,
VK_F2 = 0x5A,
VK_F3 = 0x5B,
VK_F4 = 0x5C,
VK_F5 = 0x5D,
VK_F6 = 0x5E,
VK_F7 = 0x5F,
VK_F8 = 0x60,
VK_F9 = 0x61,
VK_F10 = 0x62,
VK_F11 = 0x63,
VK_F12 = 0x64,
VK_F13 = 0x65,
VK_F14 = 0x66,
VK_F15 = 0x67,
VK_F16 = 0x68,
VK_F17 = 0x69,
VK_F18 = 0x6A,
VK_F19 = 0x6B,
VK_F20 = 0x6C,
VK_F21 = 0x6D,
VK_F22 = 0x6E,
VK_F23 = 0x6F,
VK_F24 = 0x70,

VK_BROWSER_BACK = 0x7A,
VK_BROWSER_FORWARD = 0x7B,
VK_BROWSER_REFRESH = 0x7C,
VK_BROWSER_STOP = 0x7D,
VK_BROWSER_SEARCH = 0x7E,
VK_BROWSER_FAVORITES = 0x7F,
VK_BROWSER_HOME = 0x80,
VK_VOLUME_MUTE = 0x81,
VK_VOLUME_DOWN = 0x82,
VK_VOLUME_UP = 0x83,
VK_MEDIA_NEXT_TRACK = 0x84,
VK_MEDIA_PREV_TRACK = 0x85,
VK_MEDIA_STOP = 0x86,
VK_MEDIA_PLAY_PAUSE = 0x87,
VK_LAUNCH_MAIL = 0x88,
VK_LAUNCH_MEDIA_SELECT = 0x89,
VK_LAUNCH_APP1 = 0x8A,
VK_LAUNCH_APP2 = 0x8B,
VK_POWER = 0x8C,
VK_WAKE = 0x8D,
VK_SLEEP = 0x8E,
VK_PLAY = 0x8F,
VK_ZOOM = 0x90,
VK_BROWSER_BACK = 0x71,
VK_BROWSER_FORWARD = 0x72,
VK_BROWSER_REFRESH = 0x73,
VK_BROWSER_STOP = 0x74,
VK_BROWSER_SEARCH = 0x75,
VK_BROWSER_FAVORITES = 0x76,
VK_BROWSER_HOME = 0x77,
VK_VOLUME_MUTE = 0x78,
VK_VOLUME_DOWN = 0x79,
VK_VOLUME_UP = 0x7A,
VK_MEDIA_NEXT_TRACK = 0x7B,
VK_MEDIA_PREV_TRACK = 0x7C,
VK_MEDIA_STOP = 0x7D,
VK_MEDIA_PLAY_PAUSE = 0x7E,
VK_LAUNCH_MAIL = 0x7F,
VK_LAUNCH_MEDIA_SELECT = 0x80,
VK_LAUNCH_APP1 = 0x81,
VK_LAUNCH_APP2 = 0x82,
VK_POWER = 0x83,
VK_WAKE = 0x84,
VK_SLEEP = 0x85,
VK_PLAY = 0x86,
VK_ZOOM = 0x87,

VK_KEYCOUNT = 0x91
} KeyCode_t;
VK_KEYCOUNT = 0x88
};

typedef enum KeyModifiers {
enum KeyModifiers {
VK_MODIFIER_LSHIFT = 0x1,
VK_MODIFIER_RSHIFT = 0x2,
VK_MODIFIER_LALT = 0x4,
Expand All @@ -190,8 +189,9 @@ typedef enum KeyModifiers {
VK_MODIFIER_SCROLLOCK = 0x40,
VK_MODIFIER_NUMLOCK = 0x80,
VK_MODIFIER_CAPSLOCK = 0x100,
VK_MODIFIER_REPEATED = 0x200,
VK_MODIFIER_RELEASED = 0x1000
} KeyModifiers_t;
};

_CODE_BEGIN
/**
Expand All @@ -203,8 +203,8 @@ _CODE_BEGIN
*/
CRTDECL(char,
TranslateKeyCode(
_In_ KeyCode_t keyCode,
_In_ KeyModifiers_t keyModifiers));
_In_ uint8_t keyCode,
_In_ uint16_t keyModifiers));

_CODE_END
#endif //!_KEYCODES_INTERFACE_H_
9 changes: 5 additions & 4 deletions librt/libc/os/keycodes.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* MollenOS
/**
* MollenOS
*
* Copyright 2017, Philip Meulengracht
*
Expand All @@ -24,12 +25,12 @@

#include <os/keycodes.h>

extern char GetASCIIFromKeyCodeEnUs(KeyCode_t, KeyModifiers_t);
extern char GetASCIIFromKeyCodeEnUs(uint8_t, uint16_t);

char
TranslateKeyCode(
_In_ KeyCode_t keyCode,
_In_ KeyModifiers_t keyModifiers)
_In_ uint8_t keyCode,
_In_ uint16_t keyModifiers)
{
if (keyCode != VK_INVALID) {
return GetASCIIFromKeyCodeEnUs(keyCode, keyModifiers);
Expand Down
Loading

0 comments on commit f90cf19

Please sign in to comment.