Post subject: Controller-gamepad image in the gens
Joined: 8/29/2014
Posts: 8
Location: Monaco
How to put the input gamepad image in the gens? Like in this video: Link to video
Joined: 12/7/2016
Posts: 33
I think it's very possible to do it in the Gens emulator. The emulator can run lua code and I think it can read the buttons pressed. Then I think you just need to paint some image of a joytick sega genesys and paint the color on the buttons that are pressed. I think I could take a look.
Some Zamasu's quotes: - When I was invited to this place, I thought you would teach me about justice. However, does the justice of the gods not only pass by to observe? - Every time I am attacked, I enjoy my immortality.
Joined: 8/29/2014
Posts: 8
Location: Monaco
Zamasu wrote:
I think it's very possible to do it in the Gens emulator. The emulator can run lua code and I think it can read the buttons pressed. Then I think you just need to paint some image of a joytick sega genesys and paint the color on the buttons that are pressed. I think I could take a look.
Really ? I would be grateful, as I do not understand anything about Lua script, but I love these controller inputs on the screen.
Joined: 12/7/2016
Posts: 33
I created a prototype with the buttons: up, down, left, right, A, B and C.
require "gd"

joysimg = gd.createFromPng("segajoystick.png"):gdStr()
joysw = 120
joysh = 64

transp = {0,0,0,0}
btnpress = {0,0,255,244}

gui.circle = function (x, y, r, fill, border)
	fill = fill or {0,0,0,0}
	-- Fill
	for xr = -r, r do
		yr = math.sqrt(r*r - xr*xr)
		gui.line (x+xr, y-yr, x+xr, y+yr, fill)
	end

	-- Border
	border = border or fill
	yd = 0;
	for xr = -r, r do
		yr = math.sqrt(r*r - xr*xr)
		gui.line (x+xr, y-yr, x+xr, y-yd, border)
		gui.line (x+xr, y+yr, x+xr, y+yd, border)
		--if (math.abs((y-yd) - (y-yr)) > 1) then
		--	gui.line (x+xr, y-yr, x+xr, y-yd-1, border)
		--	gui.line (x+xr, y+yr, x+xr, y+yd+1, border)
		--else
		--	gui.pixel (x+xr, y-yr, border)
		--	gui.pixel (x+xr, y+yr, border)
		--end
		yd = yr;
	end
end

gens.registerafter(function()
	gui.gdoverlay(10, 223-joysh-10, joysimg, 0.9)

	local buttons = joypad.get(1);
	if buttons.left then gui.box (10+15, 223-joysh+21, 10+23, 223-joysh+28, btnpress, 'white') end
	if buttons.right then gui.box (10+29, 223-joysh+22, 10+37, 223-joysh+29, btnpress, 'white') end
	if buttons.up then gui.box (10+23, 223-joysh+14, 10+30, 223-joysh+21, btnpress, 'white') end
	if buttons.down then gui.box (10+22, 223-joysh+27, 10+29, 223-joysh+35, btnpress, 'white') end

	if buttons.A then gui.circle (10+81, 223-joysh+34, 5, btnpress, 'white') end
	if buttons.B then gui.circle (10+93, 223-joysh+28, 5, btnpress, 'white') end
	if buttons.C then gui.circle (10+107, 223-joysh+23, 5, btnpress, 'white') end

end)
This script require "gd" library that gens emulator have in gens-lua.html an explanation to how to install. I use this joystick image, download it to run the script correctly and move it to gens emulator executable directory. Just is a test script, can be better
Some Zamasu's quotes: - When I was invited to this place, I thought you would teach me about justice. However, does the justice of the gods not only pass by to observe? - Every time I am attacked, I enjoy my immortality.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11478
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Movable, more buttons. Download pad.lua
Language: lua

