comment out gpio stuff

This commit is contained in:
dylan
2024-04-04 08:58:39 -07:00
parent 85cbf665f0
commit 903c66b1d9
3 changed files with 76 additions and 48 deletions

View File

@ -35,7 +35,10 @@ export type PicoPlayerHandle = {
rightClick: boolean;
}) => void;
setGamepadCount: (count: number) => void;
gpio: number[] & {subscribe: (f: (gpio: number[]) => void) => void}; // read + write (should be 256-tuple)
gpio: (
number[]
// & {subscribe: (f: (gpio: number[]) => void) => void}
); // read + write (should be 256-tuple)
// state
readonly state: {
@ -97,8 +100,7 @@ export const makePicoConsole = async (props: {
handle.pico8_state = {};
handle.pico8_buttons = [0,0,0,0,0,0,0,0];
handle.pico8_mouse = [0,0,0];
let gpioChanged = (gpio: number[]) => {};
const gpioInner = [
handle.pico8_gpio = [
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -116,27 +118,46 @@ export const makePicoConsole = async (props: {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
];
handle.pico8_gpio = new Proxy(gpioInner, {
get(target, prop) {
return target[prop as any];
},
set(target, prop, newValue) {
const t = target as any;
if (t.setting) {
return false;
}
const prev = [...target];
target[prop as any] = newValue;
const next = [...target];
if (!t.dontSend && prev.some((p, i) => p !== next[i])) {
gpioChanged(target);
}
return true;
}
});
(handle as any).pico8_gpio.subscribe = (f: (gpio: number[]) => void) => {
gpioChanged = f;
}
// let gpioChanged = (gpio: number[]) => {};
// const gpioInner = [
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
// ];
// handle.pico8_gpio = new Proxy(gpioInner, {
// get(target, prop) {
// return target[prop as any];
// },
// set(target, prop, newValue) {
// const t = target as any;
// if (t.setting) {
// return false;
// }
// const prev = [...target];
// target[prop as any] = newValue;
// const next = [...target];
// if (!t.dontSend && prev.some((p, i) => p !== next[i])) {
// gpioChanged(target);
// }
// return true;
// }
// });
// (handle as any).pico8_gpio.subscribe = (f: (gpio: number[]) => void) => {
// gpioChanged = f;
// }
handle.pico8_gamepads = {count: 0};
return {
raw: handle,