Josiahiscool73

12v xcloud cheats

Apr 26th, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. // == Xbox Cloud Gaming KBM Mapper v10.9 ==
  2. // • Inventory 2–4 switch your recoil preset automatically
  3. // • 1,5,6 remain pure inventory slots (pickaxe/heals)
  4. // • Mouse side buttons → slots 5/6
  5. // • All v10.8 features preserved
  6. // == End = toggle, Home = full teardown ==
  7.  
  8. (function(){
  9. // --- Flags & State ---
  10. let enabled = true,
  11. pointerLocked = false,
  12. gameArea = null,
  13. stateInt, dispatchInt;
  14.  
  15. const TOGGLE_KEY = 'end',
  16. KILL_KEY = 'home';
  17.  
  18. console.log('⚙️ KBM Mapper v10.9 – [End]=Toggle, [Home]=Kill');
  19.  
  20. // --- Config ---
  21. const POLL_MS = 16,
  22. DISPATCH_MS = 100,
  23. AXIS_DEADZONE = 0.05;
  24.  
  25. const BASE_SENS_X = 0.025,
  26. BASE_SENS_Y = 0.025,
  27. ADS_MULT = 1.75,
  28. MOUSE_DECAY = 0.0;
  29.  
  30. const ENABLE_SMOOTH = true,
  31. SMOOTH_BASE = 0.5,
  32. SMOOTH_PEAK = 0.9,
  33. SMOOTH_RAMP_MS = 300;
  34.  
  35. const ENABLE_MICRO = true,
  36. MICRO_RAD = 0.02,
  37. MICRO_SPD = 0.15;
  38.  
  39. const ENABLE_RECOIL = true,
  40. FIRE_IDX = 7; // RT
  41.  
  42. // Recoil presets (F1–F7 still available for manual override)
  43. const RECOIL_PRESETS = {
  44. scar: 0.020,
  45. m16: 0.017,
  46. compact_smg: 0.030,
  47. pump_shotgun: 0.005,
  48. bolt_sniper: 0.008,
  49. tac_shotgun: 0.007,
  50. heavy_sniper: 0.010
  51. };
  52. const RECOIL_KEYS = ['f1','f2','f3','f4','f5','f6','f7'];
  53. const RECOIL_NAMES = ['scar','m16','compact_smg','pump_shotgun','bolt_sniper','tac_shotgun','heavy_sniper'];
  54. let currentPreset = 'scar';
  55.  
  56. // --- Controller State ---
  57. const state = {
  58. axes: [0,0,0,0],
  59. buttons: Array(17).fill().map((_,i)=>({
  60. pressed:false, touched:false, value:0, index:i
  61. })),
  62. axisKey: {0:{neg:false,pos:false},1:{neg:false,pos:false}},
  63. dx: 0, dy:0,
  64. ts: performance.now(),
  65. microAngle: 0,
  66. adsStart: 0
  67. };
  68.  
  69. // --- Mappings ---
  70. const ADS_IDX = 6; // LT
  71. const keyMap = {
  72. w:{t:'a',a:1,v:-1}, s:{t:'a',a:1,v:1},
  73. a:{t:'a',a:0,v:-1}, d:{t:'a',a:0,v:1},
  74. ' ':{t:'b',i:0}, shift:{t:'b',i:10}, control:{t:'b',i:11},
  75. r:{t:'b',i:2}, e:{t:'b',i:3}, f:{t:'b',i:5}, g:{t:'b',i:1},
  76. escape:{t:'b',i:9}, tab:{t:'b',i:8}, m:{t:'b',i:8},
  77. z:{t:'b',i:14}, x:{t:'b',i:15}, c:{t:'b',i:13}, v:{t:'b',i:12}
  78. // no '1'–'4' here: we’ll intercept them below
  79. };
  80. const mouseMap = {
  81. 0:{t:'b',i:FIRE_IDX}, // Left click → Fire
  82. 2:{t:'b',i:ADS_IDX} // Right click → ADS
  83. };
  84.  
  85. // --- Build Gamepad object ---
  86. function makeGamepad() {
  87. const axes = state.axes.map(v=>Math.abs(v)<AXIS_DEADZONE?0:v);
  88. const btns = state.buttons.map(b=>({
  89. pressed:b.pressed, touched:b.touched, value:b.value, index:b.index
  90. }));
  91. return {
  92. axes, buttons: btns, connected:true,
  93. id: "KBM Mapper v10.9", index:0,
  94. mapping:"standard", timestamp:state.ts
  95. };
  96. }
  97.  
  98. // --- Core update loop ---
  99. function updateState() {
  100. if (!enabled || !pointerLocked) return;
  101. const now = performance.now();
  102. const isADS = state.buttons[ADS_IDX].pressed;
  103. const isFire = state.buttons[FIRE_IDX].pressed;
  104.  
  105. // ADS ramp timer
  106. if (isADS && state.adsStart===0) state.adsStart = now;
  107. if (!isADS) state.adsStart = 0;
  108.  
  109. // base sensitivity + decay
  110. let sx = BASE_SENS_X, sy = BASE_SENS_Y;
  111. if (isADS) { sx*=ADS_MULT; sy*=ADS_MULT; }
  112. let rx = state.axes[2]*MOUSE_DECAY + state.dx*sx;
  113. let ry = state.axes[3]*MOUSE_DECAY + state.dy*sy;
  114.  
  115. // circular micro-movement
  116. if (ENABLE_MICRO && isADS) {
  117. rx += Math.cos(state.microAngle)*MICRO_RAD;
  118. ry += Math.sin(state.microAngle)*MICRO_RAD;
  119. state.microAngle = (state.microAngle + MICRO_SPD) % (2*Math.PI);
  120. }
  121.  
  122. // anti-recoil
  123. if (ENABLE_RECOIL && isFire) {
  124. ry += RECOIL_PRESETS[currentPreset] || 0;
  125. }
  126.  
  127. // smoothing ramp
  128. if (ENABLE_SMOOTH && isADS) {
  129. const held = now - state.adsStart;
  130. const t = Math.min(1, held/SMOOTH_RAMP_MS);
  131. const factor = SMOOTH_BASE*(1-t) + SMOOTH_PEAK*t;
  132. rx = state.axes[2]*factor + rx*(1-factor);
  133. ry = state.axes[3]*factor + ry*(1-factor);
  134. }
  135.  
  136. // clamp & assign
  137. state.axes[2] = Math.max(-1,Math.min(1,rx));
  138. state.axes[3] = Math.max(-1,Math.min(1,ry));
  139. state.dx = state.dy = 0;
  140. state.ts = now;
  141. }
  142.  
  143. // --- Dispatch real GamepadEvent ---
  144. function dispatchPad() {
  145. if (!enabled) return;
  146. const gp = makeGamepad();
  147. try {
  148. const evt = new GamepadEvent('gamepadconnected',{ gamepad: gp });
  149. window.dispatchEvent(evt);
  150. } catch(e) {
  151. console.error('GamepadEvent failed:', e);
  152. }
  153. }
  154.  
  155. // --- Helpers ---
  156. function prevent(e){ e.preventDefault(); e.stopPropagation(); }
  157. function shouldCapture(key, code){
  158. if ([TOGGLE_KEY,KILL_KEY].includes(key)) return false;
  159. if (/^[a-z0-9]$/.test(key)) return true;
  160. if ("`-=[]\\;',./~_+{}|:\"<>?".includes(key)) return true;
  161. return ['Tab','Enter','Escape','ArrowUp','ArrowDown','ArrowLeft','ArrowRight']
  162. .includes(code);
  163. }
  164. function sendSlotKey(k){
  165. document.dispatchEvent(new KeyboardEvent('keydown',{key:k}));
  166. document.dispatchEvent(new KeyboardEvent('keyup',{key:k}));
  167. console.log(`→ Inventory Slot ${k}`);
  168. }
  169.  
  170. // --- Key Handlers ---
  171. function onKeyDown(e){
  172. const k = e.key.toLowerCase();
  173.  
  174. // full teardown
  175. if (k===KILL_KEY){ teardown(); return prevent(e); }
  176. // toggle mapper
  177. if (k===TOGGLE_KEY){ toggle(); return prevent(e); }
  178.  
  179. // Inventory slots 1–4:
  180. // • 1 = pickaxe
  181. // • 2 = shotgun → set recoil
  182. // • 3 = AR → set recoil
  183. // • 4 = SMG → set recoil
  184. if (['1','2','3','4'].includes(k)){
  185. // allow native switch
  186. if (k==='2') { currentPreset='pump_shotgun'; console.log('🔫 Recoil → pump_shotgun'); }
  187. if (k==='3') { currentPreset='scar'; console.log('🔫 Recoil → scar'); }
  188. if (k==='4') { currentPreset='compact_smg'; console.log('🔫 Recoil → compact_smg'); }
  189. return;
  190. }
  191.  
  192. if (!enabled) return;
  193.  
  194. // Anti-recoil can still be manually overridden via F1–F7
  195. if (ENABLE_RECOIL && RECOIL_KEYS.includes(k)){
  196. const idx = RECOIL_KEYS.indexOf(k);
  197. currentPreset = RECOIL_NAMES[idx];
  198. console.log(`🔫 Recoil → ${currentPreset}`);
  199. return prevent(e);
  200. }
  201.  
  202. const m = keyMap[k];
  203. if (m){
  204. prevent(e);
  205. if (m.t==='b'){
  206. const btn = state.buttons[m.i];
  207. btn.pressed=btn.touched=true; btn.value=1;
  208. } else {
  209. const ax = state.axisKey[m.a];
  210. m.v<0?ax.neg=true:ax.pos=true;
  211. state.axes[m.a] = ax.neg&&ax.pos?0:(ax.neg?-1:1);
  212. }
  213. } else if (shouldCapture(k,e.code)){
  214. prevent(e);
  215. }
  216. }
  217. function onKeyUp(e){
  218. const k = e.key.toLowerCase();
  219. // don’t block 1–4 / toggles
  220. if ([KILL_KEY,TOGGLE_KEY,'1','2','3','4'].includes(k)) return prevent(e);
  221. if (!enabled) return;
  222. if (ENABLE_RECOIL && RECOIL_KEYS.includes(k)) return prevent(e);
  223.  
  224. const m = keyMap[k];
  225. if (m){
  226. prevent(e);
  227. if (m.t==='b'){
  228. const btn = state.buttons[m.i];
  229. btn.pressed=btn.touched=false; btn.value=0;
  230. } else {
  231. const ax = state.axisKey[m.a];
  232. m.v<0?ax.neg=false:ax.pos=false;
  233. state.axes[m.a] = ax.neg?-1:ax.pos?1:0;
  234. }
  235. } else if (shouldCapture(k,e.code)){
  236. prevent(e);
  237. }
  238. }
  239.  
  240. // --- Mouse Handlers ---
  241. function onMouseDown(e){
  242. if (!enabled) return;
  243.  
  244. // side buttons → slots 5 & 6
  245. if (e.button===3){ prevent(e); sendSlotKey('5'); return; }
  246. if (e.button===4){ prevent(e); sendSlotKey('6'); return; }
  247.  
  248. const m = mouseMap[e.button];
  249. if (!m) return;
  250. prevent(e);
  251. const btn = state.buttons[m.i];
  252. btn.pressed=btn.touched=true; btn.value=1;
  253. }
  254. function onMouseUp(e){
  255. if (!enabled) return;
  256. const m = mouseMap[e.button];
  257. if (!m) return;
  258. prevent(e);
  259. const btn = state.buttons[m.i];
  260. btn.pressed=btn.touched=false; btn.value=0;
  261. }
  262. function onMouseMove(e){
  263. if (!enabled || !pointerLocked) return;
  264. prevent(e);
  265. state.dx += e.movementX||0;
  266. state.dy += e.movementY||0;
  267. }
  268.  
  269. // --- Pointer Lock ---
  270. function onPointerLockChange(){
  271. pointerLocked = (document.pointerLockElement===gameArea);
  272. console.log(pointerLocked?'🔒 Pointer Locked':'🔓 Pointer Unlocked');
  273. if (!pointerLocked){
  274. state.axes[2]=state.axes[3]=0;
  275. state.microAngle=0;
  276. }
  277. }
  278. function requestLock(){ gameArea?.requestPointerLock?.(); }
  279.  
  280. // --- Toggle & Teardown ---
  281. function toggle(){
  282. enabled = !enabled;
  283. console.log(enabled? '%cMapper ON':'%cMapper OFF',
  284. 'font-weight:bold;color:'+(enabled?'lightgreen':'orange'));
  285. if (!enabled){
  286. state.axes=[0,0,0,0];
  287. state.buttons.forEach(b=>b.pressed=b.touched=false,b.value=0);
  288. state.axisKey={0:{neg:false,pos:false},1:{neg:false,pos:false}};
  289. currentPreset='scar';
  290. if (pointerLocked) document.exitPointerLock();
  291. }
  292. }
  293. function teardown(){
  294. enabled=false;
  295. clearInterval(stateInt); clearInterval(dispatchInt);
  296. window.removeEventListener('keydown', onKeyDown, true);
  297. window.removeEventListener('keyup', onKeyUp, true);
  298. gameArea.removeEventListener('mousedown', onMouseDown, true);
  299. gameArea.removeEventListener('mouseup', onMouseUp, true);
  300. gameArea.removeEventListener('mousemove', onMouseMove, true);
  301. gameArea.removeEventListener('click', requestLock);
  302. document.removeEventListener('pointerlockchange', onPointerLockChange);
  303. navigator.getGamepads = ()=>[];
  304. console.warn('%cKBM Mapper v10.9 TERMINATED – refresh to reload','color:red;font-weight:bold;');
  305. }
  306.  
  307. // --- Initialization ---
  308. (function init(){
  309. gameArea = document.getElementById('game-stream')
  310. || document.querySelector('video[playsinline]')
  311. || document.querySelector('video')
  312. || document.body;
  313.  
  314. navigator.getGamepads = ()=> enabled
  315. ? [ makeGamepad() ]
  316. : [];
  317.  
  318. window.addEventListener('keydown', onKeyDown, true);
  319. window.addEventListener('keyup', onKeyUp, true);
  320. gameArea.addEventListener('mousedown', onMouseDown, true);
  321. gameArea.addEventListener('mouseup', onMouseUp, true);
  322. gameArea.addEventListener('mousemove', onMouseMove, true);
  323. gameArea.addEventListener('click', requestLock, false);
  324. document.addEventListener('pointerlockchange', onPointerLockChange, false);
  325.  
  326. stateInt = setInterval(updateState, POLL_MS);
  327. dispatchInt = setInterval(dispatchPad, DISPATCH_MS);
  328.  
  329. console.log('▶️ KBM Mapper v10.9 ACTIVE – click to lock pointer');
  330. console.log('🔫 Slots 2–4 auto-set recoil, F1–F7 manual override');
  331. })();
  332. })();
  333.  
Add Comment
Please, Sign In to add comment