From 5a079a2d114f96d4847d1ee305d5b7c16eeec50e Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 27 Dec 2025 12:03:39 -0800 Subject: Initial commit --- .../SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h | 51 ++++ .../SDL-3.2.8/src/video/riscos/SDL_riscosevents.c | 177 ++++++++++++ .../src/video/riscos/SDL_riscosevents_c.h | 33 +++ .../src/video/riscos/SDL_riscosframebuffer.c | 127 +++++++++ .../src/video/riscos/SDL_riscosframebuffer_c.h | 31 +++ .../src/video/riscos/SDL_riscosmessagebox.c | 67 +++++ .../src/video/riscos/SDL_riscosmessagebox.h | 27 ++ .../SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c | 310 +++++++++++++++++++++ .../SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h | 30 ++ .../SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c | 79 ++++++ .../SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h | 28 ++ .../SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c | 130 +++++++++ .../SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h | 36 +++ .../SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c | 56 ++++ .../SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h | 38 +++ .../SDL-3.2.8/src/video/riscos/scancodes_riscos.h | 157 +++++++++++ 16 files changed, 1377 insertions(+) create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h (limited to 'contrib/SDL-3.2.8/src/video/riscos') diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h new file mode 100644 index 0000000..85be939 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosdefs_h_ +#define SDL_riscosdefs_h_ + +typedef struct sprite_area +{ + int size; // +0 + int count; // +4 + int start; // +8 + int end; // +12 +} sprite_area; + +SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16); + +typedef struct sprite_header +{ + int next; // +0 + char name[12]; // +4 + int width; // +16 + int height; // +20 + int first_bit; // +24 + int last_bit; // +28 + int image_offset; // +32 + int mask_offset; // +36 + int mode; // +40 +} sprite_header; + +SDL_COMPILE_TIME_ASSERT(sprite_header, sizeof(sprite_header) == 44); + +#endif // SDL_riscosdefs_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c new file mode 100644 index 0000000..367ea47 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c @@ -0,0 +1,177 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../../events/SDL_events_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosevents_c.h" +#include "scancodes_riscos.h" + +#include +#include + +static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(riscos_scancode_table)) { + scancode = riscos_scancode_table[keycode]; + +#ifdef DEBUG_SCANCODES + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("The key you just pressed is not recognized by SDL: %d", keycode); + } +#endif + } + + return scancode; +} + +void RISCOS_PollKeyboard(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + Uint8 key = 2; + int i; + + // Check for key releases + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + if (internal->key_pressed[i] != 255) { + if ((_kernel_osbyte(129, internal->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, internal->key_pressed[i], SDL_RISCOS_translate_keycode(internal->key_pressed[i]), false); + internal->key_pressed[i] = 255; + } + } + } + + // Check for key presses + while (key < 0xff) { + key = _kernel_osbyte(121, key + 1, 0) & 0xff; + switch (key) { + case 255: + // Ignore mouse keys + case 9: + case 10: + case 11: + // Ignore keys with multiple INKEY codes + case 24: + case 40: + case 71: + case 87: + break; + + default: + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, key, SDL_RISCOS_translate_keycode(key), true); + + // Record the press so we can detect release later. + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + if (internal->key_pressed[i] == key) { + break; + } + if (internal->key_pressed[i] == 255) { + internal->key_pressed[i] = key; + break; + } + } + } + } +} + +static const Uint8 mouse_button_map[] = { + SDL_BUTTON_RIGHT, + SDL_BUTTON_MIDDLE, + SDL_BUTTON_LEFT, + SDL_BUTTON_X1, + SDL_BUTTON_X2, + SDL_BUTTON_X2 + 1, + SDL_BUTTON_X2 + 2, + SDL_BUTTON_X2 + 3 +}; + +void RISCOS_PollMouse(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_Rect rect; + _kernel_swi_regs regs; + int i, x, y, buttons; + + if (!SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &rect)) { + return; + } + + _kernel_swi(OS_Mouse, ®s, ®s); + x = (regs.r[0] >> 1); + y = rect.h - (regs.r[1] >> 1); + buttons = regs.r[2]; + + if (mouse->x != x || mouse->y != y) { + SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y); + } + + if (internal->last_mouse_buttons != buttons) { + for (i = 0; i < SDL_arraysize(mouse_button_map); i++) { + bool down = ((buttons & (1 << i)) != 0); + SDL_SendMouseButton(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, mouse_button_map[i], down); + } + internal->last_mouse_buttons = buttons; + } +} + +bool RISCOS_InitEvents(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + _kernel_swi_regs regs; + int i, status; + + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + internal->key_pressed[i] = 255; + } + + status = (_kernel_osbyte(202, 0, 255) & 0xFF); + SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? false : true); + SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? false : true); + SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? true : false); + + _kernel_swi(OS_Mouse, ®s, ®s); + internal->last_mouse_buttons = regs.r[2]; + + // Disable escape. + _kernel_osbyte(229, 1, 0); + + return true; +} + +void RISCOS_PumpEvents(SDL_VideoDevice *_this) +{ + RISCOS_PollMouse(_this); + RISCOS_PollKeyboard(_this); +} + +void RISCOS_QuitEvents(SDL_VideoDevice *_this) +{ + // Re-enable escape. + _kernel_osbyte(229, 0, 0); +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h new file mode 100644 index 0000000..5db26fd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_riscosevents_c_h_ +#define SDL_riscosevents_c_h_ + +#include "SDL_internal.h" + +#include "SDL_riscosvideo.h" + +extern bool RISCOS_InitEvents(SDL_VideoDevice *_this); +extern void RISCOS_PumpEvents(SDL_VideoDevice *_this); +extern void RISCOS_QuitEvents(SDL_VideoDevice *_this); + +#endif // SDL_riscosevents_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c new file mode 100644 index 0000000..a13cab8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c @@ -0,0 +1,127 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "SDL_riscosframebuffer_c.h" +#include "SDL_riscosvideo.h" +#include "SDL_riscoswindow.h" + +#include +#include + +bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_WindowData *internal = window->internal; + const char *sprite_name = "display"; + unsigned int sprite_mode; + _kernel_oserror *error; + _kernel_swi_regs regs; + const SDL_DisplayMode *mode; + int size; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + // Free the old framebuffer surface + RISCOS_DestroyWindowFramebuffer(_this, window); + + // Create a new one + mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window)); + if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) { + *format = mode->format; + sprite_mode = (unsigned int)mode->internal; + } else { + *format = SDL_PIXELFORMAT_XBGR8888; + sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27)); + } + + // Calculate pitch + *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + + // Allocate the sprite area + size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h); + internal->fb_area = SDL_malloc(size); + if (!internal->fb_area) { + return false; + } + + internal->fb_area->size = size; + internal->fb_area->count = 0; + internal->fb_area->start = 16; + internal->fb_area->end = 16; + + // Create the actual image + regs.r[0] = 256 + 15; + regs.r[1] = (int)internal->fb_area; + regs.r[2] = (int)sprite_name; + regs.r[3] = 0; + regs.r[4] = w; + regs.r[5] = h; + regs.r[6] = sprite_mode; + error = _kernel_swi(OS_SpriteOp, ®s, ®s); + if (error) { + SDL_free(internal->fb_area); + return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum); + } + + internal->fb_sprite = (sprite_header *)(((Uint8 *)internal->fb_area) + internal->fb_area->start); + *pixels = ((Uint8 *)internal->fb_sprite) + internal->fb_sprite->image_offset; + + return true; +} + +bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *internal = window->internal; + _kernel_swi_regs regs; + _kernel_oserror *error; + + regs.r[0] = 512 + 52; + regs.r[1] = (int)internal->fb_area; + regs.r[2] = (int)internal->fb_sprite; + regs.r[3] = 0; // window->x << 1; + regs.r[4] = 0; // window->y << 1; + regs.r[5] = 0x50; + regs.r[6] = 0; + regs.r[7] = 0; + error = _kernel_swi(OS_SpriteOp, ®s, ®s); + if (error) { + return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum); + } + + return true; +} + +void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *internal = window->internal; + + if (internal->fb_area) { + SDL_free(internal->fb_area); + internal->fb_area = NULL; + } + internal->fb_sprite = NULL; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h new file mode 100644 index 0000000..ee3c847 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_riscosframebuffer_c_h_ +#define SDL_riscosframebuffer_c_h_ + +#include "SDL_internal.h" + +extern bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_riscosframebuffer_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c new file mode 100644 index 0000000..a4b358c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "SDL_riscosmessagebox.h" + +#include +#include + +bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + _kernel_swi_regs regs; + _kernel_oserror error; + char buttonstring[1024]; + int i; + + error.errnum = 0; + SDL_strlcpy(error.errmess, messageboxdata->message, 252); + regs.r[0] = (unsigned int)&error; + + regs.r[1] = (1 << 8) | (1 << 4); + if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) { + regs.r[1] |= (1 << 9); + } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) { + regs.r[1] |= (2 << 9); + } + + regs.r[2] = (unsigned int)messageboxdata->title; + regs.r[3] = 0; + regs.r[4] = 0; + + SDL_strlcpy(buttonstring, "", 1024); + for (i = 0; i < messageboxdata->numbuttons; i++) { + SDL_strlcat(buttonstring, messageboxdata->buttons[i].text, 1024); + if (i + 1 < messageboxdata->numbuttons) { + SDL_strlcat(buttonstring, ",", 1024); + } + } + regs.r[5] = (unsigned int)buttonstring; + + _kernel_swi(Wimp_ReportError, ®s, ®s); + + *buttonID = (regs.r[1] == 0) ? -1 : messageboxdata->buttons[regs.r[1] - 3].buttonID; + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h new file mode 100644 index 0000000..21af02f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +extern bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c new file mode 100644 index 0000000..d4e9a53 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c @@ -0,0 +1,310 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosmodes.h" + +#include +#include + +enum +{ + MODE_FLAG_565 = 1 << 7, + + MODE_FLAG_COLOUR_SPACE = 0xF << 12, + + MODE_FLAG_TBGR = 0, + MODE_FLAG_TRGB = 1 << 14, + MODE_FLAG_ABGR = 1 << 15, + MODE_FLAG_ARGB = MODE_FLAG_TRGB | MODE_FLAG_ABGR +}; + +static const struct +{ + SDL_PixelFormat pixel_format; + int modeflags, ncolour, log2bpp; +} mode_to_pixelformat[] = { + // { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, + // { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 }, + // { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 }, + // { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 }, + { SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 }, + { SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 }, + { SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 }, + { SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 }, + { SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 }, + { SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 }, + { SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 }, + { SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 }, + { SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 }, + { SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 }, + { SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 }, + { SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 }, + { SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 }, + { SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 } +}; + +static SDL_PixelFormat RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp) +{ + int i; + + for (i = 0; i < SDL_arraysize(mode_to_pixelformat); i++) { + if (log2bpp == mode_to_pixelformat[i].log2bpp && + (ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) && + (modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) { + return mode_to_pixelformat[i].pixel_format; + } + } + + return SDL_PIXELFORMAT_UNKNOWN; +} + +static size_t measure_mode_block(const int *block) +{ + size_t blockSize = ((block[0] & 0xFF) == 3) ? 7 : 5; + while (block[blockSize] != -1) { + blockSize += 2; + } + blockSize++; + + return blockSize * 4; +} + +static bool read_mode_variable(int *block, int var) +{ + _kernel_swi_regs regs; + regs.r[0] = (int)block; + regs.r[1] = var; + _kernel_swi(OS_ReadModeVariable, ®s, ®s); + return regs.r[2]; +} + +static bool read_mode_block(int *block, SDL_DisplayMode *mode, bool extended) +{ + int xres, yres, ncolour, modeflags, log2bpp, rate; + + if ((block[0] & 0xFF) == 1) { + xres = block[1]; + yres = block[2]; + log2bpp = block[3]; + rate = block[4]; + ncolour = (1 << (1 << log2bpp)) - 1; + modeflags = MODE_FLAG_TBGR; + } else if ((block[0] & 0xFF) == 3) { + xres = block[1]; + yres = block[2]; + ncolour = block[3]; + modeflags = block[4]; + log2bpp = block[5]; + rate = block[6]; + } else { + return false; + } + + if (extended) { + xres = read_mode_variable(block, 11) + 1; + yres = read_mode_variable(block, 12) + 1; + log2bpp = read_mode_variable(block, 9); + ncolour = read_mode_variable(block, 3); + modeflags = read_mode_variable(block, 0); + } + + SDL_zerop(mode); + mode->w = xres; + mode->h = yres; + mode->format = RISCOS_ModeToPixelFormat(ncolour, modeflags, log2bpp); + mode->refresh_rate = (float)rate; + + return true; +} + +static void *convert_mode_block(const int *block) +{ + int xres, yres, log2bpp, rate, ncolour = 0, modeflags = 0; + size_t pos = 0; + int *dst; + + if ((block[0] & 0xFF) == 1) { + xres = block[1]; + yres = block[2]; + log2bpp = block[3]; + rate = block[4]; + } else if ((block[0] & 0xFF) == 3) { + xres = block[1]; + yres = block[2]; + ncolour = block[3]; + modeflags = block[4]; + log2bpp = block[5]; + rate = block[6]; + } else { + return NULL; + } + + dst = SDL_malloc(40); + if (!dst) { + return NULL; + } + + dst[pos++] = 1; + dst[pos++] = xres; + dst[pos++] = yres; + dst[pos++] = log2bpp; + dst[pos++] = rate; + if (ncolour != 0) { + dst[pos++] = 3; + dst[pos++] = ncolour; + } + if (modeflags != 0) { + dst[pos++] = 0; + dst[pos++] = modeflags; + } + dst[pos++] = -1; + + return dst; +} + +static void *copy_memory(const void *src, size_t size, size_t alloc) +{ + void *dst = SDL_malloc(alloc); + if (dst) { + SDL_memcpy(dst, src, size); + } + return dst; +} + +bool RISCOS_InitModes(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + int *current_mode; + _kernel_swi_regs regs; + _kernel_oserror *error; + size_t size; + + regs.r[0] = 1; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum); + } + + current_mode = (int *)regs.r[1]; + if (!read_mode_block(current_mode, &mode, true)) { + return SDL_SetError("Unsupported mode block format %d", current_mode[0]); + } + + size = measure_mode_block(current_mode); + mode.internal = copy_memory(current_mode, size, size); + if (!mode.internal) { + return false; + } + + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + return true; +} + +bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayMode mode; + _kernel_swi_regs regs; + _kernel_oserror *error; + void *block, *pos; + + regs.r[0] = 2; + regs.r[2] = 0; + regs.r[6] = 0; + regs.r[7] = 0; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); + } + + block = SDL_malloc(-regs.r[7]); + if (!block) { + return false; + } + + regs.r[6] = (int)block; + regs.r[7] = -regs.r[7]; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + SDL_free(block); + return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); + } + + for (pos = block; pos < (void *)regs.r[6]; pos += *((int *)pos)) { + if (!read_mode_block(pos + 4, &mode, false)) { + continue; + } + + if (mode.format == SDL_PIXELFORMAT_UNKNOWN) { + continue; + } + + mode.internal = convert_mode_block(pos + 4); + if (!mode.internal) { + SDL_free(block); + return false; + } + + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + SDL_free(mode.internal); + } + } + + SDL_free(block); + return true; +} + +bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + const char disable_cursor[] = { 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + _kernel_swi_regs regs; + _kernel_oserror *error; + int i; + + regs.r[0] = 0; + regs.r[1] = (int)mode->internal; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); + } + + // Turn the text cursor off + for (i = 0; i < SDL_arraysize(disable_cursor); i++) { + _kernel_oswrch(disable_cursor[i]); + } + + // Update cursor visibility, since it may have been disabled by the mode change. + SDL_SetCursor(NULL); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h new file mode 100644 index 0000000..fa5d65c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosmodes_h_ +#define SDL_riscosmodes_h_ + +extern bool RISCOS_InitModes(SDL_VideoDevice *_this); +extern bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); + +#endif // SDL_riscosmodes_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c new file mode 100644 index 0000000..d67e7c8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c @@ -0,0 +1,79 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "SDL_riscosvideo.h" +#include "SDL_riscosmouse.h" +#include "../../events/SDL_mouse_c.h" + +#include + +static SDL_Cursor *RISCOS_CreateDefaultCursor(void) +{ + SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + // NULL is used to indicate the default cursor + cursor->internal = NULL; + } + + return cursor; +} + +static void RISCOS_FreeCursor(SDL_Cursor *cursor) +{ + SDL_free(cursor); +} + +static bool RISCOS_ShowCursor(SDL_Cursor *cursor) +{ + if (cursor) { + // Turn the mouse pointer on + _kernel_osbyte(106, 1, 0); + } else { + // Turn the mouse pointer off + _kernel_osbyte(106, 0, 0); + } + + return true; +} + +bool RISCOS_InitMouse(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + // mouse->CreateCursor = RISCOS_CreateCursor; + // mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; + mouse->ShowCursor = RISCOS_ShowCursor; + mouse->FreeCursor = RISCOS_FreeCursor; + // mouse->WarpMouse = RISCOS_WarpMouse; + // mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; + // mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; + // mouse->CaptureMouse = RISCOS_CaptureMouse; + // mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; + + SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor()); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h new file mode 100644 index 0000000..e28d1dc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosmouse_h_ +#define SDL_riscosmouse_h_ + +extern bool RISCOS_InitMouse(SDL_VideoDevice *_this); + +#endif // SDL_riscosmouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c new file mode 100644 index 0000000..1f556d2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c @@ -0,0 +1,130 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosevents_c.h" +#include "SDL_riscosframebuffer_c.h" +#include "SDL_riscosmouse.h" +#include "SDL_riscosmodes.h" +#include "SDL_riscoswindow.h" +#include "SDL_riscosmessagebox.h" + +#define RISCOSVID_DRIVER_NAME "riscos" + +// Initialization/Query functions +static bool RISCOS_VideoInit(SDL_VideoDevice *_this); +static void RISCOS_VideoQuit(SDL_VideoDevice *_this); + +// RISC OS driver bootstrap functions + +static void RISCOS_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *RISCOS_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal data + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!data) { + SDL_free(device); + return NULL; + } + + device->internal = data; + + // Set the function pointers + device->VideoInit = RISCOS_VideoInit; + device->VideoQuit = RISCOS_VideoQuit; + device->PumpEvents = RISCOS_PumpEvents; + + device->GetDisplayModes = RISCOS_GetDisplayModes; + device->SetDisplayMode = RISCOS_SetDisplayMode; + + device->CreateSDLWindow = RISCOS_CreateWindow; + device->DestroyWindow = RISCOS_DestroyWindow; + + device->CreateWindowFramebuffer = RISCOS_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = RISCOS_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = RISCOS_DestroyWindowFramebuffer; + + device->free = RISCOS_DeleteDevice; + + // TODO: Support windowed mode + device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY; + + return device; +} + +VideoBootStrap RISCOS_bootstrap = { + RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver", + RISCOS_CreateDevice, + RISCOS_ShowMessageBox, + false +}; + +static bool RISCOS_VideoInit(SDL_VideoDevice *_this) +{ + if (!RISCOS_InitEvents(_this)) { + return false; + } + + if (!RISCOS_InitMouse(_this)) { + return false; + } + + // Assume we have a mouse and keyboard + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + + if (!RISCOS_InitModes(_this)) { + return false; + } + + // We're done! + return true; +} + +static void RISCOS_VideoQuit(SDL_VideoDevice *_this) +{ + RISCOS_QuitEvents(_this); +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h new file mode 100644 index 0000000..f9e42ee --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosvideo_h_ +#define SDL_riscosvideo_h_ + +#include "../SDL_sysvideo.h" + +#define RISCOS_MAX_KEYS_PRESSED 6 + +struct SDL_VideoData +{ + int last_mouse_buttons; + Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED]; +}; + +#endif // SDL_riscosvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c new file mode 100644 index 0000000..cc28123 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c @@ -0,0 +1,56 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscoswindow.h" + +bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *data; + + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + return false; + } + data->window = window; + + SDL_SetMouseFocus(window); + + // All done! + window->internal = data; + return true; +} + +void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal) { + SDL_free(window->internal); + window->internal = NULL; + } +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h new file mode 100644 index 0000000..eefec97 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscoswindow_h_ +#define SDL_riscoswindow_h_ + +#include "SDL_riscosdefs.h" + +struct SDL_WindowData +{ + SDL_Window *window; + sprite_area *fb_area; + sprite_header *fb_sprite; +}; + +extern bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_riscoswindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h new file mode 100644 index 0000000..2b99135 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h @@ -0,0 +1,157 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* RISC OS key code to SDL_Keycode mapping table + Sources: + - https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes +*/ +/* *INDENT-OFF* */ // clang-format off +static SDL_Scancode const riscos_scancode_table[] = { + /* 0 */ SDL_SCANCODE_UNKNOWN, // Shift + /* 1 */ SDL_SCANCODE_UNKNOWN, // Ctrl + /* 2 */ SDL_SCANCODE_UNKNOWN, // Alt + /* 3 */ SDL_SCANCODE_LSHIFT, + /* 4 */ SDL_SCANCODE_LCTRL, + /* 5 */ SDL_SCANCODE_LALT, + /* 6 */ SDL_SCANCODE_RSHIFT, + /* 7 */ SDL_SCANCODE_RCTRL, + /* 8 */ SDL_SCANCODE_RALT, + /* 9 */ SDL_SCANCODE_UNKNOWN, // Left mouse + /* 10 */ SDL_SCANCODE_UNKNOWN, // Center mouse + /* 11 */ SDL_SCANCODE_UNKNOWN, // Right mouse + /* 12 */ SDL_SCANCODE_UNKNOWN, + /* 13 */ SDL_SCANCODE_UNKNOWN, + /* 14 */ SDL_SCANCODE_UNKNOWN, + /* 15 */ SDL_SCANCODE_UNKNOWN, + /* 16 */ SDL_SCANCODE_Q, + /* 17 */ SDL_SCANCODE_3, + /* 18 */ SDL_SCANCODE_4, + /* 19 */ SDL_SCANCODE_5, + /* 20 */ SDL_SCANCODE_F4, + /* 21 */ SDL_SCANCODE_8, + /* 22 */ SDL_SCANCODE_F7, + /* 23 */ SDL_SCANCODE_MINUS, + /* 24 */ SDL_SCANCODE_6, // Duplicate of 52 + /* 25 */ SDL_SCANCODE_LEFT, + /* 26 */ SDL_SCANCODE_KP_6, + /* 27 */ SDL_SCANCODE_KP_7, + /* 28 */ SDL_SCANCODE_F11, + /* 29 */ SDL_SCANCODE_F12, + /* 30 */ SDL_SCANCODE_F10, + /* 31 */ SDL_SCANCODE_SCROLLLOCK, + /* 32 */ SDL_SCANCODE_PRINTSCREEN, + /* 33 */ SDL_SCANCODE_W, + /* 34 */ SDL_SCANCODE_E, + /* 35 */ SDL_SCANCODE_T, + /* 36 */ SDL_SCANCODE_7, + /* 37 */ SDL_SCANCODE_I, + /* 38 */ SDL_SCANCODE_9, + /* 39 */ SDL_SCANCODE_0, + /* 40 */ SDL_SCANCODE_MINUS, // Duplicate of 23 + /* 41 */ SDL_SCANCODE_DOWN, + /* 42 */ SDL_SCANCODE_KP_8, + /* 43 */ SDL_SCANCODE_KP_9, + /* 44 */ SDL_SCANCODE_PAUSE, + /* 45 */ SDL_SCANCODE_GRAVE, + /* 46 */ SDL_SCANCODE_CURRENCYUNIT, + /* 47 */ SDL_SCANCODE_BACKSPACE, + /* 48 */ SDL_SCANCODE_1, + /* 49 */ SDL_SCANCODE_2, + /* 50 */ SDL_SCANCODE_D, + /* 51 */ SDL_SCANCODE_R, + /* 52 */ SDL_SCANCODE_6, + /* 53 */ SDL_SCANCODE_U, + /* 54 */ SDL_SCANCODE_O, + /* 55 */ SDL_SCANCODE_P, + /* 56 */ SDL_SCANCODE_LEFTBRACKET, + /* 57 */ SDL_SCANCODE_UP, + /* 58 */ SDL_SCANCODE_KP_PLUS, + /* 59 */ SDL_SCANCODE_KP_MINUS, + /* 60 */ SDL_SCANCODE_KP_ENTER, + /* 61 */ SDL_SCANCODE_INSERT, + /* 62 */ SDL_SCANCODE_HOME, + /* 63 */ SDL_SCANCODE_PAGEUP, + /* 64 */ SDL_SCANCODE_CAPSLOCK, + /* 65 */ SDL_SCANCODE_A, + /* 66 */ SDL_SCANCODE_X, + /* 67 */ SDL_SCANCODE_F, + /* 68 */ SDL_SCANCODE_Y, + /* 69 */ SDL_SCANCODE_J, + /* 70 */ SDL_SCANCODE_K, + /* 71 */ SDL_SCANCODE_2, // Duplicate of 49 + /* 72 */ SDL_SCANCODE_SEMICOLON, // Duplicate of 87 + /* 73 */ SDL_SCANCODE_RETURN, + /* 74 */ SDL_SCANCODE_KP_DIVIDE, + /* 75 */ SDL_SCANCODE_UNKNOWN, + /* 76 */ SDL_SCANCODE_KP_PERIOD, + /* 77 */ SDL_SCANCODE_NUMLOCKCLEAR, + /* 78 */ SDL_SCANCODE_PAGEDOWN, + /* 79 */ SDL_SCANCODE_APOSTROPHE, + /* 80 */ SDL_SCANCODE_UNKNOWN, + /* 81 */ SDL_SCANCODE_S, + /* 82 */ SDL_SCANCODE_C, + /* 83 */ SDL_SCANCODE_G, + /* 84 */ SDL_SCANCODE_H, + /* 85 */ SDL_SCANCODE_N, + /* 86 */ SDL_SCANCODE_L, + /* 87 */ SDL_SCANCODE_SEMICOLON, + /* 88 */ SDL_SCANCODE_RIGHTBRACKET, + /* 89 */ SDL_SCANCODE_DELETE, + /* 90 */ SDL_SCANCODE_KP_HASH, + /* 91 */ SDL_SCANCODE_KP_MULTIPLY, + /* 92 */ SDL_SCANCODE_UNKNOWN, + /* 93 */ SDL_SCANCODE_EQUALS, + /* 94 */ SDL_SCANCODE_NONUSBACKSLASH, + /* 95 */ SDL_SCANCODE_UNKNOWN, + /* 96 */ SDL_SCANCODE_TAB, + /* 97 */ SDL_SCANCODE_Z, + /* 98 */ SDL_SCANCODE_SPACE, + /* 99 */ SDL_SCANCODE_V, + /* 100 */ SDL_SCANCODE_B, + /* 101 */ SDL_SCANCODE_M, + /* 102 */ SDL_SCANCODE_COMMA, + /* 103 */ SDL_SCANCODE_PERIOD, + /* 104 */ SDL_SCANCODE_SLASH, + /* 105 */ SDL_SCANCODE_END, + /* 106 */ SDL_SCANCODE_KP_0, + /* 107 */ SDL_SCANCODE_KP_1, + /* 108 */ SDL_SCANCODE_KP_3, + /* 109 */ SDL_SCANCODE_UNKNOWN, + /* 110 */ SDL_SCANCODE_UNKNOWN, + /* 111 */ SDL_SCANCODE_UNKNOWN, + /* 112 */ SDL_SCANCODE_ESCAPE, + /* 113 */ SDL_SCANCODE_F1, + /* 114 */ SDL_SCANCODE_F2, + /* 115 */ SDL_SCANCODE_F3, + /* 116 */ SDL_SCANCODE_F5, + /* 117 */ SDL_SCANCODE_F6, + /* 118 */ SDL_SCANCODE_F8, + /* 119 */ SDL_SCANCODE_F9, + /* 120 */ SDL_SCANCODE_BACKSLASH, + /* 121 */ SDL_SCANCODE_RIGHT, + /* 122 */ SDL_SCANCODE_KP_4, + /* 123 */ SDL_SCANCODE_KP_5, + /* 124 */ SDL_SCANCODE_KP_2, + /* 125 */ SDL_SCANCODE_LGUI, + /* 126 */ SDL_SCANCODE_RGUI, + /* 127 */ SDL_SCANCODE_MENU +}; +/* *INDENT-ON* */ // clang-format on -- cgit v1.2.3