gamercade-io / gamercade_console

A Neo-Retro Fantasy Console. Make WASM-powered, networked multiplayer games.
https://gamercade.io
Apache License 2.0
165 stars 10 forks source link

Support for Mouse & Mouse Api #87

Closed RobDavenport closed 1 year ago

RobDavenport commented 1 year ago

We should support mouse inputs in addition to the keyboard/gamepad.

This would be limited by pixel coordinates.

Some discussion points: -InputState is using almost all 64 bits already.

RobDavenport commented 1 year ago
    pub fn mouse_left_pressed(player_id: i32) -> i32;
    pub fn mouse_left_released(player_id: i32) -> i32;
    pub fn mouse_left_held(player_id: i32) -> i32;
    pub fn mouse_right_pressed(player_id: i32) -> i32;
    pub fn mouse_right_released(player_id: i32) -> i32;
    pub fn mouse_right_held(player_id: i32) -> i32;
    pub fn mouse_middle_pressed(player_id: i32) -> i32;
    pub fn mouse_middle_released(player_id: i32) -> i32;
    pub fn mouse_middle_held(player_id: i32) -> i32;
    pub fn mouse_x(player_id: i32) -> i32;
    pub fn mouse_y(player_id: i32) -> i32;
    pub fn raw_mouse_state(player_id: i32) -> i32;

Is the current API we're looking at. Additionally I'm investigating how to handle mouse wheel/scrolling

RobDavenport commented 1 year ago

Currently the API now looks like this:

    pub fn mouse_left_pressed(player_id: i32) -> i32;
    pub fn mouse_left_released(player_id: i32) -> i32;
    pub fn mouse_left_held(player_id: i32) -> i32;
    pub fn mouse_right_pressed(player_id: i32) -> i32;
    pub fn mouse_right_released(player_id: i32) -> i32;
    pub fn mouse_right_held(player_id: i32) -> i32;
    pub fn mouse_middle_pressed(player_id: i32) -> i32;
    pub fn mouse_middle_released(player_id: i32) -> i32;
    pub fn mouse_middle_held(player_id: i32) -> i32;

    pub fn mouse_x_pos(player_id: i32) -> i32;
    pub fn mouse_y_pos(player_id: i32) -> i32;

    // Raw mouse information, works even when locked
    pub fn mouse_x_delta(player_id: i32) -> i32;
    pub fn mouse_y_delta(player_id: i32) -> i32;

    // This is only a boolean value if the wheel moved in this direction or not
    pub fn mouse_wheel_up(player_id: i32) -> i32;
    pub fn mouse_wheel_down(player_id: i32) -> i32;
    pub fn mouse_wheel_left(player_id: i32) -> i32;
    pub fn mouse_wheel_right(player_id: i32) -> i32;

    // Locks it for the PC attached to that player
    pub fn lock_mouse(locked: i32);

    pub fn raw_mouse_state(player_id: i32) -> i64;