require "gd" joysimg = gd.createFromPng("segajoystick.png"):gdStr() joysw = 120 joysh = 64 joyx = 2 joyx = 2 joyy = 170 transp = {0,0,0,0} btnpress = {0,0,255,244} gui.circle = function (x, y, r, fill, border) fill = fill or {0,0,0,0} -- Fill for xr = -r, r do yr = math.sqrt(r*r - xr*xr) gui.line (x+xr, y-yr, x+xr, y+yr, fill) end -- Border border = border or fill yd = 0 for xr = -r, r do yr = math.sqrt(r*r - xr*xr) gui.line (x+xr, y-yr, x+xr, y-yd, border) gui.line (x+xr, y+yr, x+xr, y+yd, border) --[[-- if (math.abs((y-yd) - (y-yr)) > 1) then gui.line (x+xr, y-yr, x+xr, y-yd-1, border) gui.line (x+xr, y+yr, x+xr, y+yd+1, border) else gui.pixel (x+xr, y-yr, border) gui.pixel (x+xr, y+yr, border) end --]]-- yd = yr; end end gens.registerafter(function() keys = input.get() if keys["leftclick"] then joyx = keys.xmouse - joysw/2 joyy = keys.ymouse - joysh/2 end gui.gdoverlay(joyx, joyy-10, joysimg, 0.9) local buttons = joypad.get(1) if buttons.up then gui.box (joyx+22, joyy+14, joyx+29, joyy+21, btnpress, 'white') end if buttons.down then gui.box (joyx+22, joyy+28, joyx+29, joyy+35, btnpress, 'white') end if buttons.left then gui.box (joyx+15, joyy+21, joyx+22, joyy+28, btnpress, 'white') end if buttons.right then gui.box (joyx+29, joyy+21, joyx+36, joyy+28, btnpress, 'white') end if buttons.start then gui.box (joyx+55, joyy+19, joyx+64, joyy+23, btnpress, 'white') end if buttons.A then gui.circle (joyx+ 81, joyy+34, 5, btnpress, 'white') end if buttons.B then gui.circle (joyx+ 93, joyy+28, 5, btnpress, 'white') end if buttons.C then gui.circle (joyx+107, joyy+23, 5, btnpress, 'white') end if buttons.X then gui.circle (joyx+ 78, joyy+20, 3, btnpress, 'white') end if buttons.Y then gui.circle (joyx+ 88, joyy+15, 3, btnpress, 'white') end if buttons.Z then gui.circle (joyx+ 99, joyy+10, 3, btnpress, 'white') end end)
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Joined: 8/29/2014
Posts: 8
Location: Monaco
Nice, you can do with that picture:http://genox6.deviantart.com/art/Mega-Drive-Genesis-2-6-Button-Controller-Vector-661885102 Can you put the joystick on the black screen?
Joined: 12/7/2016
Posts: 33
subzero13, you are graphic designer? Because that image is great, but it would be better if its size is 120x64, I try to resize it and it lose much the textual detail. EDIT:
subzero13 wrote:
Can you put the joystick on the black screen?
That is not possible because the black screen is not part of the drawing element of the emulator, even thanks to the feos's script when i moving the joystick toward the black part is lost. Or well, I do not know if someone more experienced of the site knew something about it.
Some Zamasu's quotes: - When I was invited to this place, I thought you would teach me about justice. However, does the justice of the gods not only pass by to observe? - Every time I am attacked, I enjoy my immortality.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11478
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Just put gui.box(0,0,320,224,"black","black") before gui.gdoverlay().
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Joined: 8/29/2014
Posts: 8
Location: Monaco
Zamasu wrote:
subzero13, you are graphic designer?
No haha, i just found on google, i found more imgs you can choose here: http://www.mediafire.com/file/i3z971id554wi4h/pad+gens+img.zip
Joined: 8/29/2014
Posts: 8
Location: Monaco
feos wrote:
Just put gui.box(0,0,320,224,"black","black") before gui.gdoverlay().
Now the screen is all black, is it better to leave the control on the "black border" of the screen?