Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlling Flash with nipple on touchscreen, what about buttons? #190

Closed
Txori opened this issue Jun 22, 2022 · 4 comments
Closed

Controlling Flash with nipple on touchscreen, what about buttons? #190

Txori opened this issue Jun 22, 2022 · 4 comments

Comments

@Txori
Copy link

Txori commented Jun 22, 2022

Hello, I'm currently toying the nipple in order to control Flash content in the Ruffle emulator on touchscreen devices:
https://www.txori.com/stuff/ruffle/nipplejs.php

nipplejs

I was wondering if nipples could be use as buttons too, or if not, if you had plan to add buttons?

Thanks

@Txori Txori changed the title [FEAT] Controlling Flash with nipple on touchscreen Jun 22, 2022
@Txori Txori changed the title Controlling Flash with nipple on touchscreen Controlling Flash with nipple on touchscreen, what about buttons? Jun 22, 2022
@Txori
Copy link
Author

Txori commented Jun 22, 2022

So I programmed my own buttons, thanks to this useful hint.
Now I'm trying to use a static nipple instead. It's there, working, but not throwing any events...
I just got from this:

	var nippleManager = nipplejs.create({
	    zone: document.getElementById('box'),
	    color: 'red'
	});

to that:

	var nippleManager = nipplejs.create({
	    zone: document.getElementById('box'),
	    color: 'red',
	    mode: 'static',
	    position: {left: '100px', bottom: '100px'}
	});

What am I missing?

@Txori
Copy link
Author

Txori commented Jun 23, 2022

I made a very simple test, and everything is working but the static nipple:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Nipple debug</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>

<body bgcolor="#CCCCCC">

<script src="nipplejs.js"></script>

<div class="static-box" id="nipplebox"></div>

<script>
	
var nippleManager = nipplejs.create({
    zone: document.getElementById('nipplebox'),
    color: 'red',
    //mode: 'semi',
    //mode: 'static',
    //catchDistance: 200,
	position: {left: '50%', bottom: '50%'}
});

nippleManager.on('added', function (evt, nipple) {
	nipple.on('start move end', function(evt, data) {
		console.log(data);
	});
});

</script>

<style>
#nipplebox {
	width:800px;
	height: 600px;
	background-color:#bbccaa;
	border: 2px solid rgba(90, 90, 60);
	position:relative;
	top:0;
	left:0;
	margin-left: auto;
	margin-right: auto;
}
</style>

</body>
</html>

I really don't know what's going on with it...
It is available here:
https://www.txori.com/stuff/ruffle/simplenipple.php

@Txori
Copy link
Author

Txori commented Jun 27, 2022

I'm still digging, and it appears that the on added doesn't work when the nipple is static:

nippleManager.on('added', function (evt, nipple) {
	console.log("nipple added");
}

So I replaced it by:

var nipple = nippleManager.get(0);
nipple .on('start move end', function(evt, data) {
	console.log(data);
});

There should be a bit of explanations about this in the help doc :)

@yoannmoinet
Copy link
Owner

it appears that the on added doesn't work when the nipple is static

This is expected since the joystick is already there and never actually added.
The added event is for other modes than static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants