Configure Joystick for vice.js
nodepond opened this issue ยท 4 comments
Does someone know, how to configure a joystick-keymapping for vice.js?
As far as what I have found, I can only trigger C64 key-codes, but not codes for the joystick programatically. (Like: function sendSpaceKeyPressedCode() { Module.ccall('keyboard_key_pressed', 'undefined', ['number'], [32]); } )
Can I do something similar with the joystick?
I found a thread from a user on a forum, that pretends to got the joystick working online (here the example). When I went to the code, I just found a command line option, and it seems, that the emulator uses the joystick default-config with the num-block, that seems not a good choice for making it compatible to the web.
Can the joystick-config somehow get configured?
There seems to be some news, at this thread:
https://www.forum64.de/index.php?thread/106793-emulator-im-browser/&postID=1630975#post1630975
Seems, that Vice3.4 makes joystick-configuraion via command-line params possible.
I was wondering how difficult i would be, to update this repo to the latest version of vice? If you need help, I could also help or assist... Greetings from Scene World.
Hi. Maybe I was a little but too euphoric. It seems the solution from the user on Forum64 does actually not work, because the parameter he proposed are actually not command-line parameters, but params read from a config-file.
So updating the version of VICE would not really help on this issue so it seems.
Another last question. I've found some "living example", where at least emulated joystick-buttons work on the web.
I looked at the code, and wonder how this joystick_set_value_and
and joystick_set_value_or
commands work? The look similar to keyboard_key_pressed
that you can send directly to the emulator with i.e. Module.ccall('keyboard_key_released','undefined',['number'],[121])
I found the joystick_set_value_and-commands at the end of this file:
https://vice.janicek.co/js/index.js
At this example:
https://vice.janicek.co/c64/
For reference, in this passage here:
function c(e){return t.JOYSTICK_BITS[$(e.currentTarget).attr("joystick")]}var f={};f[o.ALT]=t.JOYSTICK_BITS.FIRE,f[o.KP1]=t.JOYSTICK_BITS.SOUTHWEST,f[o.KP2]=t.JOYSTICK_BITS.SOUTH,f[o.KP3]=t.JOYSTICK_BITS.SOUTHEAST,f[o.KP4]=t.JOYSTICK_BITS.WEST,f[o.KP5]=t.JOYSTICK_BITS.SOUTH,f[o.KP6]=t.JOYSTICK_BITS.EAST,f[o.KP7]=t.JOYSTICK_BITS.NORTHWEST,f[o.KP8]=t.JOYSTICK_BITS.NORTH,f[o.KP9]=t.JOYSTICK_BITS.NORTHEAST,u.onChange(e),e(),$("#joystickPort").on("click",n),$("[joystick]").on("mousedown touchstart",(function(e){var n=c(e);t.joystick_set_value_or(a.port,n)})).on("mouseup touchend",(function(e){var n=c(e);t.joystick_set_value_and(a.port,~n)})),$(document).on("keydown",(function(e){var r=f[e.which];r&&t.joystick_set_value_or(a.port,r),e.which===o.KP_SUBTRACT&&n()})).on("keyup",(function(e){var n=f[e.which];n&&t.joystick_set_value_and(a.port,~n)}))};t.exports=a},function(t,e,n){"use strict";var r={each:n(0)},o=n(2),u=n(4),i=n(15),a=n(36);t.exports=function(t){function e(){var t=u.getArguments(o.get()).keys;t&&($("#virtualKeys").empty(),r.each(t,(function(t,e){var n=a[e];t=t||n.label;var r=n.code,o=$('<button class="btn btn-lg btn-primary" title="'+e+'">'+t+"</button>");