From 0646bbf2373a2c7bb12a81bca58f40022b8e5f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 13 Nov 2022 23:06:15 +0000 Subject: [PATCH] feat: keyboard as feature --- examples/web/gb.ts | 8 +++++++- examples/web/react/app.tsx | 42 +++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/examples/web/gb.ts b/examples/web/gb.ts index d38d87db..5b0c961e 100644 --- a/examples/web/gb.ts +++ b/examples/web/gb.ts @@ -346,7 +346,13 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { } get features(): Feature[] { - return [Feature.Debug, Feature.Palettes, Feature.Benchmark]; + return [ + Feature.Debug, + Feature.Palettes, + Feature.Benchmark, + Feature.Keyboard, + Feature.KeyboardGB + ]; } get romExts(): string[] { diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx index bed7224e..4f02e160 100644 --- a/examples/web/react/app.tsx +++ b/examples/web/react/app.tsx @@ -15,6 +15,7 @@ import { DrawHandler, Footer, Info, + KeyboardChip8, KeyboardGB, Link, Modal, @@ -80,7 +81,10 @@ export type BenchmarkResult = { export enum Feature { Debug = 1, Palettes, - Benchmark + Benchmark, + Keyboard, + KeyboardChip8, + KeyboardGB } export interface ObservableI { @@ -591,11 +595,19 @@ export const App: FC<AppProps> = ({ } > <Section visible={keyboardVisible} separatorBottom={true}> - <KeyboardGB - fullscreen={fullscreenState} - onKeyDown={onKeyDown} - onKeyUp={onKeyUp} - /> + {hasFeature(Feature.KeyboardChip8) && ( + <KeyboardChip8 + onKeyDown={onKeyDown} + onKeyUp={onKeyUp} + /> + )} + {hasFeature(Feature.KeyboardGB) && ( + <KeyboardGB + fullscreen={fullscreenState} + onKeyDown={onKeyDown} + onKeyUp={onKeyUp} + /> + )} </Section> <Title text={emulator.name} @@ -774,14 +786,16 @@ export const App: FC<AppProps> = ({ style={["simple", "border", "padded"]} onClick={onFullscreenClick} /> - <Button - text={"Keyboard"} - image={require("../res/dialpad.svg")} - imageAlt="keyboard" - enabled={keyboardVisible} - style={["simple", "border", "padded"]} - onClick={onKeyboardClick} - /> + {hasFeature(Feature.Keyboard) && ( + <Button + text={"Keyboard"} + image={require("../res/dialpad.svg")} + imageAlt="keyboard" + enabled={keyboardVisible} + style={["simple", "border", "padded"]} + onClick={onKeyboardClick} + /> + )} <Button text={"Information"} image={require("../res/info.svg")} -- GitLab