Skip to content

Commit

Permalink
feat: fist version project (#1)
Browse files Browse the repository at this point in the history
* chore: project skeleton

* chore: add tests

* feat: animate draw

* chore: rename mouses to fingers

* feat: start support mobile

* fix: mouse interfering with touch events

* feat: support multi touch

* feat: support gamepad axis

* feat: emulate keyboard

* chore: prepare to publish in npm
  • Loading branch information
RodrigoDornelles authored Nov 6, 2023
1 parent fe884bd commit 5a10e53
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 25 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check

on:
push:
branches: []
pull_request:
branches: []
workflow_dispatch:

jobs:
tests:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Restore node modules cache
uses: actions/cache@v3
with:
path: ./node_modules/
key: npm-${{ hashFiles('package.json') }}
-
name: Install dependencies
run: npm install
-
name: Check
run: npm run test
37 changes: 37 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: npm

on:
push:
tags:
- "*.*.*"

jobs:
package:
runs-on: ubuntu-latest
container: emscripten/emsdk
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Restore node modules cache
uses: actions/cache@v3
with:
path: ./node_modules/
key: npm-${{ hashFiles('package.json') }}
-
name: Install dependencies
run: npm install
-
name: Build project
run: npm run build

- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Publish project
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
./.github/
./tests/
./examples/
./dist/index.html
LICENSE
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
<head>
<script src='gamepadzilla.js'></script>
</head>
<body>
<body style="touch-action: none">
<canvas
class="gpz-joy"
data-gpz-bind="ArrowUp ArrowLeft ArrowDown ArrowRight">
</canvas>
<canvas
class="gpz-btn"
data-gpz-color="yellow"
data-gpz-bind="KeyF">
</canvas>
</body>
Expand Down
4 changes: 2 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Demo</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='main.js'></script>
<script src='gamepadzilla.js'></script>
</head>
<body>
<body style="touch-action: none">
<canvas class="gpz-joy" data-gpz-bind="ArrowUp ArrowLeft ArrowDown ArrowRight"></canvas>
<canvas class="gpz-btn" data-gpz-color="yellow" data-gpz-bind="KeyF"></canvas>
</body>
Expand Down
266 changes: 266 additions & 0 deletions keycodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
{
"Backspace": {
"key": "Backspace",
"keyCode": 8
},
"Tab": {
"key": "Tab",
"keyCode": 9
},
"Enter": {
"key": "Enter",
"keyCode": 13
},
"ShiftLeft": {
"key": "Shift",
"keyCode": 16
},
"ControlLeft": {
"key": "Control",
"keyCode": 17
},
"AltLeft": {
"key": "Alt",
"keyCode": 18
},
"CapsLock": {
"key": "CapsLock",
"keyCode": 20
},
"Escape": {
"key": "Escape",
"keyCode": 27
},
"Space": {
"key": " ",
"keyCode": 32
},
"PageUp": {
"key": "PageUp",
"keyCode": 33
},
"PageDown": {
"key": "PageDown",
"keyCode": 34
},
"End": {
"key": "End",
"keyCode": 35
},
"Home": {
"key": "Home",
"keyCode": 36
},
"ArrowLeft": {
"key": "ArrowLeft",
"keyCode": 37
},
"ArrowUp": {
"key": "ArrowUp",
"keyCode": 38
},
"ArrowRight": {
"key": "ArrowRight",
"keyCode": 39
},
"ArrowDown": {
"key": "ArrowDown",
"keyCode": 40
},
"Delete": {
"key": "Delete",
"keyCode": 46
},
"Digit0": {
"key": "0",
"keyCode": 48
},
"Digit1": {
"key": "1",
"keyCode": 49
},
"Digit2": {
"key": "2",
"keyCode": 50
},
"Digit3": {
"key": "3",
"keyCode": 51
},
"Digit4": {
"key": "4",
"keyCode": 52
},
"Digit5": {
"key": "5",
"keyCode": 53
},
"Digit6": {
"key": "6",
"keyCode": 54
},
"Digit7": {
"key": "7",
"keyCode": 55
},
"Digit8": {
"key": "8",
"keyCode": 56
},
"Digit9": {
"key": "9",
"keyCode": 57
},
"KeyA": {
"key": "a",
"keyCode": 65
},
"KeyB": {
"key": "b",
"keyCode": 66
},
"KeyC": {
"key": "c",
"keyCode": 67
},
"KeyD": {
"key": "d",
"keyCode": 68
},
"KeyE": {
"key": "e",
"keyCode": 69
},
"KeyF": {
"key": "f",
"keyCode": 70
},
"KeyG": {
"key": "g",
"keyCode": 71
},
"KeyH": {
"key": "h",
"keyCode": 72
},
"KeyI": {
"key": "i",
"keyCode": 73
},
"KeyJ": {
"key": "j",
"keyCode": 74
},
"KeyK": {
"key": "k",
"keyCode": 75
},
"KeyL": {
"key": "l",
"keyCode": 76
},
"KeyM": {
"key": "m",
"keyCode": 77
},
"KeyN": {
"key": "n",
"keyCode": 78
},
"KeyO": {
"key": "o",
"keyCode": 79
},
"KeyP": {
"key": "p",
"keyCode": 80
},
"KeyQ": {
"key": "q",
"keyCode": 81
},
"KeyR": {
"key": "r",
"keyCode": 82
},
"KeyS": {
"key": "s",
"keyCode": 83
},
"KeyT": {
"key": "t",
"keyCode": 84
},
"KeyU": {
"key": "u",
"keyCode": 85
},
"KeyV": {
"key": "v",
"keyCode": 86
},
"KeyW": {
"key": "w",
"keyCode": 87
},
"KeyX": {
"key": "x",
"keyCode": 88
},
"KeyY": {
"key": "y",
"keyCode": 89
},
"KeyZ": {
"key": "z",
"keyCode": 90
},
"F1": {
"key": "F1",
"keyCode": 112
},
"F2": {
"key": "F2",
"keyCode": 113
},
"F3": {
"key": "F3",
"keyCode": 114
},
"F4": {
"key": "F4",
"keyCode": 115
},
"F5": {
"key": "F5",
"keyCode": 116
},
"F6": {
"key": "F6",
"keyCode": 117
},
"F7": {
"key": "F7",
"keyCode": 118
},
"F8": {
"key": "F8",
"keyCode": 119
},
"F9": {
"key": "F9",
"keyCode": 120
},
"F10": {
"key": "F10",
"keyCode": 121
},
"F11": {
"key": "F11",
"keyCode": 122
},
"F12": {
"key": "F12",
"keyCode": 123
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "gamepadzilla",
"version": "0.0.1",
"version": "1.0.0",
"author": "RodrigoDornelles",
"license": "AGPL-3.0-or-later",
"keywords": [
"gamepadzilla",
"joystick",
"gamepad",
"gpz"
"gpz",
"bun"
],
"description": "gpz is a plug and play virtual and physical gamepad for html5 mobile games. (no script need)",
"scripts": {
"test": "bun test .",
"start": "bun run build --watch",
"build": "bun build --minify --outdir dist --target browser --asset-naming '[name].[ext]' --entry-naming '[name].[ext]' src/main.ts",
"build": "bun build --minify --outdir dist --target browser --entry-naming 'gamepadzilla.js' src/main.ts",
"build:example": "npm run build && cp examples/* dist"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 5a10e53

Please sign in to comment.