mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-19 09:34:12 +00:00
* Allow HTTP access to Raspberry Pi over local network Lower audio buffer maximum theoretical size to get the worker code to compile on Raspberry Pi * Add https port flag to run https worker and coordinator on the same machine Add https chain and key flags to allow to use an existing certificate and bypass letsencrypt Note the ping address resolution is still broken with this configuration * Add option to define a ping server in the coordinator This is useful when it is not predicatable what address and port the worker will be runnning at This only works when there is a single worker * Free temporarily allocated CStrings Store constant CString * Only load core once and unload it when done * Add Nintendo 64 support! Disclaimer: only tested with Mupen64plus and Mupen64plusNext on Raspberry Pi. It probably needs more work to run on every system and with other OpenGL libretro libraries. Input controls are hacked together, it really needs analog stick and remapping support to play in a nicer way. I am worried there might be a memory leak when unloading Mupen64plus but this needs further investigation. * Add analog sticks + R2,L2,R3,L3 support * Add client logic to control left analog stick via keyboard and touch Add client logic to toggle between dpad mode and analog mode (even for joystick) Might need to revisit if and when remapping is implemented Tocuh sensitivity of analog stick is pretty high, might need tweaking * Add cores for Raspberry Pi Add N64 core for linux x86_64 * Reset use OpenGL flag on nanoarch shutdown (line lost in refactoring)
90 lines
2.9 KiB
JavaScript
Vendored
90 lines
2.9 KiB
JavaScript
Vendored
/**
|
|
* Event publishing / subscribe module.
|
|
* Just a simple observer pattern.
|
|
* @version 1
|
|
*/
|
|
const event = (() => {
|
|
const topics = {};
|
|
|
|
return {
|
|
/**
|
|
* Subscribes onto some event.
|
|
*
|
|
* @param topic The name of the event.
|
|
* @param listener A callback function to call during the event.
|
|
* @param order A number in a queue of event handlers to run callback in ordered manner.
|
|
* @returns {{unsub: unsub}} The function to remove this subscription.
|
|
* @example
|
|
* const sub01 = event.sub('rapture', () => {a}, 1)
|
|
* ...
|
|
* sub01.unsub()
|
|
*/
|
|
sub: (topic, listener, order) => {
|
|
if (!topics[topic]) topics[topic] = [];
|
|
|
|
// order handling stuff
|
|
const value = {order: order || 0, listener: listener};
|
|
topics[topic].push(value);
|
|
topics[topic].sort((a, b) => a.order - b.order);
|
|
const index = topics[topic].indexOf(value);
|
|
|
|
return {
|
|
unsub: () => {
|
|
topics[topic].splice(index, 1);
|
|
}
|
|
};
|
|
},
|
|
|
|
/**
|
|
* Publishes some event for handling.
|
|
*
|
|
* @param topic The name of the event.
|
|
* @param data Additional data for the event handling.
|
|
* Because of compatibility we have to use a dumb obj wrapper {a: a, b: b} for params instead of (topic, ...data).
|
|
* @example
|
|
* event.pub('rapture', {time: now()})
|
|
*/
|
|
pub: (topic, data) => {
|
|
if (!topics[topic] || topics[topic].length < 1) return;
|
|
|
|
topics[topic].forEach((listener) => {
|
|
listener.listener(data !== undefined ? data : {})
|
|
});
|
|
}
|
|
}
|
|
})();
|
|
|
|
// events
|
|
const LATENCY_CHECK_REQUESTED = 'latencyCheckRequested';
|
|
const PING_REQUEST = 'pingRequest';
|
|
const PING_RESPONSE = 'pingResponse';
|
|
|
|
const GAME_ROOM_AVAILABLE = 'gameRoomAvailable';
|
|
const GAME_SAVED = 'gameSaved';
|
|
const GAME_LOADED = 'gameLoaded';
|
|
const GAME_PLAYER_IDX = 'gamePlayerIndex';
|
|
|
|
const CONNECTION_READY = 'connectionReady';
|
|
const CONNECTION_CLOSED = 'connectionClosed';
|
|
|
|
const MEDIA_STREAM_INITIALIZED = 'mediaStreamInitialized';
|
|
const MEDIA_STREAM_SDP_AVAILABLE = 'mediaStreamSdpAvailable';
|
|
const MEDIA_STREAM_CANDIDATE_ADD = 'mediaStreamCandidateAdd';
|
|
const MEDIA_STREAM_CANDIDATE_FLUSH = 'mediaStreamCandidateFlush';
|
|
const MEDIA_STREAM_READY = 'mediaStreamReady';
|
|
|
|
const GAMEPAD_CONNECTED = 'gamepadConnected';
|
|
const GAMEPAD_DISCONNECTED = 'gamepadDisconnected';
|
|
|
|
const MENU_HANDLER_ATTACHED = 'menuHandlerAttached';
|
|
const MENU_PRESSED = 'menuPressed';
|
|
const MENU_RELEASED = 'menuReleased';
|
|
|
|
const KEY_PRESSED = 'keyPressed';
|
|
const KEY_RELEASED = 'keyReleased';
|
|
const AXIS_CHANGED = 'axisChanged';
|
|
const CONTROLLER_UPDATED = 'controllerUpdated';
|
|
|
|
const DPAD_TOGGLE = 'dpadToggle';
|
|
const STATS_TOGGLE = 'statsToggle';
|
|
const HELP_OVERLAY_TOGGLED = 'helpOverlayToggled';
|